@douyinfe/semi-ui 2.35.0-beta.0 → 2.36.0-alpha.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 (111) hide show
  1. package/dist/css/semi.css +494 -25
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +188 -77
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/anchor/index.d.ts +1 -1
  8. package/lib/cjs/autoComplete/index.d.ts +1 -1
  9. package/lib/cjs/button/Button.d.ts +1 -1
  10. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  11. package/lib/cjs/button/index.d.ts +1 -1
  12. package/lib/cjs/collapse/item.d.ts +2 -0
  13. package/lib/cjs/collapse/item.js +3 -2
  14. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  15. package/lib/cjs/datePicker/datePicker.d.ts +2 -2
  16. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  17. package/lib/cjs/datePicker/yearAndMonth.d.ts +1 -1
  18. package/lib/cjs/form/baseForm.d.ts +1 -1
  19. package/lib/cjs/form/field.d.ts +1 -1
  20. package/lib/cjs/input/index.d.ts +1 -1
  21. package/lib/cjs/input/inputGroup.d.ts +1 -1
  22. package/lib/cjs/modal/confirm.d.ts +17 -17
  23. package/lib/cjs/navigation/Item.d.ts +4 -0
  24. package/lib/cjs/navigation/Item.js +29 -10
  25. package/lib/cjs/navigation/SubNav.d.ts +5 -0
  26. package/lib/cjs/navigation/SubNav.js +51 -26
  27. package/lib/cjs/overflowList/index.js +4 -1
  28. package/lib/cjs/rating/index.d.ts +1 -1
  29. package/lib/cjs/rating/item.d.ts +1 -1
  30. package/lib/cjs/skeleton/index.d.ts +1 -0
  31. package/lib/cjs/skeleton/index.js +1 -0
  32. package/lib/cjs/skeleton/item.d.ts +1 -0
  33. package/lib/cjs/skeleton/item.js +6 -1
  34. package/lib/cjs/steps/basicStep.d.ts +3 -0
  35. package/lib/cjs/steps/basicStep.js +8 -2
  36. package/lib/cjs/steps/basicSteps.js +2 -1
  37. package/lib/cjs/steps/fillStep.d.ts +2 -0
  38. package/lib/cjs/steps/fillStep.js +3 -1
  39. package/lib/cjs/steps/fillSteps.js +5 -8
  40. package/lib/cjs/steps/index.d.ts +63 -1
  41. package/lib/cjs/steps/index.js +9 -0
  42. package/lib/cjs/steps/navStep.d.ts +3 -0
  43. package/lib/cjs/steps/navStep.js +6 -2
  44. package/lib/cjs/steps/navSteps.js +2 -1
  45. package/lib/cjs/steps/step.d.ts +4 -1
  46. package/lib/cjs/steps/step.js +1 -0
  47. package/lib/cjs/switch/index.d.ts +1 -1
  48. package/lib/cjs/table/Table.d.ts +2 -2
  49. package/lib/cjs/table/index.d.ts +1 -1
  50. package/lib/cjs/tagInput/index.d.ts +1 -1
  51. package/lib/cjs/timePicker/TimePicker.d.ts +1 -1
  52. package/lib/cjs/timePicker/index.d.ts +1 -1
  53. package/lib/cjs/timeline/context.d.ts +8 -0
  54. package/lib/cjs/timeline/context.js +15 -0
  55. package/lib/cjs/timeline/index.d.ts +2 -1
  56. package/lib/cjs/timeline/index.js +8 -2
  57. package/lib/cjs/timeline/item.d.ts +10 -0
  58. package/lib/cjs/timeline/item.js +42 -3
  59. package/lib/es/anchor/index.d.ts +1 -1
  60. package/lib/es/autoComplete/index.d.ts +1 -1
  61. package/lib/es/button/Button.d.ts +1 -1
  62. package/lib/es/button/buttonGroup.d.ts +1 -1
  63. package/lib/es/button/index.d.ts +1 -1
  64. package/lib/es/collapse/item.d.ts +2 -0
  65. package/lib/es/collapse/item.js +3 -2
  66. package/lib/es/datePicker/dateInput.d.ts +1 -1
  67. package/lib/es/datePicker/datePicker.d.ts +2 -2
  68. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  69. package/lib/es/datePicker/yearAndMonth.d.ts +1 -1
  70. package/lib/es/form/baseForm.d.ts +1 -1
  71. package/lib/es/form/field.d.ts +1 -1
  72. package/lib/es/input/index.d.ts +1 -1
  73. package/lib/es/input/inputGroup.d.ts +1 -1
  74. package/lib/es/modal/confirm.d.ts +17 -17
  75. package/lib/es/navigation/Item.d.ts +4 -0
  76. package/lib/es/navigation/Item.js +28 -10
  77. package/lib/es/navigation/SubNav.d.ts +5 -0
  78. package/lib/es/navigation/SubNav.js +52 -26
  79. package/lib/es/overflowList/index.js +4 -1
  80. package/lib/es/rating/index.d.ts +1 -1
  81. package/lib/es/rating/item.d.ts +1 -1
  82. package/lib/es/skeleton/index.d.ts +1 -0
  83. package/lib/es/skeleton/index.js +1 -0
  84. package/lib/es/skeleton/item.d.ts +1 -0
  85. package/lib/es/skeleton/item.js +6 -1
  86. package/lib/es/steps/basicStep.d.ts +3 -0
  87. package/lib/es/steps/basicStep.js +8 -2
  88. package/lib/es/steps/basicSteps.js +2 -1
  89. package/lib/es/steps/fillStep.d.ts +2 -0
  90. package/lib/es/steps/fillStep.js +3 -1
  91. package/lib/es/steps/fillSteps.js +6 -8
  92. package/lib/es/steps/index.d.ts +63 -1
  93. package/lib/es/steps/index.js +6 -0
  94. package/lib/es/steps/navStep.d.ts +3 -0
  95. package/lib/es/steps/navStep.js +6 -2
  96. package/lib/es/steps/navSteps.js +2 -1
  97. package/lib/es/steps/step.d.ts +4 -1
  98. package/lib/es/steps/step.js +1 -0
  99. package/lib/es/switch/index.d.ts +1 -1
  100. package/lib/es/table/Table.d.ts +2 -2
  101. package/lib/es/table/index.d.ts +1 -1
  102. package/lib/es/tagInput/index.d.ts +1 -1
  103. package/lib/es/timePicker/TimePicker.d.ts +1 -1
  104. package/lib/es/timePicker/index.d.ts +1 -1
  105. package/lib/es/timeline/context.d.ts +8 -0
  106. package/lib/es/timeline/context.js +3 -0
  107. package/lib/es/timeline/index.d.ts +2 -1
  108. package/lib/es/timeline/index.js +7 -2
  109. package/lib/es/timeline/item.d.ts +10 -0
  110. package/lib/es/timeline/item.js +41 -3
  111. package/package.json +8 -8
