@douyinfe/semi-ui 2.17.1 → 2.19.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 (172) hide show
  1. package/anchor/index.tsx +1 -1
  2. package/anchor/link.tsx +3 -4
  3. package/autoComplete/__test__/autoComplete.test.js +6 -6
  4. package/autoComplete/index.tsx +1 -1
  5. package/autoComplete/option.tsx +164 -0
  6. package/calendar/__test__/calendar.test.js +21 -2
  7. package/calendar/_story/calendar.stories.js +31 -0
  8. package/calendar/index.tsx +3 -1
  9. package/calendar/interface.ts +2 -1
  10. package/carousel/index.tsx +5 -5
  11. package/checkbox/checkbox.tsx +10 -2
  12. package/checkbox/checkboxGroup.tsx +2 -0
  13. package/dist/css/semi.css +160 -22
  14. package/dist/css/semi.min.css +1 -1
  15. package/dist/umd/semi-ui.js +15144 -16407
  16. package/dist/umd/semi-ui.js.map +1 -1
  17. package/dist/umd/semi-ui.min.js +1 -1
  18. package/dist/umd/semi-ui.min.js.map +1 -1
  19. package/form/_story/FieldProps/labelOptional.jsx +30 -0
  20. package/form/_story/form.stories.js +7 -0
  21. package/form/hoc/withField.tsx +1 -0
  22. package/form/label.tsx +21 -7
  23. package/gulpfile.js +3 -1
  24. package/lib/cjs/_base/base.css +35 -0
  25. package/lib/cjs/anchor/index.js +2 -1
  26. package/lib/cjs/anchor/link.d.ts +1 -1
  27. package/lib/cjs/anchor/link.js +9 -5
  28. package/lib/cjs/autoComplete/index.d.ts +1 -1
  29. package/lib/cjs/autoComplete/index.js +1 -1
  30. package/lib/cjs/autoComplete/option.d.ts +50 -0
  31. package/lib/cjs/autoComplete/option.js +218 -0
  32. package/lib/cjs/calendar/index.d.ts +2 -0
  33. package/lib/cjs/calendar/index.js +3 -1
  34. package/lib/cjs/calendar/interface.d.ts +2 -1
  35. package/lib/cjs/carousel/index.js +2 -2
  36. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  37. package/lib/cjs/checkbox/checkbox.js +9 -3
  38. package/lib/cjs/checkbox/checkboxGroup.js +4 -2
  39. package/lib/cjs/form/baseForm.d.ts +1 -1
  40. package/lib/cjs/form/field.d.ts +1 -1
  41. package/lib/cjs/form/hoc/withField.js +2 -1
  42. package/lib/cjs/form/label.d.ts +8 -5
  43. package/lib/cjs/form/label.js +15 -4
  44. package/lib/cjs/locale/interface.d.ts +3 -0
  45. package/lib/cjs/locale/source/ar.js +3 -0
  46. package/lib/cjs/locale/source/de.js +3 -0
  47. package/lib/cjs/locale/source/en_GB.js +3 -0
  48. package/lib/cjs/locale/source/en_US.js +3 -0
  49. package/lib/cjs/locale/source/es.js +3 -0
  50. package/lib/cjs/locale/source/fr.js +3 -0
  51. package/lib/cjs/locale/source/id_ID.js +3 -0
  52. package/lib/cjs/locale/source/it.js +3 -0
  53. package/lib/cjs/locale/source/ja_JP.js +3 -0
  54. package/lib/cjs/locale/source/ko_KR.js +3 -0
  55. package/lib/cjs/locale/source/ms_MY.js +3 -0
  56. package/lib/cjs/locale/source/pt_BR.js +3 -0
  57. package/lib/cjs/locale/source/ru_RU.js +3 -0
  58. package/lib/cjs/locale/source/th_TH.js +3 -0
  59. package/lib/cjs/locale/source/tr_TR.js +3 -0
  60. package/lib/cjs/locale/source/vi_VN.js +3 -0
  61. package/lib/cjs/locale/source/zh_CN.js +3 -0
  62. package/lib/cjs/locale/source/zh_TW.js +3 -0
  63. package/lib/cjs/modal/Modal.js +0 -8
  64. package/lib/cjs/modal/ModalContent.js +4 -1
  65. package/lib/cjs/radio/radio.d.ts +2 -0
  66. package/lib/cjs/radio/radio.js +33 -8
  67. package/lib/cjs/radio/radioGroup.js +4 -2
  68. package/lib/cjs/tag/group.d.ts +3 -0
  69. package/lib/cjs/tag/group.js +24 -6
  70. package/lib/cjs/tag/index.d.ts +2 -1
  71. package/lib/cjs/tag/index.js +7 -5
  72. package/lib/cjs/tag/interface.d.ts +2 -1
  73. package/lib/cjs/tree/index.d.ts +3 -1
  74. package/lib/cjs/tree/index.js +23 -0
  75. package/lib/cjs/tree/interface.d.ts +4 -0
  76. package/lib/cjs/typography/title.d.ts +1 -1
  77. package/lib/es/_base/base.css +35 -0
  78. package/lib/es/anchor/index.js +2 -1
  79. package/lib/es/anchor/link.d.ts +1 -1
  80. package/lib/es/anchor/link.js +9 -5
  81. package/lib/es/autoComplete/index.d.ts +1 -1
  82. package/lib/es/autoComplete/index.js +1 -1
  83. package/lib/es/autoComplete/option.d.ts +50 -0
  84. package/lib/es/autoComplete/option.js +188 -0
  85. package/lib/es/calendar/index.d.ts +2 -0
  86. package/lib/es/calendar/index.js +3 -1
  87. package/lib/es/calendar/interface.d.ts +2 -1
  88. package/lib/es/carousel/index.js +2 -2
  89. package/lib/es/checkbox/checkbox.d.ts +4 -0
  90. package/lib/es/checkbox/checkbox.js +10 -4
  91. package/lib/es/checkbox/checkboxGroup.js +4 -2
  92. package/lib/es/form/baseForm.d.ts +1 -1
  93. package/lib/es/form/field.d.ts +1 -1
  94. package/lib/es/form/hoc/withField.js +2 -1
  95. package/lib/es/form/label.d.ts +8 -5
  96. package/lib/es/form/label.js +13 -4
  97. package/lib/es/locale/interface.d.ts +3 -0
  98. package/lib/es/locale/source/ar.js +3 -0
  99. package/lib/es/locale/source/de.js +3 -0
  100. package/lib/es/locale/source/en_GB.js +3 -0
  101. package/lib/es/locale/source/en_US.js +3 -0
  102. package/lib/es/locale/source/es.js +3 -0
  103. package/lib/es/locale/source/fr.js +3 -0
  104. package/lib/es/locale/source/id_ID.js +3 -0
  105. package/lib/es/locale/source/it.js +3 -0
  106. package/lib/es/locale/source/ja_JP.js +3 -0
  107. package/lib/es/locale/source/ko_KR.js +3 -0
  108. package/lib/es/locale/source/ms_MY.js +3 -0
  109. package/lib/es/locale/source/pt_BR.js +3 -0
  110. package/lib/es/locale/source/ru_RU.js +3 -0
  111. package/lib/es/locale/source/th_TH.js +3 -0
  112. package/lib/es/locale/source/tr_TR.js +3 -0
  113. package/lib/es/locale/source/vi_VN.js +3 -0
  114. package/lib/es/locale/source/zh_CN.js +3 -0
  115. package/lib/es/locale/source/zh_TW.js +3 -0
  116. package/lib/es/modal/Modal.js +0 -8
  117. package/lib/es/modal/ModalContent.js +4 -1
  118. package/lib/es/radio/radio.d.ts +2 -0
  119. package/lib/es/radio/radio.js +31 -8
  120. package/lib/es/radio/radioGroup.js +4 -2
  121. package/lib/es/tag/group.d.ts +3 -0
  122. package/lib/es/tag/group.js +24 -6
  123. package/lib/es/tag/index.d.ts +2 -1
  124. package/lib/es/tag/index.js +7 -5
  125. package/lib/es/tag/interface.d.ts +2 -1
  126. package/lib/es/tree/index.d.ts +3 -1
  127. package/lib/es/tree/index.js +22 -0
  128. package/lib/es/tree/interface.d.ts +4 -0
  129. package/lib/es/typography/title.d.ts +1 -1
  130. package/locale/interface.ts +3 -0
  131. package/locale/source/ar.ts +3 -0
  132. package/locale/source/de.ts +3 -0
  133. package/locale/source/en_GB.ts +3 -0
  134. package/locale/source/en_US.ts +3 -0
  135. package/locale/source/es.ts +3 -0
  136. package/locale/source/fr.ts +3 -0
  137. package/locale/source/id_ID.ts +3 -0
  138. package/locale/source/it.ts +3 -0
  139. package/locale/source/ja_JP.ts +3 -0
  140. package/locale/source/ko_KR.ts +3 -0
  141. package/locale/source/ms_MY.ts +3 -0
  142. package/locale/source/pt_BR.ts +3 -0
  143. package/locale/source/ru_RU.ts +3 -0
  144. package/locale/source/th_TH.ts +3 -0
  145. package/locale/source/tr_TR.ts +4 -1
  146. package/locale/source/vi_VN.ts +3 -0
  147. package/locale/source/zh_CN.ts +3 -0
  148. package/locale/source/zh_TW.ts +3 -0
  149. package/modal/Modal.tsx +0 -6
  150. package/modal/ModalContent.tsx +4 -1
  151. package/modal/__test__/modal.test.js +1 -1
  152. package/modal/_story/__snapshots__/modal.stories.tsx.snap +203 -0
  153. package/package.json +7 -7
  154. package/radio/_story/radio.stories.js +2 -2
  155. package/radio/radio.tsx +27 -5
  156. package/radio/radioGroup.tsx +2 -0
  157. package/rating/__test__/rating.test.js +1 -1
  158. package/select/__test__/select.test.js +11 -17
  159. package/select/_story/select.stories.js +6 -6
  160. package/steps/_story/steps.stories.js +3 -3
  161. package/switch/_story/switch.stories.js +4 -4
  162. package/switch/_story/switch.stories.tsx +4 -4
  163. package/tag/_story/tag.stories.js +57 -1
  164. package/tag/group.tsx +20 -3
  165. package/tag/index.tsx +6 -5
  166. package/tag/interface.ts +2 -1
  167. package/transfer/_story/transfer.stories.js +2 -2
  168. package/tree/_story/tree.stories.js +152 -3
  169. package/tree/index.tsx +16 -1
  170. package/tree/interface.ts +6 -0
  171. package/upload/_story/upload.stories.js +2 -2
  172. package/webpack.config.js +10 -2
