@douyinfe/semi-ui 2.9.1 → 2.10.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 (74) hide show
  1. package/banner/_story/banner.stories.js +62 -1
  2. package/banner/index.tsx +5 -5
  3. package/button/buttonGroup.tsx +2 -2
  4. package/carousel/CarouselArrow.tsx +62 -0
  5. package/carousel/CarouselIndicator.tsx +83 -0
  6. package/carousel/__test__/carousel.test.js +159 -0
  7. package/carousel/_story/carousel.stories.js +486 -0
  8. package/carousel/index.tsx +292 -0
  9. package/carousel/interface.ts +63 -0
  10. package/cascader/index.tsx +1 -2
  11. package/datePicker/monthsGrid.tsx +8 -8
  12. package/dist/css/semi.css +342 -0
  13. package/dist/css/semi.min.css +1 -1
  14. package/dist/umd/semi-ui.js +1238 -266
  15. package/dist/umd/semi-ui.js.map +1 -1
  16. package/dist/umd/semi-ui.min.js +1 -1
  17. package/dist/umd/semi-ui.min.js.map +1 -1
  18. package/form/baseForm.tsx +10 -1
  19. package/form/hoc/withField.tsx +17 -5
  20. package/index.ts +2 -0
  21. package/inputNumber/__test__/inputNumber.test.js +40 -3
  22. package/inputNumber/_story/inputNumber.stories.js +56 -1
  23. package/inputNumber/index.tsx +22 -14
  24. package/lib/cjs/banner/index.js +11 -5
  25. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  26. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  27. package/lib/cjs/carousel/CarouselArrow.js +88 -0
  28. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  29. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  30. package/lib/cjs/carousel/index.d.ts +58 -0
  31. package/lib/cjs/carousel/index.js +343 -0
  32. package/lib/cjs/carousel/interface.d.ts +61 -0
  33. package/lib/cjs/carousel/interface.js +7 -0
  34. package/lib/cjs/cascader/index.js +1 -1
  35. package/lib/cjs/datePicker/monthsGrid.js +6 -6
  36. package/lib/cjs/form/baseForm.d.ts +1 -0
  37. package/lib/cjs/form/baseForm.js +10 -1
  38. package/lib/cjs/form/hoc/withField.js +8 -1
  39. package/lib/cjs/index.d.ts +1 -0
  40. package/lib/cjs/index.js +9 -0
  41. package/lib/cjs/inputNumber/index.d.ts +2 -6
  42. package/lib/cjs/inputNumber/index.js +27 -11
  43. package/lib/cjs/switch/index.d.ts +3 -0
  44. package/lib/cjs/switch/index.js +26 -6
  45. package/lib/cjs/transfer/index.js +5 -5
  46. package/lib/cjs/treeSelect/index.js +1 -1
  47. package/lib/es/banner/index.js +11 -5
  48. package/lib/es/button/buttonGroup.d.ts +1 -1
  49. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  50. package/lib/es/carousel/CarouselArrow.js +70 -0
  51. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  52. package/lib/es/carousel/CarouselIndicator.js +125 -0
  53. package/lib/es/carousel/index.d.ts +58 -0
  54. package/lib/es/carousel/index.js +309 -0
  55. package/lib/es/carousel/interface.d.ts +61 -0
  56. package/lib/es/carousel/interface.js +1 -0
  57. package/lib/es/cascader/index.js +1 -1
  58. package/lib/es/datePicker/monthsGrid.js +7 -7
  59. package/lib/es/form/baseForm.d.ts +1 -0
  60. package/lib/es/form/baseForm.js +10 -1
  61. package/lib/es/form/hoc/withField.js +8 -1
  62. package/lib/es/index.d.ts +1 -0
  63. package/lib/es/index.js +1 -0
  64. package/lib/es/inputNumber/index.d.ts +2 -6
  65. package/lib/es/inputNumber/index.js +26 -11
  66. package/lib/es/switch/index.d.ts +3 -0
  67. package/lib/es/switch/index.js +26 -6
  68. package/lib/es/transfer/index.js +1 -1
  69. package/lib/es/treeSelect/index.js +1 -1
  70. package/package.json +9 -9
  71. package/switch/index.tsx +20 -3
  72. package/tagInput/__test__/tagInput.test.js +11 -11
  73. package/transfer/index.tsx +1 -1
  74. package/treeSelect/index.tsx +1 -1
@@ -1,7 +1,7 @@
1
1
  import _noop from "lodash/noop";
2
2
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
3
3
 
