@jetbrains/ring-ui 5.0.134 → 5.0.135

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.
@@ -27,14 +27,19 @@ function createAngularComponent(Component) {
27
27
  $postLink() {
28
28
  const {$transclude} = this.$inject;
29
29
 
30
+
30
31
  $transclude(clone => {
31
- this.innerNodes = Array.from(clone);
32
+ this.container = document.createElement('div');
33
+
34
+ for (let i = 0; i < clone.length; i++) {
35
+ this.container.appendChild(clone[i]);
36
+ }
32
37
  this.render();
33
38
  });
34
39
  }
35
40
 
36
41
  $onChanges() {
37
- if (!this.innerNodes) {
42
+ if (!this.container) {
38
43
  return;
39
44
  }
40
45
  this.render();
@@ -62,11 +67,11 @@ function createAngularComponent(Component) {
62
67
  }
63
68
  });
64
69
 
65
- const hasInnerContent = this.innerNodes && this.innerNodes.length;
70
+ const hasInnerContent = this.container.hasChildNodes();
66
71
 
67
72
  render(
68
73
  <Component {...props}>
69
- {hasInnerContent ? <DomRenderer nodes={this.innerNodes}/> : null}
74
+ {hasInnerContent ? <DomRenderer nodes={this.container.childNodes}/> : null}
70
75
  </Component>,
71
76
  container
72
77
  );
@@ -4,7 +4,7 @@ import angular from 'angular';
4
4
  import 'angular-mocks';
5
5
  import React, {PureComponent} from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import {Simulate} from 'react-dom/test-utils';
7
+ import {act, Simulate} from 'react-dom/test-utils';
8
8
 
9
9
  import angularComponentFactory from './angular-component-factory';
10
10
 
@@ -13,7 +13,8 @@ class TestComponent extends PureComponent {
13
13
  id: PropTypes.string,
14
14
  someObj: PropTypes.object,
15
15
  onClick: PropTypes.func,
16
- className: PropTypes.string
16
+ className: PropTypes.string,
17
+ children: PropTypes.node
17
18
  };
18
19
 
19
20
  static defaultProps = {
@@ -23,15 +24,18 @@ class TestComponent extends PureComponent {
23
24
  handleClick = () => this.props.onClick('payload');
24
25
 
25
26
  render() {
26
- const {id, someObj, className} = this.props;
27
+ const {id, someObj, className, children} = this.props;
27
28
  return (
28
- <button
29
- type="button"
30
- id={id}
31
- data-some-obj={someObj.foo}
32
- onClick={this.handleClick}
33
- className={className}
34
- />
29
+ <>
30
+ <button
31
+ type="button"
32
+ id={id}
33
+ data-some-obj={someObj.foo}
34
+ onClick={this.handleClick}
35
+ className={className}
36
+ />
37
+ {children}
38
+ </>
35
39
  );
36
40
  }
37
41
  }
@@ -115,4 +119,20 @@ describe('angularComponentFactory', () => {
115
119
  $rootScope.callback.should.have.been.called;
116
120
  $rootScope.callback.should.have.been.calledWith('payload');
117
121
  });
122
+
123
+ it('should support ng-if in nested content', () => {
124
+ let $element = null;
125
+ act(() => {
126
+ $element = $compile(`
127
+ <rg-test-component>
128
+ <span data-test="hello">HELLO</span>
129
+ </rg-test-component>`
130
+ )($rootScope);
131
+ });
132
+
133
+ const component = $element[0].querySelector('[data-test~=hello]');
134
+ $rootScope.$digest();
135
+
136
+ should.exist(component);
137
+ });
118
138
  });