@@ -0,0 +1,30 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import React, { useState, useLayoutEffect, useEffect, useRef } from 'react';
3
+ import { storiesOf } from '@storybook/react';
4
+ import { Button, Modal, TreeSelect, Row, Col, Avatar, Tabs, TabPane, Badge, LocaleProvider } from '@douyinfe/semi-ui';
5
+ import {
6
+ Form,
7
+ } from '../../index';
8
+
9
+ const { Input, Select, DatePicker, Switch, Slider, CheckboxGroup, Checkbox, RadioGroup, Radio, TimePicker } = Form;
10
+
11
+
12
+ const LableOptionalDemo = () => {
13
+ const helpText = <span style={{ color: 'var(--semi-color-warning)' }}>密码强度:弱</span>;
14
+ return (
15
+ <Form>
16
+ <Form.Input
17
+ field="semi"
18
+ label={{ text: 'semi', optional: true }}
19
+ helpText={helpText}
20
+ />
21
+ <Form.Input
22
+ field="label2"
23
+ label={{ text: 'semi', optional: true }}
24
+ helpText={helpText}
25
+ />
26
+ </Form>
27
+ );
28
+ };
29
+
30
+ export { LableOptionalDemo };
@@ -70,6 +70,7 @@ import { HelpAndExtra, ExtraPositionDemo } from './FieldProps/helpAndExtra';
70
70
  import { BigNumberFieldDemo } from './FieldProps/bigNumberFieldPath';
