@douyinfe/semi-ui 2.19.0-alpha.2 → 2.19.0-alpha.5

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.
@@ -1,9 +1,10 @@
1
- import React, { isValidElement, cloneElement } from 'react';
1
+ import React, { isValidElement, cloneElement, ReactNode } from 'react';
2
2
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
5
5
  import { cssClasses, strings } from '@douyinfe/semi-foundation/button/constants';
6
- import { Type, Size } from './Button';
6
+ import { get } from 'lodash';
7
+ import { Type, Size, ButtonProps } from './Button';
7
8
 
8
9
  import '@douyinfe/semi-foundation/button/button.scss';
9
10
 
@@ -39,9 +40,41 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
39
40
  size: 'default',
40
41
  };
41
42
 
43
+ getInnerWithLine(inner) {
44
+ const innerWithLine: ReactNode[] = [];
45
+ let lineCls = `${prefixCls}-group-line`;
46
+ if (inner.length > 1) {
47
+ inner.slice(0, -1).forEach(item => {
48
+ const isButtonType = [get(item, 'type.displayName'), get(item, 'type.name')].includes('Button');
49
+ const buttonProps = get(item, 'props') as ButtonProps;
50
+ if (buttonProps) {
51
+ const { type, theme, disabled } = buttonProps;
52
+ lineCls = classNames(
53
+ `${prefixCls}-group-line`,
54
+ `${prefixCls}-group-line-${theme ?? 'light'}`,
55
+ `${prefixCls}-group-line-${type ?? 'primary'}`,
56
+ {
57
+ [`${prefixCls}-group-line-disabled`]: disabled,
58
+ }
59
+ );
60
+ }
61
+ if (isButtonType) {
62
+ innerWithLine.push(item, <span className={lineCls} />);
63
+ } else {
64
+ innerWithLine.push(item);
65
+ }
66
+ });
67
+ innerWithLine.push(inner.slice(-1));
68
+ return innerWithLine;
69
+ } else {
70
+ return inner;
71
+ }
72
+ }
73
+
42
74
  render() {
43
75
  const { children, disabled, size, type, className, 'aria-label': ariaLabel, ...rest } = this.props;
44
- let inner;
76
+ let inner: ReactNode[];
77
+ let innerWithLine: ReactNode[] = [];
45
78
  const cls = classNames(`${prefixCls}-group`, className);
46
79
 
47
80
  if (children) {
@@ -50,7 +83,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
50
83
  ? cloneElement(itm, { disabled, size, type, ...itm.props, ...rest, key: index })
51
84
  : itm
52
85
  ));
86
+ innerWithLine = this.getInnerWithLine(inner);
53
87
  }
54
- return <div className={cls} role="group" aria-label={ariaLabel}>{inner}</div>;
88
+ return <div className={cls} role="group" aria-label={ariaLabel}>{innerWithLine}</div>;
55
89
  }
56
90
  }
@@ -6,7 +6,7 @@ import { checkboxGroupClasses as css, strings } from '@douyinfe/semi-foundation/
6
6
  import CheckboxGroupFoundation, { CheckboxGroupAdapter } from '@douyinfe/semi-foundation/checkbox/checkboxGroupFoundation';
7
7
  import BaseComponent from '../_base/baseComponent';
8
8
  import { Context } from './context';
9
- import { get, isEqual } from 'lodash';
9
+ import { isEqual } from 'lodash';
10
10
  import Checkbox, { CheckboxEvent } from './checkbox';
11
11
 
12
12
  export type CheckboxDirection = 'horizontal' | 'vertical';
@@ -136,7 +136,6 @@ class CheckboxGroup extends BaseComponent<CheckboxGroupProps, CheckboxGroupState
136
136
  disabled={this.props.disabled}
137
137
  value={option}
138
138
  prefixCls={prefixCls}
139
- type={type}
140
139
  >
141
140
  {option}
142
141
  </Checkbox>
@@ -153,7 +152,6 @@ class CheckboxGroup extends BaseComponent<CheckboxGroupProps, CheckboxGroupState
153
152
  className={option.className}
154
153
  style={option.style}
155
154
  onChange={option.onChange}
156
- type={type}
157
155
  >
158
156
  {option.label}
159
157
  </Checkbox>
@@ -161,14 +159,7 @@ class CheckboxGroup extends BaseComponent<CheckboxGroupProps, CheckboxGroupState
161
159
  }
162
160
  });
163
161
  } else if (children) {
164
- inner = (React.Children.toArray(children) as React.ReactElement[]).map((itm, index) => {
165
- const props: Record<string, any> = { key: index, role: 'listitem' };
166
- const isCheckboxComp = ['Checkbox', 'CheckboxWithGroup'].some(comp => [get(itm, 'type.displayName'), get(itm, 'type.name')].includes(comp));
167
- if (isCheckboxComp) {
168
- props.type = type;
169
- }
170
- return React.cloneElement(itm, props);
171
- });
162
+ inner = (React.Children.toArray(children) as React.ReactElement[]).map((itm, index) => React.cloneElement(itm, { key: index, role: 'listitem' }));
172
163
  }
