@raylang/elements 0.4.1 → 0.5.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/core/host.js +5 -4
- package/core/raylang.js +11 -14
- package/package.json +1 -1
package/core/host.js
CHANGED
|
@@ -64,10 +64,11 @@ const INTERACTIVE = "button, a[href], input, select, textarea, label, summary, [
|
|
|
64
64
|
/**
|
|
65
65
|
* Makes `el` drag the window when the page runs under a host's title bar
|
|
66
66
|
* (titlebar() is not null): it gets data-ray-drag, the attribute the std/ui
|
|
67
|
-
* shell reads. The shell
|
|
68
|
-
*
|
|
69
|
-
* inside `el` (a
|
|
70
|
-
* until the pointer is up. Returns the
|
|
67
|
+
* shell reads. The shell walks the event's composed path, but only spares
|
|
68
|
+
* buttons, links and form fields; for a pointer down on anything else
|
|
69
|
+
* interactive inside `el` (a tab, a summary, a [role=button] in a shadow
|
|
70
|
+
* root) the attribute steps aside until the pointer is up. Returns the
|
|
71
|
+
* function that undoes it.
|
|
71
72
|
*/
|
|
72
73
|
export function dragRegion(el) {
|
|
73
74
|
const guard = (e) => {
|
package/core/raylang.js
CHANGED
|
@@ -29,9 +29,8 @@ const MAC_BUTTONS = 78;
|
|
|
29
29
|
* long to wait for that answer; `ray` replaces window.ray (tests).
|
|
30
30
|
* `windowColors` (default true) keeps the window's background in the
|
|
31
31
|
* theme's background color, so a resize or a reopen never shows the other
|
|
32
|
-
* theme. The title bar is tinted too
|
|
33
|
-
*
|
|
34
|
-
* the system's, so the page keeps following the system.
|
|
32
|
+
* theme. The title bar is tinted too when the theme is light or dark: with
|
|
33
|
+
* "system" it stays the system's, so the page keeps following the system.
|
|
35
34
|
*/
|
|
36
35
|
export function enableRaylang({ timeout = 2000, ray = globalThis.ray, windowColors = true } = {}) {
|
|
37
36
|
if (ray !== globalThis.ray) return connect(ray, timeout, windowColors);
|
|
@@ -114,22 +113,20 @@ async function connect(ray, timeout, windowColors) {
|
|
|
114
113
|
if (windowColors && ops.has("window_colors")) {
|
|
115
114
|
// A title bar color also sets the window's appearance (macOS picks light
|
|
116
115
|
// or dark by its luminance), which the page's prefers-color-scheme
|
|
117
|
-
// follows
|
|
118
|
-
//
|
|
119
|
-
//
|
|
116
|
+
// follows. So the bar is tinted only for a chosen theme (light or dark),
|
|
117
|
+
// and given back to the system once after that. In a full_content window
|
|
118
|
+
// the bar stays transparent either way.
|
|
120
119
|
let tinted = false;
|
|
121
120
|
const paint = (theme) => {
|
|
122
121
|
const background = hex(theme.background);
|
|
123
122
|
if (!background) return;
|
|
124
123
|
const colors = { background };
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
tinted = false;
|
|
132
|
-
}
|
|
124
|
+
if (getTheme() !== "system") {
|
|
125
|
+
colors.titlebar = background;
|
|
126
|
+
tinted = true;
|
|
127
|
+
} else if (tinted) {
|
|
128
|
+
colors.titlebar = "";
|
|
129
|
+
tinted = false;
|
|
133
130
|
}
|
|
134
131
|
host.setWindowColors(colors).catch(() => {});
|
|
135
132
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raylang/elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Web components for any app, with raylang extras (shadcn/ui + Mantine inspired)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": ["web-components", "custom-elements", "design-system", "ui", "raylang"],
|