@instructure/ui-position 8.25.1-snapshot-10 → 8.25.1-snapshot-13

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.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
6
+ ## [8.25.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-13) (2022-06-22)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-position
9
9
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _dec3, _class;
1
+ var _dec, _dec2, _dec3, _class, _class2;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -44,28 +44,50 @@ category: components/utilities
44
44
  ---
45
45
  @tsProps
46
46
  **/
47
- let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = class Position extends Component {
48
- static displayName = "Position";
49
- static componentId = 'Position';
50
- static allowedProps = allowedProps;
51
- static propTypes = propTypes;
52
- static defaultProps = {
53
- placement: 'bottom center',
54
- mountNode: null,
55
- insertAt: 'bottom',
56
- constrain: 'window',
57
- offsetX: 0,
58
- offsetY: 0,
59
- shouldTrackPosition: true,
60
- shouldPositionOverTarget: false,
61
- children: null
62
- };
63
- static locatorAttribute = 'data-position';
64
- static targetLocatorAttribute = 'data-position-target';
65
- static contentLocatorAttribute = 'data-position-content';
66
-
47
+ let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Position extends Component {
67
48
  constructor(props) {
68
49
  super(props);
50
+ this.ref = null;
51
+ this._id = void 0;
52
+ this._timeouts = [];
53
+ this._listener = null;
54
+ this._content = void 0;
55
+ this._target = void 0;
56
+
57
+ this.handleRef = el => {
58
+ const elementRef = this.props.elementRef;
59
+ this.ref = el;
60
+
61
+ if (typeof elementRef === 'function') {
62
+ elementRef(el);
63
+ }
64
+ };
65
+
66
+ this.handlePortalOpen = () => {
67
+ this.position();
68
+
69
+ if (this.props.shouldTrackPosition) {
70
+ this.startTracking();
71
+ }
72
+
73
+ this._timeouts.push(setTimeout(() => {
74
+ if (this.state.positioned && typeof this.props.onPositioned === 'function') {
75
+ this.props.onPositioned({
76
+ top: this.state.style.top,
77
+ left: this.state.style.left,
78
+ placement: this.state.placement
79
+ });
80
+ }
81
+ }, 0));
82
+ };
83
+
84
+ this.position = () => {
85
+ this.setState({
86
+ positioned: true,
87
+ ...this.calculatePosition(this.props)
88
+ });
89
+ };
90
+
69
91
  this.state = {
70
92
  positioned: false,
71
93
  ...this.calculatePosition(props)
@@ -77,21 +99,6 @@ let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
77
99
  this._id = this.props.id || props.deterministicId();
78
100
  }
79
101
 
80
- ref = null;
81
- _id;
82
- _timeouts = [];
83
- _listener = null;
84
- _content;
85
- _target;
86
- handleRef = el => {
87
- const elementRef = this.props.elementRef;
88
- this.ref = el;
89
-
90
- if (typeof elementRef === 'function') {
91
- elementRef(el);
92
- }
93
- };
94
-
95
102
  shouldComponentUpdate(nextProps, nextState, nextContext) {
96
103
  return !deepEqual(this.state, nextState) || !shallowEqual(this.props, nextProps) || !shallowEqual(this.context, nextContext);
97
104
  }
@@ -160,24 +167,6 @@ let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
160
167
  }
161
168
  }
162
169
 
163
- handlePortalOpen = () => {
164
- this.position();
165
-
166
- if (this.props.shouldTrackPosition) {
167
- this.startTracking();
168
- }
169
-
170
- this._timeouts.push(setTimeout(() => {
171
- if (this.state.positioned && typeof this.props.onPositioned === 'function') {
172
- this.props.onPositioned({
173
- top: this.state.style.top,
174
- left: this.state.style.left,
175
- placement: this.state.placement
176
- });
177
- }
178
- }, 0));
179
- };
180
-
181
170
  calculatePosition(props) {
182
171
  return calculateElementPosition(this._content, this._target, {
183
172
  placement: props.placement,
@@ -189,13 +178,6 @@ let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
189
178
  });
190
179
  }
191
180
 
192
- position = () => {
193
- this.setState({
194
- positioned: true,
195
- ...this.calculatePosition(this.props)
196
- });
197
- };
198
-
199
181
  startTracking() {
200
182
  this._listener = this._listener || addPositionChangeListener(this._target, this.position);
201
183
  }
@@ -267,6 +249,16 @@ let Position = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
267
249
  }), this.renderTarget(), this.renderContent());
