rsuite 4.10.1 → 4.10.5

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 (133) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/rsuite.js +52 -159
  3. package/dist/rsuite.min.js +2 -2
  4. package/dist/rsuite.min.js.map +1 -1
  5. package/es/AutoComplete/AutoComplete.js +1 -1
  6. package/es/Avatar/Avatar.js +1 -2
  7. package/es/Breadcrumb/Breadcrumb.js +1 -2
  8. package/es/Button/Button.js +1 -2
  9. package/es/ButtonGroup/ButtonGroup.js +1 -2
  10. package/es/Calendar/TimeDropdown.js +3 -3
  11. package/es/Cascader/Cascader.js +23 -6
  12. package/es/CheckTreePicker/CheckTreePicker.js +8 -7
  13. package/es/Drawer/index.js +1 -2
  14. package/es/Dropdown/Dropdown.js +1 -2
  15. package/es/FlexboxGrid/FlexboxGrid.js +1 -2
  16. package/es/FormGroup/FormGroup.js +1 -2
  17. package/es/Input/Input.js +1 -2
  18. package/es/InputGroup/InputGroup.js +1 -2
  19. package/es/IntlProvider/withLocale.js +1 -1
  20. package/es/List/List.js +1 -2
  21. package/es/List/ListItem.js +1 -2
  22. package/es/Loader/Loader.js +1 -2
  23. package/es/Modal/Modal.js +1 -2
  24. package/es/Modal/ModalDialog.js +1 -2
  25. package/es/MultiCascader/MultiCascader.js +14 -1
  26. package/es/Nav/Nav.js +1 -2
  27. package/es/Navbar/Navbar.js +1 -2
  28. package/es/Pagination/Pagination.js +1 -2
  29. package/es/Rate/Rate.js +1 -2
  30. package/es/Sidenav/Sidenav.js +1 -2
  31. package/es/Slider/Slider.d.ts +4 -11
  32. package/es/Steps/Steps.js +1 -2
  33. package/es/Table/Table.js +1 -2
  34. package/es/Table/TablePagination.js +1 -2
  35. package/es/Tag/Tag.js +1 -2
  36. package/es/TagPicker/index.js +1 -2
  37. package/es/Timeline/Timeline.js +1 -2
  38. package/es/Timeline/TimelineItem.js +1 -2
  39. package/es/Toggle/Toggle.js +1 -2
  40. package/es/Uploader/Uploader.js +2 -3
  41. package/es/utils/defaultProps.js +1 -1
  42. package/es/utils/index.js +1 -0
  43. package/es/utils/recompose.js +42 -0
  44. package/es/utils/treeUtils.js +5 -1
  45. package/es/utils/withStyleProps.js +1 -1
  46. package/lib/AutoComplete/AutoComplete.js +2 -4
  47. package/lib/Avatar/Avatar.js +1 -3
  48. package/lib/Breadcrumb/Breadcrumb.js +1 -3
  49. package/lib/Button/Button.js +1 -3
  50. package/lib/ButtonGroup/ButtonGroup.js +1 -3
  51. package/lib/Calendar/TimeDropdown.js +3 -3
  52. package/lib/Cascader/Cascader.js +23 -6
  53. package/lib/CheckTreePicker/CheckTreePicker.js +8 -7
  54. package/lib/Drawer/index.js +4 -6
  55. package/lib/Dropdown/Dropdown.js +2 -4
  56. package/lib/FlexboxGrid/FlexboxGrid.js +1 -3
  57. package/lib/FormGroup/FormGroup.js +1 -3
  58. package/lib/Input/Input.js +1 -3
  59. package/lib/InputGroup/InputGroup.js +3 -5
  60. package/lib/IntlProvider/withLocale.js +3 -3
  61. package/lib/List/List.js +1 -3
  62. package/lib/List/ListItem.js +1 -3
  63. package/lib/Loader/Loader.js +1 -3
  64. package/lib/Modal/Modal.js +5 -7
  65. package/lib/Modal/ModalDialog.js +1 -3
  66. package/lib/MultiCascader/MultiCascader.js +14 -1
  67. package/lib/Nav/Nav.js +1 -3
  68. package/lib/Navbar/Navbar.js +2 -4
  69. package/lib/Pagination/Pagination.js +1 -3
  70. package/lib/Rate/Rate.js +1 -3
  71. package/lib/Sidenav/Sidenav.js +3 -5
  72. package/lib/Slider/Slider.d.ts +4 -11
  73. package/lib/Steps/Steps.js +1 -3
  74. package/lib/Table/Table.js +6 -8
  75. package/lib/Table/TablePagination.js +1 -3
  76. package/lib/Tag/Tag.js +1 -3
  77. package/lib/TagPicker/index.js +1 -3
  78. package/lib/Timeline/Timeline.js +1 -3
  79. package/lib/Timeline/TimelineItem.js +1 -3
  80. package/lib/Toggle/Toggle.js +1 -3
  81. package/lib/Uploader/Uploader.js +2 -4
  82. package/lib/utils/defaultProps.js +1 -1
  83. package/lib/utils/index.js +8 -0
  84. package/lib/utils/recompose.js +57 -0
  85. package/lib/utils/treeUtils.js +5 -1
  86. package/lib/utils/withStyleProps.js +1 -1
  87. package/package.json +4 -5
  88. package/src/AutoComplete/AutoComplete.tsx +1 -1
  89. package/src/Avatar/Avatar.tsx +1 -2
  90. package/src/Breadcrumb/Breadcrumb.tsx +1 -2
  91. package/src/Button/Button.tsx +8 -2
  92. package/src/ButtonGroup/ButtonGroup.tsx +1 -2
  93. package/src/Calendar/TimeDropdown.tsx +2 -3
  94. package/src/Cascader/Cascader.tsx +24 -5
  95. package/src/Cascader/test/CascaderSpec.js +56 -1
  96. package/src/CheckTreePicker/CheckTreePicker.tsx +15 -7
  97. package/src/CheckTreePicker/test/CheckTreePickerSpec.js +184 -1
  98. package/src/DatePicker/test/DatePickerSpec.js +20 -0
  99. package/src/Drawer/index.tsx +1 -3
  100. package/src/Dropdown/Dropdown.tsx +1 -1
  101. package/src/FlexboxGrid/FlexboxGrid.tsx +1 -2
  102. package/src/FormGroup/FormGroup.tsx +1 -2
  103. package/src/Input/Input.tsx +1 -1
  104. package/src/InputGroup/InputGroup.tsx +1 -2
  105. package/src/IntlProvider/withLocale.tsx +1 -1
  106. package/src/List/List.tsx +1 -2
  107. package/src/List/ListItem.tsx +1 -2
  108. package/src/Loader/Loader.tsx +1 -2
  109. package/src/Modal/Modal.tsx +1 -2
  110. package/src/Modal/ModalDialog.tsx +1 -2
  111. package/src/MultiCascader/MultiCascader.tsx +17 -1
  112. package/src/Nav/Nav.tsx +1 -1
  113. package/src/Navbar/Navbar.tsx +1 -2
  114. package/src/Pagination/Pagination.tsx +1 -2
  115. package/src/Rate/Rate.tsx +1 -2
  116. package/src/Sidenav/Sidenav.tsx +1 -2
  117. package/src/Slider/Slider.d.ts +4 -11
  118. package/src/Steps/Steps.tsx +1 -2
  119. package/src/Table/Table.tsx +1 -2
  120. package/src/Table/TablePagination.tsx +1 -2
  121. package/src/Tag/Tag.tsx +1 -2
  122. package/src/TagPicker/index.tsx +1 -3
  123. package/src/Timeline/Timeline.tsx +1 -2
  124. package/src/Timeline/TimelineItem.tsx +1 -2
  125. package/src/Toggle/Toggle.tsx +1 -2
  126. package/src/TreePicker/test/TreePickerSpec.js +43 -15
  127. package/src/Uploader/Uploader.tsx +2 -3
  128. package/src/utils/defaultProps.ts +1 -1
  129. package/src/utils/index.ts +1 -0
  130. package/src/utils/recompose.ts +52 -0
  131. package/src/utils/test/recomposeSpec.js +107 -0
  132. package/src/utils/treeUtils.ts +4 -1
  133. package/src/utils/withStyleProps.tsx +1 -1
