@instructure/ui-position 8.8.1-snapshot.7 → 8.9.1-snapshot.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.
- package/CHANGELOG.md +6 -0
- package/es/Position/index.js +15 -31
- package/es/Position/props.js +44 -0
- package/lib/Position/index.js +15 -33
- package/lib/Position/props.js +57 -0
- package/package.json +17 -17
- package/src/Position/index.tsx +9 -34
- package/src/Position/{types.ts → props.ts} +63 -17
- package/src/index.ts +1 -1
- package/types/Position/index.d.ts +77 -20
- package/types/Position/index.d.ts.map +1 -1
- package/types/Position/{types.d.ts → props.d.ts} +23 -16
- package/types/Position/props.d.ts.map +1 -0
- package/types/index.d.ts +1 -1
- package/es/Position/types.js +0 -1
- package/lib/Position/types.js +0 -1
- package/types/Position/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
|
11
|
+
|
|
6
12
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/es/Position/index.js
CHANGED
|
@@ -26,8 +26,6 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Component } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
|
-
import { element } from '@instructure/ui-prop-types';
|
|
31
29
|
import { safeCloneElement, callRenderProp, ensureSingleChild } from '@instructure/ui-react-utils';
|
|
32
30
|
import { addPositionChangeListener, findDOMNode } from '@instructure/ui-dom-utils';
|
|
33
31
|
import { uid } from '@instructure/uid';
|
|
@@ -38,15 +36,15 @@ import { Portal } from '@instructure/ui-portal';
|
|
|
38
36
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
39
37
|
import generateStyle from './styles';
|
|
40
38
|
import generateComponentTheme from './theme';
|
|
39
|
+
import { allowedProps, propTypes } from './props';
|
|
41
40
|
import { calculateElementPosition } from '../calculateElementPosition';
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
/**
|
|
44
43
|
---
|
|
45
44
|
category: components/utilities
|
|
46
45
|
---
|
|
47
46
|
@tsProps
|
|
48
47
|
**/
|
|
49
|
-
|
|
50
48
|
let Position = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Position extends Component {
|
|
51
49
|
constructor(props) {
|
|
52
50
|
super(props);
|
|
@@ -97,11 +95,15 @@ let Position = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
componentDidMount() {
|
|
98
|
+
var _this$props$makeStyle, _this$props;
|
|
99
|
+
|
|
100
100
|
this.toggleLocatorAttributes(true);
|
|
101
|
-
this.props.makeStyles();
|
|
101
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
componentDidUpdate(prevProps, prevState) {
|
|
105
|
+
var _this$props$makeStyle2, _this$props3;
|
|
106
|
+
|
|
105
107
|
this.position();
|
|
106
108
|
this.toggleLocatorAttributes(true);
|
|
107
109
|
|
|
@@ -114,14 +116,16 @@ let Position = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
114
116
|
placement = _this$state.placement;
|
|
115
117
|
|
|
116
118
|
if (style && prevState.style && (placement !== prevState.placement || style.top !== prevState.style.top || style.left !== prevState.style.left)) {
|
|
117
|
-
|
|
119
|
+
var _this$props$onPositio, _this$props2;
|
|
120
|
+
|
|
121
|
+
(_this$props$onPositio = (_this$props2 = this.props).onPositionChanged) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props2, {
|
|
118
122
|
top: style.top,
|
|
119
123
|
left: style.left,
|
|
120
124
|
placement
|
|
121
125
|
});
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
this.props.makeStyles();
|
|
128
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
componentWillUnmount() {
|
|
@@ -183,13 +187,15 @@ let Position = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
183
187
|
let content = ensureSingleChild(this.props.children);
|
|
184
188
|
|
|
185
189
|
if (content) {
|
|
190
|
+
var _this$props$styles;
|
|
191
|
+
|
|
186
192
|
content = safeCloneElement(content, {
|
|
187
193
|
ref: el => {
|
|
188
194
|
this._content = el;
|
|
189
195
|
},
|
|
190
196
|
style: {
|
|
191
197
|
boxSizing: 'border-box',
|
|
192
|
-
zIndex: this.props.styles.zIndex,
|
|
198
|
+
zIndex: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.zIndex,
|
|
193
199
|
...content.props.style,
|
|
194
200
|
...this.state.style
|
|
195
201
|
},
|
|
@@ -233,35 +239,13 @@ let Position = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
233
239
|
return jsx("span", props, this.renderTarget(), this.renderContent());
|
|
234
240
|
}
|
|
235
241
|
|
|
236
|
-
}, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.propTypes = {
|
|
237
|
-
// eslint-disable-next-line react/require-default-props
|
|
238
|
-
makeStyles: PropTypes.func,
|
|
239
|
-
// eslint-disable-next-line react/require-default-props
|
|
240
|
-
styles: PropTypes.object,
|
|
241
|
-
renderTarget: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
242
|
-
target: PropTypes.oneOfType([element, PropTypes.func]),
|
|
243
|
-
placement: PositionPropTypes.placement,
|
|
244
|
-
mountNode: PositionPropTypes.mountNode,
|
|
245
|
-
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
246
|
-
constrain: PositionPropTypes.constrain,
|
|
247
|
-
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
248
|
-
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
249
|
-
id: PropTypes.string,
|
|
250
|
-
shouldTrackPosition: PropTypes.bool,
|
|
251
|
-
shouldPositionOverTarget: PropTypes.bool,
|
|
252
|
-
onPositionChanged: PropTypes.func,
|
|
253
|
-
onPositioned: PropTypes.func,
|
|
254
|
-
children: PropTypes.node
|
|
255
|
-
}, _class2.defaultProps = {
|
|
256
|
-
renderTarget: void 0,
|
|
257
|
-
target: void 0,
|
|
242
|
+
}, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
258
243
|
placement: 'bottom center',
|
|
259
244
|
mountNode: null,
|
|
260
245
|
insertAt: 'bottom',
|
|
261
246
|
constrain: 'window',
|
|
262
247
|
offsetX: 0,
|
|
263
248
|
offsetY: 0,
|
|
264
|
-
id: void 0,
|
|
265
249
|
shouldTrackPosition: true,
|
|
266
250
|
shouldPositionOverTarget: false,
|
|
267
251
|
onPositioned: () => {},
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { element } from '@instructure/ui-prop-types';
|
|
26
|
+
import { PositionPropTypes } from '../PositionPropTypes';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
renderTarget: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
29
|
+
target: PropTypes.oneOfType([element, PropTypes.func]),
|
|
30
|
+
placement: PositionPropTypes.placement,
|
|
31
|
+
mountNode: PositionPropTypes.mountNode,
|
|
32
|
+
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
33
|
+
constrain: PositionPropTypes.constrain,
|
|
34
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
36
|
+
id: PropTypes.string,
|
|
37
|
+
shouldTrackPosition: PropTypes.bool,
|
|
38
|
+
shouldPositionOverTarget: PropTypes.bool,
|
|
39
|
+
onPositionChanged: PropTypes.func,
|
|
40
|
+
onPositioned: PropTypes.func,
|
|
41
|
+
children: PropTypes.node
|
|
42
|
+
};
|
|
43
|
+
const allowedProps = ['renderTarget', 'target', 'placement', 'mountNode', 'insertAt', 'constrain', 'offsetX', 'offsetY', 'id', 'shouldTrackPosition', 'shouldPositionOverTarget', 'onPositionChanged', 'onPositioned', 'children'];
|
|
44
|
+
export { propTypes, allowedProps };
|
package/lib/Position/index.js
CHANGED
|
@@ -9,10 +9,6 @@ exports.Position = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _element = require("@instructure/ui-prop-types/lib/element.js");
|
|
15
|
-
|
|
16
12
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
17
13
|
|
|
18
14
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
@@ -41,9 +37,9 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
41
37
|
|
|
42
38
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
43
39
|
|
|
44
|
-
var
|
|
40
|
+
var _props = require("./props");
|
|
45
41
|
|
|
46
|
-
var
|
|
42
|
+
var _calculateElementPosition = require("../calculateElementPosition");
|
|
47
43
|
|
|
48
44
|
var _dec, _dec2, _class, _class2, _temp;
|
|
49
45
|
|
|
@@ -103,11 +99,15 @@ let Position = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
componentDidMount() {
|
|
102
|
+
var _this$props$makeStyle, _this$props;
|
|
103
|
+
|
|
106
104
|
this.toggleLocatorAttributes(true);
|
|
107
|
-
this.props.makeStyles();
|
|
105
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
componentDidUpdate(prevProps, prevState) {
|
|
109
|
+
var _this$props$makeStyle2, _this$props3;
|
|
110
|
+
|
|
111
111
|
this.position();
|
|
112
112
|
this.toggleLocatorAttributes(true);
|
|
113
113
|
|
|
@@ -120,14 +120,16 @@ let Position = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
120
120
|
placement = _this$state.placement;
|
|
121
121
|
|
|
122
122
|
if (style && prevState.style && (placement !== prevState.placement || style.top !== prevState.style.top || style.left !== prevState.style.left)) {
|
|
123
|
-
|
|
123
|
+
var _this$props$onPositio, _this$props2;
|
|
124
|
+
|
|
125
|
+
(_this$props$onPositio = (_this$props2 = this.props).onPositionChanged) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props2, {
|
|
124
126
|
top: style.top,
|
|
125
127
|
left: style.left,
|
|
126
128
|
placement
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
|
|
130
|
-
this.props.makeStyles();
|
|
132
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
componentWillUnmount() {
|
|
@@ -189,13 +191,15 @@ let Position = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
189
191
|
let content = (0, _ensureSingleChild.ensureSingleChild)(this.props.children);
|
|
190
192
|
|
|
191
193
|
if (content) {
|
|
194
|
+
var _this$props$styles;
|
|
195
|
+
|
|
192
196
|
content = (0, _safeCloneElement.safeCloneElement)(content, {
|
|
193
197
|
ref: el => {
|
|
194
198
|
this._content = el;
|
|
195
199
|
},
|
|
196
200
|
style: {
|
|
197
201
|
boxSizing: 'border-box',
|
|
198
|
-
zIndex: this.props.styles.zIndex,
|
|
202
|
+
zIndex: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.zIndex,
|
|
199
203
|
...content.props.style,
|
|
200
204
|
...this.state.style
|
|
201
205
|
},
|
|
@@ -239,35 +243,13 @@ let Position = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
239
243
|
return (0, _emotion.jsx)("span", props, this.renderTarget(), this.renderContent());
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
}, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.propTypes = {
|
|
243
|
-
// eslint-disable-next-line react/require-default-props
|
|
244
|
-
makeStyles: _propTypes.default.func,
|
|
245
|
-
// eslint-disable-next-line react/require-default-props
|
|
246
|
-
styles: _propTypes.default.object,
|
|
247
|
-
renderTarget: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
248
|
-
target: _propTypes.default.oneOfType([_element.element, _propTypes.default.func]),
|
|
249
|
-
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
250
|
-
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
251
|
-
insertAt: _propTypes.default.oneOf(['bottom', 'top']),
|
|
252
|
-
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
253
|
-
offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
254
|
-
offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
255
|
-
id: _propTypes.default.string,
|
|
256
|
-
shouldTrackPosition: _propTypes.default.bool,
|
|
257
|
-
shouldPositionOverTarget: _propTypes.default.bool,
|
|
258
|
-
onPositionChanged: _propTypes.default.func,
|
|
259
|
-
onPositioned: _propTypes.default.func,
|
|
260
|
-
children: _propTypes.default.node
|
|
261
|
-
}, _class2.defaultProps = {
|
|
262
|
-
renderTarget: void 0,
|
|
263
|
-
target: void 0,
|
|
246
|
+
}, _class2.displayName = "Position", _class2.componentId = 'Position', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
264
247
|
placement: 'bottom center',
|
|
265
248
|
mountNode: null,
|
|
266
249
|
insertAt: 'bottom',
|
|
267
250
|
constrain: 'window',
|
|
268
251
|
offsetX: 0,
|
|
269
252
|
offsetY: 0,
|
|
270
|
-
id: void 0,
|
|
271
253
|
shouldTrackPosition: true,
|
|
272
254
|
shouldPositionOverTarget: false,
|
|
273
255
|
onPositioned: () => {},
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _element = require("@instructure/ui-prop-types/lib/element.js");
|
|
13
|
+
|
|
14
|
+
var _PositionPropTypes = require("../PositionPropTypes");
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* The MIT License (MIT)
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
23
|
+
* in the Software without restriction, including without limitation the rights
|
|
24
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
26
|
+
* furnished to do so, subject to the following conditions:
|
|
27
|
+
*
|
|
28
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
29
|
+
* copies or substantial portions of the Software.
|
|
30
|
+
*
|
|
31
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
+
* SOFTWARE.
|
|
38
|
+
*/
|
|
39
|
+
const propTypes = {
|
|
40
|
+
renderTarget: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
41
|
+
target: _propTypes.default.oneOfType([_element.element, _propTypes.default.func]),
|
|
42
|
+
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
43
|
+
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
44
|
+
insertAt: _propTypes.default.oneOf(['bottom', 'top']),
|
|
45
|
+
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
46
|
+
offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
47
|
+
offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
48
|
+
id: _propTypes.default.string,
|
|
49
|
+
shouldTrackPosition: _propTypes.default.bool,
|
|
50
|
+
shouldPositionOverTarget: _propTypes.default.bool,
|
|
51
|
+
onPositionChanged: _propTypes.default.func,
|
|
52
|
+
onPositioned: _propTypes.default.func,
|
|
53
|
+
children: _propTypes.default.node
|
|
54
|
+
};
|
|
55
|
+
exports.propTypes = propTypes;
|
|
56
|
+
const allowedProps = ['renderTarget', 'target', 'placement', 'mountNode', 'insertAt', 'constrain', 'offsetX', 'offsetY', 'id', 'shouldTrackPosition', 'shouldPositionOverTarget', 'onPositionChanged', 'onPositioned', 'children'];
|
|
57
|
+
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-position",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.1-snapshot.2+7f5faa3df",
|
|
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
|
"type": "commonjs",
|
|
@@ -25,24 +25,24 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/debounce": "8.
|
|
29
|
-
"@instructure/emotion": "8.
|
|
30
|
-
"@instructure/
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-
|
|
36
|
-
"@instructure/
|
|
28
|
+
"@instructure/debounce": "8.9.1-snapshot.2+7f5faa3df",
|
|
29
|
+
"@instructure/emotion": "8.9.1-snapshot.2+7f5faa3df",
|
|
30
|
+
"@instructure/shared-types": "8.9.1-snapshot.2+7f5faa3df",
|
|
31
|
+
"@instructure/ui-dom-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
32
|
+
"@instructure/ui-portal": "8.9.1-snapshot.2+7f5faa3df",
|
|
33
|
+
"@instructure/ui-prop-types": "8.9.1-snapshot.2+7f5faa3df",
|
|
34
|
+
"@instructure/ui-react-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
35
|
+
"@instructure/ui-testable": "8.9.1-snapshot.2+7f5faa3df",
|
|
36
|
+
"@instructure/ui-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
37
|
+
"@instructure/uid": "8.9.1-snapshot.2+7f5faa3df",
|
|
37
38
|
"prop-types": "^15"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@instructure/
|
|
41
|
-
"@instructure/ui-
|
|
42
|
-
"@instructure/ui-
|
|
43
|
-
"@instructure/ui-test-
|
|
44
|
-
"@instructure/ui-
|
|
45
|
-
"@instructure/ui-themes": "8.8.1-snapshot.7+90b251d58"
|
|
41
|
+
"@instructure/ui-babel-preset": "8.9.1-snapshot.2+7f5faa3df",
|
|
42
|
+
"@instructure/ui-color-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
43
|
+
"@instructure/ui-test-locator": "8.9.1-snapshot.2+7f5faa3df",
|
|
44
|
+
"@instructure/ui-test-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
45
|
+
"@instructure/ui-themes": "8.9.1-snapshot.2+7f5faa3df"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=16.8 <=17"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7f5faa3df83667636304e0901ef1008d98dffc9a"
|
|
55
55
|
}
|
package/src/Position/index.tsx
CHANGED
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
|
-
import { element } from '@instructure/ui-prop-types'
|
|
30
28
|
import {
|
|
31
29
|
safeCloneElement,
|
|
32
30
|
callRenderProp,
|
|
@@ -49,10 +47,11 @@ import { withStyle, jsx } from '@instructure/emotion'
|
|
|
49
47
|
|
|
50
48
|
import generateStyle from './styles'
|
|
51
49
|
import generateComponentTheme from './theme'
|
|
52
|
-
import { PositionProps, PositionState } from './
|
|
50
|
+
import type { PositionProps, PositionState } from './props'
|
|
51
|
+
import { allowedProps, propTypes } from './props'
|
|
53
52
|
|
|
54
53
|
import { calculateElementPosition } from '../calculateElementPosition'
|
|
55
|
-
import { PositionElement
|
|
54
|
+
import { PositionElement } from '../PositionPropTypes'
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
---
|
|
@@ -65,37 +64,16 @@ category: components/utilities
|
|
|
65
64
|
class Position extends Component<PositionProps, PositionState> {
|
|
66
65
|
static readonly componentId = 'Position'
|
|
67
66
|
|
|
68
|
-
static
|
|
69
|
-
|
|
70
|
-
makeStyles: PropTypes.func,
|
|
71
|
-
// eslint-disable-next-line react/require-default-props
|
|
72
|
-
styles: PropTypes.object,
|
|
73
|
-
renderTarget: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
74
|
-
target: PropTypes.oneOfType([element, PropTypes.func]),
|
|
75
|
-
placement: PositionPropTypes.placement,
|
|
76
|
-
mountNode: PositionPropTypes.mountNode,
|
|
77
|
-
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
78
|
-
constrain: PositionPropTypes.constrain,
|
|
79
|
-
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
80
|
-
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
81
|
-
id: PropTypes.string,
|
|
82
|
-
shouldTrackPosition: PropTypes.bool,
|
|
83
|
-
shouldPositionOverTarget: PropTypes.bool,
|
|
84
|
-
onPositionChanged: PropTypes.func,
|
|
85
|
-
onPositioned: PropTypes.func,
|
|
86
|
-
children: PropTypes.node
|
|
87
|
-
}
|
|
67
|
+
static allowedProps = allowedProps
|
|
68
|
+
static propTypes = propTypes
|
|
88
69
|
|
|
89
70
|
static defaultProps: PositionProps = {
|
|
90
|
-
renderTarget: undefined,
|
|
91
|
-
target: undefined,
|
|
92
71
|
placement: 'bottom center',
|
|
93
72
|
mountNode: null,
|
|
94
73
|
insertAt: 'bottom',
|
|
95
74
|
constrain: 'window',
|
|
96
75
|
offsetX: 0,
|
|
97
76
|
offsetY: 0,
|
|
98
|
-
id: undefined,
|
|
99
77
|
shouldTrackPosition: true,
|
|
100
78
|
shouldPositionOverTarget: false,
|
|
101
79
|
onPositioned: () => {},
|
|
@@ -142,8 +120,7 @@ class Position extends Component<PositionProps, PositionState> {
|
|
|
142
120
|
|
|
143
121
|
componentDidMount() {
|
|
144
122
|
this.toggleLocatorAttributes(true)
|
|
145
|
-
|
|
146
|
-
this.props.makeStyles()
|
|
123
|
+
this.props.makeStyles?.()
|
|
147
124
|
}
|
|
148
125
|
|
|
149
126
|
componentDidUpdate(prevProps: PositionProps, prevState: PositionState) {
|
|
@@ -165,15 +142,14 @@ class Position extends Component<PositionProps, PositionState> {
|
|
|
165
142
|
style.top !== prevState.style.top ||
|
|
166
143
|
style.left !== prevState.style.left)
|
|
167
144
|
) {
|
|
168
|
-
this.props.onPositionChanged({
|
|
145
|
+
this.props.onPositionChanged?.({
|
|
169
146
|
top: style.top,
|
|
170
147
|
left: style.left,
|
|
171
148
|
placement
|
|
172
149
|
})
|
|
173
150
|
}
|
|
174
151
|
|
|
175
|
-
|
|
176
|
-
this.props.makeStyles()
|
|
152
|
+
this.props.makeStyles?.()
|
|
177
153
|
}
|
|
178
154
|
|
|
179
155
|
componentWillUnmount() {
|
|
@@ -280,8 +256,7 @@ class Position extends Component<PositionProps, PositionState> {
|
|
|
280
256
|
},
|
|
281
257
|
style: {
|
|
282
258
|
boxSizing: 'border-box',
|
|
283
|
-
|
|
284
|
-
zIndex: this.props.styles.zIndex,
|
|
259
|
+
zIndex: this.props.styles?.zIndex,
|
|
285
260
|
...content.props.style,
|
|
286
261
|
...this.state.style
|
|
287
262
|
},
|
|
@@ -23,17 +23,22 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
26
27
|
|
|
27
|
-
import {
|
|
28
|
+
import { element } from '@instructure/ui-prop-types'
|
|
29
|
+
|
|
30
|
+
import { PositionPropTypes } from '../PositionPropTypes'
|
|
31
|
+
|
|
32
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
33
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
34
|
+
import type {
|
|
28
35
|
PositionConstraint,
|
|
29
36
|
PositionMountNode,
|
|
30
37
|
PlacementPropValues,
|
|
31
38
|
ElementPosition
|
|
32
39
|
} from '../PositionPropTypes'
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type PositionProps = {
|
|
41
|
+
type PositionOwnProps = {
|
|
37
42
|
/**
|
|
38
43
|
* The node to use as the position target
|
|
39
44
|
*/
|
|
@@ -47,35 +52,35 @@ type PositionProps = {
|
|
|
47
52
|
/**
|
|
48
53
|
* The placement of the content in relation to the target
|
|
49
54
|
*/
|
|
50
|
-
placement
|
|
55
|
+
placement?: PlacementPropValues
|
|
51
56
|
|
|
52
57
|
/**
|
|
53
58
|
* An element or a function returning an element to use as the mount node
|
|
54
59
|
* for the `<Position />` (defaults to `document.body`)
|
|
55
60
|
*/
|
|
56
|
-
mountNode
|
|
61
|
+
mountNode?: PositionMountNode
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
64
|
* Insert the element at the 'top' of the mountNode or at the 'bottom'
|
|
60
65
|
*/
|
|
61
|
-
insertAt
|
|
66
|
+
insertAt?: 'bottom' | 'top'
|
|
62
67
|
|
|
63
68
|
/**
|
|
64
69
|
* The parent in which to constrain the placement.
|
|
65
|
-
* One of
|
|
70
|
+
* One of?: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
66
71
|
* or a function returning an element
|
|
67
72
|
*/
|
|
68
|
-
constrain
|
|
73
|
+
constrain?: PositionConstraint
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* The horizontal offset for the positioned content
|
|
72
77
|
*/
|
|
73
|
-
offsetX
|
|
78
|
+
offsetX?: string | number
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
81
|
* The vertical offset for the positioned content
|
|
77
82
|
*/
|
|
78
|
-
offsetY
|
|
83
|
+
offsetY?: string | number
|
|
79
84
|
|
|
80
85
|
/**
|
|
81
86
|
* An id will be generated if not provided
|
|
@@ -85,28 +90,28 @@ type PositionProps = {
|
|
|
85
90
|
/**
|
|
86
91
|
* Whether or not position of the target should be tracked or just set statically on render
|
|
87
92
|
*/
|
|
88
|
-
shouldTrackPosition
|
|
93
|
+
shouldTrackPosition?: boolean
|
|
89
94
|
|
|
90
95
|
/**
|
|
91
96
|
* Whether or not you want the content to position over the target
|
|
92
97
|
*/
|
|
93
|
-
shouldPositionOverTarget
|
|
98
|
+
shouldPositionOverTarget?: boolean
|
|
94
99
|
|
|
95
100
|
/**
|
|
96
101
|
* Callback fired when the position changes
|
|
97
102
|
*/
|
|
98
|
-
onPositionChanged
|
|
103
|
+
onPositionChanged?: (position: Position) => any
|
|
99
104
|
|
|
100
105
|
/**
|
|
101
106
|
* Callback fired when `<Position />` content has been mounted and is initially positioned
|
|
102
107
|
*/
|
|
103
|
-
onPositioned
|
|
108
|
+
onPositioned?: (position: Position) => any
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
111
|
* The content to be positioned
|
|
107
112
|
*/
|
|
108
|
-
children
|
|
109
|
-
}
|
|
113
|
+
children?: React.ReactNode
|
|
114
|
+
}
|
|
110
115
|
|
|
111
116
|
type PositionState = {
|
|
112
117
|
positioned: boolean
|
|
@@ -116,4 +121,45 @@ type Position = ElementPosition['style'] & {
|
|
|
116
121
|
placement: ElementPosition['placement']
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
type PropKeys = keyof PositionOwnProps
|
|
125
|
+
|
|
126
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
127
|
+
|
|
128
|
+
type PositionProps = PositionOwnProps & WithStyleProps
|
|
129
|
+
|
|
130
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
131
|
+
renderTarget: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
132
|
+
target: PropTypes.oneOfType([element, PropTypes.func]),
|
|
133
|
+
placement: PositionPropTypes.placement,
|
|
134
|
+
mountNode: PositionPropTypes.mountNode,
|
|
135
|
+
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
136
|
+
constrain: PositionPropTypes.constrain,
|
|
137
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
138
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
139
|
+
id: PropTypes.string,
|
|
140
|
+
shouldTrackPosition: PropTypes.bool,
|
|
141
|
+
shouldPositionOverTarget: PropTypes.bool,
|
|
142
|
+
onPositionChanged: PropTypes.func,
|
|
143
|
+
onPositioned: PropTypes.func,
|
|
144
|
+
children: PropTypes.node
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const allowedProps: AllowedPropKeys = [
|
|
148
|
+
'renderTarget',
|
|
149
|
+
'target',
|
|
150
|
+
'placement',
|
|
151
|
+
'mountNode',
|
|
152
|
+
'insertAt',
|
|
153
|
+
'constrain',
|
|
154
|
+
'offsetX',
|
|
155
|
+
'offsetY',
|
|
156
|
+
'id',
|
|
157
|
+
'shouldTrackPosition',
|
|
158
|
+
'shouldPositionOverTarget',
|
|
159
|
+
'onPositionChanged',
|
|
160
|
+
'onPositioned',
|
|
161
|
+
'children'
|
|
162
|
+
]
|
|
163
|
+
|
|
119
164
|
export type { PositionProps, PositionState }
|
|
165
|
+
export { propTypes, allowedProps }
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { Component } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import type { PositionChangeListenerType } from '@instructure/ui-dom-utils';
|
|
6
5
|
import { jsx } from '@instructure/emotion';
|
|
7
|
-
import { PositionProps, PositionState } from './
|
|
6
|
+
import type { PositionProps, PositionState } from './props';
|
|
8
7
|
import { PositionElement } from '../PositionPropTypes';
|
|
9
8
|
/**
|
|
10
9
|
---
|
|
@@ -14,24 +13,82 @@ category: components/utilities
|
|
|
14
13
|
**/
|
|
15
14
|
declare class Position extends Component<PositionProps, PositionState> {
|
|
16
15
|
static readonly componentId = "Position";
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
static allowedProps: readonly (keyof {
|
|
17
|
+
renderTarget?: import("react").ReactNode | ((...args: any[]) => import("react").ReactNode);
|
|
18
|
+
target?: import("../PositionPropTypes").PositionMountNode | undefined;
|
|
19
|
+
placement?: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
20
|
+
mountNode?: import("../PositionPropTypes").PositionMountNode | undefined;
|
|
21
|
+
insertAt?: "top" | "bottom" | undefined;
|
|
22
|
+
constrain?: import("../PositionPropTypes").PositionConstraint | undefined;
|
|
23
|
+
offsetX?: string | number | undefined;
|
|
24
|
+
offsetY?: string | number | undefined;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
shouldTrackPosition?: boolean | undefined;
|
|
27
|
+
shouldPositionOverTarget?: boolean | undefined;
|
|
28
|
+
onPositionChanged?: ((position: {
|
|
29
|
+
top?: 0 | undefined;
|
|
30
|
+
left?: 0 | "-9999em" | undefined;
|
|
31
|
+
overflow?: "hidden" | undefined;
|
|
32
|
+
position?: "absolute" | undefined;
|
|
33
|
+
display?: "none" | null | undefined;
|
|
34
|
+
minWidth?: number | null | undefined;
|
|
35
|
+
minHeight?: number | null | undefined;
|
|
36
|
+
transform?: string | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
placement: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
39
|
+
}) => any) | undefined;
|
|
40
|
+
onPositioned?: ((position: {
|
|
41
|
+
top?: 0 | undefined;
|
|
42
|
+
left?: 0 | "-9999em" | undefined;
|
|
43
|
+
overflow?: "hidden" | undefined;
|
|
44
|
+
position?: "absolute" | undefined;
|
|
45
|
+
display?: "none" | null | undefined;
|
|
46
|
+
minWidth?: number | null | undefined;
|
|
47
|
+
minHeight?: number | null | undefined;
|
|
48
|
+
transform?: string | undefined;
|
|
49
|
+
} & {
|
|
50
|
+
placement: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
51
|
+
}) => any) | undefined;
|
|
52
|
+
children?: import("react").ReactNode;
|
|
53
|
+
})[];
|
|
54
|
+
static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
|
|
55
|
+
renderTarget?: import("react").ReactNode | ((...args: any[]) => import("react").ReactNode);
|
|
56
|
+
target?: import("../PositionPropTypes").PositionMountNode | undefined;
|
|
57
|
+
placement?: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
58
|
+
mountNode?: import("../PositionPropTypes").PositionMountNode | undefined;
|
|
59
|
+
insertAt?: "top" | "bottom" | undefined;
|
|
60
|
+
constrain?: import("../PositionPropTypes").PositionConstraint | undefined;
|
|
61
|
+
offsetX?: string | number | undefined;
|
|
62
|
+
offsetY?: string | number | undefined;
|
|
63
|
+
id?: string | undefined;
|
|
64
|
+
shouldTrackPosition?: boolean | undefined;
|
|
65
|
+
shouldPositionOverTarget?: boolean | undefined;
|
|
66
|
+
onPositionChanged?: ((position: {
|
|
67
|
+
top?: 0 | undefined;
|
|
68
|
+
left?: 0 | "-9999em" | undefined;
|
|
69
|
+
overflow?: "hidden" | undefined;
|
|
70
|
+
position?: "absolute" | undefined;
|
|
71
|
+
display?: "none" | null | undefined;
|
|
72
|
+
minWidth?: number | null | undefined;
|
|
73
|
+
minHeight?: number | null | undefined;
|
|
74
|
+
transform?: string | undefined;
|
|
75
|
+
} & {
|
|
76
|
+
placement: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
77
|
+
}) => any) | undefined;
|
|
78
|
+
onPositioned?: ((position: {
|
|
79
|
+
top?: 0 | undefined;
|
|
80
|
+
left?: 0 | "-9999em" | undefined;
|
|
81
|
+
overflow?: "hidden" | undefined;
|
|
82
|
+
position?: "absolute" | undefined;
|
|
83
|
+
display?: "none" | null | undefined;
|
|
84
|
+
minWidth?: number | null | undefined;
|
|
85
|
+
minHeight?: number | null | undefined;
|
|
86
|
+
transform?: string | undefined;
|
|
87
|
+
} & {
|
|
88
|
+
placement: import("../PositionPropTypes").PlacementPropValues | undefined;
|
|
89
|
+
}) => any) | undefined;
|
|
90
|
+
children?: import("react").ReactNode;
|
|
91
|
+
}>;
|
|
35
92
|
static defaultProps: PositionProps;
|
|
36
93
|
static locatorAttribute: string;
|
|
37
94
|
static targetLocatorAttribute: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Position/index.tsx"],"names":[],"mappings":";AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Position/index.tsx"],"names":[],"mappings":";AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAWjC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAS3E,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD;;;;;GAKG;AACH,cAEM,QAAS,SAAQ,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,WAAW,cAAa;IAExC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY,EAAE,aAAa,CAYjC;IAED,MAAM,CAAC,gBAAgB,SAAkB;IACzC,MAAM,CAAC,sBAAsB,SAAyB;IACtD,MAAM,CAAC,uBAAuB,SAA0B;gBAE5C,KAAK,EAAE,aAAa;IAehC,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,CAAK;IAChC,SAAS,EAAE,0BAA0B,GAAG,IAAI,CAAO;IACnD,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAA;IAEzB,qBAAqB,CACnB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,GAAG;IASlB,iBAAiB;IAKjB,kBAAkB,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa;IA6BrE,oBAAoB;IAQpB,uBAAuB,CAAC,GAAG,EAAE,OAAO;IAiBpC,sBAAsB,CACpB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,OAAO;IAad,gBAAgB,aAqBf;IAED,iBAAiB,CAAC,KAAK,EAAE,aAAa;IAWtC,QAAQ,aAKP;IAED,aAAa;IAKb,YAAY;IAOZ,aAAa;IAiCb,YAAY;;;IAgBZ,MAAM;CASP;AAED,eAAe,QAAQ,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PositionConstraint, PositionMountNode, PlacementPropValues, ElementPosition } from '../PositionPropTypes';
|
|
3
2
|
import type { WithStyleProps } from '@instructure/emotion';
|
|
4
|
-
|
|
3
|
+
import type { PropValidators } from '@instructure/shared-types';
|
|
4
|
+
import type { PositionConstraint, PositionMountNode, PlacementPropValues, ElementPosition } from '../PositionPropTypes';
|
|
5
|
+
declare type PositionOwnProps = {
|
|
5
6
|
/**
|
|
6
7
|
* The node to use as the position target
|
|
7
8
|
*/
|
|
@@ -13,30 +14,30 @@ declare type PositionProps = {
|
|
|
13
14
|
/**
|
|
14
15
|
* The placement of the content in relation to the target
|
|
15
16
|
*/
|
|
16
|
-
placement
|
|
17
|
+
placement?: PlacementPropValues;
|
|
17
18
|
/**
|
|
18
19
|
* An element or a function returning an element to use as the mount node
|
|
19
20
|
* for the `<Position />` (defaults to `document.body`)
|
|
20
21
|
*/
|
|
21
|
-
mountNode
|
|
22
|
+
mountNode?: PositionMountNode;
|
|
22
23
|
/**
|
|
23
24
|
* Insert the element at the 'top' of the mountNode or at the 'bottom'
|
|
24
25
|
*/
|
|
25
|
-
insertAt
|
|
26
|
+
insertAt?: 'bottom' | 'top';
|
|
26
27
|
/**
|
|
27
28
|
* The parent in which to constrain the placement.
|
|
28
|
-
* One of
|
|
29
|
+
* One of?: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
29
30
|
* or a function returning an element
|
|
30
31
|
*/
|
|
31
|
-
constrain
|
|
32
|
+
constrain?: PositionConstraint;
|
|
32
33
|
/**
|
|
33
34
|
* The horizontal offset for the positioned content
|
|
34
35
|
*/
|
|
35
|
-
offsetX
|
|
36
|
+
offsetX?: string | number;
|
|
36
37
|
/**
|
|
37
38
|
* The vertical offset for the positioned content
|
|
38
39
|
*/
|
|
39
|
-
offsetY
|
|
40
|
+
offsetY?: string | number;
|
|
40
41
|
/**
|
|
41
42
|
* An id will be generated if not provided
|
|
42
43
|
*/
|
|
@@ -44,29 +45,35 @@ declare type PositionProps = {
|
|
|
44
45
|
/**
|
|
45
46
|
* Whether or not position of the target should be tracked or just set statically on render
|
|
46
47
|
*/
|
|
47
|
-
shouldTrackPosition
|
|
48
|
+
shouldTrackPosition?: boolean;
|
|
48
49
|
/**
|
|
49
50
|
* Whether or not you want the content to position over the target
|
|
50
51
|
*/
|
|
51
|
-
shouldPositionOverTarget
|
|
52
|
+
shouldPositionOverTarget?: boolean;
|
|
52
53
|
/**
|
|
53
54
|
* Callback fired when the position changes
|
|
54
55
|
*/
|
|
55
|
-
onPositionChanged
|
|
56
|
+
onPositionChanged?: (position: Position) => any;
|
|
56
57
|
/**
|
|
57
58
|
* Callback fired when `<Position />` content has been mounted and is initially positioned
|
|
58
59
|
*/
|
|
59
|
-
onPositioned
|
|
60
|
+
onPositioned?: (position: Position) => any;
|
|
60
61
|
/**
|
|
61
62
|
* The content to be positioned
|
|
62
63
|
*/
|
|
63
|
-
children
|
|
64
|
-
}
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
};
|
|
65
66
|
declare type PositionState = {
|
|
66
67
|
positioned: boolean;
|
|
67
68
|
} & ElementPosition;
|
|
68
69
|
declare type Position = ElementPosition['style'] & {
|
|
69
70
|
placement: ElementPosition['placement'];
|
|
70
71
|
};
|
|
72
|
+
declare type PropKeys = keyof PositionOwnProps;
|
|
73
|
+
declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
|
|
74
|
+
declare type PositionProps = PositionOwnProps & WithStyleProps;
|
|
75
|
+
declare const propTypes: PropValidators<PropKeys>;
|
|
76
|
+
declare const allowedProps: AllowedPropKeys;
|
|
71
77
|
export type { PositionProps, PositionState };
|
|
72
|
-
|
|
78
|
+
export { propTypes, allowedProps };
|
|
79
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/Position/props.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EAChB,MAAM,sBAAsB,CAAA;AAE7B,aAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAA;IAEtE;;OAEG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAE/B;;;OAGG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;IAE3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAA;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEzB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAElC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,GAAG,CAAA;IAE/C;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,GAAG,CAAA;IAE1C;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED,aAAK,aAAa,GAAG;IACnB,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG,eAAe,CAAA;AAEnB,aAAK,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG;IACzC,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;CACxC,CAAA;AAED,aAAK,QAAQ,GAAG,MAAM,gBAAgB,CAAA;AAEtC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,aAAa,GAAG,gBAAgB,GAAG,cAAc,CAAA;AAEtD,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAevC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAenB,CAAA;AAED,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
|
package/types/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { mirrorHorizontalPlacement } from './mirrorHorizontalPlacement';
|
|
|
6
6
|
export { mirrorPlacement } from './mirrorPlacement';
|
|
7
7
|
export { parsePlacement } from './parsePlacement';
|
|
8
8
|
export type { PlacementPropValues, PositionMountNode, PositionConstraint } from './PositionPropTypes';
|
|
9
|
-
export type { PositionProps } from './Position/
|
|
9
|
+
export type { PositionProps } from './Position/props';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/es/Position/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/Position/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Position/types.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EAChB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,aAAK,aAAa,GAAG;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAA;IAEtE;;OAEG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAE1B;;OAEG;IACH,SAAS,EAAE,mBAAmB,CAAA;IAE9B;;;OAGG;IACH,SAAS,EAAE,iBAAiB,CAAA;IAE5B;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAA;IAE1B;;;;OAIG;IACH,SAAS,EAAE,kBAAkB,CAAA;IAE7B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IAExB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAA;IAE5B;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAA;IAEjC;;OAEG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,GAAG,CAAA;IAE9C;;OAEG;IACH,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,GAAG,CAAA;IAEzC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,GAAG,cAAc,CAAA;AAElB,aAAK,aAAa,GAAG;IACnB,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG,eAAe,CAAA;AAEnB,aAAK,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG;IACzC,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;CACxC,CAAA;AAED,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAA"}
|