268
250
  }
269
251
 
270
- }) || _class) || _class) || _class);
252
+ }, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
253
+ placement: 'bottom center',
254
+ mountNode: null,
255
+ insertAt: 'bottom',
256
+ constrain: 'window',
257
+ offsetX: 0,
258
+ offsetY: 0,
259
+ shouldTrackPosition: true,
260
+ shouldPositionOverTarget: false,
261
+ children: null
262
+ }, _class2.locatorAttribute = 'data-position', _class2.targetLocatorAttribute = 'data-position-target', _class2.contentLocatorAttribute = 'data-position-content', _class2)) || _class) || _class) || _class);
271
263
  export default Position;
272
264
  export { Position };
@@ -58,6 +58,10 @@ class PositionedElement {
58
58
  top: 0,
59
59
  left: 0
60
60
  };
61
+ this.node = void 0;
62
+ this.placement = void 0;
63
+ this.rect = void 0;
64
+ this._offset = void 0;
61
65
  this.node = findDOMNode(element);
62
66
 
63
67
  if (typeof placement === 'string') {
@@ -72,11 +76,6 @@ class PositionedElement {
72
76
  this._offset = offsetToPx(offset, this.size);
73
77
  }
74
78
 
75
- node;
76
- placement;
77
- rect;
78
- _offset;
79
-
80
79
  get width() {
81
80
  return this.rect.width;
82
81
  }
@@ -227,6 +226,10 @@ class PositionedElement {
227
226
 
228
227
  class PositionData {
229
228
  constructor(element, target, options) {
229
+ this.options = void 0;
230
+ this.container = void 0;
231
+ this.element = void 0;
232
+ this.target = void 0;
230
233
  this.options = options || {};
231
234
  const _this$options = this.options,
232
235
  container = _this$options.container,
@@ -254,11 +257,6 @@ class PositionData {
254
257
  }
255
258
  }
256
259
 
257
- options;
258
- container;
259
- element;
260
- target;
261
-
262
260
  get offset() {
263
261
  const _this$target$calculat = this.target.calculateOffset(this.element.placement),
264
262
  top = _this$target$calculat.top,
@@ -41,7 +41,7 @@ var _props = require("./props");
41
41
 
42
42
  var _calculateElementPosition = require("../calculateElementPosition");
43
43
 
44
- var _dec, _dec2, _dec3, _class;
44
+ var _dec, _dec2, _dec3, _class, _class2;
45
45
 
46
46
  /**
47
47
  ---
@@ -49,28 +49,50 @@ category: components/utilities
49
49
  ---
50
50
  @tsProps
51
51
  **/
52
- let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = class Position extends _react.Component {
53
- static displayName = "Position";
54
- static componentId = 'Position';
55
- static allowedProps = _props.allowedProps;
56
- static propTypes = _props.propTypes;
57
- static defaultProps = {
58
- placement: 'bottom center',
59
- mountNode: null,
60
- insertAt: 'bottom',
61
- constrain: 'window',
62
- offsetX: 0,
63
- offsetY: 0,
64
- shouldTrackPosition: true,
65
- shouldPositionOverTarget: false,
66
- children: null
67
- };
68
- static locatorAttribute = 'data-position';
69
- static targetLocatorAttribute = 'data-position-target';
70
- static contentLocatorAttribute = 'data-position-content';
71
-
52
+ let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Position extends _react.Component {
72
53
  constructor(props) {
73
54
  super(props);
55
+ this.ref = null;
56
+ this._id = void 0;
57
+ this._timeouts = [];
58
+ this._listener = null;
59
+ this._content = void 0;
60
+ this._target = void 0;
61
+
62
+ this.handleRef = el => {
63
+ const elementRef = this.props.elementRef;
64
+ this.ref = el;
65
+
66
+ if (typeof elementRef === 'function') {
67
+ elementRef(el);
68
+ }
69
+ };
70
+
71
+ this.handlePortalOpen = () => {
72
+ this.position();
73
+
74
+ if (this.props.shouldTrackPosition) {
75
+ this.startTracking();
76
+ }
77
+
78
+ this._timeouts.push(setTimeout(() => {
79
+ if (this.state.positioned && typeof this.props.onPositioned === 'function') {
80
+ this.props.onPositioned({
81
+ top: this.state.style.top,
82
+ left: this.state.style.left,
83
+ placement: this.state.placement
84
+ });
85
+ }
86
+ }, 0));
87
+ };
88
+
89
+ this.position = () => {
90
+ this.setState({
91
+ positioned: true,
92
+ ...this.calculatePosition(this.props)
93
+ });
94
+ };
95
+
74
96
  this.state = {
75
97
  positioned: false,
76
98
  ...this.calculatePosition(props)
@@ -82,21 +104,6 @@ let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
82
104
  this._id = this.props.id || props.deterministicId();
83
105
  }
84
106
 
85
- ref = null;
86
- _id;
87
- _timeouts = [];
88
- _listener = null;
89
- _content;
90
- _target;
91
- handleRef = el => {
92
- const elementRef = this.props.elementRef;
93
- this.ref = el;
94
-
95
- if (typeof elementRef === 'function') {
96
- elementRef(el);
97
- }
98
- };
99
-
100
107
  shouldComponentUpdate(nextProps, nextState, nextContext) {
101
108
  return !(0, _deepEqual.deepEqual)(this.state, nextState) || !(0, _shallowEqual.shallowEqual)(this.props, nextProps) || !(0, _shallowEqual.shallowEqual)(this.context, nextContext);
102
109
  }
@@ -165,24 +172,6 @@ let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
165
172
  }
166
173
  }
167
174
 
168
- handlePortalOpen = () => {
169
- this.position();
170
-
171
- if (this.props.shouldTrackPosition) {
172
- this.startTracking();
173
- }
174
-
175
- this._timeouts.push(setTimeout(() => {
176
- if (this.state.positioned && typeof this.props.onPositioned === 'function') {
177
- this.props.onPositioned({
178
- top: this.state.style.top,
179
- left: this.state.style.left,
180
- placement: this.state.placement
181
- });
182
- }
183
- }, 0));
184
- };
185
-
186
175
  calculatePosition(props) {
187
176
  return (0, _calculateElementPosition.calculateElementPosition)(this._content, this._target, {
188
177
  placement: props.placement,
@@ -194,13 +183,6 @@ let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
194
183
  });
195
184
  }
196
185
 
197
- position = () => {
198
- this.setState({
199
- positioned: true,
200
- ...this.calculatePosition(this.props)
201
- });
202
- };
203
-
204
186
  startTracking() {
205
187
  this._listener = this._listener || (0, _addPositionChangeListener.addPositionChangeListener)(this._target, this.position);
206
188
  }
@@ -272,7 +254,17 @@ let Position = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
272
254
  }), this.renderTarget(), this.renderContent());
273
255
  }
274
256
 
275
- }) || _class) || _class) || _class);
257
+ }, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
258
+ placement: 'bottom center',
259
+ mountNode: null,
260
+ insertAt: 'bottom',
261
+ constrain: 'window',
262
+ offsetX: 0,
263
+ offsetY: 0,
264
+ shouldTrackPosition: true,
265
+ shouldPositionOverTarget: false,
266
+ children: null
267
+ }, _class2.locatorAttribute = 'data-position', _class2.targetLocatorAttribute = 'data-position-target', _class2.contentLocatorAttribute = 'data-position-content', _class2)) || _class) || _class) || _class);
276
268
  exports.Position = Position;