@@ -69,9 +69,11 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
69
69
  }
70
70
  };
71
71
 
72
+ toggleRef: React.RefObject<any>;
72
73
  triggerRef: React.RefObject<any>;
73
74
  containerRef: React.RefObject<any>;
74
75
  positionRef: React.RefObject<any>;
76
+ menuWrapperRef: React.RefObject<any>;
75
77
  menuContainerRef: React.RefObject<any>;
76
78
  isControlled: boolean;
77
79
 
@@ -97,20 +99,22 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
97
99
  this.state = {
98
100
  ...initState,
99
101
  ...getDerivedStateForCascade(props, initState),
100
- flattenData: flattenTree(props.data)
102
+ flattenData: flattenTree(props.data, props.childrenKey)
101
103
  };
102
104
 
103
105
  this.isControlled = !_.isUndefined(props.value);
104
106
  this.triggerRef = React.createRef();
105
107
  this.containerRef = React.createRef();
106
108
  this.positionRef = React.createRef();
109
+ this.toggleRef = React.createRef();
107
110
 
108
111
  // for test
112
+ this.menuWrapperRef = React.createRef();
109
113
  this.menuContainerRef = React.createRef();
110
114
  }
111
115
 
112
116
  static getDerivedStateFromProps(nextProps, prevState) {
113
- const { value, data, labelKey, valueKey } = nextProps;
117
+ const { value, data, labelKey, valueKey, childrenKey } = nextProps;
114
118
  if (data !== prevState.data) {
115
119
  // First get the value of the clicked node `selectNodeValue`, and then get the new `newChildren`.
116
120
  const selectNodeValue = prevState?.selectNode?.[valueKey];
@@ -127,13 +131,13 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
127
131
  newChildren.map(item => stringToObject(item, labelKey, valueKey))
128
132
  ),
129
133
  data,
130
- flattenData: flattenTree(data)
134
+ flattenData: flattenTree(data, childrenKey)
131
135
  };
