rsuite 4.8.8 → 4.8.9

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 (37) hide show
  1. package/CHANGELOG.md +14 -5
  2. package/dist/rsuite.js +7 -7
  3. package/dist/rsuite.min.js +1 -1
  4. package/dist/rsuite.min.js.map +1 -1
  5. package/dist/styles/rsuite-dark-rtl.css +2 -5
  6. package/dist/styles/rsuite-dark-rtl.min.css +1 -1
  7. package/dist/styles/rsuite-dark-rtl.min.css.map +1 -1
  8. package/dist/styles/rsuite-dark.css +2 -5
  9. package/dist/styles/rsuite-dark.min.css +1 -1
  10. package/dist/styles/rsuite-dark.min.css.map +1 -1
  11. package/dist/styles/rsuite-default-rtl.css +2 -5
  12. package/dist/styles/rsuite-default-rtl.min.css +1 -1
  13. package/dist/styles/rsuite-default-rtl.min.css.map +1 -1
  14. package/dist/styles/rsuite-default.css +2 -5
  15. package/dist/styles/rsuite-default.min.css +1 -1
  16. package/dist/styles/rsuite-default.min.css.map +1 -1
  17. package/es/InputPicker/InputAutosize.js +11 -6
  18. package/es/InputPicker/styles/common.less +2 -2
  19. package/es/Modal/BaseModal.js +1 -1
  20. package/es/Modal/ModalDialog.js +3 -1
  21. package/es/Picker/propTypes.js +1 -1
  22. package/es/Table/styles/common.less +0 -4
  23. package/lib/InputPicker/InputAutosize.js +11 -6
  24. package/lib/InputPicker/styles/common.less +2 -2
  25. package/lib/Modal/BaseModal.js +1 -1
  26. package/lib/Modal/ModalDialog.js +3 -1
  27. package/lib/Picker/propTypes.js +1 -1
  28. package/lib/Table/styles/common.less +0 -4
  29. package/package.json +2 -2
  30. package/src/Drawer/test/DrawerSpec.js +14 -0
  31. package/src/InputPicker/InputAutosize.tsx +15 -10
  32. package/src/InputPicker/styles/common.less +2 -2
  33. package/src/Modal/BaseModal.tsx +1 -6
  34. package/src/Modal/ModalDialog.tsx +3 -1
  35. package/src/Modal/test/ModalSpec.js +13 -0
  36. package/src/Picker/propTypes.ts +1 -1
  37. package/src/Table/styles/common.less +0 -4