173
164
 
174
165
  return (
package/dist/css/semi.css CHANGED
@@ -1778,6 +1778,10 @@ body {
1778
1778
  .semi-button-block {
1779
1779
  width: 100%;
1780
1780
  }
1781
+ .semi-button-group {
1782
+ display: flex;
1783
+ flex-wrap: wrap;
1784
+ }
1781
1785
  .semi-button-group > .semi-button {
1782
1786
  margin: 0;
1783
1787
  padding-left: 0;
@@ -1816,13 +1820,46 @@ body {
1816
1820
  border-top-left-radius: var(--semi-border-radius-small);
1817
1821
  border-bottom-left-radius: var(--semi-border-radius-small);
1818
1822
  }
1819
- .semi-button-group > .semi-button:not(:last-child) .semi-button-content {
1820
- border-right: 1px var(--semi-color-border) solid;
1821
- }
1822
1823
  .semi-button-group > .semi-button:last-child {
1823
1824
  border-top-right-radius: var(--semi-border-radius-small);
1824
1825
  border-bottom-right-radius: var(--semi-border-radius-small);
1825
1826
  }
1827
+ .semi-button-group-line {
1828
+ display: inline-flex;
1829
+ align-items: center;
1830
+ background-color: var(--semi-color-border);
1831
+ }
1832
+ .semi-button-group-line-primary {
1833
+ background-color: var(--semi-color-primary);
1834
+ }
1835
+ .semi-button-group-line-secondary {
1836
+ background-color: var(--semi-color-secondary);
1837
+ }
1838
+ .semi-button-group-line-tertiary {
1839
+ background-color: var(--semi-color-tertiary);
1840
+ }
1841
+ .semi-button-group-line-warning {
1842
+ background-color: var(--semi-color-warning);
1843
+ }
1844
+ .semi-button-group-line-danger {
1845
+ background-color: var(--semi-color-danger);
1846
+ }
1847
+ .semi-button-group-line-disabled {
1848
+ background-color: var(--semi-color-disabled-bg);
1849
+ }
1850
+ .semi-button-group-line-light {
1851
+ background-color: var(--semi-color-fill-0);
1852
+ }
1853
+ .semi-button-group-line-borderless {
1854
+ background-color: transparent;
1855
+ }
1856
+ .semi-button-group-line::before {
1857
+ display: block;
1858
+ content: "";
1859
+ width: 1px;
1860
+ height: 20px;
1861
+ background-color: var(--semi-color-border);
1862
+ }
1826
1863
 
1827
1864
  .semi-rtl .semi-button,
1828
1865
  .semi-portal-rtl .semi-button {
@@ -15309,7 +15346,6 @@ body {
15309
15346
  .semi-select-option-icon {
15310
15347
  width: 12px;
15311
15348
  color: transparent;
15312
- visibility: hidden;
15313
15349
  margin-right: 8px;
15314
15350
  display: flex;
15315
15351
  justify-content: center;
@@ -15350,7 +15386,6 @@ body {
15350
15386
  font-weight: 600;
15351
15387
  }
15352
15388
  .semi-select-option-selected .semi-select-option-icon {
15353
- visibility: visible;
15354
15389
  color: var(--semi-color-text-2);
15355
15390
  }
15356
15391
  .semi-select-option-focused {
@@ -17395,10 +17430,14 @@ body {
17395
17430
  display: inline-block;
17396
17431
  width: 16px;
17397
17432
  height: 16px;
17398
- cursor: pointer;
17399
17433
  vertical-align: middle;
17400
17434
  text-align: center;
17401
17435
  }
17436
+ .semi-table .semi-table-column-sorter-wrapper {
17437
+ display: inline-flex;
17438
+ align-items: center;
17439
+ cursor: pointer;
17440
+ }
17402
17441
  .semi-table .semi-table-column-sorter-up, .semi-table .semi-table-column-sorter-down {
17403
17442
  height: 0;
17404
17443
  display: block;
@@ -17421,11 +17460,11 @@ body {
17421
17460
  display: inline-flex;
17422
17461
  cursor: pointer;
17423
17462
  color: var(--semi-color-text-2);
17424
- vertical-align: middle;
17463
+ align-items: center;
17425
17464
  }
17426
17465
  .semi-table .semi-table-column-filter svg {
17427
- width: 12px;
17428
- height: 12px;
17466
+ width: 16px;
17467
+ height: 16px;
17429
17468
  }
17430
17469
  .semi-table .semi-table-column-filter.on {
17431
17470
  color: var(--semi-color-primary);