ember-container-query 2.1.0 → 2.1.1
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/.stylelintrc.js +64 -0
- package/CHANGELOG.md +20 -0
- package/addon/components/container-query.hbs +7 -7
- package/addon/components/container-query.ts +15 -86
- package/addon/helpers/cq-aspect-ratio.ts +1 -6
- package/addon/helpers/cq-height.ts +1 -6
- package/addon/helpers/cq-width.ts +1 -6
- package/addon/modifiers/container-query.ts +170 -0
- package/app/modifiers/container-query.js +1 -0
- package/components/container-query.d.ts +7 -23
- package/helpers/cq-aspect-ratio.d.ts +1 -5
- package/helpers/cq-height.d.ts +1 -5
- package/helpers/cq-width.d.ts +1 -5
- package/modifiers/container-query.d.ts +54 -0
- package/package.json +60 -52
package/.stylelintrc.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable-next-line n/no-unpublished-require */
|
|
4
|
+
const { browsers } = require('./tests/dummy/config/targets');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
extends: ['stylelint-config-standard'],
|
|
8
|
+
plugins: ['stylelint-no-unsupported-browser-features', 'stylelint-order'],
|
|
9
|
+
rules: {
|
|
10
|
+
/*
|
|
11
|
+
Customize plugins
|
|
12
|
+
*/
|
|
13
|
+
'order/properties-order': [
|
|
14
|
+
[
|
|
15
|
+
// Defined by ember-css-modules
|
|
16
|
+
'composes',
|
|
17
|
+
],
|
|
18
|
+
{
|
|
19
|
+
unspecified: 'bottomAlphabetical',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
'plugin/no-unsupported-browser-features': [
|
|
24
|
+
true,
|
|
25
|
+
{
|
|
26
|
+
browsers,
|
|
27
|
+
ignore: [
|
|
28
|
+
// grid-template-columns falsely identified as multicolumn
|
|
29
|
+
'multicolumn',
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
Customize rules
|
|
36
|
+
*/
|
|
37
|
+
'declaration-block-no-redundant-longhand-properties': [
|
|
38
|
+
true,
|
|
39
|
+
{
|
|
40
|
+
ignoreShorthands: ['grid-gap', 'grid-template'],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
'property-no-unknown': [
|
|
45
|
+
true,
|
|
46
|
+
{
|
|
47
|
+
ignoreProperties: [
|
|
48
|
+
// Defined by ember-css-modules
|
|
49
|
+
'composes',
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
|
|
54
|
+
'selector-pseudo-class-no-unknown': [
|
|
55
|
+
true,
|
|
56
|
+
{
|
|
57
|
+
ignorePseudoClasses: [
|
|
58
|
+
// Defined by ember-css-modules
|
|
59
|
+
'global',
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 2.1.1 (2022-12-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fix
|
|
4
|
+
* [#128](https://github.com/ijlee2/ember-container-query/pull/128) Replaced @ember/render-modifiers with ember-modifier ([@ijlee2](https://github.com/ijlee2))
|
|
5
|
+
* [#126](https://github.com/ijlee2/ember-container-query/pull/126) Listed ember-test-selectors as a dependency ([@ijlee2](https://github.com/ijlee2))
|
|
6
|
+
|
|
7
|
+
### Enhancement
|
|
8
|
+
* [#128](https://github.com/ijlee2/ember-container-query/pull/128) Replaced @ember/render-modifiers with ember-modifier ([@ijlee2](https://github.com/ijlee2))
|
|
9
|
+
|
|
10
|
+
### Internal
|
|
11
|
+
* [#133](https://github.com/ijlee2/ember-container-query/pull/133) Addressed ember-modifier deprecations ([@ijlee2](https://github.com/ijlee2))
|
|
12
|
+
* [#132](https://github.com/ijlee2/ember-container-query/pull/132) Updated dependencies to their latest version ([@ijlee2](https://github.com/ijlee2))
|
|
13
|
+
* [#128](https://github.com/ijlee2/ember-container-query/pull/128) Replaced @ember/render-modifiers with ember-modifier ([@ijlee2](https://github.com/ijlee2))
|
|
14
|
+
* [#125](https://github.com/ijlee2/ember-container-query/pull/125) Updated dependencies to their latest version ([@ijlee2](https://github.com/ijlee2))
|
|
15
|
+
* [#124](https://github.com/ijlee2/ember-container-query/pull/124) Installed stylelint to help with maintaining the demo app ([@ijlee2](https://github.com/ijlee2))
|
|
16
|
+
|
|
17
|
+
### Committers: 1
|
|
18
|
+
- Isaac Lee ([@ijlee2](https://github.com/ijlee2))
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
## 2.1.0 (2022-06-03)
|
|
2
22
|
|
|
3
23
|
### Enhancement
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
<Tag
|
|
3
3
|
class="container-query"
|
|
4
4
|
data-test-container-query
|
|
5
|
-
{{
|
|
6
|
-
|
|
5
|
+
{{container-query
|
|
6
|
+
dataAttributePrefix=@dataAttributePrefix
|
|
7
|
+
debounce=@debounce
|
|
8
|
+
features=@features
|
|
9
|
+
onQuery=this.updateState
|
|
10
|
+
}}
|
|
7
11
|
...attributes
|
|
8
12
|
>
|
|
9
13
|
{{yield (hash
|
|
14
|
+
dimensions=this.dimensions
|
|
10
15
|
features=this.queryResults
|
|
11
|
-
dimensions=(hash
|
|
12
|
-
aspectRatio=this.aspectRatio
|
|
13
|
-
height=this.height
|
|
14
|
-
width=this.width
|
|
15
|
-
)
|
|
16
16
|
)}}
|
|
17
17
|
</Tag>
|
|
18
18
|
{{/let}}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
min: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type Features = {
|
|
13
|
-
[featureName: string]: Metadata;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type QueryResults = {
|
|
17
|
-
[featureName: string]: boolean;
|
|
18
|
-
};
|
|
4
|
+
import type {
|
|
5
|
+
Dimensions,
|
|
6
|
+
Features,
|
|
7
|
+
QueryResults,
|
|
8
|
+
} from 'ember-container-query/modifiers/container-query';
|
|
19
9
|
|
|
20
10
|
interface ContainerQueryComponentArgs {
|
|
21
11
|
dataAttributePrefix?: string;
|
|
@@ -25,81 +15,20 @@ interface ContainerQueryComponentArgs {
|
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
export default class ContainerQueryComponent extends Component<ContainerQueryComponentArgs> {
|
|
28
|
-
@tracked
|
|
29
|
-
@tracked
|
|
30
|
-
@tracked height?: number;
|
|
31
|
-
@tracked width?: number;
|
|
32
|
-
|
|
33
|
-
get features(): Features {
|
|
34
|
-
return this.args.features ?? {};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get dataAttributePrefix(): string {
|
|
38
|
-
return this.args.dataAttributePrefix ?? 'container-query';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get debounce(): number {
|
|
42
|
-
return this.args.debounce ?? 0;
|
|
43
|
-
}
|
|
18
|
+
@tracked dimensions?: Dimensions;
|
|
19
|
+
@tracked queryResults?: QueryResults;
|
|
44
20
|
|
|
45
21
|
// The dynamic tag is restricted to be immutable
|
|
46
22
|
tagName = this.args.tagName ?? 'div';
|
|
47
23
|
|
|
48
|
-
@action
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.queryContainer(element);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@action queryContainer(element: Element): void {
|
|
60
|
-
this.measureDimensions(element);
|
|
61
|
-
this.evaluateQueries();
|
|
62
|
-
this.setDataAttributes(element);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
measureDimensions(element: Element): void {
|
|
66
|
-
this.height = element.clientHeight;
|
|
67
|
-
this.width = element.clientWidth;
|
|
68
|
-
this.aspectRatio = this.width / this.height;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
evaluateQueries(): void {
|
|
72
|
-
const queryResults = {} as QueryResults;
|
|
73
|
-
|
|
74
|
-
for (const [featureName, metadata] of Object.entries(this.features)) {
|
|
75
|
-
const { dimension, min, max } = metadata;
|
|
76
|
-
const value = this[dimension]!;
|
|
77
|
-
|
|
78
|
-
queryResults[featureName] = min <= value && value < max;
|
|
79
|
-
}
|
|
80
|
-
|
|
24
|
+
@action updateState({
|
|
25
|
+
dimensions,
|
|
26
|
+
queryResults,
|
|
27
|
+
}: {
|
|
28
|
+
dimensions: Dimensions;
|
|
29
|
+
queryResults: QueryResults;
|
|
30
|
+
}): void {
|
|
31
|
+
this.dimensions = dimensions;
|
|
81
32
|
this.queryResults = queryResults;
|
|
82
33
|
}
|
|
83
|
-
|
|
84
|
-
setDataAttributes(element: Element): void {
|
|
85
|
-
const prefix = this.dataAttributePrefix;
|
|
86
|
-
|
|
87
|
-
for (const [featureName, meetsFeature] of Object.entries(
|
|
88
|
-
this.queryResults
|
|
89
|
-
)) {
|
|
90
|
-
let attributeName;
|
|
91
|
-
|
|
92
|
-
if (prefix) {
|
|
93
|
-
attributeName = `data-${prefix}-${featureName}`;
|
|
94
|
-
} else {
|
|
95
|
-
attributeName = `data-${featureName}`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (meetsFeature) {
|
|
99
|
-
element.setAttribute(attributeName, '');
|
|
100
|
-
} else {
|
|
101
|
-
element.removeAttribute(attributeName);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
34
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
|
-
|
|
3
|
-
type Metadata = {
|
|
4
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
5
|
-
max: number;
|
|
6
|
-
min: number;
|
|
7
|
-
};
|
|
2
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
8
3
|
|
|
9
4
|
function cqAspectRatio(
|
|
10
5
|
positional: unknown[],
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
|
-
|
|
3
|
-
type Metadata = {
|
|
4
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
5
|
-
max: number;
|
|
6
|
-
min: number;
|
|
7
|
-
};
|
|
2
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
8
3
|
|
|
9
4
|
function cqHeight(
|
|
10
5
|
positional: unknown[],
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
|
-
|
|
3
|
-
type Metadata = {
|
|
4
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
5
|
-
max: number;
|
|
6
|
-
min: number;
|
|
7
|
-
};
|
|
2
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
8
3
|
|
|
9
4
|
function cqWidth(
|
|
10
5
|
positional: unknown[],
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { debounce as _debounce } from '@ember/runloop';
|
|
4
|
+
import { inject as service } from '@ember/service';
|
|
5
|
+
import Modifier, { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
|
|
6
|
+
|
|
7
|
+
export type Metadata = {
|
|
8
|
+
dimension: 'aspectRatio' | 'height' | 'width';
|
|
9
|
+
max: number;
|
|
10
|
+
min: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type Features = {
|
|
14
|
+
[featureName: string]: Metadata;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type Dimensions = {
|
|
18
|
+
aspectRatio: number;
|
|
19
|
+
height: number;
|
|
20
|
+
width: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type QueryResults = {
|
|
24
|
+
[featureName: string]: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface ContainerQueryModifierSignature {
|
|
28
|
+
Args: {
|
|
29
|
+
Named: {
|
|
30
|
+
dataAttributePrefix?: string;
|
|
31
|
+
debounce?: number;
|
|
32
|
+
features?: Features;
|
|
33
|
+
onQuery?: ({
|
|
34
|
+
dimensions,
|
|
35
|
+
queryResults,
|
|
36
|
+
}: {
|
|
37
|
+
dimensions: Dimensions;
|
|
38
|
+
queryResults: QueryResults;
|
|
39
|
+
}) => void;
|
|
40
|
+
};
|
|
41
|
+
Positional: [];
|
|
42
|
+
};
|
|
43
|
+
Element: Element;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default class ContainerQueryModifier extends Modifier<ContainerQueryModifierSignature> {
|
|
47
|
+
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
48
|
+
/* @ts-ignore */
|
|
49
|
+
@service private declare readonly resizeObserver;
|
|
50
|
+
|
|
51
|
+
dimensions!: Dimensions;
|
|
52
|
+
queryResults!: QueryResults;
|
|
53
|
+
|
|
54
|
+
private _dataAttributes: string[] = [];
|
|
55
|
+
private _element?: Element;
|
|
56
|
+
private _named!: NamedArgs<ContainerQueryModifierSignature>;
|
|
57
|
+
|
|
58
|
+
get dataAttributePrefix(): string {
|
|
59
|
+
return this._named.dataAttributePrefix ?? 'container-query';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get debounce(): number {
|
|
63
|
+
return this._named.debounce ?? 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get features(): Features {
|
|
67
|
+
return this._named.features ?? {};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
constructor(owner: unknown, args: ArgsFor<ContainerQueryModifierSignature>) {
|
|
71
|
+
super(owner, args);
|
|
72
|
+
|
|
73
|
+
registerDestructor(this, () => {
|
|
74
|
+
this.resizeObserver.unobserve(this._element, this.onResize);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
modify(
|
|
79
|
+
element: Element,
|
|
80
|
+
_positional: PositionalArgs<ContainerQueryModifierSignature>,
|
|
81
|
+
named: NamedArgs<ContainerQueryModifierSignature>
|
|
82
|
+
): void {
|
|
83
|
+
this._named = named;
|
|
84
|
+
|
|
85
|
+
this.registerResizeObserver(element);
|
|
86
|
+
this.queryContainer(element);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@action private onResize(resizeObserverEntry: ResizeObserverEntry): void {
|
|
90
|
+
const element = resizeObserverEntry.target;
|
|
91
|
+
|
|
92
|
+
if (this.debounce > 0) {
|
|
93
|
+
_debounce(this, this.queryContainer, element, this.debounce);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.queryContainer(element);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private registerResizeObserver(element: Element): void {
|
|
101
|
+
this.resizeObserver.unobserve(this._element, this.onResize);
|
|
102
|
+
|
|
103
|
+
this._element = element;
|
|
104
|
+
this.resizeObserver.observe(this._element, this.onResize);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private queryContainer(element: Element): void {
|
|
108
|
+
this.measureDimensions(element);
|
|
109
|
+
this.evaluateQueries();
|
|
110
|
+
this.resetDataAttributes(element);
|
|
111
|
+
this.setDataAttributes(element);
|
|
112
|
+
|
|
113
|
+
this._named.onQuery?.({
|
|
114
|
+
dimensions: this.dimensions,
|
|
115
|
+
queryResults: this.queryResults,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private measureDimensions(element: Element): void {
|
|
120
|
+
const height = element.clientHeight;
|
|
121
|
+
const width = element.clientWidth;
|
|
122
|
+
|
|
123
|
+
this.dimensions = {
|
|
124
|
+
aspectRatio: width / height,
|
|
125
|
+
height,
|
|
126
|
+
width,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private evaluateQueries(): void {
|
|
131
|
+
const queryResults = {} as QueryResults;
|
|
132
|
+
|
|
133
|
+
for (const [featureName, metadata] of Object.entries(this.features)) {
|
|
134
|
+
const { dimension, min, max } = metadata;
|
|
135
|
+
const value = this.dimensions[dimension];
|
|
136
|
+
|
|
137
|
+
queryResults[featureName] = min <= value && value < max;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.queryResults = queryResults;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private resetDataAttributes(element: Element): void {
|
|
144
|
+
this._dataAttributes.forEach((dataAttribute) => {
|
|
145
|
+
element.removeAttribute(dataAttribute);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
this._dataAttributes = [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private setDataAttributes(element: Element): void {
|
|
152
|
+
const prefix = this.dataAttributePrefix;
|
|
153
|
+
|
|
154
|
+
for (const [featureName, meetsFeature] of Object.entries(
|
|
155
|
+
this.queryResults
|
|
156
|
+
)) {
|
|
157
|
+
if (!meetsFeature) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const dataAttribute = prefix
|
|
162
|
+
? `data-${prefix}-${featureName}`
|
|
163
|
+
: `data-${featureName}`;
|
|
164
|
+
|
|
165
|
+
element.setAttribute(dataAttribute, '');
|
|
166
|
+
|
|
167
|
+
this._dataAttributes.push(dataAttribute);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from 'ember-container-query/modifiers/container-query';
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
|
|
3
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
4
|
-
max: number;
|
|
5
|
-
min: number;
|
|
6
|
-
};
|
|
7
|
-
declare type Features = {
|
|
8
|
-
[featureName: string]: Metadata;
|
|
9
|
-
};
|
|
10
|
-
declare type QueryResults = {
|
|
11
|
-
[featureName: string]: boolean;
|
|
12
|
-
};
|
|
2
|
+
import type { Dimensions, Features, QueryResults } from 'ember-container-query/modifiers/container-query';
|
|
13
3
|
interface ContainerQueryComponentArgs {
|
|
14
4
|
dataAttributePrefix?: string;
|
|
15
5
|
debounce?: number;
|
|
@@ -17,19 +7,13 @@ interface ContainerQueryComponentArgs {
|
|
|
17
7
|
tagName?: string;
|
|
18
8
|
}
|
|
19
9
|
export default class ContainerQueryComponent extends Component<ContainerQueryComponentArgs> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
height?: number;
|
|
23
|
-
width?: number;
|
|
24
|
-
get features(): Features;
|
|
25
|
-
get dataAttributePrefix(): string;
|
|
26
|
-
get debounce(): number;
|
|
10
|
+
dimensions?: Dimensions;
|
|
11
|
+
queryResults?: QueryResults;
|
|
27
12
|
tagName: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setDataAttributes(element: Element): void;
|
|
13
|
+
updateState({ dimensions, queryResults, }: {
|
|
14
|
+
dimensions: Dimensions;
|
|
15
|
+
queryResults: QueryResults;
|
|
16
|
+
}): void;
|
|
33
17
|
}
|
|
34
18
|
export {};
|
|
35
19
|
//# sourceMappingURL=container-query.d.ts.map
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
3
|
-
max: number;
|
|
4
|
-
min: number;
|
|
5
|
-
};
|
|
1
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
6
2
|
declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
|
|
7
3
|
Args: {
|
|
8
4
|
Positional: unknown[];
|
package/helpers/cq-height.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
3
|
-
max: number;
|
|
4
|
-
min: number;
|
|
5
|
-
};
|
|
1
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
6
2
|
declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
|
|
7
3
|
Args: {
|
|
8
4
|
Positional: unknown[];
|
package/helpers/cq-width.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
dimension: 'aspectRatio' | 'height' | 'width';
|
|
3
|
-
max: number;
|
|
4
|
-
min: number;
|
|
5
|
-
};
|
|
1
|
+
import type { Metadata } from 'ember-container-query/modifiers/container-query';
|
|
6
2
|
declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
|
|
7
3
|
Args: {
|
|
8
4
|
Positional: unknown[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Modifier, { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
|
|
2
|
+
export type Metadata = {
|
|
3
|
+
dimension: 'aspectRatio' | 'height' | 'width';
|
|
4
|
+
max: number;
|
|
5
|
+
min: number;
|
|
6
|
+
};
|
|
7
|
+
export type Features = {
|
|
8
|
+
[featureName: string]: Metadata;
|
|
9
|
+
};
|
|
10
|
+
export type Dimensions = {
|
|
11
|
+
aspectRatio: number;
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
};
|
|
15
|
+
export type QueryResults = {
|
|
16
|
+
[featureName: string]: boolean;
|
|
17
|
+
};
|
|
18
|
+
interface ContainerQueryModifierSignature {
|
|
19
|
+
Args: {
|
|
20
|
+
Named: {
|
|
21
|
+
dataAttributePrefix?: string;
|
|
22
|
+
debounce?: number;
|
|
23
|
+
features?: Features;
|
|
24
|
+
onQuery?: ({ dimensions, queryResults, }: {
|
|
25
|
+
dimensions: Dimensions;
|
|
26
|
+
queryResults: QueryResults;
|
|
27
|
+
}) => void;
|
|
28
|
+
};
|
|
29
|
+
Positional: [];
|
|
30
|
+
};
|
|
31
|
+
Element: Element;
|
|
32
|
+
}
|
|
33
|
+
export default class ContainerQueryModifier extends Modifier<ContainerQueryModifierSignature> {
|
|
34
|
+
private readonly resizeObserver;
|
|
35
|
+
dimensions: Dimensions;
|
|
36
|
+
queryResults: QueryResults;
|
|
37
|
+
private _dataAttributes;
|
|
38
|
+
private _element?;
|
|
39
|
+
private _named;
|
|
40
|
+
get dataAttributePrefix(): string;
|
|
41
|
+
get debounce(): number;
|
|
42
|
+
get features(): Features;
|
|
43
|
+
constructor(owner: unknown, args: ArgsFor<ContainerQueryModifierSignature>);
|
|
44
|
+
modify(element: Element, _positional: PositionalArgs<ContainerQueryModifierSignature>, named: NamedArgs<ContainerQueryModifierSignature>): void;
|
|
45
|
+
private onResize;
|
|
46
|
+
private registerResizeObserver;
|
|
47
|
+
private queryContainer;
|
|
48
|
+
private measureDimensions;
|
|
49
|
+
private evaluateQueries;
|
|
50
|
+
private resetDataAttributes;
|
|
51
|
+
private setDataAttributes;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=container-query.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-container-query",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Container queries using Ember modifiers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"container-queries",
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
"build": "ember build --environment=production",
|
|
27
27
|
"build:test": "ember build --environment=test",
|
|
28
28
|
"changelog": "lerna-changelog",
|
|
29
|
-
"lint": "
|
|
29
|
+
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
|
|
30
|
+
"lint:css": "stylelint \"tests/dummy/app/**/*.css\" --cache",
|
|
31
|
+
"lint:css:fix": "stylelint \"tests/dummy/app/**/*.css\" --fix",
|
|
30
32
|
"lint:dependency": "ember dependency-lint",
|
|
31
|
-
"lint:fix": "npm
|
|
33
|
+
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
|
|
32
34
|
"lint:hbs": "ember-template-lint .",
|
|
33
35
|
"lint:hbs:fix": "ember-template-lint . --fix",
|
|
34
36
|
"lint:js": "eslint . --cache --ext=.js,.ts",
|
|
@@ -52,55 +54,58 @@
|
|
|
52
54
|
}
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@ember/render-modifiers": "^2.0.4",
|
|
56
57
|
"ember-cli-babel": "^7.26.11",
|
|
57
|
-
"ember-cli-htmlbars": "^6.
|
|
58
|
-
"ember-cli-typescript": "^5.1
|
|
58
|
+
"ember-cli-htmlbars": "^6.1.1",
|
|
59
|
+
"ember-cli-typescript": "^5.2.1",
|
|
59
60
|
"ember-element-helper": "^0.6.1",
|
|
60
|
-
"ember-
|
|
61
|
+
"ember-modifier": "^3.2.7",
|
|
62
|
+
"ember-resize-observer-service": "^1.1.0",
|
|
63
|
+
"ember-test-selectors": "^6.0.0"
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
63
66
|
"@ember/optional-features": "^2.0.0",
|
|
64
67
|
"@ember/test-helpers": "^2.8.1",
|
|
65
|
-
"@embroider/test-setup": "^
|
|
68
|
+
"@embroider/test-setup": "^2.0.2",
|
|
66
69
|
"@glimmer/component": "^1.1.2",
|
|
67
70
|
"@glimmer/tracking": "^1.1.2",
|
|
68
|
-
"@percy/cli": "^1.
|
|
69
|
-
"@percy/ember": "^
|
|
70
|
-
"@types/ember-qunit": "^5.0.
|
|
71
|
-
"@types/ember-resolver": "^5.0.
|
|
72
|
-
"@types/ember__application": "^4.0.
|
|
73
|
-
"@types/ember__array": "^4.0.
|
|
74
|
-
"@types/ember__component": "^4.0.
|
|
75
|
-
"@types/ember__controller": "^4.0.
|
|
76
|
-
"@types/ember__debug": "^4.0.
|
|
77
|
-
"@types/
|
|
78
|
-
"@types/
|
|
79
|
-
"@types/
|
|
80
|
-
"@types/
|
|
81
|
-
"@types/
|
|
82
|
-
"@types/
|
|
83
|
-
"@types/
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/
|
|
87
|
-
"@types/ember__test
|
|
88
|
-
"@types/
|
|
71
|
+
"@percy/cli": "^1.16.0",
|
|
72
|
+
"@percy/ember": "^4.0.0",
|
|
73
|
+
"@types/ember-qunit": "^5.0.2",
|
|
74
|
+
"@types/ember-resolver": "^5.0.13",
|
|
75
|
+
"@types/ember__application": "^4.0.4",
|
|
76
|
+
"@types/ember__array": "^4.0.3",
|
|
77
|
+
"@types/ember__component": "^4.0.11",
|
|
78
|
+
"@types/ember__controller": "^4.0.4",
|
|
79
|
+
"@types/ember__debug": "^4.0.3",
|
|
80
|
+
"@types/ember__destroyable": "^4.0.1",
|
|
81
|
+
"@types/ember__engine": "^4.0.4",
|
|
82
|
+
"@types/ember__error": "^4.0.1",
|
|
83
|
+
"@types/ember__object": "^4.0.5",
|
|
84
|
+
"@types/ember__polyfills": "^4.0.1",
|
|
85
|
+
"@types/ember__routing": "^4.0.12",
|
|
86
|
+
"@types/ember__runloop": "^4.0.2",
|
|
87
|
+
"@types/ember__service": "^4.0.1",
|
|
88
|
+
"@types/ember__string": "^3.0.10",
|
|
89
|
+
"@types/ember__template": "^4.0.1",
|
|
90
|
+
"@types/ember__test": "^4.0.1",
|
|
91
|
+
"@types/ember__test-helpers": "^2.8.2",
|
|
92
|
+
"@types/ember__utils": "^4.0.2",
|
|
89
93
|
"@types/htmlbars-inline-precompile": "^3.0.0",
|
|
90
|
-
"@types/qunit": "^2.19.
|
|
94
|
+
"@types/qunit": "^2.19.3",
|
|
91
95
|
"@types/rsvp": "^4.0.4",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
93
|
-
"@typescript-eslint/parser": "^5.
|
|
96
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
97
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
94
98
|
"broccoli-asset-rev": "^3.0.0",
|
|
95
|
-
"
|
|
99
|
+
"concurrently": "^7.6.0",
|
|
100
|
+
"d3-array": "^3.2.0",
|
|
96
101
|
"d3-axis": "^3.0.0",
|
|
97
102
|
"d3-scale": "^4.0.2",
|
|
98
103
|
"d3-selection": "^3.0.0",
|
|
99
104
|
"d3-shape": "^3.1.0",
|
|
100
|
-
"ember-a11y-refocus": "^
|
|
105
|
+
"ember-a11y-refocus": "^3.0.2",
|
|
101
106
|
"ember-a11y-testing": "^5.0.0",
|
|
102
|
-
"ember-auto-import": "^2.
|
|
103
|
-
"ember-cli": "~4.
|
|
107
|
+
"ember-auto-import": "^2.5.0",
|
|
108
|
+
"ember-cli": "~4.8.0",
|
|
104
109
|
"ember-cli-dependency-checker": "^3.3.1",
|
|
105
110
|
"ember-cli-dependency-lint": "^2.0.1",
|
|
106
111
|
"ember-cli-inject-live-reload": "^2.1.0",
|
|
@@ -109,32 +114,35 @@
|
|
|
109
114
|
"ember-cli-terser": "^4.0.2",
|
|
110
115
|
"ember-css-modules": "^2.0.1",
|
|
111
116
|
"ember-disable-prototype-extensions": "^1.1.3",
|
|
112
|
-
"ember-export-application-global": "^2.0.1",
|
|
113
117
|
"ember-load-initializers": "^2.1.2",
|
|
114
118
|
"ember-named-blocks-polyfill": "^0.2.5",
|
|
115
119
|
"ember-page-title": "^7.0.0",
|
|
116
|
-
"ember-qunit": "^
|
|
120
|
+
"ember-qunit": "^6.0.0",
|
|
117
121
|
"ember-resolver": "^8.0.3",
|
|
118
|
-
"ember-source": "~4.
|
|
122
|
+
"ember-source": "~4.8.0",
|
|
119
123
|
"ember-source-channel-url": "^3.0.0",
|
|
120
|
-
"ember-svg-jar": "^2.
|
|
121
|
-
"ember-template-lint": "^
|
|
122
|
-
"ember-
|
|
123
|
-
"ember-truth-helpers": "^3.0.0",
|
|
124
|
+
"ember-svg-jar": "^2.4.2",
|
|
125
|
+
"ember-template-lint": "^5.0.2",
|
|
126
|
+
"ember-truth-helpers": "^3.1.1",
|
|
124
127
|
"ember-try": "^2.0.0",
|
|
125
|
-
"eslint": "^8.
|
|
128
|
+
"eslint": "^8.28.0",
|
|
126
129
|
"eslint-config-prettier": "^8.5.0",
|
|
127
|
-
"eslint-plugin-ember": "^
|
|
128
|
-
"eslint-plugin-
|
|
129
|
-
"eslint-plugin-prettier": "^4.
|
|
130
|
+
"eslint-plugin-ember": "^11.2.1",
|
|
131
|
+
"eslint-plugin-n": "^15.5.1",
|
|
132
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
133
|
+
"eslint-plugin-qunit": "^7.3.4",
|
|
134
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
130
135
|
"lerna-changelog": "^2.2.0",
|
|
131
136
|
"loader.js": "^4.7.0",
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"qunit": "^2.19.1",
|
|
137
|
+
"prettier": "^2.8.0",
|
|
138
|
+
"qunit": "^2.19.3",
|
|
135
139
|
"qunit-dom": "^2.0.0",
|
|
136
|
-
"
|
|
137
|
-
"
|
|
140
|
+
"stylelint": "^14.15.0",
|
|
141
|
+
"stylelint-config-standard": "^29.0.0",
|
|
142
|
+
"stylelint-no-unsupported-browser-features": "^6.0.1",
|
|
143
|
+
"stylelint-order": "^5.0.0",
|
|
144
|
+
"typescript": "^4.9.3",
|
|
145
|
+
"webpack": "^5.75.0"
|
|
138
146
|
},
|
|
139
147
|
"engines": {
|
|
140
148
|
"node": "12.* || 14.* || >= 16"
|