@surreal-ui/web 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.
Files changed (124) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/index.js +12075 -0
  3. package/package.json +27 -0
  4. package/src/components/GlassmorphismAlert.ts +116 -0
  5. package/src/components/GlassmorphismButton.ts +19 -0
  6. package/src/components/GlassmorphismCard.ts +33 -0
  7. package/src/components/GlassmorphismEmptyState.ts +29 -0
  8. package/src/components/GlassmorphismInputGroup.ts +202 -0
  9. package/src/components/GlassmorphismMenubar.ts +36 -0
  10. package/src/components/GlassmorphismScrollArea.ts +83 -0
  11. package/src/components/GlassmorphismTable.ts +52 -0
  12. package/src/components/GlassmorphismTypography.ts +67 -0
  13. package/src/components/MinimalistAccordion.ts +248 -0
  14. package/src/components/MinimalistAlert.ts +99 -0
  15. package/src/components/MinimalistAlertDialog.ts +100 -0
  16. package/src/components/MinimalistAspectRatio.ts +34 -0
  17. package/src/components/MinimalistAvatar.ts +98 -0
  18. package/src/components/MinimalistBadge.ts +71 -0
  19. package/src/components/MinimalistBreadcrumb.ts +92 -0
  20. package/src/components/MinimalistButton.ts +111 -0
  21. package/src/components/MinimalistButtonGroup.ts +110 -0
  22. package/src/components/MinimalistCalendar.ts +282 -0
  23. package/src/components/MinimalistCard.ts +131 -0
  24. package/src/components/MinimalistCarousel.ts +122 -0
  25. package/src/components/MinimalistChart.ts +151 -0
  26. package/src/components/MinimalistCheckbox.ts +179 -0
  27. package/src/components/MinimalistCodeBlock.ts +113 -0
  28. package/src/components/MinimalistCollapsible.ts +155 -0
  29. package/src/components/MinimalistCommand.ts +112 -0
  30. package/src/components/MinimalistContextMenu.ts +99 -0
  31. package/src/components/MinimalistDialog.ts +104 -0
  32. package/src/components/MinimalistDrawer.ts +223 -0
  33. package/src/components/MinimalistDropdownMenu.ts +120 -0
  34. package/src/components/MinimalistEmpty.ts +98 -0
  35. package/src/components/MinimalistEmptyState.ts +38 -0
  36. package/src/components/MinimalistField.ts +171 -0
  37. package/src/components/MinimalistForm.ts +101 -0
  38. package/src/components/MinimalistHoverCard.ts +150 -0
  39. package/src/components/MinimalistInput.ts +105 -0
  40. package/src/components/MinimalistInputGroup.ts +93 -0
  41. package/src/components/MinimalistInputOtp.ts +155 -0
  42. package/src/components/MinimalistItem.ts +160 -0
  43. package/src/components/MinimalistKbd.ts +38 -0
  44. package/src/components/MinimalistLabel.ts +54 -0
  45. package/src/components/MinimalistMenubar.ts +82 -0
  46. package/src/components/MinimalistNativeSelect.ts +144 -0
  47. package/src/components/MinimalistNavigationMenu.ts +98 -0
  48. package/src/components/MinimalistPagination.ts +141 -0
  49. package/src/components/MinimalistPopover.ts +113 -0
  50. package/src/components/MinimalistProgress.ts +71 -0
  51. package/src/components/MinimalistRadioGroup.ts +226 -0
  52. package/src/components/MinimalistRangeCalendar.ts +267 -0
  53. package/src/components/MinimalistResizable.ts +44 -0
  54. package/src/components/MinimalistScrollArea.ts +11 -0
  55. package/src/components/MinimalistSelect.ts +104 -0
  56. package/src/components/MinimalistSeparator.ts +53 -0
  57. package/src/components/MinimalistSheet.ts +166 -0
  58. package/src/components/MinimalistSidebar.ts +75 -0
  59. package/src/components/MinimalistSkeleton.ts +33 -0
  60. package/src/components/MinimalistSlider.ts +237 -0
  61. package/src/components/MinimalistSonner.ts +94 -0
  62. package/src/components/MinimalistSpinner.ts +53 -0
  63. package/src/components/MinimalistSwitch.ts +166 -0
  64. package/src/components/MinimalistTable.ts +35 -0
  65. package/src/components/MinimalistTabs.ts +98 -0
  66. package/src/components/MinimalistTextarea.ts +100 -0
  67. package/src/components/MinimalistToggle.ts +105 -0
  68. package/src/components/MinimalistToggleGroup.ts +175 -0
  69. package/src/components/MinimalistTooltip.ts +83 -0
  70. package/src/components/MinimalistTypography.ts +107 -0
  71. package/src/components/NeubrutalismCard.ts +35 -0
  72. package/src/components/NeubrutalismItem.ts +67 -0
  73. package/src/components/ShadcnAccordion.ts +244 -0
  74. package/src/components/ShadcnAlertDialog.ts +96 -0
  75. package/src/components/ShadcnAspectRatio.ts +30 -0
  76. package/src/components/ShadcnAvatar.ts +94 -0
  77. package/src/components/ShadcnBadge.ts +67 -0
  78. package/src/components/ShadcnBreadcrumb.ts +88 -0
  79. package/src/components/ShadcnButton.ts +107 -0
  80. package/src/components/ShadcnButtonGroup.ts +106 -0
  81. package/src/components/ShadcnCalendar.ts +278 -0
  82. package/src/components/ShadcnCarousel.ts +118 -0
  83. package/src/components/ShadcnChart.ts +147 -0
  84. package/src/components/ShadcnCheckbox.ts +175 -0
  85. package/src/components/ShadcnCodeBlock.ts +109 -0
  86. package/src/components/ShadcnCollapsible.ts +151 -0
  87. package/src/components/ShadcnCommand.ts +108 -0
  88. package/src/components/ShadcnContextMenu.ts +95 -0
  89. package/src/components/ShadcnDialog.ts +100 -0
  90. package/src/components/ShadcnDrawer.ts +219 -0
  91. package/src/components/ShadcnDropdownMenu.ts +116 -0
  92. package/src/components/ShadcnEmpty.ts +94 -0
  93. package/src/components/ShadcnField.ts +167 -0
  94. package/src/components/ShadcnForm.ts +97 -0
  95. package/src/components/ShadcnHoverCard.ts +146 -0
  96. package/src/components/ShadcnInput.ts +101 -0
  97. package/src/components/ShadcnInputGroup.ts +89 -0
  98. package/src/components/ShadcnInputOtp.ts +151 -0
  99. package/src/components/ShadcnItem.ts +156 -0
  100. package/src/components/ShadcnKbd.ts +34 -0
  101. package/src/components/ShadcnLabel.ts +50 -0
  102. package/src/components/ShadcnMenubar.ts +78 -0
  103. package/src/components/ShadcnNativeSelect.ts +140 -0
  104. package/src/components/ShadcnNavigationMenu.ts +94 -0
  105. package/src/components/ShadcnPagination.ts +137 -0
  106. package/src/components/ShadcnPopover.ts +109 -0
  107. package/src/components/ShadcnProgress.ts +67 -0
  108. package/src/components/ShadcnRadioGroup.ts +222 -0
  109. package/src/components/ShadcnRangeCalendar.ts +263 -0
  110. package/src/components/ShadcnSelect.ts +100 -0
  111. package/src/components/ShadcnSeparator.ts +49 -0
  112. package/src/components/ShadcnSheet.ts +162 -0
  113. package/src/components/ShadcnSidebar.ts +71 -0
  114. package/src/components/ShadcnSkeleton.ts +29 -0
  115. package/src/components/ShadcnSlider.ts +233 -0
  116. package/src/components/ShadcnSonner.ts +90 -0
  117. package/src/components/ShadcnSpinner.ts +49 -0
  118. package/src/components/ShadcnSwitch.ts +162 -0
  119. package/src/components/ShadcnTabs.ts +94 -0
  120. package/src/components/ShadcnTextarea.ts +96 -0
  121. package/src/components/ShadcnToggle.ts +101 -0
  122. package/src/components/ShadcnToggleGroup.ts +171 -0
  123. package/src/components/ShadcnTooltip.ts +79 -0
  124. package/src/index.ts +124 -0