4
- /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
4
+ /* eslint-disable max-len */
5
5
  import React from 'react';
6
6
  import cls from 'classnames';
7
7
  import PropTypes from 'prop-types';
@@ -14,9 +14,19 @@ import Spin from '../spin';
14
14
  class Switch extends BaseComponent {
15
15
  constructor(props) {
16
16
  super(props);
17
+
18
+ this.handleFocusVisible = event => {
19
+ this.foundation.handleFocusVisible(event);
20
+ };
21
+
22
+ this.handleBlur = event => {
23
+ this.foundation.handleBlur();
24
+ };
25
+
17
26
  this.state = {
18
27
  nativeControlChecked: false,
19
- nativeControlDisabled: false
28
+ nativeControlDisabled: false,
29
+ focusVisible: false
20
30
  };
21
31
  this.switchRef = /*#__PURE__*/React.createRef();
22
32
  this.foundation = new SwitchFoudation(this.adapter);
@@ -52,6 +62,11 @@ class Switch extends BaseComponent {
52
62
  nativeControlDisabled
53
63
  });
54
64
  },
65
+ setFocusVisible: focusVisible => {
66
+ this.setState({
67
+ focusVisible
68
+ });
69
+ },
55
70
  notifyChange: (checked, e) => {
56
71
  this.props.onChange(checked, e);
57
72
  }
@@ -61,7 +76,8 @@ class Switch extends BaseComponent {
61
76
  render() {
62
77
  const {
63
78
  nativeControlChecked,
64
- nativeControlDisabled
79
+ nativeControlDisabled,
80
+ focusVisible
65
81
  } = this.state;
66
82
  const {
67
83
  className,
@@ -80,11 +96,11 @@ class Switch extends BaseComponent {
80
96
  [cssClasses.DISABLED]: nativeControlDisabled,
81
97
  [cssClasses.LARGE]: size === 'large',
82
98
  [cssClasses.SMALL]: size === 'small',
83
- [cssClasses.LOADING]: loading
99
+ [cssClasses.LOADING]: loading,
100
+ [cssClasses.FOCUS]: focusVisible
84
101
  });
85
102
  const switchProps = {
86
103
  type: 'checkbox',
87
- role: 'switch',
88
104
  className: cssClasses.NATIVE_CONTROL,
89
105
  disabled: nativeControlDisabled || loading,
90
106
  checked: nativeControlChecked || false
@@ -109,13 +125,17 @@ class Switch extends BaseComponent {
109
125
  }, uncheckedText) : null, /*#__PURE__*/React.createElement("input", _Object$assign({}, switchProps, {
110
126
  ref: this.switchRef,
111
127
  id: id,
128
+ role: 'switch',
112
129
  "aria-checked": nativeControlChecked,
113
130
  "aria-invalid": this.props['aria-invalid'],
114
131
  "aria-errormessage": this.props['aria-errormessage'],
115
132
  "aria-label": this.props['aria-label'],
116
133
  "aria-labelledby": this.props['aria-labelledby'],
117
134
  "aria-describedby": this.props["aria-describedby"],
118
- onChange: e => this.foundation.handleChange(e.target.checked, e)
135
+ "aria-disabled": this.props['disabled'],
136
+ onChange: e => this.foundation.handleChange(e.target.checked, e),
137
+ onFocus: e => this.handleFocusVisible(e),
138
+ onBlur: e => this.handleBlur(e)
119
139
  })));
120
140
  }
121
141
 
@@ -19,7 +19,7 @@ import cls from 'classnames';
19
19
  import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
20
20
  import PropTypes from 'prop-types';
21
21
  import TransferFoundation from '@douyinfe/semi-foundation/lib/es/transfer/foundation';
22
- import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtlls';
22
+ import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtils';
23
23
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/transfer/constants';
24
24
  import '@douyinfe/semi-foundation/lib/es/transfer/transfer.css';
25
25
  import BaseComponent from '../_base/baseComponent';
@@ -40,7 +40,7 @@ import TagInput from '../tagInput';
40
40
  import { isSemiIcon } from '../_utils';
41
41
  import { IconChevronDown, IconClear, IconSearch } from '@douyinfe/semi-icons';
42
42
  const prefixcls = cssClasses.PREFIX;
43
- const prefixTree = cssClasses.PREFIXTREE;
43
+ const prefixTree = cssClasses.PREFIX_TREE;
44
44
  const key = 0;
45
45
 
46
46
  class TreeSelect extends BaseComponent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.9.1",
