ember-primitives 0.43.1 → 0.44.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.
@@ -0,0 +1,14 @@
1
+ import Component from "@glimmer/component";
2
+ import type Owner from "@ember/owner";
3
+ export declare class Heading extends Component<{
4
+ Element: HTMLElement;
5
+ Blocks: {
6
+ default: [];
7
+ };
8
+ }> {
9
+ headingScopeAnchor: Text;
10
+ constructor(owner: Owner, args: object);
11
+ get level(): number;
12
+ get hLevel(): string;
13
+ }
14
+ //# sourceMappingURL=heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.gts"],"names":[],"mappings":"AAmEA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAI3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAyBtC,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,IAAI,KAAK,WAWR;IAED,IAAI,MAAM,WAET;CAqBF"}
@@ -0,0 +1,52 @@
1
+
2
+ import Component from '@glimmer/component';
3
+ import { element } from 'ember-element-helper';
4
+ import { precompileTemplate } from '@ember/template-compilation';
5
+ import { setComponentTemplate } from '@ember/component';
6
+
7
+ const LOOKUP = new WeakMap();
8
+ function levelOf(node) {
9
+ let parent = node.parentElement;
10
+ let level = 0;
11
+ while (parent) {
12
+ if (parent instanceof Element) {
13
+ if (parent.tagName.toLowerCase() === "section") {
14
+ level++;
15
+ }
16
+ }
17
+ if (parent instanceof ShadowRoot) {
18
+ parent = parent.host;
19
+ }
20
+ parent = parent.parentNode;
21
+ }
22
+ return level;
23
+ }
24
+ class Heading extends Component {
25
+ headingScopeAnchor;
26
+ constructor(owner, args) {
27
+ super(owner, args);
28
+ this.headingScopeAnchor = document.createTextNode("");
29
+ }
30
+ get level() {
31
+ const existing = LOOKUP.get(this.headingScopeAnchor);
32
+ if (existing) return existing;
33
+ const parentLevel = levelOf(this.headingScopeAnchor);
34
+ const myLevel = parentLevel + 1;
35
+ LOOKUP.set(this.headingScopeAnchor, myLevel);
36
+ return myLevel;
37
+ }
38
+ get hLevel() {
39
+ return `h${this.level}`;
40
+ }
41
+ static {
42
+ setComponentTemplate(precompileTemplate("\n {{this.headingScopeAnchor}}\n\n {{#let (element this.hLevel) as |El|}}\n <El ...attributes>\n {{yield}}\n </El>\n {{/let}}\n ", {
43
+ strictMode: true,
44
+ scope: () => ({
45
+ element
46
+ })
47
+ }), this);
48
+ }
49
+ }
50
+
51
+ export { Heading };
52
+ //# sourceMappingURL=heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-primitives",
3
- "version": "0.43.1",
3
+ "version": "0.44.0",
4
4
  "description": "Making apps easier to build",
5
5
  "keywords": [
6
6
  "ember-addon"