@jetbrains/ring-ui 4.2.0 → 4.2.3

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.
@@ -36,6 +36,7 @@ export default class AnalyticsGAPlugin {
36
36
  }
37
37
 
38
38
  ga('set', 'anonymizeIp', true);
39
+ ga('set', 'location', domain || '/');
39
40
  ga('set', 'allowAdFeatures', false);
40
41
  }
41
42
 
@@ -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
  };
@@ -12,7 +12,11 @@ class SelectLazy {
12
12
  this.props = props || {};
13
13
  this.type = type;
14
14
  this.node = container;
15
- this.selectRef = selectRef;
15
+ this.selectInstance = null;
16
+ this.selectRef = node => {
17
+ this.selectInstance = node;
18
+ selectRef(node);
19
+ };
16
20
  this._popup = {
17
21
  isVisible: angular.noop
18
22
  };
@@ -65,6 +69,8 @@ class SelectLazy {
65
69
  this.detachEvents();
66
70
  if (this.type === 'dropdown') {
67
71
  render(this.reactSelect, this.container);
72
+ // Hack for React17, where click event is not triggered on just rendered Select node
73
+ this.selectInstance?._openPopupIfClosed?.();
68
74
  } else {
69
75
  hydrate(this.reactSelect, this.container);
70
76
  }
@@ -46,6 +46,7 @@ class AnalyticsGAPlugin {
46
46
  }
47
47
 
48
48
  ga('set', 'anonymizeIp', true);
49
+ ga('set', 'location', domain || '/');
49
50
  ga('set', 'allowAdFeatures', false);
50
51
  }
51
52
 
@@ -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,
@@ -95,7 +95,13 @@ class SelectLazy {
95
95
  this.props = props || {};
96
96
  this.type = type;
97
97
  this.node = container;
98
- this.selectRef = selectRef;
98
+ this.selectInstance = null;
99
+
100
+ this.selectRef = node => {
101
+ this.selectInstance = node;
102
+ selectRef(node);
103
+ };
104
+
99
105
  this._popup = {
100
106
  isVisible: angular.noop
101
107
  };
@@ -148,7 +154,11 @@ class SelectLazy {
148
154
  this.detachEvents();
149
155
 
150
156
  if (this.type === 'dropdown') {
151
- render(this.reactSelect, this.container);
157
+ var _this$selectInstance, _this$selectInstance$;
158
+
159
+ render(this.reactSelect, this.container); // Hack for React17, where click event is not triggered on just rendered Select node
160
+
161
+ (_this$selectInstance = this.selectInstance) === null || _this$selectInstance === void 0 ? void 0 : (_this$selectInstance$ = _this$selectInstance._openPopupIfClosed) === null || _this$selectInstance$ === void 0 ? void 0 : _this$selectInstance$.call(_this$selectInstance);
152
162
  } else {
153
163
  hydrate(this.reactSelect, this.container);
154
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "4.2.0",
3
+ "version": "4.2.3",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -70,7 +70,7 @@
70
70
  "@babel/cli": "^7.17.6",
71
71
  "@babel/eslint-parser": "^7.17.0",
72
72
  "@jetbrains/eslint-config": "^5.3.2",
73
- "@jetbrains/generator-ring-ui": "^4.1.9",
73
+ "@jetbrains/generator-ring-ui": "^4.1.10",
74
74
  "@jetbrains/stylelint-config": "^3.0.2",
75
75
  "@primer/octicons": "^17.0.0",
76
76
  "@rollup/plugin-babel": "^5.3.1",
@@ -81,20 +81,20 @@
81
81
  "@storybook/addon-storyshots": "6.5.0-alpha.59",
82
82
  "@storybook/addon-storyshots-puppeteer": "6.5.0-alpha.59",
83
83
  "@storybook/addon-storysource": "6.5.0-alpha.59",
84
- "@storybook/addons": "6.5.0-alpha.59",
85
- "@storybook/builder-webpack5": "6.5.0-alpha.59",
84
+ "@storybook/addons": "6.5.0-alpha.64",
85
+ "@storybook/builder-webpack5": "6.5.0-alpha.64",
86
86
  "@storybook/client-api": "6.5.0-alpha.59",
87
- "@storybook/core": "6.5.0-alpha.59",
87
+ "@storybook/core": "6.5.0-alpha.64",
88
88
  "@storybook/html": "6.5.0-alpha.59",
89
89
  "@storybook/manager-webpack5": "6.5.0-alpha.59",
90
90
  "@storybook/source-loader": "6.5.0-alpha.59",
91
91
  "@storybook/theming": "6.5.0-alpha.59",
92
92
  "@testing-library/react": "^13.0.0",
93
- "@testing-library/user-event": "^14.0.4",
93
+ "@testing-library/user-event": "^14.1.0",
94
94
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
95
95
  "angular": "^1.8.2",
96
96
  "angular-mocks": "^1.8.2",
97
- "angular-route": "^1.8.2",
97
+ "angular-route": "^1.8.3",
98
98
  "babel-plugin-react-docgen": "^4.2.1",
99
99
  "babel-plugin-require-context-hook": "^1.0.0",
100
100
  "chai": "^4.3.6",
@@ -147,7 +147,7 @@
147
147
  "teamcity-service-messages": "^0.1.12",
148
148
  "terser-webpack-plugin": "^5.3.1",
149
149
  "wallaby-webpack": "^3.9.16",
150
- "webpack": "^5.70.0",
150
+ "webpack": "^5.72.0",
151
151
  "webpack-cli": "^4.9.2",
152
152
  "xmlappend": "^1.0.4",
153
153
  "yo": "^4.3.0"
@@ -156,7 +156,7 @@
156
156
  "core-js": ">=3.0.0",
157
157
  "react": ">=16.8.0",
158
158
  "react-dom": ">=16.8.0",
159
- "webpack": "^5.70.0"
159
+ "webpack": "^5.72.0"
160
160
  },
161
161
  "peerDependenciesMeta": {
162
162
  "webpack": {
@@ -221,5 +221,5 @@
221
221
  "node": ">=7.4",
222
222
  "npm": ">=6.0.0"
223
223
  },
224
- "gitHead": "986c4b2e86d7e83388dc77b38bd9d62e1657b747"
224
+ "gitHead": "9d293b7a0089eab3fbadaffb55a1ede32367c2df"
225
225
  }