3
+ "version": "2.10.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.9.1",
18
- "@douyinfe/semi-animation-react": "2.9.1",
19
- "@douyinfe/semi-foundation": "2.9.1",
20
- "@douyinfe/semi-icons": "2.9.1",
21
- "@douyinfe/semi-illustrations": "2.9.1",
22
- "@douyinfe/semi-theme-default": "2.9.1",
17
+ "@douyinfe/semi-animation": "2.10.0",
18
+ "@douyinfe/semi-animation-react": "2.10.0",
19
+ "@douyinfe/semi-foundation": "2.10.0",
20
+ "@douyinfe/semi-icons": "2.10.0",
21
+ "@douyinfe/semi-illustrations": "2.10.0",
22
+ "@douyinfe/semi-theme-default": "2.10.0",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "9593ab23b59b5a18305627ac402cfd4527072f9c",
72
+ "gitHead": "0cbe3b9873aa550afa2eda0997eaa7015983fe0d",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.9.1",
78
+ "@douyinfe/semi-scss-compile": "2.10.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
package/switch/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
1
+ /* eslint-disable max-len */
2
2
  import React from 'react';
3
3
  import cls from 'classnames';
4
4
  import PropTypes from 'prop-types';
@@ -33,6 +33,7 @@ export interface SwitchProps {
33
33
  export interface SwitchState {
34
34
  nativeControlChecked: boolean;
35
35
  nativeControlDisabled: boolean;
36
+ focusVisible: boolean;
36
37
  }
37
38
 
38
39
  class Switch extends BaseComponent<SwitchProps, SwitchState> {
@@ -74,6 +75,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
74
75
  this.state = {
75
76
  nativeControlChecked: false,
76
77
  nativeControlDisabled: false,
78
+ focusVisible: false
77
79
  };
78
80
  this.switchRef = React.createRef();
79
81
  this.foundation = new SwitchFoudation(this.adapter);
@@ -105,14 +107,25 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
105
107
  setNativeControlDisabled: (nativeControlDisabled: boolean): void => {
106
108
  this.setState({ nativeControlDisabled });
107
109
  },
110
+ setFocusVisible: (focusVisible: boolean): void => {
111
+ this.setState({ focusVisible });
112
+ },
108
113
  notifyChange: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>): void => {
109
114
  this.props.onChange(checked, e);
110
115
  },
111
116
  };
112
117
  }
113
118
 