@@ -0,0 +1,131 @@
1
+ class SurrealModernCard extends HTMLElement {
2
+ private _shadow: ShadowRoot;
3
+ private _bgTheme: string = 'dark-grid';
4
+ private _title: string = '';
5
+ private _screenshot: string = '';
6
+ private _themeSupport: string = 'light-and-dark';
7
+
8
+ constructor() {
9
+ super();
10
+ this._shadow = this.attachShadow({ mode: 'open' });
11
+ }
12
+
13
+ static get observedAttributes() {
14
+ return ['title', 'screenshot', 'theme-support', 'bg-theme'];
15
+ }
16
+
17
+ attributeChangedCallback(name: string, oldValue: string, newValue: string) {
18
+ if (oldValue === newValue) return;
19
+ if (name === 'title') this._title = newValue;
20
+ if (name === 'screenshot') this._screenshot = newValue;
21
+ if (name === 'theme-support') this._themeSupport = newValue;
22
+ if (name === 'bg-theme') this._bgTheme = newValue;
23
+ this.render();
24
+ }
25
+
26
+ connectedCallback() {
27
+ this._title = this.getAttribute('title') || '';
28
+ this._screenshot = this.getAttribute('screenshot') || '';
29
+ this._themeSupport = this.getAttribute('theme-support') || 'light-and-dark';
30
+ this._bgTheme = this.getAttribute('bg-theme') || 'dark-grid';
31
+ this.render();
32
+ }
33
+
34
+ private setBgTheme(theme: string) {
35
+ this._bgTheme = theme;
36
+ this.setAttribute('bg-theme', theme);
37
+ this.dispatchEvent(new CustomEvent('bgThemeChange', { detail: { theme } }));
38
+ this.render();
39
+ }
40
+
41
+ render() {
42
+ const isDarkGrid = this._bgTheme === 'dark-grid';
43
+ const isGlass = this._bgTheme === 'glass-gradient';
44
+ const isLight = this._bgTheme === 'light';
45
+
46
+ const bgClass = isDarkGrid
47
+ ? 'bg-slate-950'
48
+ : isGlass
49
+ ? 'bg-gradient-to-tr from-indigo-900 via-purple-900 to-slate-900'
50
+ : 'bg-slate-100 text-slate-900';
51
+
52
+ this._shadow.innerHTML = `
53
+ <style>
54
+ @import "https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/tailwind.min.css";
55
+ :host { display: block; }
56
+ .rounded-3xl { border-radius: 1.5rem; }
57
+ .border { border-width: 1px; border-style: solid; }
58
+ .border-slate-800 { border-color: #1e293b; }
59
+ .overflow-hidden { overflow: hidden; }
60
+ .bg-slate-950 { background-color: #020617; }
61
+ .bg-slate-900 { background-color: #0f172a; }
62
+ .text-white { color: #ffffff; }
63
+ .text-slate-400 { color: #94a3b8; }
64
+ .text-slate-300 { color: #cbd5e1; }
65
+ .p-8 { padding: 2rem; }
66
+ .flex { display: flex; }
67
+ .items-center { align-items: center; }
68
+ .justify-center { justify-content: center; }
69
+ .justify-between { justify-content: space-between; }
70
+ .gap-2 { gap: 0.5rem; }
71
+ .gap-4 { gap: 1rem; }
72
+ .gap-15 { gap: 0.375rem; }
73
+ .px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
74
+ .py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
75
+ .text-xs { font-size: 0.75rem; line-height: 1rem; }
76
+ .font-medium { font-weight: 500; }
77
+ .font-bold { font-weight: 700; }
78
+ .rounded-xl { border-radius: 0.75rem; }
79
+ .rounded-lg { border-radius: 0.5rem; }
80
+ .p-1 { padding: 0.25rem; }
81
+ .transition-colors { transition: background-color 0.2s, color 0.2s; }
82
+ .shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
83
+ .max-w-sm { max-width: 24rem; }
84
+ .w-full { width: 100%; }
85
+ .space-y-3 > * + * { margin-top: 0.75rem; }
86
+ </style>
87
+ <section class="rounded-3xl border border-slate-800 overflow-hidden bg-slate-900 shadow-2xl">
88
+ <div class="px-6 py-3 bg-slate-900 border-b border-slate-800 flex flex-wrap items-center justify-between gap-4">
89
+ <div class="flex items-center gap-2 text-xs font-medium text-slate-300">
90
+ <span>Actual Rendered Component Preview</span>
91
+ ${this._themeSupport === 'light-and-dark' ? '<span class="text-[10px] px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-300 border border-emerald-500/20">Light & Dark Modes</span>' : ''}
92
+ </div>
93
+ <div class="flex items-center gap-15 bg-slate-950 p-1 rounded-xl border border-slate-800 text-xs">
94
+ <button id="btn-grid" class="px-2.5 py-1 rounded-lg transition-colors ${isDarkGrid ? 'bg-indigo-600 text-white' : 'text-slate-400'}">Dark Grid</button>
95
+ <button id="btn-glass" class="px-2.5 py-1 rounded-lg transition-colors ${isGlass ? 'bg-indigo-600 text-white' : 'text-slate-400'}">Glass Gradient</button>
96
+ <button id="btn-light" class="px-2.5 py-1 rounded-lg transition-colors ${isLight ? 'bg-indigo-600 text-white' : 'text-slate-400'}">Light Mode</button>
97
+ </div>
98
+ </div>
99
+ <div class="min-h-[280px] p-8 flex items-center justify-center ${bgClass}">
100
+ ${
101
+ this._screenshot
102
+ ? `<div class="max-w-lg w-full rounded-2xl overflow-hidden border border-slate-700 shadow-2xl bg-slate-900 p-2"><img src="${this._screenshot}" alt="Preview" class="w-full h-auto rounded-xl object-contain"/></div>`
103
+ : `<div class="p-8 rounded-2xl bg-slate-900 border border-slate-800 text-center space-y-3 max-w-sm"><h3 class="text-base font-bold text-white">${this._title}</h3><p class="text-xs text-slate-400">Encapsulated multi-platform component package preview.</p></div>`
104
+ }
105
+ </div>
106
+ </section>
107
+ `;
108
+
109
+ this._shadow
110
+ .getElementById('btn-grid')
111
+ ?.addEventListener('click', () => this.setBgTheme('dark-grid'));
112
+ this._shadow
113
+ .getElementById('btn-glass')
114
+ ?.addEventListener('click', () => this.setBgTheme('glass-gradient'));
115
+ this._shadow
116
+ .getElementById('btn-light')
117
+ ?.addEventListener('click', () => this.setBgTheme('light'));
118
+ }
119
+ }
120
+
121
+
122
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-modern-card')) {
123
+ customElements.define('surreal-modern-card', SurrealModernCard);
124
+ };
125
+ export { SurrealModernCard as MinimalistCard, SurrealModernCard };
126
+
127
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-card')) {
128
+ customElements.define('surreal-minimalist-card', SurrealModernCard);
129
+ }
130
+
131
+ export default SurrealModernCard;
@@ -0,0 +1,122 @@
1
+ class SurrealShadcnCarousel extends HTMLElement {
2
+ private container: HTMLElement | null = null;
3
+ private prevButton: HTMLElement | null = null;
4
+ private nextButton: HTMLElement | null = null;
5
+
6
+ static get observedAttributes() {
7
+ return ['orientation'];
8
+ }
9
+
10
+ constructor() {
11
+ super();
12
+ }
13
+
14
+ get orientation(): 'horizontal' | 'vertical' {
15
+ return (this.getAttribute('orientation') as 'horizontal' | 'vertical') || 'horizontal';
16
+ }
17
+
18
+ connectedCallback() {
19
+ this.setAttribute('data-slot', 'carousel');
20
+ this.setAttribute('role', 'region');
21
+ this.setAttribute('aria-roledescription', 'carousel');
22
+ this.classList.add('relative', 'block');
23
+
24
+ this.setupListeners();
25
+ }
26
+
27
+ private setupListeners() {
28
+ this.container = this.querySelector(
29
+ '[data-slot="carousel-content"] > [data-embla-container], [data-embla-container]',
30
+ );
31
+ this.prevButton = this.querySelector('[data-slot="carousel-previous"]');
32
+ this.nextButton = this.querySelector('[data-slot="carousel-next"]');
33
+
34
+ if (this.prevButton) {
35
+ this.prevButton.addEventListener('click', () => this.scrollPrev());
36
+ }
37
+ if (this.nextButton) {
38
+ this.nextButton.addEventListener('click', () => this.scrollNext());
39
+ }
40
+
41
+ if (this.container) {
42
+ this.container.addEventListener('scroll', () => this.updateScrollState());
43
+ this.updateScrollState();
44
+ }
45
+
46
+ this.addEventListener('keydown', (e: KeyboardEvent) => {
47
+ if (e.key === 'ArrowLeft' || (this.orientation === 'vertical' && e.key === 'ArrowUp')) {
48
+ e.preventDefault();
49
+ this.scrollPrev();
50
+ } else if (
51
+ e.key === 'ArrowRight' ||
52
+ (this.orientation === 'vertical' && e.key === 'ArrowDown')
53
+ ) {
54
+ e.preventDefault();
55
+ this.scrollNext();
56
+ }
57
+ });
58
+ }
59
+
60
+ public scrollPrev() {
61
+ if (!this.container) return;
62
+ if (this.orientation === 'horizontal') {
63
+ this.container.scrollBy({ left: -this.container.clientWidth, behavior: 'smooth' });
64
+ } else {
65
+ this.container.scrollBy({ top: -this.container.clientHeight, behavior: 'smooth' });
66
+ }
67
+ }
68
+
69
+ public scrollNext() {
70
+ if (!this.container) return;
71
+ if (this.orientation === 'horizontal') {
72
+ this.container.scrollBy({ left: this.container.clientWidth, behavior: 'smooth' });
73
+ } else {
74
+ this.container.scrollBy({ top: this.container.clientHeight, behavior: 'smooth' });
75
+ }
76
+ }
77
+
78
+ private updateScrollState() {
79
+ if (!this.container) return;
80
+ const isHoriz = this.orientation === 'horizontal';
81
+ const canPrev = isHoriz ? this.container.scrollLeft > 2 : this.container.scrollTop > 2;
82
+ const maxScroll = isHoriz
83
+ ? this.container.scrollWidth - this.container.clientWidth
84
+ : this.container.scrollHeight - this.container.clientHeight;
85
+ const canNext = isHoriz
86
+ ? this.container.scrollLeft < maxScroll - 2
87
+ : this.container.scrollTop < maxScroll - 2;
88
+
89
+ if (this.prevButton) {
90
+ if (canPrev) {
91
+ this.prevButton.removeAttribute('disabled');
92
+ this.prevButton.setAttribute('aria-disabled', 'false');
93
+ } else {
94
+ this.prevButton.setAttribute('disabled', 'true');
95
+ this.prevButton.setAttribute('aria-disabled', 'true');
96
+ }
97
+ }
98
+ if (this.nextButton) {
99
+ if (canNext) {
100
+ this.nextButton.removeAttribute('disabled');
101
+ this.nextButton.setAttribute('aria-disabled', 'false');
102
+ } else {
103
+ this.nextButton.setAttribute('disabled', 'true');
104
+ this.nextButton.setAttribute('aria-disabled', 'true');
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ if (!customElements.get('surreal-carousel')) {
111
+
112
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-carousel')) {
113
+ customElements.define('surreal-shadcn-carousel', SurrealShadcnCarousel);
114
+ }
115
+ };
116
+ export { SurrealShadcnCarousel as MinimalistCarousel, SurrealShadcnCarousel };
117
+
118
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-carousel')) {
119
+ customElements.define('surreal-minimalist-carousel', SurrealShadcnCarousel);
120
+ }
121
+
122
+ export default SurrealShadcnCarousel;
@@ -0,0 +1,151 @@
1
+ class SurrealShadcnChartContainer extends HTMLElement {
2
+ private styleTag: HTMLStyleElement | null = null;
3
+
4
+ static get observedAttributes() {
5
+ return ['config', 'chart-id'];
6
+ }
7
+
8
+ connectedCallback() {
9
+ this.render();
10
+ }
11
+
12
+ attributeChangedCallback() {
13
+ this.applyConfigStyles();
14
+ }
15
+
16
+ private get configData() {
17
+ try {
18
+ const attr = this.getAttribute('config');
19
+ return attr ? JSON.parse(attr) : {};
20
+ } catch {
21
+ return {};
22
+ }
23
+ }
24
+
25
+ private applyConfigStyles() {
26
+ const id = this.getAttribute('chart-id') || 'chart-root';
27
+ this.setAttribute('data-chart', id);
28
+ this.setAttribute('data-slot', 'chart');
29
+
30
+ const config = this.configData;
31
+ const entries = Object.entries(config);
32
+
33
+ if (!this.styleTag) {
34
+ this.styleTag = document.createElement('style');
35
+ this.prepend(this.styleTag);
36
+ }
37
+
38
+ if (!entries.length) {
39
+ this.styleTag.textContent = '';
40
+ return;
41
+ }
42
+
43
+ let css = `[data-chart="${id}"] {\n`;
44
+ for (const [key, val] of entries) {
45
+ const item = val as { color?: string; theme?: Record<string, string> };
46
+ if (item.color) {
47
+ css += ` --color-${key}: ${item.color};\n`;
48
+ }
49
+ }
50
+ css += '}\n';
51
+
52
+ css += `.dark [data-chart="${id}"] {\n`;
53
+ for (const [key, val] of entries) {
54
+ const item = val as { color?: string; theme?: Record<string, string> };
55
+ const darkColor = item.theme?.dark || item.color;
56
+ if (darkColor) {
57
+ css += ` --color-${key}: ${darkColor};\n`;
58
+ }
59
+ }
60
+ css += '}\n';
61
+
62
+ this.styleTag.textContent = css;
63
+ }
64
+
65
+ render() {
66
+ this.className = [
67
+ 'flex aspect-video justify-center overflow-visible text-xs w-full',
68
+ this.className,
69
+ ].join(' ');
70
+ this.applyConfigStyles();
71
+ }
72
+ }
73
+
74
+ class SurrealShadcnChartTooltip extends HTMLElement {
75
+ static get observedAttributes() {
76
+ return ['label', 'payload', 'indicator'];
77
+ }
78
+
79
+ connectedCallback() {
80
+ this.render();
81
+ }
82
+
83
+ attributeChangedCallback() {
84
+ this.render();
85
+ }
86
+
87
+ render() {
88
+ const label = this.getAttribute('label') || '';
89
+ const indicator = this.getAttribute('indicator') || 'dot';
90
+ let payload: Array<{ key?: string; name?: string; value?: number; color?: string }> = [];
91
+
92
+ try {
93
+ const rawPayload = this.getAttribute('payload');
94
+ if (rawPayload) payload = JSON.parse(rawPayload);
95
+ } catch {}
96
+
97
+ this.setAttribute('data-slot', 'chart-tooltip');
98
+ this.className = [
99
+ 'grid min-w-[9rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl',
100
+ this.className,
101
+ ].join(' ');
102
+
103
+ let html = '';
104
+ if (label) {
105
+ html += `<div class="font-medium text-foreground">${label}</div>`;
106
+ }
107
+
108
+ html += '<div class="grid gap-1.5">';
109
+ payload.forEach((item) => {
110
+ const itemName = item.name || item.key || 'value';
111
+ const itemVal = item.value !== undefined ? Number(item.value).toLocaleString() : '';
112
+ const color = item.color || 'var(--primary)';
113
+
114
+ let indicatorClass = 'size-2.5 rounded-[2px] shrink-0';
115
+ if (indicator === 'line') indicatorClass = 'h-3.5 w-1 rounded-[2px] shrink-0';
116
+ if (indicator === 'dashed')
117
+ indicatorClass = 'w-0 border-[1.5px] border-dashed bg-transparent shrink-0';
118
+
119
+ html += `
120
+ <div class="flex w-full items-center gap-2">
121
+ <div class="${indicatorClass}" style="background-color: ${indicator === 'dashed' ? 'transparent' : color}; border-color: ${color};"></div>
122
+ <div class="flex flex-1 justify-between items-center leading-none">
123
+ <span class="text-muted-foreground">${itemName}</span>
124
+ <span class="font-mono font-medium text-foreground tabular-nums">${itemVal}</span>
125
+ </div>
126
+ </div>
127
+ `;
128
+ });
129
+ html += '</div>';
130
+
131
+ this.innerHTML = html;
132
+ }
133
+ }
134
+
135
+ if (!customElements.get('surreal-chart-container')) {
136
+
137
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-chart')) {
138
+ customElements.define('surreal-shadcn-chart', SurrealShadcnChartContainer);
139
+ }
140
+ }
141
+
142
+ if (!customElements.get('surreal-chart-tooltip')) {
143
+ customElements.define('surreal-shadcn-chart', SurrealShadcnChartTooltip);
144
+ };
145
+ export { SurrealShadcnChartContainer as MinimalistChart, SurrealShadcnChartContainer };
146
+
147
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-chart')) {
148
+ customElements.define('surreal-minimalist-chart', SurrealShadcnChartContainer);
149
+ }
150
+
151
+ export default SurrealShadcnChartContainer;
@@ -0,0 +1,179 @@
1
+ class SurrealShadcnCheckbox extends HTMLElement {
2
+ static get observedAttributes() {
3
+ return ['checked', 'indeterminate', 'disabled', 'required', 'name', 'value', 'class'];
4
+ }
5
+
6
+ private _button: HTMLButtonElement;
7
+ private _indicator: HTMLDivElement;
8
+ private _hiddenInput: HTMLInputElement | null = null;
9
+
10
+ constructor() {
11
+ super();
12
+ this._button = document.createElement('button');
13
+ this._indicator = document.createElement('div');
14
+ }
15
+
16
+ connectedCallback() {
17
+ this.render();
18
+ this._button.addEventListener('click', this._handleClick);
19
+ this._button.addEventListener('keydown', this._handleKeyDown);
20
+ }
21
+
22
+ disconnectedCallback() {
23
+ this._button.removeEventListener('click', this._handleClick);
24
+ this._button.removeEventListener('keydown', this._handleKeyDown);
25
+ }
26
+
27
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
28
+ if (oldValue !== newValue) {
29
+ this.updateState();
30
+ }
31
+ }
32
+
33
+ get checked(): boolean {
34
+ return this.hasAttribute('checked') && this.getAttribute('checked') !== 'false';
35
+ }
36
+
37
+ set checked(val: boolean) {
38
+ if (val) {
39
+ this.setAttribute('checked', '');
40
+ } else {
41
+ this.removeAttribute('checked');
42
+ }
43
+ }
44
+
45
+ get indeterminate(): boolean {
46
+ return this.hasAttribute('indeterminate');
47
+ }
48
+
49
+ set indeterminate(val: boolean) {
50
+ if (val) {
51
+ this.setAttribute('indeterminate', '');
52
+ } else {
53
+ this.removeAttribute('indeterminate');
54
+ }
55
+ }
56
+
57
+ get disabled(): boolean {
58
+ return this.hasAttribute('disabled');
59
+ }
60
+
61
+ set disabled(val: boolean) {
62
+ if (val) {
63
+ this.setAttribute('disabled', '');
64
+ } else {
65
+ this.removeAttribute('disabled');
66
+ }
67
+ }
68
+
69
+ private _handleClick = (e: MouseEvent) => {
70
+ if (this.disabled) {
71
+ e.preventDefault();
72
+ return;
73
+ }
74
+
75
+ const nextChecked = this.indeterminate ? true : !this.checked;
76
+ this.indeterminate = false;
77
+ this.checked = nextChecked;
78
+
79
+ this.dispatchEvent(
80
+ new CustomEvent('change', {
81
+ detail: { checked: this.checked },
82
+ bubbles: true,
83
+ composed: true,
84
+ }),
85
+ );
86
+ };
87
+
88
+ private _handleKeyDown = (e: KeyboardEvent) => {
89
+ if (e.key === ' ') {
90
+ e.preventDefault();
91
+ this._handleClick(e as unknown as MouseEvent);
92
+ }
93
+ };
94
+
95
+ private updateState() {
96
+ const isIndeterminate = this.indeterminate;
97
+ const isChecked = !isIndeterminate && this.checked;
98
+ const isDisabled = this.disabled;
99
+ const isRequired = this.hasAttribute('required');
100
+ const extraClasses = this.getAttribute('class') || '';
101
+
102
+ this._button.type = 'button';
103
+ this._button.setAttribute('role', 'checkbox');
104
+ this._button.setAttribute(
105
+ 'aria-checked',
106
+ isIndeterminate ? 'mixed' : isChecked ? 'true' : 'false',
107
+ );
108
+ this._button.setAttribute('aria-required', isRequired ? 'true' : 'false');
109
+ this._button.setAttribute('data-slot', 'checkbox');
110
+ this._button.setAttribute(
111
+ 'data-state',
112
+ isIndeterminate ? 'indeterminate' : isChecked ? 'checked' : 'unchecked',
113
+ );
114
+ this._button.disabled = isDisabled;
115
+ if (isDisabled) {
116
+ this._button.setAttribute('data-disabled', '');
117
+ } else {
118
+ this._button.removeAttribute('data-disabled');
119
+ }
120
+
121
+ this._button.className =
122
+ `peer relative inline-flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors group-has-disabled/field:opacity-50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50 ${extraClasses}`.trim();
123
+
124
+ this._indicator.setAttribute('data-slot', 'checkbox-indicator');
125
+ this._indicator.className =
126
+ '[&>svg]:size-3.5 grid place-content-center text-current transition-none';
127
+
128
+ if (isChecked) {
129
+ this._indicator.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5"><polyline points="20 6 9 17 4 12"/></svg>`;
130
+ } else if (isIndeterminate) {
131
+ this._indicator.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;
132
+ } else {
133
+ this._indicator.innerHTML = '';
134
+ }
135
+
136
+ const name = this.getAttribute('name');
137
+ if (name) {
138
+ if (!this._hiddenInput) {
139
+ this._hiddenInput = document.createElement('input');
140
+ this._hiddenInput.type = 'checkbox';
141
+ this._hiddenInput.tabIndex = -1;
142
+ this._hiddenInput.setAttribute('aria-hidden', 'true');
143
+ this._hiddenInput.className = 'sr-only pointer-events-none';
144
+ this.appendChild(this._hiddenInput);
145
+ }
146
+ this._hiddenInput.name = name;
147
+ this._hiddenInput.value = this.getAttribute('value') || 'on';
148
+ this._hiddenInput.checked = isChecked;
149
+ this._hiddenInput.disabled = isDisabled;
150
+ this._hiddenInput.required = isRequired;
151
+ } else if (this._hiddenInput) {
152
+ this._hiddenInput.remove();
153
+ this._hiddenInput = null;
154
+ }
155
+ }
156
+
157
+ private render() {
158
+ if (!this.contains(this._button)) {
159
+ this.innerHTML = '';
160
+ this._button.appendChild(this._indicator);
161
+ this.appendChild(this._button);
162
+ }
163
+ this.updateState();
164
+ }
165
+ }
166
+
167
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-checkbox')) {
168
+
169
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-checkbox')) {
170
+ customElements.define('surreal-shadcn-checkbox', SurrealShadcnCheckbox);
171
+ }
172
+ }
173
+
174
+ export { SurrealShadcnCheckbox };
175
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-checkbox')) {
176
+ customElements.define('surreal-minimalist-checkbox', SurrealShadcnCheckbox);
177
+ }
178
+
179
+ export default SurrealShadcnCheckbox;