277
269
  var _default = Position;
278
270
  exports.default = _default;
@@ -82,6 +82,10 @@ class PositionedElement {
82
82
  top: 0,
83
83
  left: 0
84
84
  };
85
+ this.node = void 0;
86
+ this.placement = void 0;
87
+ this.rect = void 0;
88
+ this._offset = void 0;
85
89
  this.node = (0, _findDOMNode.findDOMNode)(element);
86
90
 
87
91
  if (typeof placement === 'string') {
@@ -96,11 +100,6 @@ class PositionedElement {
96
100
  this._offset = offsetToPx(offset, this.size);
97
101
  }
98
102
 
99
- node;
100
- placement;
101
- rect;
102
- _offset;
103
-
104
103
  get width() {
105
104
  return this.rect.width;
106
105
  }
@@ -251,6 +250,10 @@ class PositionedElement {
251
250
 
252
251
  class PositionData {
253
252
  constructor(element, target, options) {
253
+ this.options = void 0;
254
+ this.container = void 0;
255
+ this.element = void 0;
256
+ this.target = void 0;
254
257
  this.options = options || {};
255
258
  const _this$options = this.options,
256
259
  container = _this$options.container,
@@ -278,11 +281,6 @@ class PositionData {
278
281
  }
279
282
  }
280
283
 
281
- options;
282
- container;
283
- element;
284
- target;
285
-
286
284
  get offset() {
287
285
  const _this$target$calculat = this.target.calculateOffset(this.element.placement),
288
286
  top = _this$target$calculat.top,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-position",
3
- "version": "8.25.1-snapshot-10",
3
+ "version": "8.25.1-snapshot-13",
4
4
  "description": "A component for positioning content with respect to a designated target.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,24 +24,24 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.13.10",
27
- "@instructure/debounce": "8.25.1-snapshot-10",
28
- "@instructure/emotion": "8.25.1-snapshot-10",
29
- "@instructure/shared-types": "8.25.1-snapshot-10",
30
- "@instructure/ui-dom-utils": "8.25.1-snapshot-10",
31
- "@instructure/ui-portal": "8.25.1-snapshot-10",
32
- "@instructure/ui-prop-types": "8.25.1-snapshot-10",
33
- "@instructure/ui-react-utils": "8.25.1-snapshot-10",
34
- "@instructure/ui-testable": "8.25.1-snapshot-10",
35
- "@instructure/ui-utils": "8.25.1-snapshot-10",
36
- "@instructure/uid": "8.25.1-snapshot-10",
27
+ "@instructure/debounce": "8.25.1-snapshot-13",
28
+ "@instructure/emotion": "8.25.1-snapshot-13",
29
+ "@instructure/shared-types": "8.25.1-snapshot-13",
30
+ "@instructure/ui-dom-utils": "8.25.1-snapshot-13",
31
+ "@instructure/ui-portal": "8.25.1-snapshot-13",
32
+ "@instructure/ui-prop-types": "8.25.1-snapshot-13",
33
+ "@instructure/ui-react-utils": "8.25.1-snapshot-13",
34
+ "@instructure/ui-testable": "8.25.1-snapshot-13",
35
+ "@instructure/ui-utils": "8.25.1-snapshot-13",
36
+ "@instructure/uid": "8.25.1-snapshot-13",
37
37
  "prop-types": "^15"
38
38
  },
39
39
  "devDependencies": {
40
- "@instructure/ui-babel-preset": "8.25.1-snapshot-10",
41
- "@instructure/ui-color-utils": "8.25.1-snapshot-10",
42
- "@instructure/ui-test-locator": "8.25.1-snapshot-10",
43
- "@instructure/ui-test-utils": "8.25.1-snapshot-10",
44
- "@instructure/ui-themes": "8.25.1-snapshot-10"
40
+ "@instructure/ui-babel-preset": "8.25.1-snapshot-13",
41
+ "@instructure/ui-color-utils": "8.25.1-snapshot-13",
42
+ "@instructure/ui-test-locator": "8.25.1-snapshot-13",
43
+ "@instructure/ui-test-utils": "8.25.1-snapshot-13",
44
+ "@instructure/ui-themes": "8.25.1-snapshot-13"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8 <=17"