71
71
  import { UpdateDemo, RuleupdateDemo } from './FieldProps/rulesUpdateDemo';
72
72
  import { FieldRefDemo } from './FieldProps/fieldRef';
73
+ import { LableOptionalDemo } from './FieldProps/labelOptional';
73
74
 
74
75
  // arrayField
75
76
  import {
@@ -129,6 +130,12 @@ LayoutInsetLabel.story = {
129
130
  name: 'Layout-insetLabel',
130
131
  };
131
132
 
133
+ export const LableOptional = () => <LableOptionalDemo></LableOptionalDemo>;
134
+
135
+ LableOptional.story = {
136
+ name: 'Layout-label show optional',
137
+ };
138
+
132
139
  export const LayoutSlotErrorMessageLabel = () => <AssistComponent />;
133
140
 
134
141
  LayoutSlotErrorMessageLabel.story = {
@@ -110,6 +110,7 @@ function withField<
110
110
  }
111
111
  } catch (err) {}
112
112
 
113
+ // FIXME typeof initVal
113
114
  const [value, setValue, getVal] = useStateWithGetter(typeof initVal !== undefined ? initVal : null);
114
115
  const validateOnMount = trigger.includes('mount');
115
116
 
package/form/label.tsx CHANGED
@@ -2,26 +2,29 @@ import React, { PureComponent } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
4
  import { cssClasses } from '@douyinfe/semi-foundation/form/constants';
5
+ import LocaleConsumer from '../locale/localeConsumer';
6
+ import { Locale } from '../locale/interface';
5
7
 