@@ -25,7 +25,9 @@ const BasicStep = props => {
25
25
  stepNumber,
26
26
  onClick,
27
27
  onChange,
28
- onKeyDown
28
+ onKeyDown,
29
+ usedInC2D,
30
+ direction: direction
29
31
  } = props;
30
32
 
31
33
  const renderIcon = () => {
@@ -88,7 +90,10 @@ const BasicStep = props => {
88
90
  [`${prefixCls}-active`]: active,
89
91
  [`${prefixCls}-done`]: done,
90
92
  [`${prefixCls}-hover`]: onChange || props.onClick,
91
- [`${prefixCls}-${status}-hover`]: onChange || props.onClick
93
+ [`${prefixCls}-${status}-hover`]: onChange || props.onClick,
94
+ [`${prefixCls}-basic`]: usedInC2D,
95
+ [`${prefixCls}-${direction}`]: direction,
96
+ [`${prefixCls}-small`]: size === 'small'
92
97
  }, className);
93
98
 
94
99
  const handleClick = e => {
@@ -146,4 +151,5 @@ BasicStep.defaultProps = {
146
151
  status: 'wait',
147
152
  className: ''
148
153
  };
154
+ BasicStep.elementType = 'Steps.BasicStep';
149
155
  export default BasicStep;
@@ -27,7 +27,8 @@ const Steps = props => {
27
27
  const stepNumber = initial + index;
28
28
  const childProps = Object.assign({
29
29
  stepNumber: `${stepNumber + 1}`,
30
- size
30
+ size,
31
+ direction
31
32
  }, child.props);
32
33
 
33
34
  if (status === 'error' && index === current - 1) {
@@ -15,6 +15,7 @@ export interface FillStepProps {
15
15
  onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
16
16
  "role"?: React.AriaRole;
17
17
  "aria-label"?: React.AriaAttributes["aria-label"];
18
+ usedInC2D?: boolean;
18
19
  }
19
20
  declare const FillStep: {
20
21
  (props: FillStepProps): JSX.Element;
@@ -33,5 +34,6 @@ declare const FillStep: {
33
34
  status: string;
34
35
  className: string;
35
36
  };
37
+ elementType: string;
36
38
  };
37
39
  export default FillStep;
@@ -92,7 +92,8 @@ const FillStep = props => {
92
92
  [prefixCls]: true,
93
93
  [`${prefixCls}-${status}`]: Boolean(status),
94
94
  [`${prefixCls}-${status}-hover`]: Boolean(status) && (onChange || onClick),
95
- [`${prefixCls}-clickable`]: onClick
95
+ [`${prefixCls}-clickable`]: onClick,
96
+ [`${prefixCls}-fill`]: props.usedInC2D
96
97
  }, className),
97
98
  style: style,
98
99
  onClick: e => {
@@ -127,4 +128,5 @@ FillStep.defaultProps = {
127
128
  status: 'wait',
128
129
  className: ''
129
130
  };
131
+ FillStep.elementType = 'Steps.FillStep';
130
132
  export default FillStep;
@@ -17,10 +17,8 @@ const Steps = props => {
17
17
  onChange
18
18
  } = props;
19
19
  const inner = useMemo(() => {
20
- const filteredChildren = Children.toArray(children).filter(c => /*#__PURE__*/isValidElement(c));
21
- const colStyle = direction === 'vertical' ? null : {
22
- width: `${100 / filteredChildren.length}%`
23
- };
20
+ const filteredChildren = Children.toArray(children).filter(c => /*#__PURE__*/isValidElement(c)); // const colStyle = direction === 'vertical' ? null : { width: `${100 / filteredChildren.length }%` };
21
+
24
22
  const content = Children.map(filteredChildren, (child, index) => {
25
23
  if (!child) {
26
24
  return null;
@@ -50,10 +48,10 @@ const Steps = props => {
50
48
  if (index !== current) {
51
49
  onChange(index + initial);
52
50
  }
53
- } : undefined;
54
- return /*#__PURE__*/React.createElement(Col, {
55
- style: colStyle
56
- }, /*#__PURE__*/cloneElement(child, Object.assign({}, childProps)));
51
+ } : undefined; // Whether colStyle is set has no effect
52
+ // return <Col style={colStyle}>{cloneElement(child, { ...childProps })}</Col>;
53
+
54
+ return /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/cloneElement(child, Object.assign({}, childProps)));
57
55
  });
58
56
  return content;
59
57
  }, [children, initial, prefixCls, direction, status, current, onChange]);
@@ -22,7 +22,69 @@ export interface NavStepsAllProps extends NavStepsProps {
22
22
  }
23
23
  export declare type StepsProps = FillStepsAllProps | BasicStepsAllProps | NavStepsAllProps;
24
24
  declare class Steps extends Component<StepsProps> {
25
- static Step: (props: import("./step").StepProps) => JSX.Element;
25
+ static Step: {
26
+ (props: import("./step").StepProps): JSX.Element;
27
+ elementType: string;
28
+ };
29
+ static FillStep: {
30
+ (props: import("./fillStep").FillStepProps): JSX.Element;
31
+ propTypes: {
32
+ prefixCls: PropTypes.Requireable<string>;
33
+ description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
34
+ icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
35
+ status: PropTypes.Requireable<string>;
36
+ title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
37
+ className: PropTypes.Requireable<string>;
38
+ style: PropTypes.Requireable<object>;
39
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
40
+ };
41
+ defaultProps: {
42
+ prefixCls: string;
43
+ status: string;
44
+ className: string;
45
+ };
46
+ elementType: string;
47
+ };
48
+ static BasicStep: {
49
+ (props: import("./basicStep").BasicStepProps): JSX.Element;
50
+ propTypes: {
51
+ prefixCls: PropTypes.Requireable<string>;
52
+ description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
53
+ icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
54
+ status: PropTypes.Requireable<string>;
55
+ title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
56
+ className: PropTypes.Requireable<string>;
57
+ style: PropTypes.Requireable<object>;
58
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
59
+ active: PropTypes.Requireable<boolean>;
60
+ done: PropTypes.Requireable<boolean>;
61
+ };
62
+ defaultProps: {
63
+ prefixCls: string;
64
+ active: boolean;
65
+ done: boolean;
66
+ status: string;
67
+ className: string;
68
+ };
69
+ elementType: string;
70
+ };
71
+ static NavStep: {
72
+ (props: import("./navStep").NavStepProps): JSX.Element;
73
+ propTypes: {
74
+ prefixCls: PropTypes.Requireable<string>;
75
+ title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
76
+ className: PropTypes.Requireable<string>;
77
+ style: PropTypes.Requireable<object>;
78
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
79
+ active: PropTypes.Requireable<boolean>;
80
+ };
81
+ defaultProps: {
82
+ prefixCls: string;
83
+ active: boolean;
84
+ className: string;
85
+ };
86
+ elementType: string;
87
+ };
26
88
  static propTypes: {
27
89
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
28
90
  type: PropTypes.Requireable<string>;
@@ -16,6 +16,9 @@ import Step from './step';
16
16
  import FillSteps from './fillSteps';
17
17
  import BasicSteps from './basicSteps';
18
18
  import NavSteps from './navSteps';
19
+ import FillStep from './fillStep';
20
+ import BasicStep from './basicStep';
21
+ import NavStep from './navStep';
19
22
  import Context from './context';
20
23
 
21
24
  class Steps extends Component {
@@ -55,6 +58,9 @@ class Steps extends Component {
55
58
  }
56
59
 
57
60
  Steps.Step = Step;
61
+ Steps.FillStep = FillStep;
62
+ Steps.BasicStep = BasicStep;
63
+ Steps.NavStep = NavStep;
58
64
  Steps.propTypes = {
59
65
  onChange: PropTypes.func,
60
66
  type: PropTypes.oneOf(['fill', 'basic', 'nav']),
@@ -13,6 +13,8 @@ export interface NavStepProps {
13
13
  onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
14
14
  "role"?: React.AriaRole;
15
15
  "aria-label"?: React.AriaAttributes["aria-label"];
16
+ usedInC2D?: boolean;
17
+ size?: string;
16
18
  }
17
19
  declare const NavStep: {
18
20
  (props: NavStepProps): JSX.Element;
@@ -29,5 +31,6 @@ declare const NavStep: {
29
31
  active: boolean;
30
32
  className: string;
31
33
  };
34
+ elementType: string;
32
35
  };
33
36
  export default NavStep;
@@ -15,10 +15,13 @@ const NavStep = props => {
15
15
  total,
16
16
  onClick,
17
17
  onKeyDown,
18
- onChange
18
+ onChange,
19
+ size
19
20
  } = props;
20
21
  const classString = classnames(prefixCls, {
21
- [`${prefixCls}-active`]: active
22
+ [`${prefixCls}-active`]: active,
23
+ [`${prefixCls}-nav`]: props.usedInC2D,
24
+ [`${prefixCls}-small`]: size === 'small'
22
25
  }, className);
23
26
 
24
27
  const handleClick = e => {
@@ -68,4 +71,5 @@ NavStep.defaultProps = {
68
71
  active: false,
69
72
  className: ''
70
73
  };
74
+ NavStep.elementType = 'Steps.NavStep';
71
75
  export default NavStep;
@@ -24,7 +24,8 @@ const Steps = props => {
24
24
 
25
25
  const childProps = Object.assign({
26
26
  index,
27
- total
27
+ total,
28
+ size
28
29
  }, child.props);
29
30
  childProps.active = index === current;
30
31
  childProps.onChange = onChange ? () => {
@@ -9,5 +9,8 @@ export interface StepProps {
9
9
  style?: React.CSSProperties;
10
10
  onClick?: React.MouseEventHandler<HTMLDivElement>;
11
11
  }
12
- declare const Step: (props: StepProps) => JSX.Element;
12
+ declare const Step: {
13
+ (props: StepProps): JSX.Element;
14
+ elementType: string;
15
+ };
13
16
  export default Step;
@@ -28,4 +28,5 @@ const Step = props => {
28
28
  return renderStep();
29
29
  };
30
30
 
31
+ Step.elementType = 'Steps.Step';
31
32
  export default Step;
@@ -45,7 +45,7 @@ declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
45
45
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
47
47
  style: PropTypes.Requireable<object>;
48
- size: PropTypes.Requireable<"default" | "small" | "large">;
48
+ size: PropTypes.Requireable<"small" | "default" | "large">;
49
49
  uncheckedText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
50
50
  id: PropTypes.Requireable<string>;
51
51
  };
@@ -60,7 +60,7 @@ declare class Table<RecordType extends Record<string, any>> extends BaseComponen
60
60
  components: PropTypes.Requireable<any>;
61
61
  bordered: PropTypes.Requireable<boolean>;
62
62
  loading: PropTypes.Requireable<boolean>;
63
- size: PropTypes.Requireable<"default" | "small" | "middle">;
63
+ size: PropTypes.Requireable<"small" | "default" | "middle">;
64
64
  tableLayout: PropTypes.Requireable<"" | "fixed" | "auto">;
65
65
  columns: PropTypes.Requireable<PropTypes.InferProps<{
66
66
  align: PropTypes.Requireable<"left" | "right" | "center">;
@@ -297,7 +297,7 @@ declare class Table<RecordType extends Record<string, any>> extends BaseComponen
297
297
  showTotal?: boolean;
298
298
  pageSize?: number;
299
299
  pageSizeOpts?: number[];
300
- size?: "default" | "small";
300
+ size?: "small" | "default";
301
301
  currentPage?: number;
302
302
  defaultCurrentPage?: number;
303
303
  onPageChange?: (currentPage: number) => void;
@@ -16,7 +16,7 @@ declare class Table<RecordType extends Record<string, any> = Data> extends React
16
16
  components: PropTypes.Requireable<any>;
17
17
  bordered: PropTypes.Requireable<boolean>;
18
18
  loading: PropTypes.Requireable<boolean>;
19
- size: PropTypes.Requireable<"default" | "small" | "middle">;
19
+ size: PropTypes.Requireable<"small" | "default" | "middle">;
20
20
  tableLayout: PropTypes.Requireable<"" | "fixed" | "auto">;
21
21
  columns: PropTypes.Requireable<PropTypes.InferProps<{
22
22
  align: PropTypes.Requireable<"left" | "right" | "center">;
@@ -96,7 +96,7 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
96
96
  onAdd: PropTypes.Requireable<(...args: any[]) => any>;
97
97
  onRemove: PropTypes.Requireable<(...args: any[]) => any>;
98
98
  onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
99
- size: PropTypes.Requireable<"default" | "small" | "large">;
99
+ size: PropTypes.Requireable<"small" | "default" | "large">;
100
100
  validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
101
101
  prefix: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
102
102
  suffix: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
@@ -132,7 +132,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
132
132
  secondStep: PropTypes.Requireable<number>;
133
133
  focusOnOpen: PropTypes.Requireable<boolean>;
134
134
  autoFocus: PropTypes.Requireable<boolean>;
135
- size: PropTypes.Requireable<"default" | "small" | "large">;
135
+ size: PropTypes.Requireable<"small" | "default" | "large">;
136
136
  panels: PropTypes.Requireable<PropTypes.InferProps<{
137
137
  panelHeader: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
138
138
  panelFooter: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
@@ -49,7 +49,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
49
49
  secondStep: import("prop-types").Requireable<number>;
50
50
  focusOnOpen: import("prop-types").Requireable<boolean>;
51
51
  autoFocus: import("prop-types").Requireable<boolean>;
52
- size: import("prop-types").Requireable<"default" | "small" | "large">;
52
+ size: import("prop-types").Requireable<"small" | "default" | "large">;
53
53
  panels: import("prop-types").Requireable<import("prop-types").InferProps<{
54
54
  panelHeader: import("prop-types").Requireable<NonNullable<import("prop-types").ReactNodeLike>>;
55
55
  panelFooter: import("prop-types").Requireable<NonNullable<import("prop-types").ReactNodeLike>>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export declare type ModeType = 'left' | 'right' | 'center' | 'alternate';
3
+ export interface TimelineContextValue {
4
+ mode?: ModeType;
5
+ sum?: number;
6
+ }
7
+ declare const Context: React.Context<TimelineContextValue>;
8
+ export default Context;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ const Context = /*#__PURE__*/React.createContext(null);
3
+ export default Context;
@@ -2,12 +2,13 @@ import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import '@douyinfe/semi-foundation/lib/es/timeline/timeline.css';
4
4
  import Item, { TimelineItemProps } from './item';
5
+ import { ModeType } from './context';
5
6
  export type { TimelineItemProps } from './item';
6
7
  export interface Data extends TimelineItemProps {
7
8
  content: React.ReactNode;
8
9
  }
9
10
  export interface TimelineProps extends Pick<React.AriaAttributes, 'aria-label'> {
10
- mode?: 'left' | 'right' | 'center' | 'alternate';
11
+ mode?: ModeType;
11
12
  className?: string;
12
13
  style?: React.CSSProperties;
13
14
  dataSource?: Data[];
@@ -5,6 +5,7 @@ import '@douyinfe/semi-foundation/lib/es/timeline/timeline.css';
5
5
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/timeline/constants';
6
6
  import ConfigContext from '../configProvider/context';
7
7
  import Item from './item';
8
+ import Context from './context';
8
9
  const prefixCls = cssClasses.PREFIX;
9
10
 
10
11
  class Timeline extends PureComponent {
@@ -76,11 +77,15 @@ class Timeline extends PureComponent {
76
77
  }
77
78
 
78
79
  const items = childrenList || this.addClassName(children);
79
- return /*#__PURE__*/React.createElement("ul", {
80
+ return /*#__PURE__*/React.createElement(Context.Provider, {
81
+ value: {
82
+ mode
83
+ }
84
+ }, /*#__PURE__*/React.createElement("ul", {
80
85
  "aria-label": this.props['aria-label'],
81
86
  style: style,
82
87
  className: classString
83
- }, items);
88
+ }, items));
84
89
  }
85
90
 
86
91
  }
@@ -1,6 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import '@douyinfe/semi-foundation/lib/es/timeline/timeline.css';
4
+ import { ModeType, TimelineContextValue } from './context';
4
5
  export interface TimelineItemProps {
5
6
  color?: string;
6
7
  children?: React.ReactNode;
@@ -12,8 +13,13 @@ export interface TimelineItemProps {
12
13
  className?: string;
13
14
  style?: React.CSSProperties;
14
15
  onClick?: React.MouseEventHandler<HTMLLIElement>;
16
+ mode?: ModeType;
17
+ odd?: boolean;
18
+ usedInC2D?: boolean;
15
19
  }
16
20
  export default class Item extends PureComponent<TimelineItemProps> {
21
+ static contextType: React.Context<TimelineContextValue>;
22
+ static elementType: string;
17
23
  static propTypes: {
18
24
  color: PropTypes.Requireable<string>;
19
25
  time: PropTypes.Requireable<PropTypes.ReactNodeLike>;
@@ -24,11 +30,15 @@ export default class Item extends PureComponent<TimelineItemProps> {
24
30
  className: PropTypes.Requireable<string>;
25
31
  style: PropTypes.Requireable<object>;
26
32
  onClick: PropTypes.Requireable<(...args: any[]) => any>;
33
+ mode: PropTypes.Requireable<string>;
34
+ lastChild: PropTypes.Requireable<boolean>;
27
35
  };
36
+ context: TimelineContextValue;
28
37
  static defaultProps: {
29
38
  type: string;
30
39
  time: string;
31
40
  onClick: (...args: any[]) => void;
32
41
  };
42
+ getC2DCls: () => string;
33
43
  render(): JSX.Element;
34
44
  }
@@ -4,8 +4,42 @@ import cls from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
5
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/timeline/constants';
6
6
  import '@douyinfe/semi-foundation/lib/es/timeline/timeline.css';
7
+ import Context from './context';
7
8
  const prefixCls = cssClasses.ITEM;
8
9
  export default class Item extends PureComponent {
10
+ constructor() {
11
+ super(...arguments); // getC2DCls is used in C2D, it does not work in non-C2D scenes
12
+
13
+ this.getC2DCls = () => {
14
+ let c2dCls = '';
15
+ const {
16
+ mode,
17
+ odd,
18
+ usedInC2D
19
+ } = this.props;
20
+
21
+ if (usedInC2D) {
22
+ switch (mode) {
23
+ case 'center':
24
+ c2dCls = `${prefixCls}-center ${prefixCls}-left`;
25
+ break;
26
+
27
+ case 'alternate':
28
+ c2dCls = `${prefixCls}-alternate ${prefixCls}-${odd ? 'left' : 'right'}`;
29
+ break;
30
+
31
+ default:
32
+ c2dCls = `${prefixCls}-${mode} ${mode === 'right' ? `${prefixCls}-mode-right` : ''}`;
33
+ break;
34
+ }
35
+
36
+ c2dCls += ` ${prefixCls}-not-last-child`;
37
+ }
38
+
39
+ return c2dCls;
40
+ };
41
+ }
42
+
9
43
  render() {
10
44
  const {
11
45
  className,
@@ -18,7 +52,7 @@ export default class Item extends PureComponent {
18
52
  extra,
19
53
  onClick
20
54
  } = this.props;
21
- const itemCls = cls(prefixCls, className);
55
+ const itemCls = cls(prefixCls, className, this.getC2DCls());
22
56
  const dotCls = cls({
23
57
  [`${prefixCls}-head`]: true,
24
58
  [`${prefixCls}-head-custom`]: dot,
@@ -49,6 +83,7 @@ export default class Item extends PureComponent {
49
83
  }
50
84
 
51
85
  }
86
+ Item.contextType = Context;
52
87
  Item.propTypes = {
53
88
  color: PropTypes.string,
54
89
  time: PropTypes.node,
@@ -58,10 +93,13 @@ Item.propTypes = {
58
93
  position: PropTypes.oneOf(strings.ITEM_POS),
59
94
  className: PropTypes.string,
60
95
  style: PropTypes.object,
61
- onClick: PropTypes.func
96
+ onClick: PropTypes.func,
97
+ mode: PropTypes.string,
98
+ lastChild: PropTypes.bool
62
99
  };
63
100
  Item.defaultProps = {
64
101
  type: 'default',
65
102
  time: '',
66
103
  onClick: _noop
67
- };
104
+ };
105
+ Item.elementType = 'Timeline.Item';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.35.0-beta.0",
3
+ "version": "2.36.0-alpha.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.35.0-beta.0",
21
- "@douyinfe/semi-animation-react": "2.35.0-beta.0",
22
- "@douyinfe/semi-foundation": "2.35.0-beta.0",
23
- "@douyinfe/semi-icons": "2.35.0-beta.0",
24
- "@douyinfe/semi-illustrations": "2.35.0-beta.0",
25
- "@douyinfe/semi-theme-default": "2.35.0-beta.0",
20
+ "@douyinfe/semi-animation": "2.36.0-alpha.0",
21
+ "@douyinfe/semi-animation-react": "2.36.0-alpha.0",
22
+ "@douyinfe/semi-foundation": "2.36.0-alpha.0",
23
+ "@douyinfe/semi-icons": "2.36.0-alpha.0",
24
+ "@douyinfe/semi-illustrations": "2.36.0-alpha.0",
25
+ "@douyinfe/semi-theme-default": "2.36.0-alpha.0",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "5f8a2d3593d072d886ec8863c31892fdd4caf8d2",
72
+ "gitHead": "b0ea78a81e9ba459f9f5a06c831235a5d5e9d3a0",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",