ember-container-query 3.2.0 → 4.0.0-alpha.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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/addon-main.js +5 -0
  3. package/dist/_app_/components/container-query.js +1 -0
  4. package/dist/_app_/helpers/aspect-ratio.js +1 -0
  5. package/dist/_app_/helpers/height.js +1 -0
  6. package/dist/_app_/helpers/width.js +1 -0
  7. package/dist/_app_/modifiers/container-query.js +1 -0
  8. package/dist/applyDecoratedDescriptor-fa858ac4.js +77 -0
  9. package/dist/applyDecoratedDescriptor-fa858ac4.js.map +1 -0
  10. package/{addon/styles → dist/components}/container-query.css +0 -0
  11. package/{components → dist/components}/container-query.d.ts +4 -4
  12. package/dist/components/container-query.d.ts.map +1 -0
  13. package/dist/components/container-query.js +40 -0
  14. package/dist/components/container-query.js.map +1 -0
  15. package/{helpers → dist/helpers}/aspect-ratio.d.ts +3 -3
  16. package/dist/helpers/aspect-ratio.js +15 -0
  17. package/dist/helpers/aspect-ratio.js.map +1 -0
  18. package/{helpers → dist/helpers}/height.d.ts +3 -3
  19. package/dist/helpers/height.js +15 -0
  20. package/dist/helpers/height.js.map +1 -0
  21. package/{helpers → dist/helpers}/width.d.ts +3 -3
  22. package/dist/helpers/width.js +15 -0
  23. package/dist/helpers/width.js.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.js +6 -0
  26. package/dist/index.js.map +1 -0
  27. package/{modifiers → dist/modifiers}/container-query.d.ts +5 -5
  28. package/dist/modifiers/container-query.js +106 -0
  29. package/dist/modifiers/container-query.js.map +1 -0
  30. package/dist/template-registry.d.ts +13 -0
  31. package/dist/template-registry.js +2 -0
  32. package/dist/template-registry.js.map +1 -0
  33. package/package.json +45 -105
  34. package/.netlifyredirects +0 -1
  35. package/.stylelintcache +0 -1
  36. package/.stylelintrc.js +0 -64
  37. package/CHANGELOG.md +0 -425
  38. package/addon/components/container-query.hbs +0 -21
  39. package/addon/components/container-query.ts +0 -49
  40. package/addon/helpers/aspect-ratio.ts +0 -26
  41. package/addon/helpers/height.ts +0 -24
  42. package/addon/helpers/width.ts +0 -24
  43. package/addon/index.ts +0 -5
  44. package/addon/modifiers/container-query.ts +0 -179
  45. package/addon/template-registry.ts +0 -16
  46. package/app/components/container-query.js +0 -1
  47. package/app/helpers/aspect-ratio.js +0 -1
  48. package/app/helpers/cq-aspect-ratio.js +0 -18
  49. package/app/helpers/cq-height.js +0 -18
  50. package/app/helpers/cq-width.js +0 -18
  51. package/app/helpers/height.js +0 -1
  52. package/app/helpers/width.js +0 -1
  53. package/app/modifiers/container-query.js +0 -1
  54. package/index.d.ts +0 -6
  55. package/index.js +0 -5
  56. package/template-registry.d.ts +0 -16
  57. package/tsconfig.json +0 -47
  58. package/types/dummy/index.d.ts +0 -33
  59. package/types/global.d.ts +0 -6