@@ -34,7 +34,13 @@ function (_React$Component) {
34
34
  _this.inputRef = void 0;
35
35
  _this.sizerRef = void 0;
36
36
  _this.placeHolderSizerRef = void 0;
37
+
38
+ _this.getInputId = function () {
39
+ return _this.props.inputId || _this.state.inputId;
40
+ };
41
+
37
42
  _this.state = {
43
+ inputId: '_' + Math.random().toString(36).substr(2, 12),
38
44
  inputWidth: props.minWidth
39
45
  };
40
46
  _this.inputRef = React.createRef();
@@ -115,7 +121,7 @@ function (_React$Component) {
115
121
  };
116
122
 
117
123
  _proto.renderStyles = function renderStyles() {
118
- var inputId = this.props.inputId;
124
+ var inputId = this.getInputId();
119
125
  return isIE() ? React.createElement("style", {
120
126
  dangerouslySetInnerHTML: {
121
127
  __html: "input#" + inputId + "::-ms-clear {display: none;}"
@@ -132,8 +138,8 @@ function (_React$Component) {
132
138
  className = _this$props3.className,
133
139
  placeholder = _this$props3.placeholder,
134
140
  inputClassName = _this$props3.inputClassName,
135
- inputStyle = _this$props3.inputStyle,
136
- inputId = _this$props3.inputId;
141
+ inputStyle = _this$props3.inputStyle;
142
+ var inputId = this.getInputId();
137
143
  var sizerValue = [defaultValue, value, ''].reduce(function (previousValue, currentValue) {
138
144
  if (previousValue !== null && previousValue !== undefined) {
139
145
  return previousValue;
@@ -157,7 +163,7 @@ function (_React$Component) {
157
163
  htmlInputProps = _partitionHTMLProps[0];
158
164
 
159
165
  htmlInputProps.className = inputClassName;
160
- htmlInputProps.id = inputId;
166
+ htmlInputProps.id = inputId || inputId;
161
167
  htmlInputProps.style = nextInputStyle;
162
168
  return React.createElement("div", {
163
169
  className: className,
@@ -191,7 +197,6 @@ InputAutosize.propTypes = {
191
197
  onAutosize: PropTypes.func
192
198
  };
193
199
  InputAutosize.defaultProps = {
194
- minWidth: 1,
195
- inputId: '_' + Math.random().toString(36).substr(2, 12)
200
+ minWidth: 1
196
201
  };
197
202
  export default InputAutosize;
@@ -43,10 +43,10 @@
43
43
  }
44
44
 
45
45
  .@{ns}picker-tag-wrapper {
46
- padding-right: @dropdown-toggle-padding-right;
46
+ margin-right: @dropdown-toggle-padding-right;
47
47
 
48
48
  .@{ns}picker-cleanable & {
49
- padding-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
49
+ margin-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
50
50
  }
51
51
  }
52
52
 
@@ -296,7 +296,7 @@ function (_React$Component2) {
296
296
  container: container
297
297
  }, React.createElement("div", {
298
298
  ref: this.modalNodeRef,
299
- role: rest.role || 'dialog',
299
+ role: rest.role,
300
300
  style: style,
301
301
  className: className
302
302
  }, backdrop && this.renderBackdrop(), React.createElement(RefHolder, {
@@ -14,7 +14,9 @@ export var modalDialogPropTypes = {
14
14
  style: PropTypes.object,
15
15
  dialogStyle: PropTypes.object,
16
16
  children: PropTypes.node,
17
- dialogRef: refType
17
+ dialogRef: refType,
18
+ id: PropTypes.string,
19
+ 'aria-labelledby': PropTypes.string
18
20
  };
19
21
 
20
22
  var ModalDialog =
@@ -11,7 +11,7 @@ export var pickerPropTypes = _extends({}, animationPropTypes, {
11
11
  appearance: PropTypes.oneOf(['default', 'subtle']),
12
12
  block: PropTypes.bool,
13
13
  containerPadding: PropTypes.number,
14
- container: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
14
+ container: PropTypes.any,
15
15
  disabled: PropTypes.bool,
16
16
  toggleComponentClass: PropTypes.elementType,
17
17
  menuClassName: PropTypes.string,
@@ -291,10 +291,6 @@
291
291
  background: @table-body-background;
292
292
  }
293
293
 
294
- &-fixed-right {
295
- margin-left: @table-scrollbar-width;
296
- }
297
-
298
294
  &-shadow,
299
295
  &-left-shadow {
300
296
  box-shadow: 3px @table-table-cell-fixed-shadow /* rtl:ignore */;
@@ -48,7 +48,13 @@ function (_React$Component) {
48
48
  _this.inputRef = void 0;
49
49
  _this.sizerRef = void 0;
50
50
  _this.placeHolderSizerRef = void 0;
51
+
52
+ _this.getInputId = function () {
53
+ return _this.props.inputId || _this.state.inputId;
54
+ };
55
+
51
56
  _this.state = {
57
+ inputId: '_' + Math.random().toString(36).substr(2, 12),
52
58
  inputWidth: props.minWidth
53
59
  };
54
60
  _this.inputRef = React.createRef();
@@ -129,7 +135,7 @@ function (_React$Component) {
129
135
  };
130
136
 
131
137
  _proto.renderStyles = function renderStyles() {
132
- var inputId = this.props.inputId;
138
+ var inputId = this.getInputId();
133
139
  return (0, _utils.isIE)() ? React.createElement("style", {
134
140
  dangerouslySetInnerHTML: {
135
141
  __html: "input#" + inputId + "::-ms-clear {display: none;}"
@@ -146,8 +152,8 @@ function (_React$Component) {
146
152
  className = _this$props3.className,
147
153
  placeholder = _this$props3.placeholder,
148
154
  inputClassName = _this$props3.inputClassName,
149
- inputStyle = _this$props3.inputStyle,
150
- inputId = _this$props3.inputId;
155
+ inputStyle = _this$props3.inputStyle;
156
+ var inputId = this.getInputId();
151
157
  var sizerValue = [defaultValue, value, ''].reduce(function (previousValue, currentValue) {
152
158
  if (previousValue !== null && previousValue !== undefined) {
153
159
  return previousValue;
@@ -170,7 +176,7 @@ function (_React$Component) {
170
176
  htmlInputProps = _partitionHTMLProps[0];
171
177
 
172
178
  htmlInputProps.className = inputClassName;
173
- htmlInputProps.id = inputId;
179
+ htmlInputProps.id = inputId || inputId;
174
180
  htmlInputProps.style = nextInputStyle;
175
181
  return React.createElement("div", {
176
182
  className: className,
@@ -204,8 +210,7 @@ InputAutosize.propTypes = {
204
210
  onAutosize: _propTypes.default.func
205
211
  };
206
212
  InputAutosize.defaultProps = {
207
- minWidth: 1,
208
- inputId: '_' + Math.random().toString(36).substr(2, 12)
213
+ minWidth: 1
209
214
  };
210
215
  var _default = InputAutosize;
211
216
  exports.default = _default;
@@ -43,10 +43,10 @@
43
43
  }
44
44
 
45
45
  .@{ns}picker-tag-wrapper {
46
- padding-right: @dropdown-toggle-padding-right;
46
+ margin-right: @dropdown-toggle-padding-right;
47
47
 
48
48
  .@{ns}picker-cleanable & {
49
- padding-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
49
+ margin-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
50
50
  }
51
51
  }
52
52
 
@@ -315,7 +315,7 @@ function (_React$Component2) {
315
315
  container: container
316
316
  }, React.createElement("div", {
317
317
  ref: this.modalNodeRef,
318
- role: rest.role || 'dialog',
318
+ role: rest.role,
319
319
  style: style,
320
320
  className: className
321
321
  }, backdrop && this.renderBackdrop(), React.createElement(RefHolder, {
@@ -32,7 +32,9 @@ var modalDialogPropTypes = {
32
32
  style: _propTypes.default.object,
33
33
  dialogStyle: _propTypes.default.object,
34
34
  children: _propTypes.default.node,
35
- dialogRef: _utils.refType
35
+ dialogRef: _utils.refType,
36
+ id: _propTypes.default.string,
37
+ 'aria-labelledby': _propTypes.default.string
36
38
  };
37
39
  exports.modalDialogPropTypes = modalDialogPropTypes;
38
40
 
@@ -23,7 +23,7 @@ var pickerPropTypes = (0, _extends2.default)({}, _propTypes2.animationPropTypes,
23
23
  appearance: _propTypes.default.oneOf(['default', 'subtle']),
24
24
  block: _propTypes.default.bool,
25
25
  containerPadding: _propTypes.default.number,
26
- container: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
26
+ container: _propTypes.default.any,
27
27
  disabled: _propTypes.default.bool,
28
28
  toggleComponentClass: _propTypes.default.elementType,
29
29
  menuClassName: _propTypes.default.string,
@@ -291,10 +291,6 @@
291
291
  background: @table-body-background;
292
292
  }
293
293
 
294
- &-fixed-right {
295
- margin-left: @table-scrollbar-width;
296
- }
297
-
298
294
  &-shadow,
299
295
  &-left-shadow {
300
296
  box-shadow: 3px @table-table-cell-fixed-shadow /* rtl:ignore */;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "4.8.8",
3
+ "version": "4.8.9",
4
4
  "description": "A suite of react components",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -63,7 +63,7 @@
63
63
  "react-lifecycles-compat": "^3.0.4",
64
64
  "react-virtualized": "^9.21.0",
65
65
  "recompose": "^0.30.0",
66
- "rsuite-table": "^3.14.2",
66
+ "rsuite-table": "^3.14.3",
67
67
  "schema-typed": "^1.5.1"
68
68
  },
69
69
  "peerDependencies": {
@@ -11,6 +11,7 @@ describe('Drawer', () => {
11
11
  </Drawer>
12
12
  );
13
13
  assert.ok(instance.querySelectorAll('.rs-drawer.rs-drawer-right'));
14
+ assert.ok(instance.querySelector('[role="dialog"]'));
14
15
  });
15
16
 
16
17
  it('Should be full', () => {
@@ -36,6 +37,19 @@ describe('Drawer', () => {
36
37
  assert.ok(instance.querySelector('.rs-drawer.custom'));
37
38
  });
38
39
 
40
+ it('Should accept id and aria-labelledby attribute', () => {
41
+ const instance = getDOMNode(
42
+ <Drawer show id="drawer" aria-labelledby="drawer-title">
43
+ <h4 id="drawer-title">My Drawer</h4>
44
+ <p>message</p>
45
+ </Drawer>
46
+ );
47
+
48
+ const dialog = instance.querySelector('[role="dialog"]');
49
+ assert.equal(dialog.getAttribute('id'), 'drawer');
50
+ assert.equal(dialog.getAttribute('aria-labelledby'), 'drawer-title');
51
+ });
52
+
39
53
  it('Should have a custom style', () => {
40
54
  const fontSize = '12px';
41
55
  const instance = getDOMNode(<Drawer style={{ fontSize }} show />);
@@ -36,6 +36,7 @@ export interface InputAutosizeProps {
36
36
  }
37
37
 
38
38
  interface InputAutosizeState {
39
+ inputId: string;
39
40
  inputWidth: number;
40
41
  }
41
42
 
@@ -54,12 +55,7 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
54
55
  onAutosize: PropTypes.func
55
56
  };
56
57
  static defaultProps = {
57
- minWidth: 1,
58
- inputId:
59
- '_' +
60
- Math.random()
61
- .toString(36)
62
- .substr(2, 12)
58
+ minWidth: 1
63
59
  };
64
60
 
65
61
  inputRef: React.RefObject<any>;
@@ -69,6 +65,11 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
69
65
  constructor(props) {
70
66
  super(props);
71
67
  this.state = {
68
+ inputId:
69
+ '_' +
70
+ Math.random()
71
+ .toString(36)
72
+ .substr(2, 12),
72
73
  inputWidth: props.minWidth
73
74
  };
74
75
 
@@ -81,6 +82,10 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
81
82
  return this.inputRef.current;
82
83
  }
83
84
 
85
+ getInputId = () => {
86
+ return this.props.inputId || this.state.inputId;
87
+ };
88
+
84
89
  componentDidMount() {
85
90
  this.copyInputStyles();
86
91
  this.updateInputWidth();
@@ -135,7 +140,7 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
135
140
  }
136
141
 
137
142
  renderStyles() {
138
- const { inputId } = this.props;
143
+ const inputId = this.getInputId();
139
144
  return isIE() ? (
140
145
  <style
141
146
  dangerouslySetInnerHTML={{
@@ -153,10 +158,10 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
153
158
  className,
154
159
  placeholder,
155
160
  inputClassName,
156
- inputStyle,
157
- inputId
161
+ inputStyle
158
162
  } = this.props;
159
163
 
164
+ const inputId = this.getInputId();
160
165
  const sizerValue = [defaultValue, value, ''].reduce((previousValue, currentValue) => {
161
166
  if (previousValue !== null && previousValue !== undefined) {
162
167
  return previousValue;
@@ -178,7 +183,7 @@ class InputAutosize extends React.Component<InputAutosizeProps, InputAutosizeSta
178
183
  const [htmlInputProps] = partitionHTMLProps(this.props);
179
184
 
180
185
  htmlInputProps.className = inputClassName;
181
- htmlInputProps.id = inputId;
186
+ htmlInputProps.id = inputId || inputId;
182
187
  htmlInputProps.style = nextInputStyle;
183
188
 
184
189
  return (
@@ -43,10 +43,10 @@
43
43
  }
44
44
 
45
45
  .@{ns}picker-tag-wrapper {
46
- padding-right: @dropdown-toggle-padding-right;
46
+ margin-right: @dropdown-toggle-padding-right;
47
47
 
48
48
  .@{ns}picker-cleanable & {
49
- padding-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
49
+ margin-right: @dropdown-toggle-padding-right + @picker-toggle-clean-width;
50
50
  }
51
51
  }
52
52
 
@@ -269,12 +269,7 @@ class BaseModal extends React.Component<BaseModalProps, BaseModalState> {
269
269
 
270
270
  return (
271
271
  <Portal ref={this.setMountNodeRef} container={container}>
272
- <div
273
- ref={this.modalNodeRef}
274
- role={rest.role || 'dialog'}
275
- style={style}
276
- className={className}
277
- >
272
+ <div ref={this.modalNodeRef} role={rest.role} style={style} className={className}>
278
273
  {backdrop && this.renderBackdrop()}
279
274
  <RefHolder ref={this.dialogRef}>{dialog}</RefHolder>
280
275
  </div>
@@ -14,7 +14,9 @@ export const modalDialogPropTypes = {
14
14
  style: PropTypes.object,
15
15
  dialogStyle: PropTypes.object,
16
16
  children: PropTypes.node,
17
- dialogRef: refType
17
+ dialogRef: refType,
18
+ id: PropTypes.string,
19
+ 'aria-labelledby': PropTypes.string
18
20
  };
19
21
 
20
22
  class ModalDialog extends React.Component<ModalDialogProps> {
@@ -5,6 +5,19 @@ import { getInstance } from '@test/testUtils';
5
5
  import Modal from '../Modal';
6
6
 
7
7
  describe('Modal', () => {
8
+ it('Should render exactly one element with dialog role', () => {
9
+ const instance = getInstance(
10
+ <Modal show>
11
+ <p>message</p>
12
+ </Modal>
13
+ );
14
+
15
+ assert.notOk(
16
+ instance.modalRef.current.getDialogElement().parentNode.closest('[role="dialog"]')
17
+ );
18
+ assert.equal(instance.modalRef.current.getDialogElement().getAttribute('role'), 'dialog');
19
+ });
20
+
8
21
  it('Should render the modal content', () => {
9
22
  const instance = getInstance(
10
23
  <Modal show>
@@ -12,7 +12,7 @@ export const pickerPropTypes = {
12
12
  appearance: PropTypes.oneOf(['default', 'subtle']),
13
13
  block: PropTypes.bool,
14
14
  containerPadding: PropTypes.number,
15
- container: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
15
+ container: PropTypes.any,
16
16
  disabled: PropTypes.bool,
17
17
  toggleComponentClass: PropTypes.elementType,
18
18
  menuClassName: PropTypes.string,
@@ -291,10 +291,6 @@
291
291
  background: @table-body-background;
292
292
  }
293
293
 
294
- &-fixed-right {
295
- margin-left: @table-scrollbar-width;
296
- }
297
-
298
294
  &-shadow,
299
295
  &-left-shadow {
300
296
  box-shadow: 3px @table-table-cell-fixed-shadow /* rtl:ignore */;