ember-primitives 0.45.1 → 0.46.0
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/declarations/components/heading.d.ts.map +1 -1
- package/declarations/components/rating/{index.d.ts → rating.d.ts} +1 -1
- package/declarations/components/rating/rating.d.ts.map +1 -0
- package/declarations/components/rating.d.ts +1 -1
- package/declarations/components/rating.d.ts.map +1 -1
- package/declarations/test-support/a11y.d.ts +20 -0
- package/declarations/test-support/a11y.d.ts.map +1 -1
- package/declarations/test-support/dom.d.ts +69 -1
- package/declarations/test-support/dom.d.ts.map +1 -1
- package/declarations/test-support/otp.d.ts +13 -0
- package/declarations/test-support/otp.d.ts.map +1 -1
- package/declarations/test-support/routing.d.ts +3 -0
- package/declarations/test-support/routing.d.ts.map +1 -1
- package/dist/components/heading.js +2 -90
- package/dist/components/rating.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index-D052JWRa.js → rating-D052JWRa.js} +1 -1
- package/dist/rating-D052JWRa.js.map +1 -0
- package/dist/test-support.js +109 -1
- package/package.json +3 -2
- package/declarations/components/rating/index.d.ts.map +0 -1
- package/dist/index-D052JWRa.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.gts"],"names":[],"mappings":"AAoCA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAK3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,qBAAa,OAAQ,SAAQ,SAAS,CAAC;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE;QAAE,OAAO,EAAE,EAAE,CAAA;KAAE,CAAC;CACzB,CAAC;IACA,kBAAkB,EAAE,IAAI,CAAC;gBACb,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM;IAMtC,IAA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,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CACpE,CAAC;gBACF;;mBAEG;gBACH,KAAK,EAAE,aAAa,CAAC,OAAO,WAAW,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,CAAC,CAAC;aACrF;SACF,CAAC;QACF,KAAK,EAAE;YACL,KAAK,EAAE;gBACL;;mBAEG;gBACH,KAAK,EAAE,MAAM,CAAC;gBAEd;;mBAEG;gBACH,KAAK,EAAE,MAAM,CAAC;aACf;SACF,CAAC;KACH,CAAC;CACH;AAED,qBAAa,MAAO,SAAQ,SAAS,CAAC,SAAS,CAAC;IAC9C,IAAI,SAA0B;IAE9B,IAAI,IAAI;;;;;;;;OAEP;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,YAAY,YAIf;IAED,IAAI,UAAU,YAEb;IAED,IAAI,gBAAgB,YAEnB;CAgFF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rating.d.ts","sourceRoot":"","sources":["../../src/components/rating.gts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"rating.d.ts","sourceRoot":"","sources":["../../src/components/rating.gts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A QUnit test utility for setting up the tabbing utility that a few of the components in ember-primitive use for providing enhanced keyboard support.
|
|
3
|
+
*
|
|
4
|
+
* ```gjs
|
|
5
|
+
* import { module, test } from 'qunit';
|
|
6
|
+
* import { setupRenderingTest } from 'ember-qunit';
|
|
7
|
+
* import { setupTabster } from 'ember-primitives/test-support';
|
|
8
|
+
*
|
|
9
|
+
* module('your suite', function (hooks) {
|
|
10
|
+
* setupRenderingTest(hooks);
|
|
11
|
+
* setupTabster(hooks);
|
|
12
|
+
*
|
|
13
|
+
* test('your test', async function (assert) {
|
|
14
|
+
* // ...
|
|
15
|
+
* });
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* This utility takes no options.
|
|
20
|
+
*/
|
|
1
21
|
export declare function setupTabster(hooks: {
|
|
2
22
|
beforeEach: (callback: () => void | Promise<void>) => unknown;
|
|
3
23
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/test-support/a11y.ts"],"names":[],"mappings":"AAgBA,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;CAC/D,QAWA"}
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/test-support/a11y.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;CAC/D,QAWA"}
|
|
@@ -1,14 +1,82 @@
|
|
|
1
1
|
import { find } from '@ember/test-helpers';
|
|
2
2
|
type Findable = Parameters<typeof find>[0] | Element;
|
|
3
3
|
/**
|
|
4
|
-
* Find an element within a shadow-root.
|
|
4
|
+
* Find an element within a given element that has a shadow-root.
|
|
5
|
+
*
|
|
6
|
+
* If the `root` can't be found, or if there actually is no shadow root,
|
|
7
|
+
* nothing will be returned.
|
|
8
|
+
*
|
|
9
|
+
* ```gjs
|
|
10
|
+
* import { findInShadow } from 'ember-primitives/test-support';
|
|
11
|
+
*
|
|
12
|
+
* // ...
|
|
13
|
+
*
|
|
14
|
+
* test('...', async function (assert) {
|
|
15
|
+
* // ...
|
|
16
|
+
* const root = find('div.with-shadowdom');
|
|
17
|
+
* assert.dom(findInShadow(root, 'h1')).containsText('welcome');
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
5
20
|
*/
|
|
6
21
|
export declare function findInShadow(root: Findable, query: string): Element | null | undefined;
|
|
7
22
|
/**
|
|
8
23
|
* Does the element have a shadow root?
|
|
24
|
+
*
|
|
25
|
+
* Using this utility function will only save a few characters over using its implementation directly.
|
|
26
|
+
*
|
|
27
|
+
* ```gjs
|
|
28
|
+
* import { hasShadowRoot } from 'ember-primitives/test-support';
|
|
29
|
+
*
|
|
30
|
+
* // ...
|
|
31
|
+
*
|
|
32
|
+
* test('...', async function (assert) {
|
|
33
|
+
* // ...
|
|
34
|
+
* const el = find('div.with-shadowdom');
|
|
35
|
+
* assert.ok(hasShadowRoot(el), 'expecting el to have a shadow root');
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
9
38
|
*/
|
|
10
39
|
export declare function hasShadowRoot(el: Element): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Find an element within `root`, that has a shadow root.
|
|
42
|
+
* The `root` param is optional, and if not provided, all of `#ember-testing` will be searched.
|
|
43
|
+
*
|
|
44
|
+
* This only returns the first-found shadow, so if you want a specifc shadow root,
|
|
45
|
+
* you'll need to narrow down the search by specifying a `root`.
|
|
46
|
+
*
|
|
47
|
+
* ```gjs
|
|
48
|
+
* import { findShadow } from 'ember-primitives/test-support';
|
|
49
|
+
*
|
|
50
|
+
* // ...
|
|
51
|
+
*
|
|
52
|
+
* test('...', async function (assert) {
|
|
53
|
+
* // ...
|
|
54
|
+
* const el = findShadow('div.with-shadowdom');
|
|
55
|
+
* // ...
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
11
59
|
export declare function findShadow(root?: Findable): Element | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* For the first available shadow root on the page, query in to it, like you would with `querySelector`.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* ```gjs
|
|
65
|
+
* import { findInFirstShadow } from 'ember-primitives/test-support';
|
|
66
|
+
*
|
|
67
|
+
* // ...
|
|
68
|
+
*
|
|
69
|
+
* test('...', async function (assert) {
|
|
70
|
+
* // ...
|
|
71
|
+
* assert.dom(findInFirstShadow('h1')).containsText('welcome');
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* If there are multiple shadow roots on the page / test-render,
|
|
76
|
+
* this is not the utility for you.
|
|
77
|
+
*
|
|
78
|
+
* For querying in specific shadow roots, you'll want to use `findInShadow`
|
|
79
|
+
*/
|
|
12
80
|
export declare function findInFirstShadow(query: string): Element | null | undefined;
|
|
13
81
|
export {};
|
|
14
82
|
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/test-support/dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/test-support/dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAIzD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,WAExC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,uBAczC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,8BAM9C"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Fill the OTP input
|
|
3
|
+
*
|
|
4
|
+
* ```gjs
|
|
5
|
+
* import { fillOTP } from 'ember-primitives/test-support';
|
|
6
|
+
*
|
|
7
|
+
* test('...', async function(assert) {
|
|
8
|
+
* // ...
|
|
9
|
+
* await fillOTP('123456');
|
|
10
|
+
* // ...
|
|
11
|
+
* })
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
2
15
|
* @param {string} code the code to fill the input(s) with.
|
|
3
16
|
* @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.
|
|
4
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["../../src/test-support/otp.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["../../src/test-support/otp.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,iBA2C5D"}
|
|
@@ -28,5 +28,8 @@ import type RouterService from '@ember/routing/router-service';
|
|
|
28
28
|
export declare function setupRouting(owner: Owner, map: DSLCallback, options?: {
|
|
29
29
|
rootURL: string;
|
|
30
30
|
}): void;
|
|
31
|
+
/**
|
|
32
|
+
* A small utility that only gives you a _typed_ router service.
|
|
33
|
+
*/
|
|
31
34
|
export declare function getRouter(owner: Owner): RouterService;
|
|
32
35
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/test-support/routing.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,QAqBzF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAErD"}
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/test-support/routing.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,QAqBzF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAErD"}
|
|
@@ -1,93 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import { assert } from '@ember/debug';
|
|
4
3
|
import { element } from 'ember-element-helper';
|
|
4
|
+
import { getSectionHeadingLevel } from 'which-heading-do-i-need';
|
|
5
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
7
|
|
|
8
|
-
const LOOKUP = new WeakMap();
|
|
9
|
-
const BOUNDARY_ELEMENTS = new Set(["SECTION", "ARTICLE", "ASIDE", "HEADER", "FOOTER", "MAIN", "NAV"]);
|
|
10
|
-
/**
|
|
11
|
-
* A set with both cases is more performant than calling toLowerCase
|
|
12
|
-
*/
|
|
13
|
-
const SECTION_HEADINGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6", "H1", "H2", "H3", "H4", "H5", "H6"]);
|
|
14
|
-
const TEST_BOUNDARY = "ember-testing";
|
|
15
|
-
function isRoot(element) {
|
|
16
|
-
return element === document.body || element.id === TEST_BOUNDARY;
|
|
17
|
-
}
|
|
18
|
-
function findHeadingIn(node) {
|
|
19
|
-
if (!(node instanceof Element)) return;
|
|
20
|
-
if (SECTION_HEADINGS.has(node.tagName)) {
|
|
21
|
-
const level = parseInt(node.tagName.replace("h", "").replace("H", ""));
|
|
22
|
-
return level;
|
|
23
|
-
}
|
|
24
|
-
for (const child of node.children) {
|
|
25
|
-
const level = findHeadingIn(child);
|
|
26
|
-
if (level) return level;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The Platform native 'closest' function can't punch through shadow-boundaries
|
|
31
|
-
*/
|
|
32
|
-
function nearestAncestor(node, matcher) {
|
|
33
|
-
let parent = node.parentElement;
|
|
34
|
-
if (!parent) return;
|
|
35
|
-
while (parent) {
|
|
36
|
-
if (parent instanceof Element) {
|
|
37
|
-
if (matcher(parent)) return parent;
|
|
38
|
-
}
|
|
39
|
-
if (parent instanceof ShadowRoot) {
|
|
40
|
-
parent = parent.host;
|
|
41
|
-
}
|
|
42
|
-
parent = parent.parentNode;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The algorithm:
|
|
47
|
-
*
|
|
48
|
-
* section <- "our" level-changing boundary element
|
|
49
|
-
* h# <- the element we want to figure out the level of
|
|
50
|
-
*
|
|
51
|
-
* We start assuming we'll emit an h1.
|
|
52
|
-
* We adjust this based on what we find crawling up the tree.
|
|
53
|
-
*
|
|
54
|
-
* While traversing up, when we go from the h# to the section,
|
|
55
|
-
* and ignore it. Because this alone has no bearing on if the h# should be an h2.
|
|
56
|
-
* We need to continue traversing upwards, until we hit the next boundary element.
|
|
57
|
-
*
|
|
58
|
-
* IF we would change the level the heading, we will find another heading between
|
|
59
|
-
* these two boundary elements.
|
|
60
|
-
* We'll need to check the subtrees between these elements, stopping if we
|
|
61
|
-
* encounter other boundary elements.
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
function levelOf(node) {
|
|
65
|
-
const ourBoundary = nearestAncestor(node, el => BOUNDARY_ELEMENTS.has(el.tagName));
|
|
66
|
-
/**
|
|
67
|
-
* We are the top-level
|
|
68
|
-
*/
|
|
69
|
-
if (!ourBoundary) {
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
const stopAt = nearestAncestor(ourBoundary, el => {
|
|
73
|
-
if (BOUNDARY_ELEMENTS.has(el.tagName)) return true;
|
|
74
|
-
return isRoot(el);
|
|
75
|
-
});
|
|
76
|
-
assert(`[BUG]: Could not find a stopping boundary for automatic heading level detection. Checked for ${[...BOUNDARY_ELEMENTS, "body", "#ember-testing"].map(x => x.toLowerCase()).join(", ")}`, stopAt);
|
|
77
|
-
let current = ourBoundary.parentNode;
|
|
78
|
-
while (current) {
|
|
79
|
-
const level = findHeadingIn(current);
|
|
80
|
-
if (level) {
|
|
81
|
-
return level + 1;
|
|
82
|
-
}
|
|
83
|
-
if (current === stopAt) break;
|
|
84
|
-
if (current instanceof ShadowRoot) {
|
|
85
|
-
current = current.host;
|
|
86
|
-
}
|
|
87
|
-
current = current.parentNode;
|
|
88
|
-
}
|
|
89
|
-
return 1;
|
|
90
|
-
}
|
|
91
8
|
class Heading extends Component {
|
|
92
9
|
headingScopeAnchor;
|
|
93
10
|
constructor(owner, args) {
|
|
@@ -95,12 +12,7 @@ class Heading extends Component {
|
|
|
95
12
|
this.headingScopeAnchor = document.createTextNode("");
|
|
96
13
|
}
|
|
97
14
|
get level() {
|
|
98
|
-
|
|
99
|
-
if (existing) return existing;
|
|
100
|
-
const parentLevel = levelOf(this.headingScopeAnchor);
|
|
101
|
-
const myLevel = parentLevel;
|
|
102
|
-
LOOKUP.set(this.headingScopeAnchor, myLevel);
|
|
103
|
-
return myLevel;
|
|
15
|
+
return getSectionHeadingLevel(this.headingScopeAnchor);
|
|
104
16
|
}
|
|
105
17
|
get hLevel() {
|
|
106
18
|
return `h${this.level}`;
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { Popover } from './components/popover.js';
|
|
|
14
14
|
export { Portal } from './components/portal.js';
|
|
15
15
|
export { TARGETS as PORTALS, PortalTargets } from './components/portal-targets.js';
|
|
16
16
|
export { Progress } from './components/progress.js';
|
|
17
|
-
export { R as Rating } from './
|
|
17
|
+
export { R as Rating } from './rating-D052JWRa.js';
|
|
18
18
|
export { Scroller } from './components/scroller.js';
|
|
19
19
|
export { Shadowed } from './components/shadowed.js';
|
|
20
20
|
export { Switch } from './components/switch.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rating-D052JWRa.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/test-support.js
CHANGED
|
@@ -16,6 +16,27 @@ async function setup(owner) {
|
|
|
16
16
|
});
|
|
17
17
|
document.querySelector('#ember-testing')?.setAttribute('data-tabster', '{ "root": {} }');
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A QUnit test utility for setting up the tabbing utility that a few of the components in ember-primitive use for providing enhanced keyboard support.
|
|
22
|
+
*
|
|
23
|
+
* ```gjs
|
|
24
|
+
* import { module, test } from 'qunit';
|
|
25
|
+
* import { setupRenderingTest } from 'ember-qunit';
|
|
26
|
+
* import { setupTabster } from 'ember-primitives/test-support';
|
|
27
|
+
*
|
|
28
|
+
* module('your suite', function (hooks) {
|
|
29
|
+
* setupRenderingTest(hooks);
|
|
30
|
+
* setupTabster(hooks);
|
|
31
|
+
*
|
|
32
|
+
* test('your test', async function (assert) {
|
|
33
|
+
* // ...
|
|
34
|
+
* });
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* This utility takes no options.
|
|
39
|
+
*/
|
|
19
40
|
function setupTabster(hooks) {
|
|
20
41
|
hooks.beforeEach(async function () {
|
|
21
42
|
const owner = this.owner;
|
|
@@ -25,7 +46,22 @@ function setupTabster(hooks) {
|
|
|
25
46
|
}
|
|
26
47
|
|
|
27
48
|
/**
|
|
28
|
-
* Find an element within a shadow-root.
|
|
49
|
+
* Find an element within a given element that has a shadow-root.
|
|
50
|
+
*
|
|
51
|
+
* If the `root` can't be found, or if there actually is no shadow root,
|
|
52
|
+
* nothing will be returned.
|
|
53
|
+
*
|
|
54
|
+
* ```gjs
|
|
55
|
+
* import { findInShadow } from 'ember-primitives/test-support';
|
|
56
|
+
*
|
|
57
|
+
* // ...
|
|
58
|
+
*
|
|
59
|
+
* test('...', async function (assert) {
|
|
60
|
+
* // ...
|
|
61
|
+
* const root = find('div.with-shadowdom');
|
|
62
|
+
* assert.dom(findInShadow(root, 'h1')).containsText('welcome');
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
29
65
|
*/
|
|
30
66
|
function findInShadow(root, query) {
|
|
31
67
|
const rootElement = root instanceof Element ? root : find(root);
|
|
@@ -34,10 +70,44 @@ function findInShadow(root, query) {
|
|
|
34
70
|
|
|
35
71
|
/**
|
|
36
72
|
* Does the element have a shadow root?
|
|
73
|
+
*
|
|
74
|
+
* Using this utility function will only save a few characters over using its implementation directly.
|
|
75
|
+
*
|
|
76
|
+
* ```gjs
|
|
77
|
+
* import { hasShadowRoot } from 'ember-primitives/test-support';
|
|
78
|
+
*
|
|
79
|
+
* // ...
|
|
80
|
+
*
|
|
81
|
+
* test('...', async function (assert) {
|
|
82
|
+
* // ...
|
|
83
|
+
* const el = find('div.with-shadowdom');
|
|
84
|
+
* assert.ok(hasShadowRoot(el), 'expecting el to have a shadow root');
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
37
87
|
*/
|
|
38
88
|
function hasShadowRoot(el) {
|
|
39
89
|
return Boolean(el.shadowRoot);
|
|
40
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Find an element within `root`, that has a shadow root.
|
|
94
|
+
* The `root` param is optional, and if not provided, all of `#ember-testing` will be searched.
|
|
95
|
+
*
|
|
96
|
+
* This only returns the first-found shadow, so if you want a specifc shadow root,
|
|
97
|
+
* you'll need to narrow down the search by specifying a `root`.
|
|
98
|
+
*
|
|
99
|
+
* ```gjs
|
|
100
|
+
* import { findShadow } from 'ember-primitives/test-support';
|
|
101
|
+
*
|
|
102
|
+
* // ...
|
|
103
|
+
*
|
|
104
|
+
* test('...', async function (assert) {
|
|
105
|
+
* // ...
|
|
106
|
+
* const el = findShadow('div.with-shadowdom');
|
|
107
|
+
* // ...
|
|
108
|
+
* });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
41
111
|
function findShadow(root) {
|
|
42
112
|
const rootElement = root ? root instanceof Element ? root : find(root) : document.getElementById('ember-testing');
|
|
43
113
|
if (!rootElement) return;
|
|
@@ -47,6 +117,27 @@ function findShadow(root) {
|
|
|
47
117
|
}
|
|
48
118
|
}
|
|
49
119
|
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* For the first available shadow root on the page, query in to it, like you would with `querySelector`.
|
|
123
|
+
*
|
|
124
|
+
*
|
|
125
|
+
* ```gjs
|
|
126
|
+
* import { findInFirstShadow } from 'ember-primitives/test-support';
|
|
127
|
+
*
|
|
128
|
+
* // ...
|
|
129
|
+
*
|
|
130
|
+
* test('...', async function (assert) {
|
|
131
|
+
* // ...
|
|
132
|
+
* assert.dom(findInFirstShadow('h1')).containsText('welcome');
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* If there are multiple shadow roots on the page / test-render,
|
|
137
|
+
* this is not the utility for you.
|
|
138
|
+
*
|
|
139
|
+
* For querying in specific shadow roots, you'll want to use `findInShadow`
|
|
140
|
+
*/
|
|
50
141
|
function findInFirstShadow(query) {
|
|
51
142
|
const host = findShadow();
|
|
52
143
|
assert(`No element with a shadow root could be found`, host);
|
|
@@ -54,6 +145,19 @@ function findInFirstShadow(query) {
|
|
|
54
145
|
}
|
|
55
146
|
|
|
56
147
|
/**
|
|
148
|
+
* Fill the OTP input
|
|
149
|
+
*
|
|
150
|
+
* ```gjs
|
|
151
|
+
* import { fillOTP } from 'ember-primitives/test-support';
|
|
152
|
+
*
|
|
153
|
+
* test('...', async function(assert) {
|
|
154
|
+
* // ...
|
|
155
|
+
* await fillOTP('123456');
|
|
156
|
+
* // ...
|
|
157
|
+
* })
|
|
158
|
+
*
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
57
161
|
* @param {string} code the code to fill the input(s) with.
|
|
58
162
|
* @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.
|
|
59
163
|
*/
|
|
@@ -209,6 +313,10 @@ function setupRouting(owner, map, options) {
|
|
|
209
313
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
210
314
|
iKnowWhatIMDoing.setupRouter();
|
|
211
315
|
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* A small utility that only gives you a _typed_ router service.
|
|
319
|
+
*/
|
|
212
320
|
function getRouter(owner) {
|
|
213
321
|
return owner.lookup('service:router');
|
|
214
322
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Making apps easier to build",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"should-handle-link": "^1.2.2",
|
|
26
26
|
"tabster": "^8.5.5",
|
|
27
27
|
"tracked-built-ins": "^4.0.0",
|
|
28
|
-
"tracked-toolbox": "^2.0.0"
|
|
28
|
+
"tracked-toolbox": "^2.0.0",
|
|
29
|
+
"which-heading-do-i-need": "0.1.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@arethetypeswrong/cli": "^0.18.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/rating/index.gts"],"names":[],"mappings":"AAoNA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAK3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,SAAS;IAOxB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG;QACrC;;;;WAIG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;QAEb;;;;WAIG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;QAEf;;;;WAIG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QAEnB;;;;;;WAMG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;QAEtB;;;WAGG;QACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KACpC,CAAC;IAEF,MAAM,EAAE;QACN,OAAO,EAAE;YACP,MAAM,EAAE;gBACN;;mBAEG;gBACH,GAAG,EAAE,MAAM,CAAC;gBACZ;;mBAEG;gBACH,KAAK,EAAE,MAAM,CAAC;gBACd;;mBAEG;gBACH,KAAK,EAAE,MAAM,CAAC;gBACd;;mBAEG;gBACH,IAAI,EAAE,MAAM,CAAC;gBACb;;mBAEG;gBACH,UAAU,EAAE,OAAO,CAAC;gBACpB;;mBAEG;gBACH,YAAY,EAAE,OAAO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