132
136
  }
133
137
 
134
138
  return {
135
139
  ...getDerivedStateForCascade(nextProps, prevState),
136
- flattenData: flattenTree(data),
140
+ flattenData: flattenTree(data, childrenKey),
137
141
  data
138
142
  };
139
143
  }
@@ -397,6 +401,14 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
397
401
  return items;
398
402
  }
399
403
 
404
+ getPositionInstance = () => {
405
+ return this.positionRef.current;
406
+ };
407
+
408
+ getToggleInstance = () => {
409
+ return this.toggleRef.current;
410
+ };
411
+
400
412
  renderSearchResultPanel() {
401
413
  const { locale } = this.props;
402
414
  const { searchKeyword } = this.state;
@@ -439,7 +451,13 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
439
451
  );
440
452
 
441
453
  return (
442
- <MenuWrapper className={classes} style={menuStyle}>
454
+ <MenuWrapper
455
+ ref={this.menuWrapperRef}
456
+ className={classes}
457
+ style={menuStyle}
458
+ getToggleInstance={this.getToggleInstance}
459
+ getPositionInstance={this.getPositionInstance}
460
+ >
443
461
  {searchable && (
444
462
  <SearchBar
445
463
  placeholder={locale.searchPlaceholder}
@@ -538,6 +556,7 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
538
556
  >
539
557
  <PickerToggle
540
558
  {...unhandled}
559
+ ref={this.toggleRef}
541
560
  componentClass={toggleComponentClass}
542
561
  onClean={createChainedFunction(this.handleClean, onClean)}
543
562
  cleanable={cleanable && !disabled}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import ReactTestUtils from 'react-dom/test-utils';
2
+ import ReactTestUtils, { act } from 'react-dom/test-utils';
3
3
  import Cascader from '../Cascader';
4
4
  import Button from '../../Button';
5
5
  import { getDOMNode, getInstance } from '@test/testUtils';
@@ -214,4 +214,59 @@ describe('Cascader', () => {
214
214
  assert.equal(instance2.querySelector('.rs-picker-toggle-placeholder').innerText, 'Select');
215
215
  assert.equal(instance3.querySelector('.rs-picker-toggle-placeholder').innerText, 'Select');
216
216
  });
217
+
218
+ it('Should show search items with childrenKey', () => {
219
+ const itemsWithChildrenKey = {
220
+ childrenKey: 'sub',
221
+ data: [
222
+ {
223
+ value: 't',
224
+ label: 't'
225
+ },
226
+ {
227
+ value: 'h',
228
+ label: 'h'
229
+ },
230
+ {
231
+ value: 'g',
232
+ label: 'g',
233
+ sub: [
234
+ {
235
+ value: 'g-m',
236
+ label: 'g-m'
237
+ },
238
+ {
239
+ value: 'g-b',
240
+ label: 'g-b'
241
+ }
242
+ ]
243
+ }
244
+ ]
245
+ };
246
+
247
+ const instance = getInstance(
248
+ <Cascader
249
+ defaultOpen
250
+ data={itemsWithChildrenKey.data}
251
+ childrenKey={itemsWithChildrenKey.childrenKey}
252
+ />
253
+ );
254
+
255
+ const overlay = getDOMNode(instance.menuWrapperRef.current);
256
+
257
+ ReactTestUtils.act(() => {
258
+ const input = overlay.querySelector('.rs-picker-search-bar-input');
259
+
260
+ ReactTestUtils.Simulate.focus(input);
261
+
262
+ input.value = 'g';
263
+ ReactTestUtils.Simulate.change(input);
264
+ });
265
+
266
+ ReactTestUtils.act(() => {
267
+ const searchResult = overlay.querySelectorAll('.rs-picker-cascader-row');
268
+
269
+ assert.equal(searchResult.length, 2);
270
+ });
271
+ });
217
272
  });
@@ -195,11 +195,14 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
195
195
  nextState.value = value;
196
196
  }
