@jetbrains/ring-ui 4.2.1 → 4.2.2

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.
@@ -5,6 +5,8 @@ import warningIcon from '@jetbrains/icons/warning';
5
5
  import reactDecorator from '../../.storybook/react-decorator';
6
6
  import hubConfig from '../../.storybook/hub-config';
7
7
 
8
+ import Text from '../text/text';
9
+
8
10
  import Link from '@jetbrains/ring-ui/components/link/link';
9
11
  import Popup from '@jetbrains/ring-ui/components/popup/popup';
10
12
  import List from '@jetbrains/ring-ui/components/list/list';
@@ -961,6 +963,31 @@ export const multipleWithSelectAllAndDisabledItem = args => <Select {...args}/>;
961
963
  multipleWithSelectAllAndDisabledItem.storyName = 'multiple with select all and disabled item';
962
964
  multipleWithSelectAllAndDisabledItem.parameters = {hermione: {skip: true}};
963
965
 
966
+ export const multipleWithSelectAllAndCustomLabels = args => <Select {...args}/>;
967
+ {
968
+ const data = [
969
+ {label: 'One long label', key: '1'},
970
+ {label: 'Two long label', key: '2'},
971
+ {label: 'Three long label', key: '3'}
972
+ ];
973
+
974
+ const multipleConfig = {
975
+ selectAll: true,
976
+ selectAllLabel: 'All Items',
977
+ deselectAllLabel: 'None Items',
978
+ renderSelectedItemsDescription: selected => <Text info>{`${selected.length} items selected`}</Text>
979
+ };
980
+
981
+ multipleWithSelectAllAndCustomLabels.args = {
982
+ filter: true,
983
+ multiple: multipleConfig,
984
+ selected: [data[1]],
985
+ data
986
+ };
987
+ }
988
+
989
+ multipleWithSelectAllAndCustomLabels.storyName = 'multiple with select all and custom labels';
990
+ multipleWithSelectAllAndCustomLabels.parameters = {hermione: {skip: true}};
964
991
 
965
992
  export const multipleWithLimit = args => <Select {...args}/>;
966
993
  {
@@ -63,7 +63,10 @@ export default class SelectPopup extends PureComponent {
63
63
  multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
64
64
  label: PropTypes.string,
65
65
  limit: PropTypes.number,
66
- selectAll: PropTypes.bool
66
+ selectAll: PropTypes.bool,
67
+ selectAllLabel: PropTypes.string,
68
+ deselectAllLabel: PropTypes.string,
69
+ renderSelectedItemsDescription: PropTypes.func
67
70
  })]),
68
71
  left: PropTypes.bool,
69
72
  loading: PropTypes.bool,
@@ -406,12 +409,15 @@ export default class SelectPopup extends PureComponent {
406
409
  onClick={this.handleSelectAll}
407
410
  >
408
411
  {activeFilters.length !== this.props.selected.length
409
- ? 'Select all'
410
- : 'Deselect all'}
412
+ ? this.props.multiple.selectAllLabel || 'Select all'
413
+ : this.props.multiple.deselectAllLabel || 'Deselect all'}
411
414
  </Button>
412
415
  )
413
416
  }
414
- <Text info>{`${this.props.selected.length} selected`}</Text>
417
+ {this.props.multiple.renderSelectedItemsDescription
418
+ ?.(this.props.selected, activeFilters.length) || (
419
+ <Text info>{`${this.props.selected.length} selected`}</Text>
420
+ )}
415
421
  </div>
416
422
  );
417
423
  };
@@ -158,6 +158,8 @@ class SelectPopup extends PureComponent {
158
158
  _defineProperty(this, "handleSelectAll", () => this.props.onSelectAll(this.props.data.filter(item => !item.disabled).length !== this.props.selected.length));
159
159
 
160
160
  _defineProperty(this, "getSelectAll", () => {
161
+ var _this$props$multiple$, _this$props$multiple;
162
+
161
163
  const activeFilters = this.props.data.filter(item => !item.disabled);
162
164
  return /*#__PURE__*/React.createElement("div", {
163
165
  className: modules_b607bec2.selectAll
@@ -165,7 +167,7 @@ class SelectPopup extends PureComponent {
165
167
  text: true,
166
168
  inline: true,
167
169
  onClick: this.handleSelectAll
168
- }, activeFilters.length !== this.props.selected.length ? 'Select all' : 'Deselect all'), /*#__PURE__*/React.createElement(Text, {
170
+ }, activeFilters.length !== this.props.selected.length ? this.props.multiple.selectAllLabel || 'Select all' : this.props.multiple.deselectAllLabel || 'Deselect all'), ((_this$props$multiple$ = (_this$props$multiple = this.props.multiple).renderSelectedItemsDescription) === null || _this$props$multiple$ === void 0 ? void 0 : _this$props$multiple$.call(_this$props$multiple, this.props.selected, activeFilters.length)) || /*#__PURE__*/React.createElement(Text, {
169
171
  info: true
170
172
  }, "".concat(this.props.selected.length, " selected")));
171
173
  });
@@ -502,7 +504,10 @@ _defineProperty(SelectPopup, "propTypes", {
502
504
  multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
503
505
  label: PropTypes.string,
504
506
  limit: PropTypes.number,
505
- selectAll: PropTypes.bool
507
+ selectAll: PropTypes.bool,
508
+ selectAllLabel: PropTypes.string,
509
+ deselectAllLabel: PropTypes.string,
510
+ renderSelectedItemsDescription: PropTypes.func
506
511
  })]),
507
512
  left: PropTypes.bool,
508
513
  loading: PropTypes.bool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -221,5 +221,5 @@
221
221
  "node": ">=7.4",
222
222
  "npm": ">=6.0.0"
223
223
  },
224
- "gitHead": "d2354ec4b296cfa3cae3e988197efbc1f49eedd2"
224
+ "gitHead": "e83463856025904b6b4d8409f1460b9b1b9ceaec"
225
225
  }