@douyinfe/semi-ui 2.33.1 → 2.34.0-alpha.1

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 (61) hide show
  1. package/dist/css/semi.css +493 -23
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +260 -144
  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/navigation/Item.d.ts +4 -0
  8. package/lib/cjs/navigation/Item.js +29 -10
  9. package/lib/cjs/navigation/SubNav.d.ts +5 -0
  10. package/lib/cjs/navigation/SubNav.js +51 -26
  11. package/lib/cjs/skeleton/index.d.ts +1 -0
  12. package/lib/cjs/skeleton/index.js +1 -0
  13. package/lib/cjs/skeleton/item.d.ts +1 -0
  14. package/lib/cjs/skeleton/item.js +6 -1
  15. package/lib/cjs/steps/basicStep.d.ts +3 -0
  16. package/lib/cjs/steps/basicStep.js +8 -2
  17. package/lib/cjs/steps/basicSteps.js +2 -1
  18. package/lib/cjs/steps/fillStep.d.ts +2 -0
  19. package/lib/cjs/steps/fillStep.js +3 -1
  20. package/lib/cjs/steps/fillSteps.js +5 -8
  21. package/lib/cjs/steps/index.d.ts +63 -1
  22. package/lib/cjs/steps/index.js +9 -0
  23. package/lib/cjs/steps/navStep.d.ts +3 -0
  24. package/lib/cjs/steps/navStep.js +6 -2
  25. package/lib/cjs/steps/navSteps.js +2 -1
  26. package/lib/cjs/steps/step.d.ts +4 -1
  27. package/lib/cjs/steps/step.js +1 -0
  28. package/lib/cjs/timeline/context.d.ts +8 -0
  29. package/lib/cjs/timeline/context.js +15 -0
  30. package/lib/cjs/timeline/index.d.ts +2 -1
  31. package/lib/cjs/timeline/index.js +8 -2
  32. package/lib/cjs/timeline/item.d.ts +10 -0
  33. package/lib/cjs/timeline/item.js +42 -3
  34. package/lib/es/navigation/Item.d.ts +4 -0
  35. package/lib/es/navigation/Item.js +28 -10
  36. package/lib/es/navigation/SubNav.d.ts +5 -0
  37. package/lib/es/navigation/SubNav.js +52 -26
  38. package/lib/es/skeleton/index.d.ts +1 -0
  39. package/lib/es/skeleton/index.js +1 -0
  40. package/lib/es/skeleton/item.d.ts +1 -0
  41. package/lib/es/skeleton/item.js +6 -1
  42. package/lib/es/steps/basicStep.d.ts +3 -0
  43. package/lib/es/steps/basicStep.js +8 -2
  44. package/lib/es/steps/basicSteps.js +2 -1
  45. package/lib/es/steps/fillStep.d.ts +2 -0
  46. package/lib/es/steps/fillStep.js +3 -1
  47. package/lib/es/steps/fillSteps.js +6 -8
  48. package/lib/es/steps/index.d.ts +63 -1
  49. package/lib/es/steps/index.js +6 -0
  50. package/lib/es/steps/navStep.d.ts +3 -0
  51. package/lib/es/steps/navStep.js +6 -2
  52. package/lib/es/steps/navSteps.js +2 -1
  53. package/lib/es/steps/step.d.ts +4 -1
  54. package/lib/es/steps/step.js +1 -0
  55. package/lib/es/timeline/context.d.ts +8 -0
  56. package/lib/es/timeline/context.js +3 -0
  57. package/lib/es/timeline/index.d.ts +2 -1
  58. package/lib/es/timeline/index.js +7 -2
  59. package/lib/es/timeline/item.d.ts +10 -0
  60. package/lib/es/timeline/item.js +41 -3
  61. package/package.json +8 -8
@@ -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,11 +48,11 @@ const Steps = props => {
50
48
  if (index !== current) {
51
49
  onChange(index + initial);
52
50
  }
53
- };
51
+ }; // Whether colStyle is set has no effect
52
+ // return <Col style={colStyle}>{cloneElement(child, { ...childProps })}</Col>;
53
+
54
54
 
55
- return /*#__PURE__*/React.createElement(Col, {
56
- style: colStyle
57
- }, /*#__PURE__*/cloneElement(child, Object.assign({}, childProps)));
55
+ return /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/cloneElement(child, Object.assign({}, childProps)));
58
56
  });
59
57
  return content;
60
58
  }, [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>;
@@ -18,6 +18,9 @@ import Step from './step';
18
18
  import FillSteps from './fillSteps';
19
19
  import BasicSteps from './basicSteps';
20
20
  import NavSteps from './navSteps';
21
+ import FillStep from './fillStep';
22
+ import BasicStep from './basicStep';
23
+ import NavStep from './navStep';
21
24
  import Context from './context';
22
25
 
23
26
  class Steps extends Component {
@@ -57,6 +60,9 @@ class Steps extends Component {
57
60
  }
58
61
 
59
62
  Steps.Step = Step;
63
+ Steps.FillStep = FillStep;
64
+ Steps.BasicStep = BasicStep;
65
+ Steps.NavStep = NavStep;
60
66
  Steps.propTypes = {
61
67
  onChange: PropTypes.func,
62
68
  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;
@@ -16,10 +16,13 @@ const NavStep = props => {
16
16
  total,
17
17
  onClick,
18
18
  onKeyDown,
19
- onChange
19
+ onChange,
20
+ size
20
21
  } = props;
21
22
  const classString = classnames(prefixCls, {
22
- [`${prefixCls}-active`]: active
23
+ [`${prefixCls}-active`]: active,
24
+ [`${prefixCls}-nav`]: props.usedInC2D,
25
+ [`${prefixCls}-small`]: size === 'small'
23
26
  }, className);
24
27
 
25
28
  const handleClick = e => {
@@ -75,4 +78,5 @@ NavStep.defaultProps = {
75
78
  active: false,
76
79
  className: ''
77
80
  };
81
+ NavStep.elementType = 'Steps.NavStep';
78
82
  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
 
@@ -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;
@@ -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.33.1",
3
+ "version": "2.34.0-alpha.1",
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.33.1",
21
- "@douyinfe/semi-animation-react": "2.33.1",
22
- "@douyinfe/semi-foundation": "2.33.1",
23
- "@douyinfe/semi-icons": "2.33.1",
24
- "@douyinfe/semi-illustrations": "2.33.1",
25
- "@douyinfe/semi-theme-default": "2.33.1",
20
+ "@douyinfe/semi-animation": "2.34.0-alpha.1",
21
+ "@douyinfe/semi-animation-react": "2.34.0-alpha.1",
22
+ "@douyinfe/semi-foundation": "2.34.0-alpha.1",
23
+ "@douyinfe/semi-icons": "2.34.0-alpha.1",
24
+ "@douyinfe/semi-illustrations": "2.34.0-alpha.1",
25
+ "@douyinfe/semi-theme-default": "2.34.0-alpha.1",
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": "1810821764823ef746b7a88aae299d12a31cca5d",
72
+ "gitHead": "8990c51afec33fcfc2f89234082597e484513756",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",