6
8
  const prefixCls = cssClasses.PREFIX;
7
9
 
8
10
  export interface LabelProps {
11
+ /** text-align of label */
12
+ align?: string;
13
+ className?: string;
14
+ children?: React.ReactNode;
15
+ disabled?: boolean;
9
16
  id?: string;
10
17
  /** Whether to display the required * symbol */
11
18
  required?: boolean;
12
19
  /** Content of label */
13
20
  text?: React.ReactNode;
14
- disabled?: boolean;
15
21
  /** Used to configure the htmlFor attribute of the label tag */
16
22
  name?: string;
17
- /** text-align of label */
18
- align?: string;
19
23
  /** width of label */
20
24
  width?: number | string;
21
25
  style?: React.CSSProperties;
22
- className?: string;
23
- children?: React.ReactNode;
24
26
  extra?: React.ReactNode;
27
+ optional?: boolean;
25
28
  }
26
29
 
27
30
  export default class Label extends PureComponent<LabelProps> {
@@ -29,7 +32,8 @@ export default class Label extends PureComponent<LabelProps> {
29
32
  required: false,
30
33
  name: '',
31
34
  align: 'left',
32
- className: ''
35
+ className: '',
36
+ optional: false,
33
37
  };
34
38
 
35
39
  static propTypes = {
@@ -44,10 +48,11 @@ export default class Label extends PureComponent<LabelProps> {
44
48
  style: PropTypes.object,
45
49
  className: PropTypes.string,
46
50
  extra: PropTypes.node,
51
+ optional: PropTypes.bool,
47
52
  };
48
53
 
49
54
  render() {
50
- const { children, required, text, disabled, name, width, align, style, className, extra, id } = this.props;
55
+ const { children, required, text, disabled, name, width, align, style, className, extra, id, optional } = this.props;
51
56
 
52
57
  const labelCls = classNames(className, {
53
58
  [`${prefixCls}-field-label`]: true,
@@ -60,9 +65,18 @@ export default class Label extends PureComponent<LabelProps> {
60
65
  const labelStyle = style ? style : {};
61
66
  width ? labelStyle.width = width : null;
62
67
 
68
+ const optionalText = (
69
+ <LocaleConsumer<Locale['Form']> componentName="Form" >
70
+ {(locale: Locale['Form']) => (
71
+ <span className={`${prefixCls}-field-label-optional-text`}>{locale.optional}</span>
72
+ )}
73
+ </LocaleConsumer>
74
+ );
75
+
63
76
  const textContent = (
64
77
  <div className={`${prefixCls}-field-label-text`} x-semi-prop="label">
65
78
  {typeof text !== 'undefined' ? text : children}
79
+ {optional ? optionalText : null}
66
80
  </div>
67
81
  );
68
82
 
package/gulpfile.js CHANGED
@@ -63,8 +63,10 @@ gulp.task('compileScss', function compileScss() {
63
63
  const rootPath = path.join(__dirname, '../../');
64
64
  const scssVarStr = `@import "${rootPath}/packages/semi-theme-default/scss/index.scss";\n`;
65
65
  const cssVarStr = `@import "${rootPath}/packages/semi-theme-default/scss/global.scss";\n`;
66
+ const animationStr = `@import "${rootPath}/packages/semi-theme-default/scss/animation.scss";\n`;
67
+ const animationBuffer = Buffer.from(animationStr);
66
68
  const scssBuffer = Buffer.from(scssVarStr);
67
- const buffers = [scssBuffer];
69
+ const buffers = [scssBuffer,animationBuffer];
68
70
  if (/_base\/base\.scss/.test(chunk.path)) {
69
71
  buffers.push(Buffer.from(cssVarStr));
70
72
  }
@@ -1,6 +1,41 @@
1
1
  /* shadow */
2
2
  /* sizing */
3
3
  /* spacing */
4
+ body {
5
+ --semi-transition_duration-slowest:0ms;
6
+ --semi-transition_duration-slower:0ms;
7
+ --semi-transition_duration-slow:0ms;
8
+ --semi-transition_duration-normal:0ms;
9
+ --semi-transition_duration-fast:0ms;
10
+ --semi-transition_duration-faster:0ms;
11
+ --semi-transition_duration-fastest:0ms;
12
+ --semi-transition_function-linear:linear;
13
+ --semi-transition_function-ease:ease;
14
+ --semi-transition_function-easeIn:ease-in;
15
+ --semi-transition_function-easeOut:ease-out;
16
+ --semi-transition_function-easeInIOut:ease-in-out;
17
+ --semi-transition_delay-slowest:0ms;
18
+ --semi-transition_delay-slower:0ms;
19
+ --semi-transition_delay-slow:0ms;
20
+ --semi-transition_delay-normal:0ms;
21
+ --semi-transition_delay-fast:0ms;
22
+ --semi-transition_delay-faster:0ms;
23
+ --semi-transition_delay-fastest:0ms;
24
+ --semi-transform_scale-none:scale(1,1);
25
+ --semi-transform_scale-small:scale(1,1);
26
+ --semi-transform_scale-medium:scale(1,1);
27
+ --semi-transform_scale-large:scale(1,1);
28
+ --semi-transform-rotate-none:rotate(0deg);
29
+ --semi-transform_rotate-clockwise90deg:rotate(90deg);
30
+ --semi-transform_rotate-clockwise180deg:rotate(180deg);
31
+ --semi-transform_rotate-clockwise270deg:rotate(270deg);
32
+ --semi-transform_rotate-clockwise360deg:rotate(360deg);
33
+ --semi-transform_rotate-anticlockwise90deg:rotate(-90deg);
34
+ --semi-transform_rotate-anticlockwise180deg:rotate(-180deg);
35
+ --semi-transform_rotate-anticlockwise270deg:rotate(-270deg);
36
+ --semi-transform_rotate-anticlockwise360deg:rotate(-360deg);
37
+ }
38
+
4
39
  body,
5
40
  body .semi-always-light {
6
41
  --semi-amber-0: 254,251,235;
@@ -297,7 +297,8 @@ class Anchor extends _baseComponent.default {
297
297
  top: slideBarTop
298
298
  }
299
299
  })), /*#__PURE__*/_react.default.createElement("div", {
300
- className: anchorWrapper
300
+ className: anchorWrapper,
301
+ role: "list"
301
302
  }, children)));
302
303
  }
303
304
 
@@ -36,6 +36,6 @@ export default class Link extends BaseComponent<LinkProps, {}> {
36
36
  componentDidUpdate(prevProps: LinkProps): void;
37
37
  componentWillUnmount(): void;
38
38
  renderTitle: () => string | number | boolean | React.ReactFragment | JSX.Element;
39
- renderChildren: () => React.ReactNode;
39
+ renderChildren: () => JSX.Element;
40
40
  render(): JSX.Element;
41
41
  }
@@ -87,10 +87,14 @@ class Link extends _baseComponent.default {
87
87
  } = this.props;
88
88
 
89
89
  if (!this.context.autoCollapse) {
90
- return this.props.children;
90
+ return /*#__PURE__*/_react.default.createElement("div", {
91
+ role: "list"
92
+ }, children);
91
93
  }
92
94
 
93
- return activeLink === href || childMap[href] && childMap[href].has(activeLink) ? children : null;
95
+ return activeLink === href || childMap[href] && childMap[href].has(activeLink) ? /*#__PURE__*/_react.default.createElement("div", {
96
+ role: "list"
97
+ }, children) : null;
94
98
  };
95
99
 
96
100
  this.foundation = new _linkFoundation.default(this.adapter);
@@ -166,8 +170,7 @@ class Link extends _baseComponent.default {
166
170
  ["".concat(prefixCls, "-link-title-disabled")]: disabled
167
171
  });
168
172
  const ariaProps = {
169
- 'aria-disabled': disabled,
170
- 'aria-label': href
173
+ 'aria-disabled': disabled
171
174
  };
172
175
 
173
176
  if (active) {
@@ -180,7 +183,8 @@ class Link extends _baseComponent.default {
180
183
 
181
184
  return /*#__PURE__*/_react.default.createElement("div", {
182
185
  className: linkCls,
183
- style: style
186
+ style: style,
187
+ role: "listitem"
184
188
  }, /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
185
189
  role: "link",
186
190
  tabIndex: 0
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { AutoCompleteAdapter, StateOptionItem, DataItem } from '@douyinfe/semi-foundation/lib/cjs/autoComplete/foundation';
4
4
  import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
5
5
  import { Position } from '../tooltip';
6
- import Option from '../select/option';
6
+ import Option from './option';
7
7
  import '@douyinfe/semi-foundation/lib/cjs/autoComplete/autoComplete.css';
8
8
  import { Motion } from '../_base/base';
9
9
  /**
@@ -48,7 +48,7 @@ var _input = _interopRequireDefault(require("../input"));
48
48
 
49
49
  var _trigger = _interopRequireDefault(require("../trigger"));
50
50
 
51
- var _option = _interopRequireDefault(require("../select/option"));
51
+ var _option = _interopRequireDefault(require("./option"));
52
52
 
53
53
  var _warning = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/warning"));
54
54
 
@@ -0,0 +1,50 @@
1
+ import React, { PureComponent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { BasicOptionProps } from '@douyinfe/semi-foundation/lib/cjs/autoComplete/optionFoundation';
4
+ export interface OptionProps extends BasicOptionProps {
5
+ [x: string]: any;
6
+ value?: string | number;
7
+ label?: string | number | React.ReactNode;
8
+ children?: React.ReactNode;
9
+ disabled?: boolean;
10
+ showTick?: boolean;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ }
14
+ interface renderOptionContentArgument {
15
+ config: {
16
+ searchWords: any;
17
+ sourceString: React.ReactNode;
18
+ };
19
+ children: React.ReactNode;
20
+ inputValue: string;
21
+ prefixCls: string;
22
+ }
23
+ declare class Option extends PureComponent<OptionProps> {
24
+ static isSelectOption: boolean;
25
+ static propTypes: {
26
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
27
+ disabled: PropTypes.Requireable<boolean>;
28
+ value: PropTypes.Requireable<string | number>;
29
+ selected: PropTypes.Requireable<boolean>;
30
+ label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
+ empty: PropTypes.Requireable<boolean>;
32
+ emptyContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
33
+ onSelect: PropTypes.Requireable<(...args: any[]) => any>;
34
+ focused: PropTypes.Requireable<boolean>;
35
+ showTick: PropTypes.Requireable<boolean>;
36
+ className: PropTypes.Requireable<string>;
37
+ style: PropTypes.Requireable<object>;
38
+ onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
39
+ prefixCls: PropTypes.Requireable<string>;
40
+ renderOptionItem: PropTypes.Requireable<(...args: any[]) => any>;
41
+ inputValue: PropTypes.Requireable<string>;
42
+ };
43
+ static defaultProps: {
44
+ prefixCls: string;
45
+ };
46
+ onClick({ value, label, children, ...rest }: Partial<OptionProps>, event: React.MouseEvent): void;
47
+ renderOptionContent({ config, children, inputValue, prefixCls }: renderOptionContentArgument): React.ReactNode;
48
+ render(): any;
49
+ }
50
+ export default Option;
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
+
9
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
+
11
+ _Object$defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+
15
+ exports.default = void 0;
16
+
17
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
18
+
19
+ var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
20
+
21
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
22
+
23
+ var _isString2 = _interopRequireDefault(require("lodash/isString"));
24
+
25
+ var _react = _interopRequireWildcard(require("react"));
26
+
27
+ var _classnames = _interopRequireDefault(require("classnames"));
28
+
29
+ var _propTypes = _interopRequireDefault(require("prop-types"));
30
+
31
+ var _constants = require("@douyinfe/semi-foundation/lib/cjs/autoComplete/constants");
32
+
33
+ var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
34
+
35
+ var _semiIcons = require("@douyinfe/semi-icons");
36
+
37
+ var _index = require("../_utils/index");
38
+
39
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
40
+
41
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
42
+
43
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
44
+ var t = {};
45
+
46
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && (0, _indexOf.default)(e).call(e, p) < 0) t[p] = s[p];
47
+
48
+ if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
49
+ if ((0, _indexOf.default)(e).call(e, p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
50
+ }
51
+ return t;
52
+ };
53
+ /* eslint-disable max-len */
54
+
55
+
56
+ class Option extends _react.PureComponent {
57
+ onClick(_a, event) {
58
+ var {
59
+ value,
60
+ label,
61
+ children
62
+ } = _a,
63
+ rest = __rest(_a, ["value", "label", "children"]);
64
+
65
+ const {
66
+ props
67
+ } = this;
68
+ const isDisabled = props.disabled;
69
+
70
+ if (!isDisabled) {
71
+ props.onSelect((0, _assign.default)((0, _assign.default)({}, rest), {
72
+ value,
73
+ label: label || children
74
+ }), event);
75
+ }
76
+ }
77
+
78
+ renderOptionContent(_ref) {
79
+ let {
80
+ config,
81
+ children,
82
+ inputValue,
83
+ prefixCls
84
+ } = _ref;
85
+
86
+ if ((0, _isString2.default)(children) && inputValue) {
87
+ return (0, _index.getHighLightTextHTML)(config);
88
+ }
89
+
90
+ return children;
91
+ }
92
+
93
+ render() {
94
+ const _a = this.props,
95
+ {
96
+ children,
97
+ disabled,
98
+ value,
99
+ selected,
100
+ label,
101
+ empty,
102
+ emptyContent,
103
+ onSelect,
104
+ focused,
105
+ showTick,
106
+ className,
107
+ style,
108
+ onMouseEnter,
109
+ prefixCls,
110
+ renderOptionItem,
111
+ inputValue
112
+ } = _a,
113
+ rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue"]);
114
+
115
+ const optionClassName = (0, _classnames.default)(prefixCls, {
116
+ ["".concat(prefixCls, "-disabled")]: disabled,
117
+ ["".concat(prefixCls, "-selected")]: selected,
118
+ ["".concat(prefixCls, "-focused")]: focused,
119
+ ["".concat(prefixCls, "-empty")]: empty,
120
+ [className]: className
121
+ });
122
+ const selectedIconClassName = (0, _classnames.default)(["".concat(prefixCls, "-icon")]);
123
+
124
+ if (empty) {
125
+ if (emptyContent === null) {
126
+ return null;
127
+ }
128
+
129
+ return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
130
+ componentName: "Select"
131
+ }, locale => /*#__PURE__*/_react.default.createElement("div", {
132
+ className: optionClassName,
133
+ "x-semi-prop": "emptyContent"
134
+ }, emptyContent || locale.emptyText));
135
+ } // Since there are empty, locale and other logic, the custom renderOptionItem is directly converged to the internal option instead of being placed in Select/index
136
+
137
+
138
+ if (typeof renderOptionItem === 'function') {
139
+ return renderOptionItem((0, _assign.default)({
140
+ disabled,
141
+ focused,
142
+ selected,
143
+ style,
144
+ label,
145
+ value,
146
+ inputValue,
147
+ onMouseEnter: e => onMouseEnter(e),
148
+ onClick: e => this.onClick((0, _assign.default)({
149
+ value,
150
+ label,
151
+ children
152
+ }, rest), e)
153
+ }, rest));
154
+ }
155
+
156
+ const config = {
157
+ searchWords: inputValue,
158
+ sourceString: children,
159
+ option: {
160
+ highlightClassName: "".concat(prefixCls, "-keyword")
161
+ }
162
+ };
163
+ return (
164
+ /*#__PURE__*/
165
+ // eslint-disable-next-line jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events
166
+ _react.default.createElement("div", {
167
+ className: optionClassName,
168
+ onClick: e => {
169
+ this.onClick((0, _assign.default)({
170
+ value,
171
+ label,
172
+ children
173
+ }, rest), e);
174
+ },
175
+ onMouseEnter: e => onMouseEnter && onMouseEnter(e),
176
+ role: "option",
177
+ "aria-selected": selected ? "true" : "false",
178
+ "aria-disabled": disabled ? "true" : "false",
179
+ style: style
180
+ }, showTick ? /*#__PURE__*/_react.default.createElement("div", {
181
+ className: selectedIconClassName
182
+ }, /*#__PURE__*/_react.default.createElement(_semiIcons.IconTick, null)) : null, (0, _isString2.default)(children) ? /*#__PURE__*/_react.default.createElement("div", {
183
+ className: "".concat(prefixCls, "-text")
184
+ }, this.renderOptionContent({
185
+ children,
186
+ config,
187
+ inputValue,
188
+ prefixCls
189
+ })) : children)
190
+ );
191
+ }
192
+
193
+ }
194
+
195
+ Option.isSelectOption = true;
196
+ Option.propTypes = {
197
+ children: _propTypes.default.node,
198
+ disabled: _propTypes.default.bool,
199
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
200
+ selected: _propTypes.default.bool,
201
+ label: _propTypes.default.node,
202
+ empty: _propTypes.default.bool,
203
+ emptyContent: _propTypes.default.node,
204
+ onSelect: _propTypes.default.func,
205
+ focused: _propTypes.default.bool,
206
+ showTick: _propTypes.default.bool,
207
+ className: _propTypes.default.string,
208
+ style: _propTypes.default.object,
209
+ onMouseEnter: _propTypes.default.func,
210
+ prefixCls: _propTypes.default.string,
211
+ renderOptionItem: _propTypes.default.func,
212
+ inputValue: _propTypes.default.string
213
+ };
214
+ Option.defaultProps = {
215
+ prefixCls: _constants.cssClasses.PREFIX_OPTION
216
+ };
217
+ var _default = Option;
218
+ exports.default = _default;
@@ -18,6 +18,7 @@ declare class Calendar extends BaseComponent<CalendarProps, {}> {
18
18
  }>[]>;
19
19
  mode: PropTypes.Requireable<string>;
20
20
  showCurrTime: PropTypes.Requireable<boolean>;
21
+ weekStartsOn: PropTypes.Requireable<number>;
21
22
  scrollTop: PropTypes.Requireable<number>;
22
23
  onClick: PropTypes.Requireable<(...args: any[]) => any>;
23
24
  renderTimeDisplay: PropTypes.Requireable<(...args: any[]) => any>;
@@ -35,6 +36,7 @@ declare class Calendar extends BaseComponent<CalendarProps, {}> {
35
36
  markWeekend: boolean;
36
37
  height: number;
37
38
  scrollTop: number;
39
+ weekStartsOn: number;
38
40
  };
39
41
  render(): React.FunctionComponentElement<any>;
40
42
  }
@@ -97,6 +97,7 @@ Calendar.propTypes = {
97
97
  })),
