ember-primitives 0.42.0 → 0.43.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.
|
@@ -31,6 +31,7 @@ export declare const colorScheme: {
|
|
|
31
31
|
export declare function sync(): void;
|
|
32
32
|
/**
|
|
33
33
|
* Helper methods to determining what the user's preferred color scheme is
|
|
34
|
+
* based on the system preferences rather than the users explicit preference.
|
|
34
35
|
*/
|
|
35
36
|
export declare const prefers: {
|
|
36
37
|
dark: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;oBACa,MAAM;;QAOpB;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;;QAKhD;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;IAKlD;;OAEG;aACY,MAAM,GAAG,SAAS;CAelC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,IAAI,
|
|
1
|
+
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;oBACa,MAAM;;QAOpB;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;;QAKhD;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;IAKlD;;OAEG;aACY,MAAM,GAAG,SAAS;CAelC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,IAAI,SAyBnB;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO;;;mBAGH,MAAM;;CAEtB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,eAAe;;;oBAGV,MAAM;;CAEvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,UAInD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;AAkBpD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,WAAW,QAItD"}
|
|
@@ -27,7 +27,7 @@ export declare class Provide<Data extends object> extends Component<{
|
|
|
27
27
|
};
|
|
28
28
|
}> {
|
|
29
29
|
get data(): Data;
|
|
30
|
-
element:
|
|
30
|
+
element: Text;
|
|
31
31
|
constructor(owner: Owner, args: {
|
|
32
32
|
data: Data | (() => Data) | Newable<Data>;
|
|
33
33
|
key?: string;
|
|
@@ -47,7 +47,7 @@ export declare class Consume<Key extends object | string> extends Component<{
|
|
|
47
47
|
};
|
|
48
48
|
}> {
|
|
49
49
|
getData: () => DataForKey<Key>;
|
|
50
|
-
element:
|
|
50
|
+
element: Text;
|
|
51
51
|
constructor(owner: Owner, args: {
|
|
52
52
|
key: Key;
|
|
53
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-context.d.ts","sourceRoot":"","sources":["../src/dom-context.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom-context.d.ts","sourceRoot":"","sources":["../src/dom-context.gts"],"names":[],"mappings":"AAwLA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAM3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAmBtC,qBAAa,OAAO,CAAC,IAAI,SAAS,MAAM,CAAE,SAAQ,SAAS,CAAC;IAC1D,IAAI,EAAE;QACJ;;;;;WAKG;QACH,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAE1C;;;;;;WAMG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE;QACN;;WAEG;QACH,OAAO,EAAE,EAAE,CAAC;KACb,CAAC;CACH,CAAC;IACA,IAAI,IAAI,SAcP;IAED,OAAO,EAAE,IAAI,CAAC;gBAGZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;KACd;CAiBJ;AAmCD,KAAK,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,MAAM,GACrC,OAAO,GACP,GAAG,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAC1B,CAAC,GACD,GAAG,SAAS,MAAM,MAAM,CAAC,GACvB,CAAC,GACD,GAAG,CAAC;AAEZ,qBAAa,OAAO,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC;IAClE,IAAI,EAAE;QACJ,GAAG,EAAE,GAAG,CAAC;KACV,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;aACvB;SACF,CAAC;KACH,CAAC;CACH,CAAC;IAES,OAAO,EAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAEzC,OAAO,EAAE,IAAI,CAAC;gBAEF,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE;IAM5C,IACI,OAAO;uBAKK,UAAU,CAAC,GAAG,CAAC;MAa9B;CAOF"}
|
package/dist/color-scheme.js
CHANGED
|
@@ -69,15 +69,10 @@ function sync() {
|
|
|
69
69
|
/**
|
|
70
70
|
* If local prefs are set, then we don't care what prefers-color-scheme is
|
|
71
71
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_colorScheme.current = 'dark';
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
setColorScheme('light');
|
|
80
|
-
_colorScheme.current = 'light';
|
|
72
|
+
const userPreference = localPreference.read();
|
|
73
|
+
if (userPreference) {
|
|
74
|
+
setColorScheme(userPreference);
|
|
75
|
+
_colorScheme.current = userPreference;
|
|
81
76
|
return;
|
|
82
77
|
}
|
|
83
78
|
if (prefers.dark()) {
|
|
@@ -91,6 +86,7 @@ function sync() {
|
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
88
|
* Helper methods to determining what the user's preferred color scheme is
|
|
89
|
+
* based on the system preferences rather than the users explicit preference.
|
|
94
90
|
*/
|
|
95
91
|
const prefers = {
|
|
96
92
|
dark: () => window.matchMedia('(prefers-color-scheme: dark)').matches,
|
package/dist/dom-context.js
CHANGED
|
@@ -25,28 +25,41 @@ class Provide extends Component {
|
|
|
25
25
|
element;
|
|
26
26
|
constructor(owner, args) {
|
|
27
27
|
super(owner, args);
|
|
28
|
-
const element = document.
|
|
29
|
-
element.style.display = "contents";
|
|
28
|
+
const element = document.createTextNode("");
|
|
30
29
|
const key = this.args.key ?? this.args.data;
|
|
31
30
|
LOOKUP.set(element, [key, () => this.data]);
|
|
32
31
|
this.element = element;
|
|
33
32
|
}
|
|
34
33
|
static {
|
|
35
|
-
setComponentTemplate(precompileTemplate("\n {{this.element}}\n
|
|
34
|
+
setComponentTemplate(precompileTemplate("\n {{this.element}}\n {{yield}}\n ", {
|
|
36
35
|
strictMode: true
|
|
37
36
|
}), this);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* How this works:
|
|
41
|
+
* - starting at some deep node (Text, Element, whatever),
|
|
42
|
+
* start crawling up the ancenstry graph (of DOM Nodes).
|
|
43
|
+
* - for each DOM node crawled upward, check all previous siblings to see if one matches the requested *key*
|
|
44
|
+
*
|
|
45
|
+
* - This algo "tops out" (since we traverse upwards (otherwise this would be "bottoming out")) at the HTMLDocument (parent of the HTML Tag)
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
40
48
|
function findForKey(startElement, key) {
|
|
41
49
|
let parent = startElement;
|
|
42
|
-
while (parent
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
continue;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
while (parent) {
|
|
51
|
+
let target = parent;
|
|
52
|
+
while (target = target?.previousSibling) {
|
|
53
|
+
if (!(target instanceof Text)) continue;
|
|
54
|
+
const maybe = LOOKUP.get(target);
|
|
55
|
+
if (!maybe) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (maybe[0] === key) {
|
|
59
|
+
return maybe[1];
|
|
60
|
+
}
|
|
49
61
|
}
|
|
62
|
+
parent = parent.parentElement;
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
class Consume extends Component {
|
|
@@ -57,8 +70,7 @@ class Consume extends Component {
|
|
|
57
70
|
element;
|
|
58
71
|
constructor(owner, args) {
|
|
59
72
|
super(owner, args);
|
|
60
|
-
this.element = document.
|
|
61
|
-
this.element.style.display = "contents";
|
|
73
|
+
this.element = document.createTextNode("");
|
|
62
74
|
}
|
|
63
75
|
get context() {
|
|
64
76
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
@@ -77,7 +89,7 @@ class Consume extends Component {
|
|
|
77
89
|
n(this.prototype, "context", [cached]);
|
|
78
90
|
}
|
|
79
91
|
static {
|
|
80
|
-
setComponentTemplate(precompileTemplate("\n {{this.element}}\n\n {{
|
|
92
|
+
setComponentTemplate(precompileTemplate("\n {{this.element}}\n\n {{yield this.context}}\n ", {
|
|
81
93
|
strictMode: true
|
|
82
94
|
}), this);
|
|
83
95
|
}
|