@@ -1,179 +0,0 @@
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
- type IndexSignatureParameter = string | number | symbol;
8
-
9
- type Dimensions = {
10
- aspectRatio: number;
11
- height: number;
12
- width: number;
13
- };
14
-
15
- type Metadata = {
16
- dimension: 'aspectRatio' | 'height' | 'width';
17
- max: number;
18
- min: number;
19
- };
20
-
21
- type Features<T extends IndexSignatureParameter> = Record<T, Metadata>;
22
-
23
- type QueryResults<T extends IndexSignatureParameter> = Record<T, boolean>;
24
-
25
- interface ContainerQueryModifierSignature<T extends IndexSignatureParameter> {
26
- Args: {
27
- Named: {
28
- dataAttributePrefix?: string;
29
- debounce?: number;
30
- features?: Features<T>;
31
- onQuery?: ({
32
- dimensions,
33
- queryResults,
34
- }: {
35
- dimensions: Dimensions;
36
- queryResults: QueryResults<T>;
37
- }) => void;
38
- };
39
- Positional: [];
40
- };
41
- Element: Element;
42
- }
43
-
44
- export default class ContainerQueryModifier<
45
- T extends IndexSignatureParameter
46
- > extends Modifier<ContainerQueryModifierSignature<T>> {
47
- @service private declare readonly resizeObserver;
48
-
49
- dimensions!: Dimensions;
50
- queryResults!: QueryResults<T>;
51
-
52
- private _dataAttributes: string[] = [];
53
- private _element?: Element;
54
- private _named!: NamedArgs<ContainerQueryModifierSignature<T>>;
55
-
56
- get dataAttributePrefix(): string {
57
- return this._named.dataAttributePrefix ?? 'container-query';
58
- }
59
-
60
- get debounce(): number {
61
- return this._named.debounce ?? 0;
62
- }
63
-
64
- get features(): Features<T> {
65
- return this._named.features ?? ({} as Features<T>);
66
- }
67
-
68
- constructor(
69
- owner: unknown,
70
- args: ArgsFor<ContainerQueryModifierSignature<T>>
71
- ) {
72
- super(owner, args);
73
-
74
- registerDestructor(this, () => {
75
- this.resizeObserver.unobserve(this._element, this.onResize);
76
- });
77
- }
78
-
79
- modify(
80
- element: Element,
81
- _positional: PositionalArgs<ContainerQueryModifierSignature<T>>,
82
- named: NamedArgs<ContainerQueryModifierSignature<T>>
83
- ): void {
84
- this._named = named;
85
-
86
- this.registerResizeObserver(element);
87
- this.queryContainer(element);
88
- }
89
-
90
- @action private onResize(resizeObserverEntry: ResizeObserverEntry): void {
91
- const element = resizeObserverEntry.target;
92
-
93
- if (this.debounce > 0) {
94
- _debounce(this, this.queryContainer, element, this.debounce);
95
- return;
96
- }
97
-
98
- this.queryContainer(element);
99
- }
100
-
101
- private registerResizeObserver(element: Element): void {
102
- this.resizeObserver.unobserve(this._element, this.onResize);
103
-
104
- this._element = element;
105
- this.resizeObserver.observe(this._element, this.onResize);
106
- }
107
-
108
- private queryContainer(element: Element): void {
109
- this.measureDimensions(element);
110
- this.evaluateQueries();
111
- this.resetDataAttributes(element);
112
- this.setDataAttributes(element);
113
-
114
- this._named.onQuery?.({
115
- dimensions: this.dimensions,
116
- queryResults: this.queryResults,
117
- });
118
- }
119
-
120
- private measureDimensions(element: Element): void {
121
- const height = element.clientHeight;
122
- const width = element.clientWidth;
123
-
124
- this.dimensions = {
125
- aspectRatio: width / height,
126
- height,
127
- width,
128
- };
129
- }
130
-
131
- private evaluateQueries(): void {
132
- const queryResults = {} as QueryResults<T>;
133
-
134
- for (const [featureName, metadata] of Object.entries(this.features)) {
135
- const { dimension, min, max } = metadata as Metadata;
136
- const value = this.dimensions[dimension];
137
-
138
- queryResults[featureName as T] = min <= value && value < max;
139
- }
140
-
141
- this.queryResults = queryResults;
142
- }
143
-
144
- private resetDataAttributes(element: Element): void {
145
- this._dataAttributes.forEach((dataAttribute) => {
146
- element.removeAttribute(dataAttribute);
147
- });
148
-
149
- this._dataAttributes = [];
150
- }
151
-
152
- private setDataAttributes(element: Element): void {
153
- const prefix = this.dataAttributePrefix;
154
-
155
- for (const [featureName, meetsFeature] of Object.entries(
156
- this.queryResults
157
- )) {
158
- if (!meetsFeature) {
159
- continue;
160
- }
161
-
162
- const dataAttribute = prefix
163
- ? `data-${prefix}-${featureName}`
164
- : `data-${featureName}`;
165
-
166
- element.setAttribute(dataAttribute, '');
167
-
168
- this._dataAttributes.push(dataAttribute);
169
- }
170
- }
171
- }
172
-
173
- export {
174
- Dimensions,
175
- Features,
176
- IndexSignatureParameter,
177
- Metadata,
178
- QueryResults,
179
- };
@@ -1,16 +0,0 @@
1
- import type ContainerQueryComponent from './components/container-query';
2
- import type AspectRatioHelper from './helpers/aspect-ratio';
3
- import type HeightHelper from './helpers/height';
4
- import type WidthHelper from './helpers/width';
5
- import type ContainerQueryModifier from './modifiers/container-query';
6
-
7
- export default interface EmberContainerQueryRegistry {
8
- ContainerQuery: typeof ContainerQueryComponent;
9
- 'aspect-ratio': typeof AspectRatioHelper;
10
- 'container-query': typeof ContainerQueryModifier;
11
- 'cq-aspect-ratio': typeof AspectRatioHelper;
12
- 'cq-height': typeof HeightHelper;
13
- 'cq-width': typeof WidthHelper;
14
- height: typeof HeightHelper;
15
- width: typeof WidthHelper;
16
- }
@@ -1 +0,0 @@
1
- export { default } from 'ember-container-query/components/container-query';
@@ -1 +0,0 @@
1
- export { default } from 'ember-container-query/helpers/aspect-ratio';
@@ -1,18 +0,0 @@
1
- import { deprecate } from '@ember/debug';
2
-
3
- deprecate(
4
- 'The {{cq-aspect-ratio}} helper has been renamed to {{aspect-ratio}}. Please update the helper name in your template.',
5
- false,
6
- {
7
- for: 'ember-container-query',
8
- id: 'ember-container-query.rename-cq-aspect-ratio-helper',
9
- since: {
10
- available: '3.2.0',
11
- enabled: '3.2.0',
12
- },
13
- until: '4.0.0',
14
- url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
15
- }
16
- );
17
-
18
- export { default } from 'ember-container-query/helpers/aspect-ratio';
@@ -1,18 +0,0 @@
1
- import { deprecate } from '@ember/debug';
2
-
3
- deprecate(
4
- 'The {{cq-height}} helper has been renamed to {{height}}. Please update the helper name in your template.',
5
- false,
6
- {
7
- for: 'ember-container-query',
8
- id: 'ember-container-query.rename-cq-height-helper',
9
- since: {
10
- available: '3.2.0',
11
- enabled: '3.2.0',
12
- },
13
- until: '4.0.0',
14
- url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
15
- }
16
- );
17
-
18
- export { default } from 'ember-container-query/helpers/height';
@@ -1,18 +0,0 @@
1
- import { deprecate } from '@ember/debug';
2
-
3
- deprecate(
4
- 'The {{cq-width}} helper has been renamed to {{width}}. Please update the helper name in your template.',
5
- false,
6
- {
7
- for: 'ember-container-query',
8
- id: 'ember-container-query.rename-cq-width-helper',
9
- since: {
10
- available: '3.2.0',
11
- enabled: '3.2.0',
12
- },
13
- until: '4.0.0',
14
- url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
15
- }
16
- );
17
-
18
- export { default } from 'ember-container-query/helpers/width';
@@ -1 +0,0 @@
1
- export { default } from 'ember-container-query/helpers/height';
@@ -1 +0,0 @@
1
- export { default } from 'ember-container-query/helpers/width';
@@ -1 +0,0 @@
1
- export { default } from 'ember-container-query/modifiers/container-query';
package/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { default as ContainerQuery } from './components/container-query';
2
- export { default as aspectRatio } from './helpers/aspect-ratio';
3
- export { default as height } from './helpers/height';
4
- export { default as width } from './helpers/width';
5
- export { default as containerQuery } from './modifiers/container-query';
6
- //# sourceMappingURL=index.d.ts.map
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- name: require('./package').name,
5
- };
@@ -1,16 +0,0 @@
1
- import type ContainerQueryComponent from './components/container-query';
2
- import type AspectRatioHelper from './helpers/aspect-ratio';
3
- import type HeightHelper from './helpers/height';
4
- import type WidthHelper from './helpers/width';
5
- import type ContainerQueryModifier from './modifiers/container-query';
6
- export default interface EmberContainerQueryRegistry {
7
- ContainerQuery: typeof ContainerQueryComponent;
8
- 'aspect-ratio': typeof AspectRatioHelper;
9
- 'container-query': typeof ContainerQueryModifier;
10
- 'cq-aspect-ratio': typeof AspectRatioHelper;
11
- 'cq-height': typeof HeightHelper;
12
- 'cq-width': typeof WidthHelper;
13
- height: typeof HeightHelper;
14
- width: typeof WidthHelper;
15
- }
16
- //# sourceMappingURL=template-registry.d.ts.map
package/tsconfig.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "extends": "@tsconfig/ember/tsconfig.json",
3
- "compilerOptions": {
4
- // Don't check the types of dependencies
5
- "skipLibCheck": true,
6
-
7
- // The combination of `baseUrl` with `paths` allows Ember's classic package
8
- // layout, which is not resolveable with the Node resolution algorithm, to
9
- // work with TypeScript.
10
- "baseUrl": ".",
11
- "paths": {
12
- "dummy/tests/*": [
13
- "tests/*"
14
- ],
15
- "dummy/*": [
16
- "tests/dummy/app/*",
17
- "app/*"
18
- ],
19
- "ember-container-query": [
20
- "addon"
21
- ],
22
- "ember-container-query/*": [
23
- "addon/*"
24
- ],
25
- "ember-container-query/test-support": [
26
- "addon-test-support"
27
- ],
28
- "ember-container-query/test-support/*": [
29
- "addon-test-support/*"
30
- ],
31
- "*": [
32
- "types/*"
33
- ]
34
- }
35
- },
36
- "include": [
37
- "app/**/*",
38
- "addon/**/*",
39
- "tests/**/*",
40
- "types/**/*",
41
- "test-support/**/*",
42
- "addon-test-support/**/*"
43
- ],
44
- "glint": {
45
- "environment": "ember-loose"
46
- }
47
- }
@@ -1,33 +0,0 @@
1
- // Add any types here that you need for local development only.
2
- // These will *not* be published as part of your addon, so be careful that your published code does not rely on them!
3
-
4
- import '@glint/environment-ember-loose';
5
-
6
- import SvgJarHelper from '@gavant/glint-template-types/types/ember-svg-jar/helpers/svg-jar';
7
- import AndHelper from '@gavant/glint-template-types/types/ember-truth-helpers/helpers/and';
8
- import OrHelper from '@gavant/glint-template-types/types/ember-truth-helpers/helpers/or';
9
- import { ComponentLike, HelperLike } from '@glint/template';
10
- import type EmberContainerQueryRegistry from 'ember-container-query/template-registry';
11
-
12
- type NavigationNarratorComponent = ComponentLike<{
13
- Args: {
14
- skipTo: string;
15
- };
16
- }>;
17
-
18
- type PageTitleHelper = HelperLike<{
19
- Args: { Positional: [title: string] };
20
- Return: void;
21
- }>;
22
-
23
- declare module '@glint/environment-ember-loose/registry' {
24
- export default interface Registry extends EmberContainerQueryRegistry {
25
- // Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
26
- // See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons
27
- NavigationNarrator: NavigationNarratorComponent;
28
- and: typeof AndHelper;
29
- or: typeof OrHelper;
30
- 'page-title': PageTitleHelper;
31
- 'svg-jar': typeof SvgJarHelper;
32
- }
33
- }
package/types/global.d.ts DELETED
@@ -1,6 +0,0 @@
1
- // Types for compiled templates
2
- declare module 'ember-container-query/templates/*' {
3
- import { TemplateFactory } from 'htmlbars-inline-precompile';
4
- const tmpl: TemplateFactory;
5
- export default tmpl;
6
- }