@@ -2,12 +2,12 @@ import { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  export interface RendererProps {
4
4
  className?: string | undefined;
5
- nodes: readonly Node[];
5
+ nodes: readonly Node[] | NodeList;
6
6
  }
7
7
  export default class Renderer extends Component<RendererProps> {
8
8
  static propTypes: {
9
9
  className: PropTypes.Requireable<string>;
10
- nodes: PropTypes.Requireable<any[]>;
10
+ nodes: PropTypes.Requireable<object>;
11
11
  };
12
12
  componentDidMount(): void;
13
13
  node?: HTMLElement | null;
@@ -3,16 +3,16 @@ import PropTypes from 'prop-types';
3
3
  class Renderer extends Component {
4
4
  static propTypes = {
5
5
  className: PropTypes.string,
6
- nodes: PropTypes.array
6
+ nodes: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
7
7
  };
8
8
  componentDidMount() {
9
+ const { node } = this;
9
10
  const { nodes } = this.props;
10
- if (!this.node || !nodes || !nodes.length) {
11
+ if (!node || !nodes || !nodes.length) {
11
12
  return;
12
13
  }
13
- const fragment = document.createDocumentFragment();
14
- nodes.forEach(nodeToRender => fragment.appendChild(nodeToRender));
15
- this.node.appendChild(fragment);
14
+ Array.from(this.props.nodes).
15
+ forEach(nodeToRender => node.appendChild(nodeToRender));
16
16
  }
17
17
  node;
18
18
  nodeRef = (node) => {
@@ -23,12 +23,15 @@ function createAngularComponent(Component) {
23
23
  $transclude
24
24
  } = this.$inject;
25
25
  $transclude(clone => {
26
- this.innerNodes = Array.from(clone);
26
+ this.container = document.createElement('div');
27
+ for (let i = 0; i < clone.length; i++) {
28
+ this.container.appendChild(clone[i]);
29
+ }
27
30
  this.render();
28
31
  });
29
32
  }
30
33
  $onChanges() {
31
- if (!this.innerNodes) {
34
+ if (!this.container) {
32
35
  return;
33
36
  }
34
37
  this.render();
@@ -58,9 +61,9 @@ function createAngularComponent(Component) {
58
61
  }
59
62
  }
60
63
  });
61
- const hasInnerContent = this.innerNodes && this.innerNodes.length;
64
+ const hasInnerContent = this.container.hasChildNodes();
62
65
  render( /*#__PURE__*/React.createElement(Component, props, hasInnerContent ? /*#__PURE__*/React.createElement(Renderer, {
63
- nodes: this.innerNodes
66
+ nodes: this.container.childNodes
64
67
  }) : null), container);
65
68
  }
66
69
  }
@@ -2,12 +2,12 @@ import { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  export interface RendererProps {
4
4
  className?: string | undefined;
5
- nodes: readonly Node[];
5
+ nodes: readonly Node[] | NodeList;
6
6
  }
7
7
  export default class Renderer extends Component<RendererProps> {
8
8
  static propTypes: {
9
9
  className: PropTypes.Requireable<string>;
10
- nodes: PropTypes.Requireable<any[]>;
10
+ nodes: PropTypes.Requireable<object>;
11
11
  };
12
12
  componentDidMount(): void;
13
13
  node?: HTMLElement | null;
@@ -4,18 +4,19 @@ import PropTypes from 'prop-types';
4
4
  class Renderer extends Component {
5
5
  static propTypes = {
6
6
  className: PropTypes.string,
7
- nodes: PropTypes.array
7
+ nodes: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
8
8
  };
9
9
  componentDidMount() {
10
+ const {
11
+ node
12
+ } = this;
10
13
  const {
11
14
  nodes
12
15
  } = this.props;
13
- if (!this.node || !nodes || !nodes.length) {
16
+ if (!node || !nodes || !nodes.length) {
14
17
  return;
15
18
  }
16
- const fragment = document.createDocumentFragment();
17
- nodes.forEach(nodeToRender => fragment.appendChild(nodeToRender));
18
- this.node.appendChild(fragment);
19
+ Array.from(this.props.nodes).forEach(nodeToRender => node.appendChild(nodeToRender));
19
20
  }
20
21
  node;
21
22
  nodeRef = node => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "5.0.134",
3
+ "version": "5.0.135",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -83,20 +83,20 @@
83
83
  "@rollup/plugin-babel": "^6.0.3",
84
84
  "@rollup/plugin-node-resolve": "^15.0.2",
85
85
  "@rollup/plugin-replace": "^5.0.2",
86
- "@storybook/addon-a11y": "7.0.5",
87
- "@storybook/addon-docs": "7.0.4",
88
- "@storybook/addon-essentials": "7.0.5",
86
+ "@storybook/addon-a11y": "7.0.6",
87
+ "@storybook/addon-docs": "7.0.5",
88
+ "@storybook/addon-essentials": "7.0.6",
89
89
  "@storybook/addon-storyshots": "7.0.2",
90
- "@storybook/addon-storyshots-puppeteer": "7.0.5",
91
- "@storybook/addon-storysource": "7.0.4",
92
- "@storybook/addons": "7.0.5",
90
+ "@storybook/addon-storyshots-puppeteer": "7.0.6",
91
+ "@storybook/addon-storysource": "7.0.5",
92
+ "@storybook/addons": "7.0.6",
93
93
  "@storybook/core": "6.5.16",
94
94
  "@storybook/html": "7.0.2",
95
95
  "@storybook/html-webpack5": "^7.0.5",
96
96
  "@storybook/preview-api": "7.0.2",
97
- "@storybook/react": "7.0.4",
97
+ "@storybook/react": "7.0.6",
98
98
  "@storybook/source-loader": "7.0.5",
99
- "@storybook/theming": "7.0.4",
99
+ "@storybook/theming": "7.0.6",
100
100
  "@testing-library/react": "^14.0.0",
101
101
  "@testing-library/user-event": "^14.4.3",
102
102
  "@types/chai": "^4.3.4",
@@ -104,12 +104,12 @@
104
104
  "@types/chai-dom": "0.0.10",
105
105
  "@types/chai-enzyme": "^0.6.8",
106
106
  "@types/enzyme": "^3.10.13",
107
- "@types/react": "^18.0.35",
107
+ "@types/react": "^18.0.37",
108
108
  "@types/react-dom": "^18.0.11",
109
109
  "@types/sinon": "^10.0.14",
110
110
  "@types/sinon-chai": "^3.2.9",
111
- "@typescript-eslint/eslint-plugin": "^5.58.0",
112
- "@typescript-eslint/parser": "^5.58.0",
111
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
112
+ "@typescript-eslint/parser": "^5.59.0",
113
113
  "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
114
114
  "angular": "^1.8.3",
115
115
  "angular-mocks": "^1.8.3",
@@ -134,7 +134,7 @@
134
134
  "eslint-plugin-react": "^7.32.2",
135
135
  "eslint-plugin-storybook": "^0.6.11",
136
136
  "events": "^3.3.0",
137
- "glob": "^10.0.0",
137
+ "glob": "^10.2.1",
138
138
  "html-webpack-plugin": "^5.5.1",
139
139
  "husky": "^8.0.3",
140
140
  "identity-obj-proxy": "^3.0.0",
@@ -153,23 +153,23 @@
153
153
  "mocha": "^10.2.0",
154
154
  "pinst": "^3.0.0",
155
155
  "prettier": "^2.8.7",
156
- "puppeteer": "^19.8.3",
156
+ "puppeteer": "^19.9.1",
157
157
  "raw-loader": "^4.0.2",
158
158
  "react": "^18.2.0",
159
159
  "react-dom": "^18.2.0",
160
160
  "react-test-renderer": "^18.2.0",
161
161
  "regenerator-runtime": "^0.13.11",
162
162
  "rimraf": "^5.0.0",
163
- "rollup": "^3.20.4",
163
+ "rollup": "^3.20.6",
164
164
  "rollup-plugin-clear": "^2.0.7",
165
165
  "rollup-plugin-styles": "^4.0.0",
166
166
  "sinon": "^15.0.3",
167
167
  "sinon-chai": "^3.7.0",
168
168
  "storage-mock": "^2.1.0",
169
- "storybook": "^7.0.5",
169
+ "storybook": "^7.0.6",
170
170
  "storybook-addon-themes": "^6.1.0",
171
171
  "storybook-zeplin": "^2.0.0",
172
- "stylelint": "^15.4.0",
172
+ "stylelint": "^15.5.0",
173
173
  "svg-inline-loader": "^0.8.2",
174
174
  "teamcity-service-messages": "^0.1.14",
175
175
  "terser-webpack-plugin": "^5.3.7",
@@ -244,7 +244,7 @@
244
244
  "postcss-font-family-system-ui": "^5.0.0",
245
245
  "postcss-loader": "^7.2.4",
246
246
  "postcss-modules-values-replace": "^4.1.0",
247
- "postcss-preset-env": "^8.3.1",
247
+ "postcss-preset-env": "^8.3.2",
248
248
  "prop-types": "^15.8.1",
249
249
  "react-markdown": "^8.0.7",
250
250
  "react-movable": "^3.0.4",