@jetbrains/ring-ui 5.0.134 → 5.0.136

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.
@@ -33,6 +33,12 @@
33
33
 
34
34
  font-size: inherit;
35
35
 
36
+ @nest .disabled & {
37
+ user-select: text;
38
+
39
+ border-radius: 0;
40
+ }
41
+
36
42
  &:focus {
37
43
  outline: 1px solid var(--ring-border-hover-color);
38
44
  }
@@ -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 => {