119
+ handleFocusVisible = (event: React.FocusEvent) => {
120
+ this.foundation.handleFocusVisible(event);
121
+ }
122
+
123
+ handleBlur = (event: React.FocusEvent) => {
124
+ this.foundation.handleBlur();
125
+ }
126
+
114
127
  render() {
115
- const { nativeControlChecked, nativeControlDisabled } = this.state;
128
+ const { nativeControlChecked, nativeControlDisabled, focusVisible } = this.state;
116
129
  const { className, style, onMouseEnter, onMouseLeave, size, checkedText, uncheckedText, loading, id } = this.props;
117
130
  const wrapperCls = cls(className, {
118
131
  [cssClasses.PREFIX]: true,
@@ -121,10 +134,10 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
121
134
  [cssClasses.LARGE]: size === 'large',
122
135
  [cssClasses.SMALL]: size === 'small',
123
136
  [cssClasses.LOADING]: loading,
137
+ [cssClasses.FOCUS]: focusVisible,
124
138
  });
125
139
  const switchProps = {
126
140
  type: 'checkbox',
127
- role: 'switch',
128
141
  className: cssClasses.NATIVE_CONTROL,
129
142
  disabled: nativeControlDisabled || loading,
130
143
  checked: nativeControlChecked || false,
@@ -157,13 +170,17 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
157
170
  {...switchProps}
158
171
  ref={this.switchRef}
159
172
  id={id}
173
+ role='switch'
160
174
  aria-checked={nativeControlChecked}
161
175
  aria-invalid={this.props['aria-invalid']}
162
176
  aria-errormessage={this.props['aria-errormessage']}
163
177
  aria-label={this.props['aria-label']}
164
178
  aria-labelledby={this.props['aria-labelledby']}
165
179
  aria-describedby={this.props["aria-describedby"]}
180
+ aria-disabled={this.props['disabled']}
166
181
  onChange={e => this.foundation.handleChange(e.target.checked, e)}
182
+ onFocus={e => this.handleFocusVisible(e)}
183
+ onBlur={e => this.handleBlur(e)}
167
184
  />
168
185
  </div>
169
186
  );
@@ -78,7 +78,7 @@ describe('TagInput', () => {
78
78
 
79
79
  it('TagInput with defaultValue and value is undefined', () => {
80
80
  const props = {
81
- defaultValue: ['tiktok', 'hotsoon'],
81
+ defaultValue: ['semi', 'hotsoon'],
82
82
  value: undefined,
83
83
  };
84
84
  const tagInput = getTagInput(props);
@@ -89,7 +89,7 @@ describe('TagInput', () => {
89
89
 
90
90
  it('TagInput with defaultValue and value is null', () => {
91
91
  const props = {
92
- defaultValue: ['tiktok', 'hotsoon'],
92
+ defaultValue: ['semi', 'hotsoon'],
93
93
  value: null,
94
94
  };
95
95
  const tagInput = getTagInput(props);
@@ -123,26 +123,26 @@ describe('TagInput', () => {
123
123
  /* when separator is null */
124
124
  const props2 = {
125
125
  separator: null,
126
- inputValue: 'tiktok-hotsoon'
126
+ inputValue: 'semi-hotsoon'
127
127
  }
128
128
  const tagInput2 = getTagInput(props2);
129
129
  tagInput2.find('input').simulate('keyDown', { keyCode: 13 });
130
130
  const tags2 = tagInput2.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
131
131
  expect(tags2.length).toEqual(1);
132
- expect(tags2.at(0).getDOMNode().textContent).toEqual('tiktok-hotsoon');
132
+ expect(tags2.at(0).getDOMNode().textContent).toEqual('semi-hotsoon');
133
133
  tagInput2.unmount();
134
134
 
135
135
  /* when separator is number */
136
136
  const props3 = {
137
137
  separator: 1,
138
- inputValue: 'tiktok1hotsoon'
138
+ inputValue: 'semi1design'
139
139
  }
140
140
  const tagInput3 = getTagInput(props3);
141
141
  tagInput3.find('input').simulate('keyDown', { keyCode: 13 });
142
142
  const tags3 = tagInput3.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
143
143
  expect(tags3.length).toEqual(2);
144
- expect(tags3.at(0).getDOMNode().textContent).toEqual('tiktok');
145
- expect(tags3.at(1).getDOMNode().textContent).toEqual('hotsoon');
144
+ expect(tags3.at(0).getDOMNode().textContent).toEqual('semi');
145
+ expect(tags3.at(1).getDOMNode().textContent).toEqual('design');
146
146
  tagInput3.unmount();
147
147
  });
148
148
 
@@ -352,10 +352,10 @@ describe('TagInput', () => {
352
352
 
353
353
  it('tagInput with set value to null ', () => {
354
354
  const props = {
355
- value: ['tiktok']
355
+ value: ['semi']
356
356
  };
357
357
  const tagInput = getTagInput(props);
358
- expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('tiktok');
358
+ expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
359
359
  tagInput.setProps({ value: null });
360
360
  tagInput.update();
361
361
  const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
@@ -364,10 +364,10 @@ describe('TagInput', () => {
364
364
 
365
365
  it('tagInput with set value to null ', () => {
366
366
  const props = {
367
- value: ['tiktok']
367
+ value: ['semi']
368
368
  };
369
369
  const tagInput = getTagInput(props);
370
- expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('tiktok');
370
+ expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
371
371
  tagInput.setProps({ value: undefined });
372
372
  tagInput.update();
373
373
  const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
@@ -4,7 +4,7 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab
4
4
  import PropTypes from 'prop-types';
5
5
  import { isEqual, noop, omit, isEmpty, isArray } from 'lodash';
6
6
  import TransferFoundation, { TransferAdapter, BasicDataItem, OnSortEndProps } from '@douyinfe/semi-foundation/transfer/foundation';
7
- import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/transferUtlls';
7
+ import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/transferUtils';
8
8
  import { cssClasses, strings } from '@douyinfe/semi-foundation/transfer/constants';
9
9
  import '@douyinfe/semi-foundation/transfer/transfer.scss';
10
10
  import BaseComponent from '../_base/baseComponent';
@@ -163,7 +163,7 @@ export interface TreeSelectState extends Omit<BasicTreeSelectInnerData, Override
163
163
  }
164
164
 
165
165
  const prefixcls = cssClasses.PREFIX;
166
- const prefixTree = cssClasses.PREFIXTREE;
166
+ const prefixTree = cssClasses.PREFIX_TREE;
167
167
 
168
168
  const key = 0;
169
169