liqgui 0.1.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/README.md +190 -0
- package/dist/components/glass-accordion.d.ts +15 -0
- package/dist/components/glass-accordion.js +173 -0
- package/dist/components/glass-avatar.d.ts +9 -0
- package/dist/components/glass-avatar.js +98 -0
- package/dist/components/glass-badge.d.ts +10 -0
- package/dist/components/glass-badge.js +151 -0
- package/dist/components/glass-button.d.ts +6 -0
- package/dist/components/glass-button.js +124 -0
- package/dist/components/glass-card.d.ts +8 -0
- package/dist/components/glass-card.js +102 -0
- package/dist/components/glass-dropdown.d.ts +12 -0
- package/dist/components/glass-dropdown.js +182 -0
- package/dist/components/glass-input.d.ts +8 -0
- package/dist/components/glass-input.js +151 -0
- package/dist/components/glass-modal.d.ts +11 -0
- package/dist/components/glass-modal.js +128 -0
- package/dist/components/glass-navbar.d.ts +6 -0
- package/dist/components/glass-navbar.js +84 -0
- package/dist/components/glass-progress.d.ts +12 -0
- package/dist/components/glass-progress.js +159 -0
- package/dist/components/glass-slider.d.ts +17 -0
- package/dist/components/glass-slider.js +168 -0
- package/dist/components/glass-tabs.d.ts +7 -0
- package/dist/components/glass-tabs.js +102 -0
- package/dist/components/glass-toast.d.ts +8 -0
- package/dist/components/glass-toast.js +128 -0
- package/dist/components/glass-toggle.d.ts +9 -0
- package/dist/components/glass-toggle.js +112 -0
- package/dist/components/glass-tooltip.d.ts +14 -0
- package/dist/components/glass-tooltip.js +214 -0
- package/dist/core/base-element.d.ts +4 -0
- package/dist/core/base-element.js +9 -0
- package/dist/core/curves.d.ts +22 -0
- package/dist/core/curves.js +32 -0
- package/dist/core/focus-trap.d.ts +1 -0
- package/dist/core/focus-trap.js +19 -0
- package/dist/core/glow.d.ts +3 -0
- package/dist/core/glow.js +57 -0
- package/dist/core/motion.d.ts +12 -0
- package/dist/core/motion.js +54 -0
- package/dist/core/spring-engine.d.ts +12 -0
- package/dist/core/spring-engine.js +90 -0
- package/dist/core/supports.d.ts +1 -0
- package/dist/core/supports.js +1 -0
- package/dist/core/theme.d.ts +2 -0
- package/dist/core/theme.js +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +40 -0
- package/package.json +47 -0
- package/src/styles/tokens.css +140 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
import { glowCSS, createRipple } from "../core/glow.js";
|
|
3
|
+
import { springAnimate, bouncySpring } from "../core/spring-engine.js";
|
|
4
|
+
export class GlassButton extends BaseElement {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ["variant", "disabled", "loading"];
|
|
7
|
+
}
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
const variant = this.getAttribute("variant") || "default";
|
|
10
|
+
this.mount(`
|
|
11
|
+
<button part="button">
|
|
12
|
+
<span class="glow"></span>
|
|
13
|
+
<span class="ripple-container"></span>
|
|
14
|
+
<span class="content">
|
|
15
|
+
<span class="loader"></span>
|
|
16
|
+
<slot></slot>
|
|
17
|
+
</span>
|
|
18
|
+
</button>
|
|
19
|
+
`, `
|
|
20
|
+
:host {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
}
|
|
23
|
+
button {
|
|
24
|
+
position: relative;
|
|
25
|
+
padding: 0.75rem 1.5rem;
|
|
26
|
+
border-radius: 999px;
|
|
27
|
+
background: var(--lg-bg);
|
|
28
|
+
backdrop-filter: blur(var(--lg-blur));
|
|
29
|
+
border: 1px solid var(--lg-border);
|
|
30
|
+
color: inherit;
|
|
31
|
+
font: inherit;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
36
|
+
}
|
|
37
|
+
button:hover {
|
|
38
|
+
border-color: rgba(255, 255, 255, 0.5);
|
|
39
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
|
40
|
+
}
|
|
41
|
+
button:focus-visible {
|
|
42
|
+
outline: 2px solid var(--lg-accent-focus, #5ac8fa);
|
|
43
|
+
outline-offset: 2px;
|
|
44
|
+
}
|
|
45
|
+
button:disabled {
|
|
46
|
+
opacity: 0.5;
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
}
|
|
50
|
+
.glow { ${glowCSS("var(--lg-accent)")} }
|
|
51
|
+
button:hover .glow { opacity: 0.5; }
|
|
52
|
+
|
|
53
|
+
/* Variants */
|
|
54
|
+
:host([variant="primary"]) button {
|
|
55
|
+
background: var(--lg-accent);
|
|
56
|
+
border-color: transparent;
|
|
57
|
+
color: white;
|
|
58
|
+
}
|
|
59
|
+
:host([variant="ghost"]) button {
|
|
60
|
+
background: transparent;
|
|
61
|
+
border-color: transparent;
|
|
62
|
+
}
|
|
63
|
+
:host([variant="ghost"]) button:hover {
|
|
64
|
+
background: rgba(255, 255, 255, 0.1);
|
|
65
|
+
}
|
|
66
|
+
:host([variant="outline"]) button {
|
|
67
|
+
background: transparent;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Loading state */
|
|
71
|
+
.loader {
|
|
72
|
+
display: none;
|
|
73
|
+
width: 16px;
|
|
74
|
+
height: 16px;
|
|
75
|
+
border: 2px solid transparent;
|
|
76
|
+
border-top-color: currentColor;
|
|
77
|
+
border-radius: 50%;
|
|
78
|
+
margin-right: 8px;
|
|
79
|
+
animation: spin 0.8s linear infinite;
|
|
80
|
+
}
|
|
81
|
+
:host([loading]) .loader {
|
|
82
|
+
display: inline-block;
|
|
83
|
+
}
|
|
84
|
+
:host([loading]) button {
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.content {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes spin {
|
|
95
|
+
to { transform: rotate(360deg); }
|
|
96
|
+
}
|
|
97
|
+
`);
|
|
98
|
+
const btn = this.root.querySelector("button");
|
|
99
|
+
// Spring press animation
|
|
100
|
+
btn.addEventListener("mousedown", () => {
|
|
101
|
+
springAnimate(1, 0.95, v => btn.style.transform = `scale(${v})`, bouncySpring);
|
|
102
|
+
});
|
|
103
|
+
btn.addEventListener("mouseup", () => {
|
|
104
|
+
springAnimate(0.95, 1, v => btn.style.transform = `scale(${v})`, bouncySpring);
|
|
105
|
+
});
|
|
106
|
+
btn.addEventListener("mouseleave", () => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
springAnimate(parseFloat(((_b = (_a = btn.style.transform) === null || _a === void 0 ? void 0 : _a.match(/scale\(([\d.]+)\)/)) === null || _b === void 0 ? void 0 : _b[1]) || "1"), 1, v => btn.style.transform = `scale(${v})`, bouncySpring);
|
|
109
|
+
});
|
|
110
|
+
// Ripple effect
|
|
111
|
+
btn.addEventListener("click", (e) => {
|
|
112
|
+
if (!this.hasAttribute("disabled")) {
|
|
113
|
+
createRipple(e, btn);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
attributeChangedCallback(name, _old, value) {
|
|
118
|
+
const btn = this.root.querySelector("button");
|
|
119
|
+
if (btn && name === "disabled") {
|
|
120
|
+
btn.disabled = value !== null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
customElements.define("glass-button", GlassButton);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
export declare class GlassCard extends BaseElement {
|
|
3
|
+
private cancelTilt?;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
connectedCallback(): void;
|
|
6
|
+
private setupTiltEffect;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
import { springAnimateMulti, gentleSpring } from "../core/spring-engine.js";
|
|
3
|
+
export class GlassCard extends BaseElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["no-tilt", "glow"];
|
|
6
|
+
}
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
this.mount(`
|
|
9
|
+
<div class="card-glow"></div>
|
|
10
|
+
<div class="card-content">
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</div>
|
|
13
|
+
`, `
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
position: relative;
|
|
17
|
+
transform-style: preserve-3d;
|
|
18
|
+
perspective: 1000px;
|
|
19
|
+
}
|
|
20
|
+
.card-content {
|
|
21
|
+
position: relative;
|
|
22
|
+
background: var(--lg-bg);
|
|
23
|
+
backdrop-filter: blur(var(--lg-blur));
|
|
24
|
+
-webkit-backdrop-filter: blur(var(--lg-blur));
|
|
25
|
+
border-radius: var(--lg-radius);
|
|
26
|
+
border: 1px solid var(--lg-border);
|
|
27
|
+
box-shadow: var(--lg-shadow);
|
|
28
|
+
padding: 1.5rem;
|
|
29
|
+
transition: transform 0.1s ease-out, box-shadow 0.3s ease;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
.card-content::before {
|
|
33
|
+
content: "";
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
height: 1px;
|
|
39
|
+
background: linear-gradient(90deg,
|
|
40
|
+
transparent,
|
|
41
|
+
rgba(255, 255, 255, 0.5),
|
|
42
|
+
transparent
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
:host(:hover) .card-content {
|
|
46
|
+
box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
|
|
47
|
+
}
|
|
48
|
+
.card-glow {
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: -4px;
|
|
51
|
+
background: var(--lg-accent);
|
|
52
|
+
filter: blur(20px);
|
|
53
|
+
opacity: 0;
|
|
54
|
+
z-index: -1;
|
|
55
|
+
border-radius: var(--lg-radius);
|
|
56
|
+
transition: opacity 0.4s ease;
|
|
57
|
+
}
|
|
58
|
+
:host([glow]:hover) .card-glow {
|
|
59
|
+
opacity: 0.4;
|
|
60
|
+
}
|
|
61
|
+
`);
|
|
62
|
+
if (!this.hasAttribute("no-tilt")) {
|
|
63
|
+
this.setupTiltEffect();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
setupTiltEffect() {
|
|
67
|
+
const card = this.root.querySelector(".card-content");
|
|
68
|
+
let targetRotateX = 0;
|
|
69
|
+
let targetRotateY = 0;
|
|
70
|
+
let currentRotateX = 0;
|
|
71
|
+
let currentRotateY = 0;
|
|
72
|
+
const handleMove = (e) => {
|
|
73
|
+
const rect = this.getBoundingClientRect();
|
|
74
|
+
const centerX = rect.left + rect.width / 2;
|
|
75
|
+
const centerY = rect.top + rect.height / 2;
|
|
76
|
+
targetRotateX = ((e.clientY - centerY) / (rect.height / 2)) * -8;
|
|
77
|
+
targetRotateY = ((e.clientX - centerX) / (rect.width / 2)) * 8;
|
|
78
|
+
};
|
|
79
|
+
const handleLeave = () => {
|
|
80
|
+
this.cancelTilt = springAnimateMulti([currentRotateX, currentRotateY], [0, 0], ([rx, ry]) => {
|
|
81
|
+
currentRotateX = rx;
|
|
82
|
+
currentRotateY = ry;
|
|
83
|
+
card.style.transform = `rotateX(${rx}deg) rotateY(${ry}deg)`;
|
|
84
|
+
}, gentleSpring);
|
|
85
|
+
};
|
|
86
|
+
// Smooth animation loop for tilt
|
|
87
|
+
const animate = () => {
|
|
88
|
+
currentRotateX += (targetRotateX - currentRotateX) * 0.1;
|
|
89
|
+
currentRotateY += (targetRotateY - currentRotateY) * 0.1;
|
|
90
|
+
card.style.transform = `rotateX(${currentRotateX}deg) rotateY(${currentRotateY}deg)`;
|
|
91
|
+
requestAnimationFrame(animate);
|
|
92
|
+
};
|
|
93
|
+
this.addEventListener("mousemove", handleMove);
|
|
94
|
+
this.addEventListener("mouseleave", handleLeave);
|
|
95
|
+
animate();
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
var _a;
|
|
99
|
+
(_a = this.cancelTilt) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
customElements.define("glass-card", GlassCard);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
export declare class GlassDropdown extends BaseElement {
|
|
3
|
+
private isOpen;
|
|
4
|
+
private menuEl?;
|
|
5
|
+
static get observedAttributes(): string[];
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
private toggle;
|
|
8
|
+
open(): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
private selectOption;
|
|
11
|
+
private focusNextOption;
|
|
12
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
import { motion } from "../core/motion.js";
|
|
3
|
+
export class GlassDropdown extends BaseElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.isOpen = false;
|
|
7
|
+
}
|
|
8
|
+
static get observedAttributes() {
|
|
9
|
+
return ["open", "disabled"];
|
|
10
|
+
}
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
this.mount(`
|
|
13
|
+
<div class="dropdown">
|
|
14
|
+
<button class="trigger" aria-haspopup="listbox" aria-expanded="false">
|
|
15
|
+
<span class="label"><slot name="trigger">Select</slot></span>
|
|
16
|
+
<svg class="chevron" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
17
|
+
<path d="M6 9l6 6 6-6"/>
|
|
18
|
+
</svg>
|
|
19
|
+
</button>
|
|
20
|
+
<div class="menu" role="listbox">
|
|
21
|
+
<slot></slot>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
`, `
|
|
25
|
+
:host {
|
|
26
|
+
display: inline-block;
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
.dropdown {
|
|
30
|
+
position: relative;
|
|
31
|
+
}
|
|
32
|
+
.trigger {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: 0.5rem;
|
|
36
|
+
padding: 0.75rem 1rem;
|
|
37
|
+
min-width: 180px;
|
|
38
|
+
background: var(--lg-bg);
|
|
39
|
+
backdrop-filter: blur(var(--lg-blur));
|
|
40
|
+
border: 1px solid var(--lg-border);
|
|
41
|
+
border-radius: var(--lg-radius);
|
|
42
|
+
color: inherit;
|
|
43
|
+
font: inherit;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: all 0.2s ease;
|
|
46
|
+
}
|
|
47
|
+
.trigger:hover {
|
|
48
|
+
border-color: var(--lg-border-hover);
|
|
49
|
+
}
|
|
50
|
+
.trigger:focus-visible {
|
|
51
|
+
outline: 2px solid var(--lg-accent-focus);
|
|
52
|
+
outline-offset: 2px;
|
|
53
|
+
}
|
|
54
|
+
:host([disabled]) .trigger {
|
|
55
|
+
opacity: 0.5;
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
}
|
|
58
|
+
.label {
|
|
59
|
+
flex: 1;
|
|
60
|
+
text-align: left;
|
|
61
|
+
}
|
|
62
|
+
.chevron {
|
|
63
|
+
transition: transform 0.2s ease;
|
|
64
|
+
}
|
|
65
|
+
:host([open]) .chevron {
|
|
66
|
+
transform: rotate(180deg);
|
|
67
|
+
}
|
|
68
|
+
.menu {
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: calc(100% + 8px);
|
|
71
|
+
left: 0;
|
|
72
|
+
right: 0;
|
|
73
|
+
background: var(--lg-bg);
|
|
74
|
+
backdrop-filter: blur(var(--lg-blur));
|
|
75
|
+
border: 1px solid var(--lg-border);
|
|
76
|
+
border-radius: var(--lg-radius);
|
|
77
|
+
box-shadow: var(--lg-shadow);
|
|
78
|
+
padding: 0.5rem;
|
|
79
|
+
display: none;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: 0.25rem;
|
|
82
|
+
z-index: 1000;
|
|
83
|
+
max-height: 300px;
|
|
84
|
+
overflow-y: auto;
|
|
85
|
+
}
|
|
86
|
+
:host([open]) .menu {
|
|
87
|
+
display: flex;
|
|
88
|
+
}
|
|
89
|
+
::slotted(button),
|
|
90
|
+
::slotted([role="option"]) {
|
|
91
|
+
display: block;
|
|
92
|
+
width: 100%;
|
|
93
|
+
padding: 0.6rem 0.75rem;
|
|
94
|
+
background: transparent;
|
|
95
|
+
border: none;
|
|
96
|
+
border-radius: calc(var(--lg-radius) - 8px);
|
|
97
|
+
color: inherit;
|
|
98
|
+
font: inherit;
|
|
99
|
+
text-align: left;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
transition: background 0.15s ease;
|
|
102
|
+
}
|
|
103
|
+
::slotted(button:hover),
|
|
104
|
+
::slotted([role="option"]:hover) {
|
|
105
|
+
background: rgba(255, 255, 255, 0.1);
|
|
106
|
+
}
|
|
107
|
+
::slotted([aria-selected="true"]) {
|
|
108
|
+
background: rgba(255, 255, 255, 0.15);
|
|
109
|
+
}
|
|
110
|
+
`);
|
|
111
|
+
const trigger = this.root.querySelector(".trigger");
|
|
112
|
+
this.menuEl = this.root.querySelector(".menu");
|
|
113
|
+
trigger.addEventListener("click", () => {
|
|
114
|
+
if (!this.hasAttribute("disabled")) {
|
|
115
|
+
this.toggle();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// Close on outside click
|
|
119
|
+
document.addEventListener("click", (e) => {
|
|
120
|
+
if (!this.contains(e.target) && this.isOpen) {
|
|
121
|
+
this.close();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
// Handle option selection
|
|
125
|
+
this.addEventListener("click", (e) => {
|
|
126
|
+
const target = e.target;
|
|
127
|
+
if (target.matches("[role='option'], button:not(.trigger)")) {
|
|
128
|
+
this.selectOption(target);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// Keyboard navigation
|
|
132
|
+
this.addEventListener("keydown", (e) => {
|
|
133
|
+
if (e.key === "Escape")
|
|
134
|
+
this.close();
|
|
135
|
+
if (e.key === "ArrowDown" && this.isOpen) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
this.focusNextOption(1);
|
|
138
|
+
}
|
|
139
|
+
if (e.key === "ArrowUp" && this.isOpen) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
this.focusNextOption(-1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
toggle() {
|
|
146
|
+
this.isOpen ? this.close() : this.open();
|
|
147
|
+
}
|
|
148
|
+
open() {
|
|
149
|
+
var _a;
|
|
150
|
+
this.isOpen = true;
|
|
151
|
+
this.setAttribute("open", "");
|
|
152
|
+
(_a = this.root.querySelector(".trigger")) === null || _a === void 0 ? void 0 : _a.setAttribute("aria-expanded", "true");
|
|
153
|
+
if (this.menuEl)
|
|
154
|
+
motion.scaleIn(this.menuEl, 150);
|
|
155
|
+
}
|
|
156
|
+
close() {
|
|
157
|
+
var _a;
|
|
158
|
+
this.isOpen = false;
|
|
159
|
+
this.removeAttribute("open");
|
|
160
|
+
(_a = this.root.querySelector(".trigger")) === null || _a === void 0 ? void 0 : _a.setAttribute("aria-expanded", "false");
|
|
161
|
+
}
|
|
162
|
+
selectOption(option) {
|
|
163
|
+
// Update selection
|
|
164
|
+
this.querySelectorAll("[role='option']").forEach(opt => opt.setAttribute("aria-selected", "false"));
|
|
165
|
+
option.setAttribute("aria-selected", "true");
|
|
166
|
+
// Update trigger label
|
|
167
|
+
const label = this.root.querySelector(".label slot");
|
|
168
|
+
const triggerContent = option.textContent || "";
|
|
169
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
170
|
+
detail: { value: option.dataset.value || triggerContent, label: triggerContent },
|
|
171
|
+
bubbles: true
|
|
172
|
+
}));
|
|
173
|
+
this.close();
|
|
174
|
+
}
|
|
175
|
+
focusNextOption(direction) {
|
|
176
|
+
const options = Array.from(this.querySelectorAll("[role='option'], button"));
|
|
177
|
+
const current = options.findIndex(opt => opt === document.activeElement);
|
|
178
|
+
const next = options[current + direction];
|
|
179
|
+
next === null || next === void 0 ? void 0 : next.focus();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
customElements.define("glass-dropdown", GlassDropdown);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
export declare class GlassInput extends BaseElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
connectedCallback(): void;
|
|
5
|
+
get value(): string;
|
|
6
|
+
set value(val: string);
|
|
7
|
+
attributeChangedCallback(name: string, _old: string, value: string): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
export class GlassInput extends BaseElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ["placeholder", "type", "value", "disabled", "error"];
|
|
5
|
+
}
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
const placeholder = this.getAttribute("placeholder") || "";
|
|
8
|
+
const type = this.getAttribute("type") || "text";
|
|
9
|
+
const value = this.getAttribute("value") || "";
|
|
10
|
+
this.mount(`
|
|
11
|
+
<div class="input-wrapper">
|
|
12
|
+
<input type="${type}" placeholder="${placeholder}" value="${value}" />
|
|
13
|
+
<span class="focus-ring"></span>
|
|
14
|
+
<span class="error-icon">!</span>
|
|
15
|
+
</div>
|
|
16
|
+
<span class="error-message"><slot name="error"></slot></span>
|
|
17
|
+
`, `
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
.input-wrapper {
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
input {
|
|
25
|
+
width: 100%;
|
|
26
|
+
padding: 0.875rem 1rem;
|
|
27
|
+
border-radius: var(--lg-radius);
|
|
28
|
+
background: var(--lg-bg);
|
|
29
|
+
backdrop-filter: blur(var(--lg-blur));
|
|
30
|
+
-webkit-backdrop-filter: blur(var(--lg-blur));
|
|
31
|
+
border: 1px solid var(--lg-border);
|
|
32
|
+
color: inherit;
|
|
33
|
+
font: inherit;
|
|
34
|
+
outline: none;
|
|
35
|
+
transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
}
|
|
38
|
+
input::placeholder {
|
|
39
|
+
color: rgba(255, 255, 255, 0.4);
|
|
40
|
+
}
|
|
41
|
+
input:hover {
|
|
42
|
+
border-color: rgba(255, 255, 255, 0.4);
|
|
43
|
+
}
|
|
44
|
+
input:focus {
|
|
45
|
+
border-color: var(--lg-accent-focus, #5ac8fa);
|
|
46
|
+
box-shadow: 0 0 0 3px rgba(90, 200, 250, 0.2);
|
|
47
|
+
}
|
|
48
|
+
input:disabled {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Focus ring animation */
|
|
54
|
+
.focus-ring {
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset: -2px;
|
|
57
|
+
border-radius: calc(var(--lg-radius) + 2px);
|
|
58
|
+
border: 2px solid var(--lg-accent-focus, #5ac8fa);
|
|
59
|
+
opacity: 0;
|
|
60
|
+
transform: scale(0.98);
|
|
61
|
+
transition: all 0.2s ease;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
}
|
|
64
|
+
input:focus ~ .focus-ring {
|
|
65
|
+
opacity: 1;
|
|
66
|
+
transform: scale(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Error state */
|
|
70
|
+
:host([error]) input {
|
|
71
|
+
border-color: #ff453a;
|
|
72
|
+
}
|
|
73
|
+
:host([error]) input:focus {
|
|
74
|
+
box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.2);
|
|
75
|
+
}
|
|
76
|
+
.error-icon {
|
|
77
|
+
position: absolute;
|
|
78
|
+
right: 12px;
|
|
79
|
+
top: 50%;
|
|
80
|
+
transform: translateY(-50%);
|
|
81
|
+
width: 20px;
|
|
82
|
+
height: 20px;
|
|
83
|
+
background: #ff453a;
|
|
84
|
+
border-radius: 50%;
|
|
85
|
+
color: white;
|
|
86
|
+
font-size: 14px;
|
|
87
|
+
font-weight: bold;
|
|
88
|
+
display: none;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
}
|
|
92
|
+
:host([error]) .error-icon {
|
|
93
|
+
display: flex;
|
|
94
|
+
}
|
|
95
|
+
.error-message {
|
|
96
|
+
display: block;
|
|
97
|
+
color: #ff453a;
|
|
98
|
+
font-size: 0.85em;
|
|
99
|
+
margin-top: 0.5rem;
|
|
100
|
+
opacity: 0;
|
|
101
|
+
transform: translateY(-5px);
|
|
102
|
+
transition: all 0.2s ease;
|
|
103
|
+
}
|
|
104
|
+
:host([error]) .error-message {
|
|
105
|
+
opacity: 1;
|
|
106
|
+
transform: translateY(0);
|
|
107
|
+
}
|
|
108
|
+
`);
|
|
109
|
+
// Sync input events to host
|
|
110
|
+
const input = this.root.querySelector("input");
|
|
111
|
+
input.addEventListener("input", () => {
|
|
112
|
+
this.dispatchEvent(new CustomEvent("input", {
|
|
113
|
+
detail: { value: input.value },
|
|
114
|
+
bubbles: true
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
input.addEventListener("change", () => {
|
|
118
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
119
|
+
detail: { value: input.value },
|
|
120
|
+
bubbles: true
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
get value() {
|
|
125
|
+
var _a;
|
|
126
|
+
return ((_a = this.root.querySelector("input")) === null || _a === void 0 ? void 0 : _a.value) || "";
|
|
127
|
+
}
|
|
128
|
+
set value(val) {
|
|
129
|
+
const input = this.root.querySelector("input");
|
|
130
|
+
if (input)
|
|
131
|
+
input.value = val;
|
|
132
|
+
}
|
|
133
|
+
attributeChangedCallback(name, _old, value) {
|
|
134
|
+
const input = this.root.querySelector("input");
|
|
135
|
+
if (!input)
|
|
136
|
+
return;
|
|
137
|
+
if (name === "disabled") {
|
|
138
|
+
input.disabled = value !== null;
|
|
139
|
+
}
|
|
140
|
+
else if (name === "placeholder") {
|
|
141
|
+
input.placeholder = value || "";
|
|
142
|
+
}
|
|
143
|
+
else if (name === "value") {
|
|
144
|
+
input.value = value || "";
|
|
145
|
+
}
|
|
146
|
+
else if (name === "type") {
|
|
147
|
+
input.type = value || "text";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
customElements.define("glass-input", GlassInput);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseElement } from "../core/base-element.js";
|
|
2
|
+
export declare class GlassModal extends BaseElement {
|
|
3
|
+
private release?;
|
|
4
|
+
private panel?;
|
|
5
|
+
private backdrop?;
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
9
|
+
open(): void;
|
|
10
|
+
close(): void;
|
|
11
|
+
}
|