98
98
  mode: _propTypes.default.string,
99
99
  showCurrTime: _propTypes.default.bool,
100
+ weekStartsOn: _propTypes.default.number,
100
101
  scrollTop: _propTypes.default.number,
101
102
  onClick: _propTypes.default.func,
102
103
  renderTimeDisplay: _propTypes.default.func,
@@ -113,7 +114,8 @@ Calendar.defaultProps = {
113
114
  mode: 'week',
114
115
  markWeekend: false,
115
116
  height: 600,
116
- scrollTop: 400
117
+ scrollTop: 400,
118
+ weekStartsOn: 0
117
119
  };
118
120
  var _default = Calendar;
119
121
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { EventObject } from '@douyinfe/semi-foundation/lib/cjs/calendar/foundation';
2
+ import { EventObject, weeekStartsOnEnum } from '@douyinfe/semi-foundation/lib/cjs/calendar/foundation';
3
3
  import { strings } from '@douyinfe/semi-foundation/lib/cjs/calendar/constants';
4
4
  import { ArrayElement } from '../_base/base';
5
5
  import { BaseProps } from '../_base/baseComponent';
@@ -10,6 +10,7 @@ export interface CalendarProps extends BaseProps {
10
10
  events?: EventObject[];
11
11
  mode?: ArrayElement<typeof strings.MODE>;
12
12
  showCurrTime?: boolean;
13
+ weekStartsOn?: weeekStartsOnEnum;
13
14
  scrollTop?: number;
14
15
  onClick?: (e: React.MouseEvent, value: Date) => void;
15
16
  onClose?: (e: React.MouseEvent) => void;
@@ -74,7 +74,7 @@ class Carousel extends _baseComponent.default {
74
74
  };
75
75
 
76
76
  this.handleAutoPlay = () => {
77
- if (!this.foundation.getIsControledComponent()) {
77
+ if (!this.foundation.getIsControlledComponent()) {
78
78
  this.foundation.handleAutoPlay();
79
79
  }
80
80
  };
@@ -94,7 +94,7 @@ class Carousel extends _baseComponent.default {
94
94
  autoPlay
95
95
  } = this.props;
96
96
 
97
- if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControledComponent()) {
97
+ if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControlledComponent()) {
98
98
  this.foundation.handleAutoPlay();
99
99
  }
100
100
  };
