@instructure/ui-responsive 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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,6 +3,19 @@
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
+ ## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-responsive
@@ -1,27 +1,4 @@
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
-
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
25
2
  import { Component } from 'react';
26
3
  import { deepEqual } from '@instructure/ui-utils';
27
4
  import { logError as error, warn } from '@instructure/console';
@@ -29,135 +6,109 @@ import { addElementQueryMatchListener, updateElementMatches } from '../../utils/
29
6
  import { addMediaQueryMatchListener } from '../../utils/v1/addMediaQueryMatchListener.js';
30
7
  import { findDOMNode } from '@instructure/ui-dom-utils';
31
8
  import { allowedProps } from './props.js';
32
-
33
- /**
34
- ---
35
- category: components
36
- ---
37
-
38
- **/
39
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
40
9
  class Responsive extends Component {
41
- static displayName = 'Responsive';
42
- static allowedProps = allowedProps;
43
- static defaultProps = {
44
- children: null,
45
- match: 'element',
46
- props: null
47
- };
48
- ref = null;
49
- _matchListener = null;
50
- state = {
51
- matches: [],
52
- hasRendered: false
53
- };
54
- handleRef = el => {
55
- const {
56
- elementRef
57
- } = this.props;
58
- this.ref = el;
59
- if (typeof elementRef === 'function') {
60
- elementRef(el);
10
+ static{
11
+ this.displayName = 'Responsive';
12
+ }
13
+ static{
14
+ this.allowedProps = allowedProps;
15
+ }
16
+ static{
17
+ this.defaultProps = {
18
+ children: null,
19
+ match: 'element',
20
+ props: null
21
+ };
22
+ }
23
+ componentDidMount() {
24
+ error(!!(this.props.render || this.props.children), `[Responsive] must have either a \`render\` prop or \`children\` prop.`);
25
+ if (this.props.match === 'element') {
26
+ const initialMatches = updateElementMatches(this.props.query, this) || [];
27
+ this.setState({
28
+ matches: initialMatches,
29
+ hasRendered: true
30
+ });
31
+ } else {
32
+ this.setState({
33
+ hasRendered: true
34
+ });
35
+ }
36
+ this._matchListener = this.addMatchListener(this.props.query, this.updateMatches);
37
+ }
38
+ componentWillUnmount() {
39
+ this.removeMatchListener();
40
+ }
41
+ componentDidUpdate(prevProps) {
42
+ const { match, query } = this.props;
43
+ if (match !== prevProps.match || !deepEqual(query, prevProps.query)) {
44
+ this.removeMatchListener();
45
+ this._matchListener = this.addMatchListener(query, this.updateMatches, match);
46
+ }
61
47
  }
62
- };
63
- componentDidMount() {
64
- error(!!(this.props.render || this.props.children), `[Responsive] must have either a \`render\` prop or \`children\` prop.`);
65
- if (this.props.match === 'element') {
66
- // Because Responsive renders an empty div initially, it always needs to
67
- // re-render with the children provided. If there are no matches the match
68
- // listener won't trigger an update, so we handle this update explicitly.
69
- const initialMatches = updateElementMatches(this.props.query, this) || [];
70
- this.setState({
71
- matches: initialMatches,
72
- hasRendered: true
73
- });
74
- } else {
75
- this.setState({
76
- hasRendered: true
77
- });
48
+ addMatchListener(query, updateMatches, match = this.props.match) {
49
+ const matchListener = match === 'element' ? addElementQueryMatchListener : addMediaQueryMatchListener;
50
+ return matchListener(query, ()=>findDOMNode(this), updateMatches);
78
51
  }
79
- this._matchListener = this.addMatchListener(this.props.query, this.updateMatches);
80
- }
81
- componentWillUnmount() {
82
- this.removeMatchListener();
83
- }
84
- componentDidUpdate(prevProps) {
85
- const {
86
- match,
87
- query
88
- } = this.props;
89
- if (match !== prevProps.match || !deepEqual(query, prevProps.query)) {
90
- this.removeMatchListener();
91
- this._matchListener = this.addMatchListener(query, this.updateMatches, match);
52
+ removeMatchListener() {
53
+ if (this._matchListener) {
54
+ this._matchListener.remove();
55
+ }
92
56
  }
93
- }
94
- addMatchListener(query, updateMatches, match = this.props.match) {
95
- const matchListener = match === 'element' ? addElementQueryMatchListener : addMediaQueryMatchListener;
96
- return matchListener(query, () => findDOMNode(this), updateMatches);
97
- }
98
- removeMatchListener() {
99
- if (this._matchListener) {
100
- this._matchListener.remove();
57
+ mergeProps(matches, props) {
58
+ if (!props) {
59
+ return null;
60
+ }
61
+ const mergedProps = {};
62
+ matches.forEach((match)=>{
63
+ const matchProps = props[match];
64
+ Object.keys(matchProps).forEach((prop)=>{
65
+ const currentValue = mergedProps[prop];
66
+ warn(!(prop in mergedProps), [
67
+ `[Responsive] The prop \`${prop}\` is defined at 2 or more breakpoints`,
68
+ `which are currently applied at the same time. Its current value, \`${currentValue}\`,`,
69
+ `will be overwritten as \`${matchProps[prop]}\`.`
70
+ ].join(' '));
71
+ mergedProps[prop] = matchProps[prop];
72
+ });
73
+ });
74
+ return mergedProps;
101
75
  }
102
- }
103
- updateMatches = (matches, cb) => {
104
- this.setState({
105
- matches
106
- }, () => {
107
- if (typeof cb === 'function') {
108
- cb();
109
- }
110
- });
111
- };
112
- mergeProps(matches, props) {
113
- if (!props) {
114
- return null;
76
+ render() {
77
+ const { matches, hasRendered } = this.state;
78
+ const { props, render, children, display } = this.props;
79
+ let renderFunc;
80
+ if (hasRendered) {
81
+ renderFunc = children || render;
82
+ }
83
+ return /*#__PURE__*/ _jsx("div", {
84
+ ref: this.handleRef,
85
+ style: {
86
+ display
87
+ },
88
+ "data-cid": this.props['data-cid'],
89
+ children: renderFunc && renderFunc(this.mergeProps(matches, props), matches)
90
+ });
115
91
  }
116
- const mergedProps = {};
117
- matches.forEach(match => {
118
- const matchProps = props[match];
119
-
120
- // Iterate over the props for the current match. If that the prop is
121
- // already in `mergedProps` that means that the prop was defined for
122
- // multiple breakpoints, and more than one of those breakpoints is being
123
- // currently applied so we log a warning.
124
- Object.keys(matchProps).forEach(prop => {
125
- const currentValue = mergedProps[prop];
126
- warn(!(prop in mergedProps), [`[Responsive] The prop \`${prop}\` is defined at 2 or more breakpoints`, `which are currently applied at the same time. Its current value, \`${currentValue}\`,`, `will be overwritten as \`${matchProps[prop]}\`.`].join(' '));
127
- mergedProps[prop] = matchProps[prop];
128
- });
129
- });
130
- return mergedProps;
131
- }
132
- render() {
133
- const {
134
- matches,
135
- hasRendered
136
- } = this.state;
137
- const {
138
- props,
139
- render,
140
- children,
141
- display
142
- } = this.props;
143
- let renderFunc;
144
- // Responsive needs to render once to measure the dom and obtain matches.
145
- // Calling the render prop on this initial render can cause visual side
146
- // effects and is slower than rendering an empty div.
147
- if (hasRendered) {
148
- // Render via the children or render method, whichever is supplied. If
149
- // both are supplied, give preference to children.
150
- renderFunc = children || render;
92
+ constructor(...args){
93
+ super(...args), this.ref = null, this._matchListener = null, this.state = {
94
+ matches: [],
95
+ hasRendered: false
96
+ }, this.handleRef = (el)=>{
97
+ const { elementRef } = this.props;
98
+ this.ref = el;
99
+ if (typeof elementRef === 'function') {
100
+ elementRef(el);
101
+ }
102
+ }, this.updateMatches = (matches, cb)=>{
103
+ this.setState({
104
+ matches
105
+ }, ()=>{
106
+ if (typeof cb === 'function') {
107
+ cb();
108
+ }
109
+ });
110
+ };
151
111
  }
152
- return _jsx("div", {
153
- ref: this.handleRef,
154
- style: {
155
- display
156
- },
157
- "data-cid": this.props['data-cid'],
158
- children: renderFunc && renderFunc(this.mergeProps(matches, props), matches)
159
- });
160
- }
161
112
  }
162
113
  export default Responsive;
163
- export { Responsive };
114
+ export { Responsive };
@@ -1,30 +1,10 @@
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
-
25
- /**
26
- * Consists of an object where the keys match the breakpoint names used in the query. The values are objects with keys representing prop names and values representing prop values Ex. `{small: { myProp: 'fillscreen' }, large: { myProp: 'fillcontainer' }}`
27
- */
28
-
29
- const allowedProps = ['match', 'query', 'props', 'render', 'children', 'display', 'elementRef'];
30
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'match',
3
+ 'query',
4
+ 'props',
5
+ 'render',
6
+ 'children',
7
+ 'display',
8
+ 'elementRef'
9
+ ];
10
+ export { allowedProps };
package/es/exports/a.js CHANGED
@@ -1,30 +1,6 @@
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
-
25
1
  export { Responsive } from '../Responsive/v1/index.js';
26
2
  export { addElementQueryMatchListener } from '../utils/v1/addElementQueryMatchListener.js';
27
3
  export { addMediaQueryMatchListener } from '../utils/v1/addMediaQueryMatchListener.js';
28
4
  export { parseQuery } from '../utils/v1/parseQuery.js';
29
5
  export { jsonToMediaQuery } from '../utils/v1/jsonToMediaQuery.js';
30
- export { ResponsivePropTypes } from '../utils/v1/ResponsivePropTypes.js';
6
+ export { ResponsivePropTypes } from '../utils/v1/ResponsivePropTypes.js';
@@ -1 +1 @@
1
- export {};
1
+ export { };
@@ -1,64 +1,13 @@
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
-
25
1
  import { jsonToMediaQuery } from './jsonToMediaQuery.js';
26
2
  const ResponsivePropTypes = {
27
- /**
28
- * Verify that the given prop is a properly formatted query object
29
- * with exactly one key and one corresponding valid value of type
30
- * string or number. The object key should be one of `minWidth`,
31
- * `maxWidth`, `minHeight`, or `maxHeight`. Note that key values
32
- * should be camel cased.
33
- *
34
- *
35
- * The following are examples of valid query objects:
36
- *
37
- * ```js
38
- * { minWidth: 350 }
39
- * { maxHeight: '400px' }
40
- * { maxWidth: '20rem' }
41
- * ```
42
- *
43
- * The following are examples of invalid query objects:
44
- *
45
- * ```js
46
- * { minwidth: 300 } // should be minWidth (case sensitive)
47
- * { minHeight: 200, maxHeight: 300 } // should consist of exactly one key
48
- * ```
49
- * @param {Object} props - object containing the component props
50
- * @param {string} propName - name of the given prop
51
- * @param {string} componentName - name of the component
52
- * @returns {Error} if prop is an invalid query
53
- */
54
- validQuery(props, propName, componentName) {
55
- try {
56
- jsonToMediaQuery(props[propName]);
57
- return null;
58
- } catch (e) {
59
- return new Error(`Invalid query prop supplied to \`${componentName}\`. ${e.message}`);
3
+ validQuery (props, propName, componentName) {
4
+ try {
5
+ jsonToMediaQuery(props[propName]);
6
+ return null;
7
+ } catch (e) {
8
+ return new Error(`Invalid query prop supplied to \`${componentName}\`. ${e.message}`);
9
+ }
60
10
  }
61
- }
62
11
  };
63
12
  export default ResponsivePropTypes;
64
- export { ResponsivePropTypes };
13
+ export { ResponsivePropTypes };
@@ -1,157 +1,66 @@
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
1
  import { parseQuery } from './parseQuery.js';
25
2
  import { findDOMNode, getBoundingClientRect } from '@instructure/ui-dom-utils';
26
3
  import { debounce } from '@instructure/debounce';
27
- /**
28
- * ---
29
- * category: utilities/layout
30
- * ---
31
- * Given an object of named queries, listens for changes in the
32
- * element size and notifies which queries match via a function
33
- * callback. The callback method is only called when the query
34
- * matches change, not on all element resizes. (If you are looking
35
- * to call a method on all element resizes use
36
- * [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) instead)
37
- *
38
- *
39
- * This function shares an interface with
40
- * [addMediaQueryMatchListener](addMediaQueryMatchListener)
41
- * so that they can be used interchangeably.
42
- *
43
- * The [Responsive](Responsive) component with the `match` prop
44
- * set to `element` utilizes this function. This is a low level
45
- * utility method and, in most cases, [Responsive](Responsive)
46
- * should be used instead.
47
- *
48
- * ```js-code
49
- * class MyComponent extends Component {
50
- * state = {
51
- * matches: []
52
- * }
53
- *
54
- * _listener = null
55
- *
56
- * componentDidMount () {
57
- * const query = {myFirstQuery: { minWidth: 100 }, mySecondQuery: { maxHeight: '30rem'}}
58
- * const el = findDOMNode(this)
59
- *
60
- * this._listener = addElementQueryMatchListener(query, el, this.updateMatches)
61
- * }
62
- *
63
- * componentWillUnmount () {
64
- * if (this._listener) {
65
- * this._listener.remove()
66
- * }
67
- * }
68
- *
69
- * updateMatches = (matches) => {
70
- * this.setState({ matches })
71
- * }
72
- * ...
73
- * }
74
- * ```
75
- * @module addElementQueryMatchListener
76
- * @param {Object} query - object consisting of names and query objects
77
- * @param {Node|Window|React.ReactElement|React.Component|function} el - a DOM node or a function returning a DOM node
78
- * @param {function} cb - called with an array of the names of the currently
79
- * matching queries whenever a matching query changes
80
- * @returns {function} remove() function to call to remove the listener
81
- */
82
- const addElementQueryMatchListener = (query, el, cb) => {
83
- const node = typeof el === 'function' ? el() : el;
84
- const {
85
- width,
86
- height
87
- } = getBoundingClientRect(node);
88
- let matches = [];
89
- const update = size => {
90
- const newMatches = updateElementMatches(query, node, matches, size);
91
- if (newMatches) {
92
- matches = newMatches;
93
- cb(matches);
94
- }
95
- return;
96
- };
97
- const debounced = debounce(update, 100, {
98
- leading: false,
99
- trailing: true
100
- });
101
- const elementResizeListener = new ResizeObserver(entries => {
102
- for (const entry of entries) {
103
- const {
104
- width: newWidth,
105
- height: newHeight
106
- } = entry.contentRect;
107
- if (width !== newWidth) {
108
- debounced({
109
- width: newWidth,
110
- height: newHeight
111
- });
112
- }
113
- }
114
- });
115
- elementResizeListener.observe(node);
116
- update({
117
- width,
118
- height
119
- });
120
- return {
121
- remove() {
122
- if (elementResizeListener) {
123
- elementResizeListener.disconnect();
124
- }
125
- if (debounced) {
126
- debounced.cancel();
127
- }
128
- }
129
- };
4
+ const addElementQueryMatchListener = (query, el, cb)=>{
5
+ const node = typeof el === 'function' ? el() : el;
6
+ const { width, height } = getBoundingClientRect(node);
7
+ let matches = [];
8
+ const update = (size)=>{
9
+ const newMatches = updateElementMatches(query, node, matches, size);
10
+ if (newMatches) {
11
+ matches = newMatches;
12
+ cb(matches);
13
+ }
14
+ return;
15
+ };
16
+ const debounced = debounce(update, 100, {
17
+ leading: false,
18
+ trailing: true
19
+ });
20
+ const elementResizeListener = new ResizeObserver((entries)=>{
21
+ for (const entry of entries){
22
+ const { width: newWidth, height: newHeight } = entry.contentRect;
23
+ if (width !== newWidth) {
24
+ debounced({
25
+ width: newWidth,
26
+ height: newHeight
27
+ });
28
+ }
29
+ }
30
+ });
31
+ elementResizeListener.observe(node);
32
+ update({
33
+ width,
34
+ height
35
+ });
36
+ return {
37
+ remove () {
38
+ if (elementResizeListener) {
39
+ elementResizeListener.disconnect();
40
+ }
41
+ if (debounced) {
42
+ debounced.cancel();
43
+ }
44
+ }
45
+ };
130
46
  };
131
47
  function updateElementMatches(query, el, matches = [], size) {
132
- const node = findDOMNode(el);
133
- let {
134
- width,
135
- height
136
- } = size || getBoundingClientRect(node);
137
-
138
- // round dimensions to make sure matcher can match queries with integer values
139
- width = Math.floor(width);
140
- height = Math.floor(height);
141
- const matchingQueries = parseQuery(query, node)({
142
- width,
143
- height
144
- });
145
- const newMatches = Object.keys(matchingQueries).filter(key => matchingQueries[key]).map(key => key);
146
-
147
- // only return matches if they have changed
148
- if (matches.length !== newMatches.length) {
149
- return newMatches;
150
- }
151
- if (matches.filter(match => newMatches.indexOf(match) === -1).length > 0) {
152
- return newMatches;
153
- }
154
- return null;
48
+ const node = findDOMNode(el);
49
+ let { width, height } = size || getBoundingClientRect(node);
50
+ width = Math.floor(width);
51
+ height = Math.floor(height);
52
+ const matchingQueries = parseQuery(query, node)({
53
+ width,
54
+ height
55
+ });
56
+ const newMatches = Object.keys(matchingQueries).filter((key)=>matchingQueries[key]).map((key)=>key);
57
+ if (matches.length !== newMatches.length) {
58
+ return newMatches;
59
+ }
60
+ if (matches.filter((match)=>newMatches.indexOf(match) === -1).length > 0) {
61
+ return newMatches;
62
+ }
63
+ return null;
155
64
  }
156
65
  export default addElementQueryMatchListener;
157
- export { addElementQueryMatchListener, updateElementMatches };
66
+ export { addElementQueryMatchListener, updateElementMatches };