197
197
 
198
- if (compareArray(expandItemValues, prevState.expandItemValues)) {
198
+ if (compareArray(expandItemValues, prevState.expandItemValues) && _.isArray(expandItemValues)) {
199
199
  nextState.expandItemValues = expandItemValues;
200
200
  }
201
201
 
202
- if (compareArray(uncheckableItemValues, prevState.uncheckableItemValues)) {
202
+ if (
203
+ compareArray(uncheckableItemValues, prevState.uncheckableItemValues) &&
204
+ _.isArray(uncheckableItemValues)
205
+ ) {
203
206
  nextState.uncheckableItemValues = uncheckableItemValues;
204
207
  }
205
208
 
@@ -258,7 +261,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
258
261
  const { value } = this.props;
259
262
  if (compareArray(value, prevState.value)) {
260
263
  this.unserializeLists({
261
- check: value,
264
+ check: value ?? [],
262
265
  expand: expandItemValues
263
266
  });
264
267
  this.setState({
@@ -271,7 +274,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
271
274
 
272
275
  updateExpandItemValuesChange(prevState: CheckTreePickerState) {
273
276
  const { expandItemValues } = this.props;
274
- if (compareArray(expandItemValues, prevState.expandItemValues)) {
277
+ if (compareArray(expandItemValues, prevState.expandItemValues) && _.isArray(expandItemValues)) {
275
278
  this.unserializeLists({
276
279
  expand: expandItemValues
277
280
  });
@@ -284,7 +287,10 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
284
287
  updateUncheckableItemValuesChange(prevState: CheckTreePickerState) {
285
288
  const { data, selectedValues, expandItemValues } = this.state;
286
289
  const { uncheckableItemValues } = this.props;
287
- if (compareArray(uncheckableItemValues, prevState.uncheckableItemValues)) {
290
+ if (
291
+ compareArray(uncheckableItemValues, prevState.uncheckableItemValues) &&
292
+ _.isArray(uncheckableItemValues)
293
+ ) {
288
294
  this.flattenNodes(data);
289
295
  this.unserializeLists({
290
296
  check: selectedValues,
@@ -343,6 +349,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
343
349
 
344
350
  if (isEveryChildChecked(node, this.nodes, this.props)) {
345
351
  this.nodes[node.refKey].checkAll = true;
352
+ this.nodes[node.refKey].check = true;
346
353
  return CHECK_STATE.CHECK;
347
354
  }
348
355
 
@@ -481,6 +488,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
481
488
  const checkItems = [];
482
489
  Object.keys(this.nodes).map((refKey: string) => {
483
490
  const node = this.nodes[refKey];
491
+
484
492
  if (selectedValues.some((value: any) => shallowEqual(node[valueKey], value))) {
485
493
  checkItems.push(node);
486
494
  }
@@ -531,7 +539,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
531
539
  }
532
540
 
533
541
  /**
534
- * 过滤选中的values中不包含 uncheckableItemValues 的那些值
542
+ * 过滤选中的 values 中不包含 uncheckableItemValues 的那些值
535
543
  * @param {*} values
536
544
  */
537
545
  filterSelectedValues(values: any[]) {
@@ -743,7 +751,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
743
751
  }
744
752
 
745
753
  toggleNode(key: string, node: Node, toggleValue: boolean) {
746
- // 如果该节点处于 disabledChecbox,则忽略该值
754
+ // 如果该节点处于 disabledCheckbox,则忽略该值
747
755
  if (!node.uncheckable) {
748
756
  this.nodes[node.refKey][key] = toggleValue;
749
757
  }
@@ -4,10 +4,23 @@ import Enzyme, { mount } from 'enzyme';
4
4
  import Adapter from 'enzyme-adapter-react-16';
5
5
  import { getDOMNode, getInstance } from '@test/testUtils';
6
6
  import CheckTreePicker from '../CheckTreePicker';
7
- import { findDOMNode } from 'react-dom';
7
+ import ReactDOM, { findDOMNode } from 'react-dom';
8
+ import { assert } from 'chai';
8
9
 
9
10
  Enzyme.configure({ adapter: new Adapter() });
10
11
 
12
+ let container;
13
+
14
+ beforeEach(() => {
15
+ container = document.createElement('div');
16
+ document.body.appendChild(container);
17
+ });
18
+
19
+ afterEach(() => {
20
+ document.body.removeChild(container);
21
+ container = null;
22
+ });
23
+
11
24
  const data = [
12
25
  {
13
26
  label: 'Master',
@@ -298,6 +311,66 @@ describe('CheckTreePicker', () => {
298
311
  instance.unmount();
299
312
  });
300
313
 
314
+ it('Should return 2 values', done => {
315
+ const customData = [
316
+ {
317
+ value: '1',
318
+ label: '1',
319
+ children: [
320
+ {
321
+ value: '1-1',
322
+ label: '1-1'
323
+ },
324
+ {
325
+ value: '1-2',
326
+ label: '1-2'
327
+ },
328
+ {
329
+ value: '1-3',
330
+ label: '1-3'
331
+ }
332
+ ]
333
+ },
334
+ {
335
+ value: '2',
336
+ label: '2',
337
+ children: [
338
+ {
339
+ value: '2-1',
340
+ label: '2-1'
341
+ },
342
+ {
343
+ value: '2-2',
344
+ label: '2-2'
345
+ },
346
+ {
347
+ value: '2-3',
348
+ label: '2-3'
349
+ }
350
+ ]
351
+ }
352
+ ];
353
+
354
+ const doneOp = values => {
355
+ if (values.length === 2) {
356
+ done();
357
+ }
358
+ };
359
+ const instance = getDOMNode(
360
+ <CheckTreePicker
361
+ data={customData}
362
+ inline
363
+ value={['1-1', '1-2', '1-3']}
364
+ cascade
365
+ defaultExpandAll
366
+ onChange={doneOp}
367
+ />
368
+ );
369
+
370
+ assert.equal(instance.querySelectorAll('.rs-checkbox-checked').length, 4);
371
+ ReactTestUtils.Simulate.change(instance.querySelectorAll('.rs-check-tree-node input')[5]);
372
+ });
373
+
301
374
  it('Should render empty tree when searchKeyword is `name`', () => {
302
375
  const instance = mount(<CheckTreePicker data={data} inline searchKeyword="name" />);
303
376
  assert.equal(instance.find('.rs-check-tree-node').length, 0);
@@ -384,4 +457,114 @@ describe('CheckTreePicker', () => {
384
457
  assert.equal(instance2.querySelector('.rs-picker-toggle-placeholder').innerText, 'Select');
385
458
  assert.equal(instance3.querySelector('.rs-picker-toggle-placeholder').innerText, 'Select');
386
459
  });
460
+
461
+ it('Should controlled by value', () => {
462
+ const TestApp = React.forwardRef((props, ref) => {
463
+ const [value, setValue] = React.useState();
464
+ const pickerRef = React.useRef();
465
+ React.useImperativeHandle(ref, () => ({
466
+ picker: pickerRef.current,
467
+ setValue
468
+ }));
469
+
470
+ return <CheckTreePicker data={data} ref={pickerRef} value={value} defaultExpandAll open />;
471
+ });
472
+
473
+ TestApp.displayName = 'TestCheckTreePicker';
474
+
475
+ const ref = React.createRef();
476
+ ReactTestUtils.act(() => {
477
+ ReactDOM.render(<TestApp ref={ref} />, container);
478
+ });
479
+
480
+ assert.equal(
481
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-checkbox-checked').length,
482
+ 0
483
+ );
484
+
485
+ ReactTestUtils.act(() => {
486
+ ref.current.setValue(['Master']);
487
+ });
488
+ assert.equal(
489
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-checkbox-checked').length,
490
+ 4
491
+ );
492
+ });
493
+
494
+ it('Should controlled by expandItemValues', () => {
495
+ const TestApp = React.forwardRef((props, ref) => {
496
+ const [expandItemValues, setExpandItemValues] = React.useState();
497
+ const pickerRef = React.useRef();
498
+ React.useImperativeHandle(ref, () => ({
499
+ picker: pickerRef.current,
500
+ setExpandItemValues
501
+ }));
502
+
503
+ return (
504
+ <CheckTreePicker data={data} ref={pickerRef} expandItemValues={expandItemValues} open />
505
+ );
506
+ });
507
+
508
+ TestApp.displayName = 'TestCheckTreePicker';
509
+
510
+ const ref = React.createRef();
511
+ ReactTestUtils.act(() => {
512
+ ReactDOM.render(<TestApp ref={ref} />, container);
513
+ });
514
+
515
+ assert.equal(
516
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-check-tree-node-expanded')
517
+ .length,
518
+ 0
519
+ );
520
+
521
+ ReactTestUtils.act(() => {
522
+ ref.current.setExpandItemValues(['Master']);
523
+ });
524
+ assert.equal(
525
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-check-tree-node-expanded')
526
+ .length,
527
+ 1
528
+ );
529
+ });
530
+
531
+ it('Should controlled by uncheckableItemValues', () => {
532
+ const TestApp = React.forwardRef((props, ref) => {
533
+ const [uncheckableItemValues, setUncheckableItemValues] = React.useState();
534
+ const pickerRef = React.useRef();
535
+ React.useImperativeHandle(ref, () => ({
536
+ picker: pickerRef.current,
537
+ setUncheckableItemValues
538
+ }));
539
+
540
+ return (
541
+ <CheckTreePicker
542
+ data={data}
543
+ ref={pickerRef}
544
+ uncheckableItemValues={uncheckableItemValues}
545
+ open
546
+ />
547
+ );
548
+ });
549
+
550
+ TestApp.displayName = 'TestCheckTreePicker';
551
+
552
+ const ref = React.createRef();
553
+ ReactTestUtils.act(() => {
554
+ ReactDOM.render(<TestApp ref={ref} />, container);
555
+ });
556
+
557
+ assert.equal(
558
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-checkbox-inner').length,
559
+ 5
560
+ );
561
+
562
+ ReactTestUtils.act(() => {
563
+ ref.current.setUncheckableItemValues(['Master']);
564
+ });
565
+ assert.equal(
566
+ ref.current.picker.treeViewRef.current.querySelectorAll('.rs-checkbox-inner').length,
567
+ 4
568
+ );
569
+ });
387
570
  });
@@ -293,4 +293,24 @@ describe('DatePicker', () => {
293
293
  );
294
294
  assert.equal(picker.querySelector('.rs-calendar-time-dropdown-column li').innerText, '12');
295
295
  });
296
+
297
+ it('Should keep AM PM unchanged', () => {
298
+ const instance = getInstance(
299
+ <DatePicker
300
+ value={parse('2017-08-14 13:00:00')}
301
+ format="hh:mm:ss A"
302
+ defaultOpen
303
+ showMeridian
304
+ />
305
+ );
306
+
307
+ const picker = instance.menuContainerRef.current;
308
+
309
+ assert.equal(picker.querySelector('.rs-calendar-header-title-time').innerText, '01:00:00');
310
+
311
+ ReactTestUtils.Simulate.click(picker.querySelector('.rs-calendar-time-dropdown-cell'));
312
+
313
+ assert.equal(picker.querySelector('.rs-calendar-header-meridian').innerText, 'PM');
314
+ assert.equal(picker.querySelector('.rs-calendar-header-title-time').innerText, '12:00:00');
315
+ });
296
316
  });
@@ -1,6 +1,4 @@
1
- import { setStatic, setDisplayName } from 'recompose';
2
-
3
- import { defaultProps } from '../utils';
1
+ import { setStatic, setDisplayName, defaultProps } from '../utils';
4
2
  import Drawer from './Drawer';
5
3
  import ModalBody from '../Modal/ModalBody';
6
4
  import ModalHeader from '../Modal/ModalHeader';
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
  import _ from 'lodash';
5
- import { setStatic } from 'recompose';
6
5
  import { contains } from 'dom-lib';
7
6
 
8
7
  import RootCloseWrapper from '../Overlay/RootCloseWrapper';
@@ -11,6 +10,7 @@ import DropdownToggle from './DropdownToggle';
11
10
  import DropdownMenu from './DropdownMenu';
12
11
  import DropdownMenuItem from './DropdownMenuItem';
13
12
  import {
13
+ setStatic,
14
14
  createChainedFunction,
15
15
  prefix,
16
16
  isOneOf,
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { setStatic } from 'recompose';
5
4
 
6
- import { defaultProps, prefix } from '../utils';
5
+ import { setStatic, defaultProps, prefix } from '../utils';
7
6
  import FlexboxGridItem from './FlexboxGridItem';
8
7
  import { FlexboxGridProps } from './FlexboxGrid.d';
9
8
 
@@ -2,8 +2,7 @@ import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
  import _ from 'lodash';
5
- import { compose } from 'recompose';
6
- import { withStyleProps, defaultProps, prefix, createContext } from '../utils';
5
+ import { compose, withStyleProps, defaultProps, prefix, createContext } from '../utils';
7
6
  import { FormGroupProps } from './FormGroup.d';
8
7
 
9
8
  export const FormGroupContext = createContext(null);
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { compose } from 'recompose';
5
4
  import _ from 'lodash';
6
5
 
7
6
  import {
7
+ compose,
8
8
  withStyleProps,
9
9
  defaultProps,
10
10
  createChainedFunction,
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { setStatic, compose } from 'recompose';
5
4
  import InputGroupAddon from './InputGroupAddon';
6
5
  import InputGroupButton from './InputGroupButton';
7
- import { prefix, withStyleProps, defaultProps, createContext } from '../utils';
6
+ import { setStatic, compose, prefix, withStyleProps, defaultProps, createContext } from '../utils';
8
7
  import { InputGroupProps } from './InputGroup.d';
9
8
 
10
9
  export const InputGroupContext = createContext(null);
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import _ from 'lodash';
3
- import { setDisplayName, wrapDisplayName } from 'recompose';
3
+ import { setDisplayName, wrapDisplayName } from '../utils';
4
4
  import format from 'date-fns/format';
5
5
  import defaultLocale from './locales/default';
6
6
  import extendReactStatics from '../utils/extendReactStatics';
package/src/List/List.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { setStatic } from 'recompose';
4
3
  import classNames from 'classnames';
5
4
  import { on } from 'dom-lib';
6
5
  import {
@@ -12,7 +11,7 @@ import {
12
11
  getEdgeOffset,
13
12
  getScrollingParent
14
13
  } from './utils';
15
- import { prefix, defaultProps, getUnhandledProps } from '../utils';
14
+ import { setStatic, prefix, defaultProps, getUnhandledProps } from '../utils';
16
15
  import ListItem from './ListItem';
17
16
  import { ListProps } from './List.d';
18
17
  import Manager from './Manager';
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { setDisplayName } from 'recompose';
4
3
  import classNames from 'classnames';
5
- import { defaultProps, getUnhandledProps, prefix } from '../utils';
4
+ import { setDisplayName, defaultProps, getUnhandledProps, prefix } from '../utils';
6
5
  import ListContext from './ListContext';
7
6
  import { ListItemProps } from './ListItem.d';
8
7
  import { ManagerRef } from './Manager';
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { compose } from 'recompose';
5
4
 
6
- import { withStyleProps, defaultProps, prefix } from '../utils';
5
+ import { compose, withStyleProps, defaultProps, prefix } from '../utils';
7
6
  import { LoaderProps } from './Loader.d';
8
7
 
9
8
  class Loader extends React.Component<LoaderProps> {
@@ -2,12 +2,11 @@ import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
  import _ from 'lodash';
5
- import { setStatic } from 'recompose';
6
5
  import bindElementResize, { unbind as unbindElementResize } from 'element-resize-event';
7
6
  import BaseModal from './BaseModal';
8
7
  import Bounce from '../Animation/Bounce';
9
8
  import { on, getHeight } from 'dom-lib';
10
- import { prefix, defaultProps, createChainedFunction } from '../utils';
9
+ import { setStatic, prefix, defaultProps, createChainedFunction } from '../utils';
11
10
  import ModalDialog, { modalDialogPropTypes } from './ModalDialog';
12
11
  import ModalBody from './ModalBody';
13
12
  import ModalHeader from './ModalHeader';
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { compose } from 'recompose';
5
4
 
6
- import { withStyleProps, defaultProps, prefix, refType } from '../utils';
5
+ import { compose, withStyleProps, defaultProps, prefix, refType } from '../utils';
7
6
  import { ModalDialogProps } from './ModalDialog.d';
8
7
  import mergeRefs from '../utils/mergeRefs';
9
8
 
@@ -80,6 +80,8 @@ class MultiCascader extends React.Component<MultiCascaderProps, MultiCascaderSta
80
80
  menuContainerRef: React.RefObject<any>;
81
81
  positionRef: React.RefObject<any>;
82
82
  triggerRef: React.RefObject<any>;
83
+ toggleRef: React.RefObject<any>;
84
+
83
85
  constructor(props) {
84
86
  super(props);
85
87
 
@@ -115,6 +117,7 @@ class MultiCascader extends React.Component<MultiCascaderProps, MultiCascaderSta
115
117
  this.menuContainerRef = React.createRef();
116
118
  this.positionRef = React.createRef();
117
119
  this.triggerRef = React.createRef();
120
+ this.toggleRef = React.createRef();
118
121
  }
119
122
 
120
123
  static getCascadeState(nextProps: MultiCascaderProps, flattenData: any[], nextValue?: any[]) {
@@ -321,6 +324,13 @@ class MultiCascader extends React.Component<MultiCascaderProps, MultiCascaderSta
321
324
  }
322
325
  return items;
323
326
  }
327
+ getPositionInstance = () => {
328
+ return this.positionRef.current;
329
+ };
330
+
331
+ getToggleInstance = () => {
332
+ return this.toggleRef.current;
333
+ };
324
334
 
325
335
  renderSearchRow = (item: any, key: number) => {
326
336
  const { labelKey, valueKey, cascade, disabledItemValues = [] } = this.props;
@@ -422,7 +432,12 @@ class MultiCascader extends React.Component<MultiCascaderProps, MultiCascaderSta
422
432
  const menuProps = _.pick(this.props, Object.keys(dropdownMenuPropTypes));
423
433
 
424
434
  return (
425
- <MenuWrapper className={classes} style={menuStyle}>
435
+ <MenuWrapper
436
+ className={classes}
437
+ style={menuStyle}
438
+ getToggleInstance={this.getToggleInstance}
439
+ getPositionInstance={this.getPositionInstance}
440
+ >
426
441
  {searchable && (
427
442
  <SearchBar
428
443
  placeholder={locale.searchPlaceholder}
@@ -533,6 +548,7 @@ class MultiCascader extends React.Component<MultiCascaderProps, MultiCascaderSta
533
548
  >
534
549
  <PickerToggle
535
550
  {...unhandled}
551
+ ref={this.toggleRef}
536
552
  componentClass={toggleComponentClass}
537
553
  onClean={createChainedFunction(this.handleClean, onClean)}
538
554
  cleanable={cleanable && !disabled}
package/src/Nav/Nav.tsx CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { setStatic } from 'recompose';
5
4
  import shallowEqual from '../utils/shallowEqual';
6
5
 
7
6
  import NavItem from './NavItem';
8
7
  import {
8
+ setStatic,
9
9
  prefix,
10
10
  getUnhandledProps,
11
11
  defaultProps,