@@ -5,6 +5,7 @@ import CheckboxInner from './checkboxInner';
5
5
  import BaseComponent from '../_base/baseComponent';
6
6
  import '@douyinfe/semi-foundation/lib/cjs/checkbox/checkbox.css';
7
7
  import { CheckboxContextType } from './context';
8
+ import { CheckboxType } from './checkboxGroup';
8
9
  export declare type CheckboxEvent = BasicCheckboxEvent;
9
10
  export declare type TargetObject = BasicTargetObject;
10
11
  export interface CheckboxProps extends BaseCheckboxProps {
@@ -24,6 +25,7 @@ export interface CheckboxProps extends BaseCheckboxProps {
24
25
  tabIndex?: number;
25
26
  addonId?: string;
26
27
  extraId?: string;
28
+ type?: CheckboxType;
27
29
  }
28
30
  interface CheckboxState {
29
31
  checked: boolean;
@@ -55,6 +57,7 @@ declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
55
57
  'aria-label': PropTypes.Requireable<string>;
56
58
  tabIndex: PropTypes.Requireable<number>;
57
59
  preventScroll: PropTypes.Requireable<boolean>;
60
+ type: PropTypes.Requireable<string>;
58
61
  };
59
62
  static defaultProps: {
60
63
  defaultChecked: boolean;
@@ -62,6 +65,7 @@ declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
62
65
  onChange: (...args: any[]) => void;
63
66
  onMouseEnter: (...args: any[]) => void;
64
67
  onMouseLeave: (...args: any[]) => void;
68
+ type: string;
65
69
  };
66
70
  checkboxEntity: CheckboxInner;
67
71
  context: CheckboxContextType;