@surreal-ui/web 0.8.0 → 0.9.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/LICENSE +21 -0
- package/dist/index.js +832 -6249
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +14 -0
- package/package.json +14 -3
- package/CHANGELOG.md +0 -142
- package/src/components/GlassmorphismAlert.ts +0 -115
- package/src/components/GlassmorphismButton.ts +0 -18
- package/src/components/GlassmorphismCard.ts +0 -36
- package/src/components/GlassmorphismEmptyState.ts +0 -35
- package/src/components/GlassmorphismInputGroup.ts +0 -205
- package/src/components/GlassmorphismMenubar.ts +0 -36
- package/src/components/GlassmorphismScrollArea.ts +0 -86
- package/src/components/GlassmorphismTable.ts +0 -52
- package/src/components/GlassmorphismTypography.ts +0 -70
- package/src/components/MinimalistAccordion.ts +0 -252
- package/src/components/MinimalistAlert.ts +0 -98
- package/src/components/MinimalistAlertDialog.ts +0 -102
- package/src/components/MinimalistAspectRatio.ts +0 -36
- package/src/components/MinimalistAvatar.ts +0 -97
- package/src/components/MinimalistBadge.ts +0 -70
- package/src/components/MinimalistBreadcrumb.ts +0 -92
- package/src/components/MinimalistButton.ts +0 -110
- package/src/components/MinimalistButtonGroup.ts +0 -112
- package/src/components/MinimalistCalendar.ts +0 -281
- package/src/components/MinimalistCard.ts +0 -130
- package/src/components/MinimalistCarousel.ts +0 -121
- package/src/components/MinimalistChart.ts +0 -150
- package/src/components/MinimalistCheckbox.ts +0 -178
- package/src/components/MinimalistCodeBlock.ts +0 -112
- package/src/components/MinimalistCollapsible.ts +0 -160
- package/src/components/MinimalistCommand.ts +0 -111
- package/src/components/MinimalistContextMenu.ts +0 -101
- package/src/components/MinimalistDialog.ts +0 -103
- package/src/components/MinimalistDrawer.ts +0 -222
- package/src/components/MinimalistDropdownMenu.ts +0 -125
- package/src/components/MinimalistEmpty.ts +0 -97
- package/src/components/MinimalistEmptyState.ts +0 -41
- package/src/components/MinimalistField.ts +0 -176
- package/src/components/MinimalistForm.ts +0 -102
- package/src/components/MinimalistHoverCard.ts +0 -149
- package/src/components/MinimalistInput.ts +0 -104
- package/src/components/MinimalistInputGroup.ts +0 -95
- package/src/components/MinimalistInputOtp.ts +0 -154
- package/src/components/MinimalistItem.ts +0 -159
- package/src/components/MinimalistKbd.ts +0 -37
- package/src/components/MinimalistLabel.ts +0 -53
- package/src/components/MinimalistMenubar.ts +0 -81
- package/src/components/MinimalistNativeSelect.ts +0 -149
- package/src/components/MinimalistNavigationMenu.ts +0 -103
- package/src/components/MinimalistPagination.ts +0 -140
- package/src/components/MinimalistPopover.ts +0 -112
- package/src/components/MinimalistProgress.ts +0 -70
- package/src/components/MinimalistRadioGroup.ts +0 -228
- package/src/components/MinimalistRangeCalendar.ts +0 -272
- package/src/components/MinimalistResizable.ts +0 -44
- package/src/components/MinimalistScrollArea.ts +0 -42
- package/src/components/MinimalistSelect.ts +0 -103
- package/src/components/MinimalistSeparator.ts +0 -52
- package/src/components/MinimalistSheet.ts +0 -165
- package/src/components/MinimalistSidebar.ts +0 -74
- package/src/components/MinimalistSkeleton.ts +0 -32
- package/src/components/MinimalistSlider.ts +0 -236
- package/src/components/MinimalistSonner.ts +0 -93
- package/src/components/MinimalistSpinner.ts +0 -52
- package/src/components/MinimalistSwitch.ts +0 -165
- package/src/components/MinimalistTable.ts +0 -35
- package/src/components/MinimalistTabs.ts +0 -97
- package/src/components/MinimalistTextarea.ts +0 -99
- package/src/components/MinimalistToggle.ts +0 -104
- package/src/components/MinimalistToggleGroup.ts +0 -177
- package/src/components/MinimalistTooltip.ts +0 -82
- package/src/components/MinimalistTypography.ts +0 -106
- package/src/components/NeubrutalismCard.ts +0 -35
- package/src/components/NeubrutalismItem.ts +0 -67
- package/src/components/ShadcnAccordion.ts +0 -248
- package/src/components/ShadcnAlertDialog.ts +0 -95
- package/src/components/ShadcnAspectRatio.ts +0 -29
- package/src/components/ShadcnAvatar.ts +0 -93
- package/src/components/ShadcnBadge.ts +0 -66
- package/src/components/ShadcnBreadcrumb.ts +0 -88
- package/src/components/ShadcnButton.ts +0 -106
- package/src/components/ShadcnButtonGroup.ts +0 -105
- package/src/components/ShadcnCalendar.ts +0 -277
- package/src/components/ShadcnCarousel.ts +0 -117
- package/src/components/ShadcnChart.ts +0 -146
- package/src/components/ShadcnCheckbox.ts +0 -174
- package/src/components/ShadcnCodeBlock.ts +0 -108
- package/src/components/ShadcnCollapsible.ts +0 -153
- package/src/components/ShadcnCommand.ts +0 -107
- package/src/components/ShadcnContextMenu.ts +0 -94
- package/src/components/ShadcnDialog.ts +0 -99
- package/src/components/ShadcnDrawer.ts +0 -218
- package/src/components/ShadcnDropdownMenu.ts +0 -118
- package/src/components/ShadcnEmpty.ts +0 -93
- package/src/components/ShadcnField.ts +0 -172
- package/src/components/ShadcnForm.ts +0 -98
- package/src/components/ShadcnHoverCard.ts +0 -145
- package/src/components/ShadcnInput.ts +0 -100
- package/src/components/ShadcnInputGroup.ts +0 -88
- package/src/components/ShadcnInputOtp.ts +0 -150
- package/src/components/ShadcnItem.ts +0 -155
- package/src/components/ShadcnKbd.ts +0 -33
- package/src/components/ShadcnLabel.ts +0 -49
- package/src/components/ShadcnMenubar.ts +0 -77
- package/src/components/ShadcnNativeSelect.ts +0 -142
- package/src/components/ShadcnNavigationMenu.ts +0 -96
- package/src/components/ShadcnPagination.ts +0 -136
- package/src/components/ShadcnPopover.ts +0 -108
- package/src/components/ShadcnProgress.ts +0 -66
- package/src/components/ShadcnRadioGroup.ts +0 -221
- package/src/components/ShadcnRangeCalendar.ts +0 -265
- package/src/components/ShadcnSelect.ts +0 -99
- package/src/components/ShadcnSeparator.ts +0 -48
- package/src/components/ShadcnSheet.ts +0 -161
- package/src/components/ShadcnSidebar.ts +0 -70
- package/src/components/ShadcnSkeleton.ts +0 -28
- package/src/components/ShadcnSlider.ts +0 -232
- package/src/components/ShadcnSonner.ts +0 -89
- package/src/components/ShadcnSpinner.ts +0 -48
- package/src/components/ShadcnSwitch.ts +0 -161
- package/src/components/ShadcnTabs.ts +0 -93
- package/src/components/ShadcnTextarea.ts +0 -95
- package/src/components/ShadcnToggle.ts +0 -100
- package/src/components/ShadcnToggleGroup.ts +0 -170
- package/src/components/ShadcnTooltip.ts +0 -78
- package/src/index.ts +0 -124
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
class SurrealModernTypography extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super();
|
|
4
|
-
this.attachShadow({ mode: 'open' });
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
const badgeText = this.getAttribute('badge-text') || 'AI Multi-Platform Synthesizer Studio';
|
|
9
|
-
const title = this.getAttribute('title-text') || 'Ingest & Generate Component';
|
|
10
|
-
const description =
|
|
11
|
-
this.getAttribute('description') ||
|
|
12
|
-
"Paste your raw component code in any framework. Surreal UI's engine will synthesize React, Svelte, and WebComponent variants, extract prop docs, and tag aesthetics automatically.";
|
|
13
|
-
|
|
14
|
-
this.shadowRoot.innerHTML = `
|
|
15
|
-
<style>
|
|
16
|
-
@import "https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css";
|
|
17
|
-
:host {
|
|
18
|
-
display: block;
|
|
19
|
-
}
|
|
20
|
-
.space-y-2 > * + * {
|
|
21
|
-
margin-top: 0.5rem;
|
|
22
|
-
}
|
|
23
|
-
.inline-flex {
|
|
24
|
-
display: inline-flex;
|
|
25
|
-
align-items: center;
|
|
26
|
-
}
|
|
27
|
-
.gap-2 {
|
|
28
|
-
gap: 0.5rem;
|
|
29
|
-
}
|
|
30
|
-
.px-3 {
|
|
31
|
-
padding-left: 0.75rem;
|
|
32
|
-
padding-right: 0.75rem;
|
|
33
|
-
}
|
|
34
|
-
.py-1 {
|
|
35
|
-
padding-top: 0.25rem;
|
|
36
|
-
padding-bottom: 0.25rem;
|
|
37
|
-
}
|
|
38
|
-
.rounded-full {
|
|
39
|
-
border-radius: 9999px;
|
|
40
|
-
}
|
|
41
|
-
.bg-pink-500-10 {
|
|
42
|
-
background-color: rgba(236, 72, 153, 0.1);
|
|
43
|
-
}
|
|
44
|
-
.border-pink-500-30 {
|
|
45
|
-
border: 1px solid rgba(236, 72, 153, 0.3);
|
|
46
|
-
}
|
|
47
|
-
.text-pink-300 {
|
|
48
|
-
color: #f472b6;
|
|
49
|
-
}
|
|
50
|
-
.text-xs {
|
|
51
|
-
font-size: 0.75rem;
|
|
52
|
-
line-height: 1rem;
|
|
53
|
-
}
|
|
54
|
-
.font-semibold {
|
|
55
|
-
font-weight: 600;
|
|
56
|
-
}
|
|
57
|
-
.text-3xl {
|
|
58
|
-
font-size: 1.875rem;
|
|
59
|
-
line-height: 2.25rem;
|
|
60
|
-
}
|
|
61
|
-
.font-extrabold {
|
|
62
|
-
font-weight: 800;
|
|
63
|
-
}
|
|
64
|
-
.text-white {
|
|
65
|
-
color: #ffffff;
|
|
66
|
-
}
|
|
67
|
-
.tracking-tight {
|
|
68
|
-
letter-spacing: -0.025em;
|
|
69
|
-
}
|
|
70
|
-
.text-slate-400 {
|
|
71
|
-
color: #94a3b8;
|
|
72
|
-
}
|
|
73
|
-
.text-slate-200 {
|
|
74
|
-
color: #e2e8f0;
|
|
75
|
-
}
|
|
76
|
-
.text-sm {
|
|
77
|
-
font-size: 0.875rem;
|
|
78
|
-
line-height: 1.25rem;
|
|
79
|
-
}
|
|
80
|
-
</style>
|
|
81
|
-
<div class="space-y-2">
|
|
82
|
-
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-pink-500-10 border-pink-500-30 text-pink-300 text-xs font-semibold">
|
|
83
|
-
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
84
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z" />
|
|
85
|
-
</svg>
|
|
86
|
-
<span>${badgeText}</span>
|
|
87
|
-
</div>
|
|
88
|
-
<h1 class="text-3xl font-extrabold text-white tracking-tight">${title}</h1>
|
|
89
|
-
<p class="text-slate-400 text-sm">
|
|
90
|
-
${description}
|
|
91
|
-
</p>
|
|
92
|
-
</div>
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-modern-typography')) {
|
|
98
|
-
customElements.define('surreal-modern-typography', SurrealModernTypography);
|
|
99
|
-
}
|
|
100
|
-
export { SurrealModernTypography as MinimalistTypography, SurrealModernTypography };
|
|
101
|
-
|
|
102
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-typography')) {
|
|
103
|
-
customElements.define('surreal-minimalist-typography', SurrealModernTypography);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default SurrealModernTypography;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
class SurrealNeubrutalismCard extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super();
|
|
4
|
-
this.attachShadow({ mode: 'open' });
|
|
5
|
-
this._loading = false;
|
|
6
|
-
this._errorMsg = '';
|
|
7
|
-
}
|
|
8
|
-
static get observedAttributes() {
|
|
9
|
-
return ['loading', 'error-msg'];
|
|
10
|
-
}
|
|
11
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
12
|
-
if (name === 'loading') this._loading = newValue !== null;
|
|
13
|
-
if (name === 'error-msg') this._errorMsg = newValue;
|
|
14
|
-
this.render();
|
|
15
|
-
}
|
|
16
|
-
connectedCallback() {
|
|
17
|
-
this.render();
|
|
18
|
-
this.shadowRoot.addEventListener('click', (e) => {
|
|
19
|
-
const btn = e.composedPath().find((node) => node.tagName === 'BUTTON');
|
|
20
|
-
if (btn && !this._loading) {
|
|
21
|
-
this.dispatchEvent(new CustomEvent('login', { bubbles: true, composed: true }));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
render() {
|
|
26
|
-
this.shadowRoot.innerHTML = `<style>@import "https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css";</style><div class="min-h-screen bg-slate-950 text-slate-100 flex items-center justify-center p-4 relative overflow-hidden"><div class="w-full max-w-md bg-white border-4 border-black shadow-[8px_8px_0px_0px_rgba(0,0,0,1)] p-8 space-y-6 text-black"><div class="text-center space-y-3"><div class="inline-flex p-3 border-2 border-black bg-indigo-400 text-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)]">✨</div><div><h1 class="text-3xl font-extrabold text-black tracking-tight bg-yellow-300 px-2 py-1 inline-block border-2 border-black">Surreal UI</h1><p class="text-xs uppercase font-mono tracking-widest text-gray-600 mt-2">Component Repository Portal</p></div></div>${this._errorMsg ? `<div class="flex items-start gap-3 p-4 bg-red-400 border-2 border-black text-black text-xs font-bold shadow-[4px_4px_0px_0px_rgba(0,0,0,1)]"><div><strong class="font-black block">Authentication Failed</strong><span>${this._errorMsg}</span></div></div>` : ''}<div class="flex items-center gap-2.5 p-3 bg-yellow-400 border-2 border-black text-black text-xs font-bold shadow-[4px_4px_0px_0px_rgba(0,0,0,1)]"><span>Access is restricted to authorized accounts only.</span></div><button ${this._loading ? 'disabled' : ''} class="w-full py-3.5 px-4 bg-green-400 hover:bg-green-500 text-black font-black border-2 border-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] flex items-center justify-center gap-2 transition-all cursor-pointer disabled:opacity-50">${this._loading ? '<span>Authenticating...</span>' : '<span>Sign In with Google</span>'}</button></div></div>`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-neubrutalism-card')) {
|
|
31
|
-
customElements.define('surreal-neubrutalism-card', SurrealNeubrutalismCard);
|
|
32
|
-
}
|
|
33
|
-
export { SurrealNeubrutalismCard as NeubrutalismCard, SurrealNeubrutalismCard };
|
|
34
|
-
|
|
35
|
-
export default SurrealNeubrutalismCard;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
class SurrealNeubrutalismItem extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super();
|
|
4
|
-
this.attachShadow({ mode: 'open' });
|
|
5
|
-
}
|
|
6
|
-
static get observedAttributes() {
|
|
7
|
-
return ['component-count'];
|
|
8
|
-
}
|
|
9
|
-
get componentCount() {
|
|
10
|
-
return this.getAttribute('component-count') || '0';
|
|
11
|
-
}
|
|
12
|
-
set componentCount(value) {
|
|
13
|
-
this.setAttribute('component-count', value);
|
|
14
|
-
}
|
|
15
|
-
connectedCallback() {
|
|
16
|
-
this.render();
|
|
17
|
-
}
|
|
18
|
-
attributeChangedCallback() {
|
|
19
|
-
this.render();
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
this.shadowRoot.innerHTML = `
|
|
23
|
-
<style>
|
|
24
|
-
@import "https://cdn.jsdelivr.net/npm/tailwindcss@3.4.1/index.min.css";
|
|
25
|
-
:host {
|
|
26
|
-
display: block;
|
|
27
|
-
}
|
|
28
|
-
</style>
|
|
29
|
-
<section class="relative overflow-hidden rounded-3xl bg-gradient-to-br from-indigo-950/60 via-slate-900/90 to-purple-950/60 border-4 border-black p-8 sm:p-12 shadow-[8px_8px_0px_0px_rgba(0,0,0,1)]">
|
|
30
|
-
<div class="absolute -right-20 -top-20 w-80 h-80 bg-indigo-500/10 rounded-full blur-3xl pointer-events-none"></div>
|
|
31
|
-
<div class="max-w-3xl space-y-4 relative z-10">
|
|
32
|
-
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-indigo-500/10 border-2 border-black text-indigo-300 text-xs font-extrabold shadow-[2px_2px_0px_0px_rgba(0,0,0,1)]">
|
|
33
|
-
<span>✨ Single Source of Truth for Cross-Platform UI</span>
|
|
34
|
-
</div>
|
|
35
|
-
<h1 class="text-4xl sm:text-5xl font-black tracking-tight text-white leading-tight">
|
|
36
|
-
Discover, Convert & Reuse <br />
|
|
37
|
-
<span class="text-indigo-400">Surreal UI Components</span>
|
|
38
|
-
</h1>
|
|
39
|
-
<p class="text-slate-300 text-base sm:text-lg font-medium leading-relaxed">
|
|
40
|
-
Ingest UI components once and automatically synthesize production-ready implementations for
|
|
41
|
-
<strong class="text-white font-bold">React</strong>,
|
|
42
|
-
<strong class="text-white font-bold">Svelte</strong>, and
|
|
43
|
-
<strong class="text-white font-bold">WebComponents</strong> with built-in version control and AI transformation.
|
|
44
|
-
</p>
|
|
45
|
-
<div class="pt-4 flex flex-wrap items-center gap-6 text-sm text-slate-200 font-semibold">
|
|
46
|
-
<div class="flex items-center gap-2 bg-black/40 px-3 py-1.5 rounded-lg border-2 border-black">
|
|
47
|
-
<span>📦 <strong class="text-white font-black">${this.componentCount}</strong> Components</span>
|
|
48
|
-
</div>
|
|
49
|
-
<div class="flex items-center gap-2 bg-black/40 px-3 py-1.5 rounded-lg border-2 border-black">
|
|
50
|
-
<span>💻 AI Multi-Platform Engine</span>
|
|
51
|
-
</div>
|
|
52
|
-
<div class="flex items-center gap-2 bg-black/40 px-3 py-1.5 rounded-lg border-2 border-black">
|
|
53
|
-
<span>⚡ MCP Server Connected</span>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</section>
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-neubrutalism-item')) {
|
|
63
|
-
customElements.define('surreal-neubrutalism-item', SurrealNeubrutalismItem);
|
|
64
|
-
}
|
|
65
|
-
export { SurrealNeubrutalismItem as NeubrutalismItem, SurrealNeubrutalismItem };
|
|
66
|
-
|
|
67
|
-
export default SurrealNeubrutalismItem;
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
class SurrealShadcnAccordion extends HTMLElement {
|
|
2
|
-
private _type: 'single' | 'multiple' = 'single';
|
|
3
|
-
private _collapsible = true;
|
|
4
|
-
private _openValues = new Set<string>();
|
|
5
|
-
|
|
6
|
-
static get observedAttributes() {
|
|
7
|
-
return ['type', 'collapsible', 'value'];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
this.attachShadow({ mode: 'open' });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
connectedCallback() {
|
|
16
|
-
this.render();
|
|
17
|
-
this.updateAttributes();
|
|
18
|
-
this.shadowRoot?.addEventListener('accordion-toggle', ((
|
|
19
|
-
e: CustomEvent<{ value: string; disabled: boolean }>
|
|
20
|
-
) => {
|
|
21
|
-
e.stopPropagation();
|
|
22
|
-
const { value, disabled } = e.detail;
|
|
23
|
-
if (disabled) return;
|
|
24
|
-
this.toggleItem(value);
|
|
25
|
-
}) as EventListener);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
29
|
-
if (oldValue === newValue) return;
|
|
30
|
-
if (name === 'type') {
|
|
31
|
-
this._type = newValue === 'multiple' ? 'multiple' : 'single';
|
|
32
|
-
} else if (name === 'collapsible') {
|
|
33
|
-
this._collapsible = newValue !== 'false';
|
|
34
|
-
} else if (name === 'value' && newValue !== null) {
|
|
35
|
-
try {
|
|
36
|
-
const parsed = JSON.parse(newValue);
|
|
37
|
-
this._openValues = new Set(Array.isArray(parsed) ? parsed : [parsed]);
|
|
38
|
-
} catch {
|
|
39
|
-
this._openValues = new Set(newValue ? [newValue] : []);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.updateChildItems();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private updateAttributes() {
|
|
46
|
-
if (this.hasAttribute('type')) {
|
|
47
|
-
this._type = this.getAttribute('type') === 'multiple' ? 'multiple' : 'single';
|
|
48
|
-
}
|
|
49
|
-
if (this.hasAttribute('collapsible')) {
|
|
50
|
-
this._collapsible = this.getAttribute('collapsible') !== 'false';
|
|
51
|
-
}
|
|
52
|
-
if (this.hasAttribute('value')) {
|
|
53
|
-
const val = this.getAttribute('value');
|
|
54
|
-
if (val) {
|
|
55
|
-
try {
|
|
56
|
-
const parsed = JSON.parse(val);
|
|
57
|
-
this._openValues = new Set(Array.isArray(parsed) ? parsed : [parsed]);
|
|
58
|
-
} catch {
|
|
59
|
-
this._openValues = new Set([val]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private toggleItem(itemValue: string) {
|
|
66
|
-
const isOpen = this._openValues.has(itemValue);
|
|
67
|
-
if (this._type === 'single') {
|
|
68
|
-
if (isOpen) {
|
|
69
|
-
if (this._collapsible) {
|
|
70
|
-
this._openValues.clear();
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
this._openValues.clear();
|
|
74
|
-
this._openValues.add(itemValue);
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
if (isOpen) {
|
|
78
|
-
this._openValues.delete(itemValue);
|
|
79
|
-
} else {
|
|
80
|
-
this._openValues.add(itemValue);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
this.updateChildItems();
|
|
85
|
-
const valueArray = Array.from(this._openValues);
|
|
86
|
-
this.dispatchEvent(
|
|
87
|
-
new CustomEvent('change', {
|
|
88
|
-
detail: { value: this._type === 'single' ? valueArray[0] || '' : valueArray },
|
|
89
|
-
bubbles: true,
|
|
90
|
-
composed: true
|
|
91
|
-
})
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private updateChildItems() {
|
|
96
|
-
const items = this.querySelectorAll('surreal-accordion-item');
|
|
97
|
-
items.forEach((item) => {
|
|
98
|
-
const val = item.getAttribute('value') || '';
|
|
99
|
-
const isOpen = this._openValues.has(val);
|
|
100
|
-
if (isOpen) {
|
|
101
|
-
item.setAttribute('data-state', 'open');
|
|
102
|
-
} else {
|
|
103
|
-
item.setAttribute('data-state', 'closed');
|
|
104
|
-
}
|
|
105
|
-
const trigger = item.querySelector('surreal-accordion-trigger');
|
|
106
|
-
const content = item.querySelector('surreal-accordion-content');
|
|
107
|
-
trigger?.setAttribute('data-state', isOpen ? 'open' : 'closed');
|
|
108
|
-
content?.setAttribute('data-state', isOpen ? 'open' : 'closed');
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private render() {
|
|
113
|
-
if (!this.shadowRoot) return;
|
|
114
|
-
this.shadowRoot.innerHTML = `
|
|
115
|
-
<style>
|
|
116
|
-
:host {
|
|
117
|
-
display: block;
|
|
118
|
-
width: 100%;
|
|
119
|
-
}
|
|
120
|
-
.root {
|
|
121
|
-
display: flex;
|
|
122
|
-
flex-direction: column;
|
|
123
|
-
width: 100%;
|
|
124
|
-
}
|
|
125
|
-
</style>
|
|
126
|
-
<div class="root">
|
|
127
|
-
<slot></slot>
|
|
128
|
-
</div>
|
|
129
|
-
`;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
class SurrealShadcnAccordionItem extends HTMLElement {
|
|
134
|
-
static get observedAttributes() {
|
|
135
|
-
return ['value', 'disabled', 'data-state'];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
connectedCallback() {
|
|
139
|
-
if (!this.hasAttribute('data-state')) {
|
|
140
|
-
this.setAttribute('data-state', 'closed');
|
|
141
|
-
}
|
|
142
|
-
this.className = 'border-b border-border last:border-b-0 block';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
class SurrealShadcnAccordionTrigger extends HTMLElement {
|
|
147
|
-
private buttonEl: HTMLButtonElement | null = null;
|
|
148
|
-
|
|
149
|
-
static get observedAttributes() {
|
|
150
|
-
return ['data-state', 'disabled'];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
connectedCallback() {
|
|
154
|
-
this.render();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
attributeChangedCallback(name: string, _old: string | null, val: string | null) {
|
|
158
|
-
if (!this.buttonEl) return;
|
|
159
|
-
if (name === 'data-state') {
|
|
160
|
-
this.buttonEl.setAttribute('data-state', val || 'closed');
|
|
161
|
-
this.buttonEl.setAttribute('aria-expanded', val === 'open' ? 'true' : 'false');
|
|
162
|
-
} else if (name === 'disabled') {
|
|
163
|
-
this.buttonEl.disabled = val !== null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private render() {
|
|
168
|
-
const text = this.innerHTML;
|
|
169
|
-
this.innerHTML = '';
|
|
170
|
-
const state = this.getAttribute('data-state') || 'closed';
|
|
171
|
-
const disabled = this.hasAttribute('disabled');
|
|
172
|
-
|
|
173
|
-
const h3 = document.createElement('h3');
|
|
174
|
-
h3.className = 'flex m-0 p-0';
|
|
175
|
-
|
|
176
|
-
const btn = document.createElement('button');
|
|
177
|
-
btn.type = 'button';
|
|
178
|
-
btn.className =
|
|
179
|
-
'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left text-foreground [&[data-state=open]>svg]:rotate-180 disabled:pointer-events-none disabled:opacity-50 cursor-pointer bg-transparent border-none w-full p-0';
|
|
180
|
-
btn.setAttribute('data-state', state);
|
|
181
|
-
btn.setAttribute('aria-expanded', state === 'open' ? 'true' : 'false');
|
|
182
|
-
btn.disabled = disabled;
|
|
183
|
-
|
|
184
|
-
btn.innerHTML = `
|
|
185
|
-
<span>${text}</span>
|
|
186
|
-
<svg class="size-4 shrink-0 text-muted-foreground transition-transform duration-200 ${state === 'open' ? 'rotate-180' : ''}" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
|
|
187
|
-
`;
|
|
188
|
-
|
|
189
|
-
btn.onclick = () => {
|
|
190
|
-
const item = this.closest('surreal-accordion-item');
|
|
191
|
-
const val = item?.getAttribute('value') || '';
|
|
192
|
-
const isItemDisabled = item?.hasAttribute('disabled') || disabled;
|
|
193
|
-
this.dispatchEvent(
|
|
194
|
-
new CustomEvent('accordion-toggle', {
|
|
195
|
-
detail: { value: val, disabled: isItemDisabled },
|
|
196
|
-
bubbles: true,
|
|
197
|
-
composed: true
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
this.buttonEl = btn;
|
|
203
|
-
h3.appendChild(btn);
|
|
204
|
-
this.appendChild(h3);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
class SurrealShadcnAccordionContent extends HTMLElement {
|
|
209
|
-
static get observedAttributes() {
|
|
210
|
-
return ['data-state'];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
connectedCallback() {
|
|
214
|
-
this.updateClasses();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
attributeChangedCallback() {
|
|
218
|
-
this.updateClasses();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private updateClasses() {
|
|
222
|
-
const isOpen = this.getAttribute('data-state') === 'open';
|
|
223
|
-
this.className = `grid transition-all duration-200 ease-out text-sm text-muted-foreground ${isOpen ? 'grid-rows-[1fr] opacity-100 block' : 'grid-rows-[0fr] opacity-0 invisible h-0 hidden'}`;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (!customElements.get('surreal-accordion')) {
|
|
228
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-accordion')) {
|
|
229
|
-
customElements.define('surreal-shadcn-accordion', SurrealShadcnAccordion);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (!customElements.get('surreal-accordion-item')) {
|
|
233
|
-
customElements.define('surreal-shadcn-accordion', SurrealShadcnAccordionItem);
|
|
234
|
-
}
|
|
235
|
-
if (!customElements.get('surreal-accordion-trigger')) {
|
|
236
|
-
customElements.define('surreal-shadcn-accordion', SurrealShadcnAccordionTrigger);
|
|
237
|
-
}
|
|
238
|
-
if (!customElements.get('surreal-accordion-content')) {
|
|
239
|
-
customElements.define('surreal-shadcn-accordion', SurrealShadcnAccordionContent);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export {
|
|
243
|
-
SurrealShadcnAccordion,
|
|
244
|
-
SurrealShadcnAccordionItem,
|
|
245
|
-
SurrealShadcnAccordionTrigger,
|
|
246
|
-
SurrealShadcnAccordionContent
|
|
247
|
-
};
|
|
248
|
-
export default SurrealShadcnAccordion;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
class SurrealShadcnAlertDialog extends HTMLElement {
|
|
2
|
-
private _open = false;
|
|
3
|
-
|
|
4
|
-
static get observedAttributes() {
|
|
5
|
-
return ['open'];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
get open() {
|
|
9
|
-
return this._open;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
set open(val: boolean) {
|
|
13
|
-
if (this._open !== val) {
|
|
14
|
-
this._open = val;
|
|
15
|
-
if (val) {
|
|
16
|
-
this.setAttribute('open', '');
|
|
17
|
-
} else {
|
|
18
|
-
this.removeAttribute('open');
|
|
19
|
-
}
|
|
20
|
-
this.render();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
connectedCallback() {
|
|
25
|
-
this._open = this.hasAttribute('open');
|
|
26
|
-
this.addEventListener('click', this.handleGlobalClick.bind(this));
|
|
27
|
-
window.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
28
|
-
this.render();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
disconnectedCallback() {
|
|
32
|
-
window.removeEventListener('keydown', this.handleKeyDown.bind(this));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
36
|
-
if (name === 'open' && oldValue !== newValue) {
|
|
37
|
-
this._open = newValue !== null;
|
|
38
|
-
this.render();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private handleKeyDown = (e: KeyboardEvent) => {
|
|
43
|
-
if (e.key === 'Escape' && this.open) {
|
|
44
|
-
this.open = false;
|
|
45
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: false } }));
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
private handleGlobalClick = (e: MouseEvent) => {
|
|
50
|
-
const target = e.target as HTMLElement;
|
|
51
|
-
const trigger = target.closest('[data-slot="alert-dialog-trigger"]');
|
|
52
|
-
if (trigger) {
|
|
53
|
-
this.open = true;
|
|
54
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: true } }));
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const cancel = target.closest(
|
|
59
|
-
'[data-slot="alert-dialog-cancel"], [data-slot="alert-dialog-action"]'
|
|
60
|
-
);
|
|
61
|
-
if (cancel) {
|
|
62
|
-
this.open = false;
|
|
63
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: false } }));
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const overlay = target.closest('[data-slot="alert-dialog-overlay"]');
|
|
68
|
-
if (overlay && target === overlay) {
|
|
69
|
-
this.open = false;
|
|
70
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: false } }));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
private render() {
|
|
75
|
-
let overlay = this.querySelector('[data-slot="alert-dialog-overlay"]') as HTMLElement;
|
|
76
|
-
let content = this.querySelector('[data-slot="alert-dialog-content"]') as HTMLElement;
|
|
77
|
-
|
|
78
|
-
if (this.open) {
|
|
79
|
-
if (overlay) overlay.style.display = 'block';
|
|
80
|
-
if (content) content.style.display = 'grid';
|
|
81
|
-
} else {
|
|
82
|
-
if (overlay) overlay.style.display = 'none';
|
|
83
|
-
if (content) content.style.display = 'none';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!customElements.get('surreal-alert-dialog')) {
|
|
89
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-alert-dialog')) {
|
|
90
|
-
customElements.define('surreal-shadcn-alert-dialog', SurrealShadcnAlertDialog);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
export { SurrealShadcnAlertDialog as ShadcnAlertDialog, SurrealShadcnAlertDialog };
|
|
94
|
-
|
|
95
|
-
export default SurrealShadcnAlertDialog;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export class AspectRatioElement extends HTMLElement {
|
|
2
|
-
static get observedAttributes() {
|
|
3
|
-
return ['ratio'];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
connectedCallback() {
|
|
7
|
-
this.render();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
attributeChangedCallback() {
|
|
11
|
-
this.render();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private render() {
|
|
15
|
-
const ratio = this.getAttribute('ratio') || '16 / 9';
|
|
16
|
-
this.dataset.slot = 'aspect-ratio';
|
|
17
|
-
this.style.position = 'relative';
|
|
18
|
-
this.style.width = '100%';
|
|
19
|
-
this.style.display = 'block';
|
|
20
|
-
this.style.aspectRatio = ratio;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-aspect-ratio')) {
|
|
25
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-aspect-ratio')) {
|
|
26
|
-
customElements.define('surreal-shadcn-aspect-ratio', AspectRatioElement);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export default AspectRatioElement;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export class SurrealShadcnAvatar extends HTMLElement {
|
|
2
|
-
static get observedAttributes() {
|
|
3
|
-
return ['size', 'src', 'alt', 'fallback'];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
private img: HTMLImageElement | null = null;
|
|
7
|
-
private fallbackEl: HTMLSpanElement | null = null;
|
|
8
|
-
|
|
9
|
-
connectedCallback() {
|
|
10
|
-
this.render();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
attributeChangedCallback() {
|
|
14
|
-
this.render();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private render() {
|
|
18
|
-
const size = this.getAttribute('size') || 'default';
|
|
19
|
-
const src = this.getAttribute('src');
|
|
20
|
-
const alt = this.getAttribute('alt') || '';
|
|
21
|
-
const fallbackText = this.getAttribute('fallback') || '';
|
|
22
|
-
|
|
23
|
-
this.setAttribute('data-slot', 'avatar');
|
|
24
|
-
this.setAttribute('data-size', size);
|
|
25
|
-
|
|
26
|
-
const sizeClasses = size === 'lg' ? 'size-10' : size === 'sm' ? 'size-6' : 'size-8';
|
|
27
|
-
this.className = `rounded-full after:rounded-full group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:border-border after:mix-blend-darken dark:after:mix-blend-lighten ${sizeClasses}`;
|
|
28
|
-
|
|
29
|
-
this.innerHTML = '';
|
|
30
|
-
|
|
31
|
-
if (src) {
|
|
32
|
-
const img = document.createElement('img');
|
|
33
|
-
img.src = src;
|
|
34
|
-
img.alt = alt;
|
|
35
|
-
img.setAttribute('data-slot', 'avatar-image');
|
|
36
|
-
img.className = 'rounded-full aspect-square size-full object-cover hidden';
|
|
37
|
-
|
|
38
|
-
const fallback = document.createElement('span');
|
|
39
|
-
fallback.setAttribute('data-slot', 'avatar-fallback');
|
|
40
|
-
fallback.className = `rounded-full bg-muted text-muted-foreground flex size-full items-center justify-center ${size === 'sm' ? 'text-xs' : 'text-sm'}`;
|
|
41
|
-
fallback.textContent = fallbackText;
|
|
42
|
-
|
|
43
|
-
img.onload = () => {
|
|
44
|
-
img.classList.remove('hidden');
|
|
45
|
-
fallback.classList.add('hidden');
|
|
46
|
-
};
|
|
47
|
-
img.onerror = () => {
|
|
48
|
-
img.remove();
|
|
49
|
-
fallback.classList.remove('hidden');
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
this.appendChild(img);
|
|
53
|
-
this.appendChild(fallback);
|
|
54
|
-
} else {
|
|
55
|
-
const fallback = document.createElement('span');
|
|
56
|
-
fallback.setAttribute('data-slot', 'avatar-fallback');
|
|
57
|
-
fallback.className = `rounded-full bg-muted text-muted-foreground flex size-full items-center justify-center ${size === 'sm' ? 'text-xs' : 'text-sm'}`;
|
|
58
|
-
fallback.textContent = fallbackText;
|
|
59
|
-
this.appendChild(fallback);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!customElements.get('surreal-avatar')) {
|
|
65
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-avatar')) {
|
|
66
|
-
customElements.define('surreal-shadcn-avatar', SurrealShadcnAvatar);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export class SurrealShadcnAvatarGroup extends HTMLElement {
|
|
71
|
-
connectedCallback() {
|
|
72
|
-
this.setAttribute('data-slot', 'avatar-group');
|
|
73
|
-
this.className =
|
|
74
|
-
'cn-avatar-group group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background';
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!customElements.get('surreal-avatar-group')) {
|
|
79
|
-
customElements.define('surreal-shadcn-avatar', SurrealShadcnAvatarGroup);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export class SurrealShadcnAvatarGroupCount extends HTMLElement {
|
|
83
|
-
connectedCallback() {
|
|
84
|
-
this.setAttribute('data-slot', 'avatar-group-count');
|
|
85
|
-
this.className =
|
|
86
|
-
'size-8 rounded-full bg-muted text-sm text-muted-foreground group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3 relative flex shrink-0 items-center justify-center ring-2 ring-background';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (!customElements.get('surreal-avatar-group-count')) {
|
|
91
|
-
customElements.define('surreal-shadcn-avatar', SurrealShadcnAvatarGroupCount);
|
|
92
|
-
}
|
|
93
|
-
export default SurrealShadcnAvatar;
|