@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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +832 -6249
  3. package/dist/utils.d.ts +9 -0
  4. package/dist/utils.js +14 -0
  5. package/package.json +14 -3
  6. package/CHANGELOG.md +0 -142
  7. package/src/components/GlassmorphismAlert.ts +0 -115
  8. package/src/components/GlassmorphismButton.ts +0 -18
  9. package/src/components/GlassmorphismCard.ts +0 -36
  10. package/src/components/GlassmorphismEmptyState.ts +0 -35
  11. package/src/components/GlassmorphismInputGroup.ts +0 -205
  12. package/src/components/GlassmorphismMenubar.ts +0 -36
  13. package/src/components/GlassmorphismScrollArea.ts +0 -86
  14. package/src/components/GlassmorphismTable.ts +0 -52
  15. package/src/components/GlassmorphismTypography.ts +0 -70
  16. package/src/components/MinimalistAccordion.ts +0 -252
  17. package/src/components/MinimalistAlert.ts +0 -98
  18. package/src/components/MinimalistAlertDialog.ts +0 -102
  19. package/src/components/MinimalistAspectRatio.ts +0 -36
  20. package/src/components/MinimalistAvatar.ts +0 -97
  21. package/src/components/MinimalistBadge.ts +0 -70
  22. package/src/components/MinimalistBreadcrumb.ts +0 -92
  23. package/src/components/MinimalistButton.ts +0 -110
  24. package/src/components/MinimalistButtonGroup.ts +0 -112
  25. package/src/components/MinimalistCalendar.ts +0 -281
  26. package/src/components/MinimalistCard.ts +0 -130
  27. package/src/components/MinimalistCarousel.ts +0 -121
  28. package/src/components/MinimalistChart.ts +0 -150
  29. package/src/components/MinimalistCheckbox.ts +0 -178
  30. package/src/components/MinimalistCodeBlock.ts +0 -112
  31. package/src/components/MinimalistCollapsible.ts +0 -160
  32. package/src/components/MinimalistCommand.ts +0 -111
  33. package/src/components/MinimalistContextMenu.ts +0 -101
  34. package/src/components/MinimalistDialog.ts +0 -103
  35. package/src/components/MinimalistDrawer.ts +0 -222
  36. package/src/components/MinimalistDropdownMenu.ts +0 -125
  37. package/src/components/MinimalistEmpty.ts +0 -97
  38. package/src/components/MinimalistEmptyState.ts +0 -41
  39. package/src/components/MinimalistField.ts +0 -176
  40. package/src/components/MinimalistForm.ts +0 -102
  41. package/src/components/MinimalistHoverCard.ts +0 -149
  42. package/src/components/MinimalistInput.ts +0 -104
  43. package/src/components/MinimalistInputGroup.ts +0 -95
  44. package/src/components/MinimalistInputOtp.ts +0 -154
  45. package/src/components/MinimalistItem.ts +0 -159
  46. package/src/components/MinimalistKbd.ts +0 -37
  47. package/src/components/MinimalistLabel.ts +0 -53
  48. package/src/components/MinimalistMenubar.ts +0 -81
  49. package/src/components/MinimalistNativeSelect.ts +0 -149
  50. package/src/components/MinimalistNavigationMenu.ts +0 -103
  51. package/src/components/MinimalistPagination.ts +0 -140
  52. package/src/components/MinimalistPopover.ts +0 -112
  53. package/src/components/MinimalistProgress.ts +0 -70
  54. package/src/components/MinimalistRadioGroup.ts +0 -228
  55. package/src/components/MinimalistRangeCalendar.ts +0 -272
  56. package/src/components/MinimalistResizable.ts +0 -44
  57. package/src/components/MinimalistScrollArea.ts +0 -42
  58. package/src/components/MinimalistSelect.ts +0 -103
  59. package/src/components/MinimalistSeparator.ts +0 -52
  60. package/src/components/MinimalistSheet.ts +0 -165
  61. package/src/components/MinimalistSidebar.ts +0 -74
  62. package/src/components/MinimalistSkeleton.ts +0 -32
  63. package/src/components/MinimalistSlider.ts +0 -236
  64. package/src/components/MinimalistSonner.ts +0 -93
  65. package/src/components/MinimalistSpinner.ts +0 -52
  66. package/src/components/MinimalistSwitch.ts +0 -165
  67. package/src/components/MinimalistTable.ts +0 -35
  68. package/src/components/MinimalistTabs.ts +0 -97
  69. package/src/components/MinimalistTextarea.ts +0 -99
  70. package/src/components/MinimalistToggle.ts +0 -104
  71. package/src/components/MinimalistToggleGroup.ts +0 -177
  72. package/src/components/MinimalistTooltip.ts +0 -82
  73. package/src/components/MinimalistTypography.ts +0 -106
  74. package/src/components/NeubrutalismCard.ts +0 -35
  75. package/src/components/NeubrutalismItem.ts +0 -67
  76. package/src/components/ShadcnAccordion.ts +0 -248
  77. package/src/components/ShadcnAlertDialog.ts +0 -95
  78. package/src/components/ShadcnAspectRatio.ts +0 -29
  79. package/src/components/ShadcnAvatar.ts +0 -93
  80. package/src/components/ShadcnBadge.ts +0 -66
  81. package/src/components/ShadcnBreadcrumb.ts +0 -88
  82. package/src/components/ShadcnButton.ts +0 -106
  83. package/src/components/ShadcnButtonGroup.ts +0 -105
  84. package/src/components/ShadcnCalendar.ts +0 -277
  85. package/src/components/ShadcnCarousel.ts +0 -117
  86. package/src/components/ShadcnChart.ts +0 -146
  87. package/src/components/ShadcnCheckbox.ts +0 -174
  88. package/src/components/ShadcnCodeBlock.ts +0 -108
  89. package/src/components/ShadcnCollapsible.ts +0 -153
  90. package/src/components/ShadcnCommand.ts +0 -107
  91. package/src/components/ShadcnContextMenu.ts +0 -94
  92. package/src/components/ShadcnDialog.ts +0 -99
  93. package/src/components/ShadcnDrawer.ts +0 -218
  94. package/src/components/ShadcnDropdownMenu.ts +0 -118
  95. package/src/components/ShadcnEmpty.ts +0 -93
  96. package/src/components/ShadcnField.ts +0 -172
  97. package/src/components/ShadcnForm.ts +0 -98
  98. package/src/components/ShadcnHoverCard.ts +0 -145
  99. package/src/components/ShadcnInput.ts +0 -100
  100. package/src/components/ShadcnInputGroup.ts +0 -88
  101. package/src/components/ShadcnInputOtp.ts +0 -150
  102. package/src/components/ShadcnItem.ts +0 -155
  103. package/src/components/ShadcnKbd.ts +0 -33
  104. package/src/components/ShadcnLabel.ts +0 -49
  105. package/src/components/ShadcnMenubar.ts +0 -77
  106. package/src/components/ShadcnNativeSelect.ts +0 -142
  107. package/src/components/ShadcnNavigationMenu.ts +0 -96
  108. package/src/components/ShadcnPagination.ts +0 -136
  109. package/src/components/ShadcnPopover.ts +0 -108
  110. package/src/components/ShadcnProgress.ts +0 -66
  111. package/src/components/ShadcnRadioGroup.ts +0 -221
  112. package/src/components/ShadcnRangeCalendar.ts +0 -265
  113. package/src/components/ShadcnSelect.ts +0 -99
  114. package/src/components/ShadcnSeparator.ts +0 -48
  115. package/src/components/ShadcnSheet.ts +0 -161
  116. package/src/components/ShadcnSidebar.ts +0 -70
  117. package/src/components/ShadcnSkeleton.ts +0 -28
  118. package/src/components/ShadcnSlider.ts +0 -232
  119. package/src/components/ShadcnSonner.ts +0 -89
  120. package/src/components/ShadcnSpinner.ts +0 -48
  121. package/src/components/ShadcnSwitch.ts +0 -161
  122. package/src/components/ShadcnTabs.ts +0 -93
  123. package/src/components/ShadcnTextarea.ts +0 -95
  124. package/src/components/ShadcnToggle.ts +0 -100
  125. package/src/components/ShadcnToggleGroup.ts +0 -170
  126. package/src/components/ShadcnTooltip.ts +0 -78
  127. package/src/index.ts +0 -124
@@ -1,281 +0,0 @@
1
- export class SurrealShadcnCalendar extends HTMLElement {
2
- private _value: Date | null = null;
3
- private _currentMonth: Date = new Date();
4
- private _captionLayout: string = 'label';
5
- private _locale: string = 'en-US';
6
-
7
- static get observedAttributes() {
8
- return ['value', 'caption-layout', 'locale'];
9
- }
10
-
11
- constructor() {
12
- super();
13
- }
14
-
15
- connectedCallback() {
16
- if (this.hasAttribute('value')) {
17
- this._value = new Date(this.getAttribute('value') || '');
18
- }
19
- if (this.hasAttribute('caption-layout')) {
20
- this._captionLayout = this.getAttribute('caption-layout') || 'label';
21
- }
22
- if (this.hasAttribute('locale')) {
23
- this._locale = this.getAttribute('locale') || 'en-US';
24
- }
25
- if (this._value && !isNaN(this._value.getTime())) {
26
- this._currentMonth = new Date(this._value.getFullYear(), this._value.getMonth(), 1);
27
- } else {
28
- this._currentMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
29
- }
30
- this.render();
31
- }
32
-
33
- attributeChangedCallback(name: string, oldValue: string, newValue: string) {
34
- if (oldValue === newValue) return;
35
- if (name === 'value') {
36
- this._value = newValue ? new Date(newValue) : null;
37
- } else if (name === 'caption-layout') {
38
- this._captionLayout = newValue || 'label';
39
- } else if (name === 'locale') {
40
- this._locale = newValue || 'en-US';
41
- }
42
- this.render();
43
- }
44
-
45
- get value(): Date | null {
46
- return this._value;
47
- }
48
-
49
- set value(val: Date | string | null) {
50
- this._value = val ? new Date(val) : null;
51
- this.render();
52
- }
53
-
54
- private _prevMonth = () => {
55
- this._currentMonth = new Date(
56
- this._currentMonth.getFullYear(),
57
- this._currentMonth.getMonth() - 1,
58
- 1
59
- );
60
- this.render();
61
- };
62
-
63
- private _nextMonth = () => {
64
- this._currentMonth = new Date(
65
- this._currentMonth.getFullYear(),
66
- this._currentMonth.getMonth() + 1,
67
- 1
68
- );
69
- this.render();
70
- };
71
-
72
- private _selectDate(date: Date) {
73
- this._value = date;
74
- this.setAttribute('value', date.toISOString());
75
- this.dispatchEvent(
76
- new CustomEvent('change', { detail: { value: date }, bubbles: true, composed: true })
77
- );
78
- this.render();
79
- }
80
-
81
- render() {
82
- const year = this._currentMonth.getFullYear();
83
- const month = this._currentMonth.getMonth();
84
- const monthNames = [
85
- 'January',
86
- 'February',
87
- 'March',
88
- 'April',
89
- 'May',
90
- 'June',
91
- 'July',
92
- 'August',
93
- 'September',
94
- 'October',
95
- 'November',
96
- 'December'
97
- ];
98
- const monthStr = new Intl.DateTimeFormat(this._locale, { month: 'long' }).format(
99
- this._currentMonth
100
- );
101
- const yearStr = new Intl.DateTimeFormat(this._locale, { year: 'numeric' }).format(
102
- this._currentMonth
103
- );
104
-
105
- const weekdays = [];
106
- const temp = new Date(2023, 0, 1);
107
- for (let i = 0; i < 7; i++) {
108
- weekdays.push(
109
- new Intl.DateTimeFormat(this._locale, { weekday: 'short' }).format(temp).slice(0, 2)
110
- );
111
- temp.setDate(temp.getDate() + 1);
112
- }
113
-
114
- const firstDay = new Date(year, month, 1);
115
- const lastDay = new Date(year, month + 1, 0);
116
- const startOffset = firstDay.getDay();
117
- const daysInMonth = lastDay.getDate();
118
- const prevMonthLastDay = new Date(year, month, 0).getDate();
119
-
120
- const today = new Date();
121
- today.setHours(0, 0, 0, 0);
122
-
123
- const cells: Array<{
124
- date: Date;
125
- isCurrentMonth: boolean;
126
- isToday: boolean;
127
- isSelected: boolean;
128
- }> = [];
129
-
130
- for (let i = startOffset - 1; i >= 0; i--) {
131
- const d = new Date(year, month - 1, prevMonthLastDay - i);
132
- d.setHours(0, 0, 0, 0);
133
- cells.push({
134
- date: d,
135
- isCurrentMonth: false,
136
- isToday: d.getTime() === today.getTime(),
137
- isSelected:
138
- !!this._value &&
139
- d.getFullYear() === this._value.getFullYear() &&
140
- d.getMonth() === this._value.getMonth() &&
141
- d.getDate() === this._value.getDate()
142
- });
143
- }
144
-
145
- for (let dNum = 1; dNum <= daysInMonth; dNum++) {
146
- const d = new Date(year, month, dNum);
147
- d.setHours(0, 0, 0, 0);
148
- cells.push({
149
- date: d,
150
- isCurrentMonth: true,
151
- isToday: d.getTime() === today.getTime(),
152
- isSelected:
153
- !!this._value &&
154
- d.getFullYear() === this._value.getFullYear() &&
155
- d.getMonth() === this._value.getMonth() &&
156
- d.getDate() === this._value.getDate()
157
- });
158
- }
159
-
160
- let nextD = 1;
161
- while (cells.length % 7 !== 0) {
162
- const d = new Date(year, month + 1, nextD);
163
- d.setHours(0, 0, 0, 0);
164
- cells.push({
165
- date: d,
166
- isCurrentMonth: false,
167
- isToday: d.getTime() === today.getTime(),
168
- isSelected:
169
- !!this._value &&
170
- d.getFullYear() === this._value.getFullYear() &&
171
- d.getMonth() === this._value.getMonth() &&
172
- d.getDate() === this._value.getDate()
173
- });
174
- nextD++;
175
- }
176
-
177
- this.innerHTML = `
178
- <div data-slot="calendar" class="p-3 rounded-lg border border-border bg-background text-foreground shadow-sm inline-block select-none">
179
- <div class="flex flex-col gap-4">
180
- <div class="relative flex items-center justify-between pt-1">
181
- <div class="flex items-center gap-1.5 text-sm font-semibold pl-1">
182
- ${
183
- this._captionLayout === 'dropdown' || this._captionLayout === 'dropdown-months'
184
- ? `<div class="relative flex items-center">
185
- <select data-role="month-select" class="appearance-none bg-transparent hover:bg-accent hover:text-accent-foreground text-sm font-medium py-1 ps-2 pe-6 rounded-md border border-input cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring">
186
- ${monthNames.map((m, idx) => `<option value="${idx}" ${idx === month ? 'selected' : ''}>${m}</option>`).join('')}
187
- </select>
188
- </div>`
189
- : `<span>${monthStr}</span>`
190
- }
191
- ${
192
- this._captionLayout === 'dropdown' || this._captionLayout === 'dropdown-years'
193
- ? `<div class="relative flex items-center">
194
- <select data-role="year-select" class="appearance-none bg-transparent hover:bg-accent hover:text-accent-foreground text-sm font-medium py-1 ps-2 pe-6 rounded-md border border-input cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring">
195
- ${Array.from({ length: 21 }, (_, i) => year - 10 + i)
196
- .map(
197
- (y) =>
198
- `<option value="${y}" ${y === year ? 'selected' : ''}>${y}</option>`
199
- )
200
- .join('')}
201
- </select>
202
- </div>`
203
- : `<span>${yearStr}</span>`
204
- }
205
- </div>
206
- <div class="flex items-center gap-1">
207
- <button type="button" data-role="prev-btn" aria-label="Previous Month" class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">
208
- <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg>
209
- </button>
210
- <button type="button" data-role="next-btn" aria-label="Next Month" class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">
211
- <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" /></svg>
212
- </button>
213
- </div>
214
- </div>
215
- <div class="w-full">
216
- <div class="grid grid-cols-7 mb-1">
217
- ${weekdays.map((d) => `<div class="size-8 flex items-center justify-center text-[0.8rem] font-medium text-muted-foreground">${d}</div>`).join('')}
218
- </div>
219
- <div class="grid grid-cols-7 gap-y-1">
220
- ${cells
221
- .map((cell, idx) => {
222
- let classes =
223
- 'size-8 flex items-center justify-center rounded-md text-sm font-normal transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring';
224
- if (!cell.isCurrentMonth) classes += ' text-muted-foreground opacity-40';
225
- if (cell.isToday && !cell.isSelected)
226
- classes += ' bg-accent text-accent-foreground font-semibold';
227
- if (cell.isSelected)
228
- classes +=
229
- ' bg-primary text-primary-foreground font-medium hover:bg-primary hover:text-primary-foreground';
230
- if (!cell.isSelected) classes += ' hover:bg-accent hover:text-accent-foreground';
231
- return `<button type="button" data-date-index="${idx}" class="${classes}">${cell.date.getDate()}</button>`;
232
- })
233
- .join('')}
234
- </div>
235
- </div>
236
- </div>
237
- </div>
238
- `;
239
-
240
- this.querySelector('[data-role="prev-btn"]')?.addEventListener('click', this._prevMonth);
241
- this.querySelector('[data-role="next-btn"]')?.addEventListener('click', this._nextMonth);
242
-
243
- const monthSelect = this.querySelector('[data-role="month-select"]') as HTMLSelectElement;
244
- if (monthSelect) {
245
- monthSelect.addEventListener('change', (e) => {
246
- const m = parseInt((e.target as HTMLSelectElement).value, 10);
247
- this._currentMonth = new Date(this._currentMonth.getFullYear(), m, 1);
248
- this.render();
249
- });
250
- }
251
-
252
- const yearSelect = this.querySelector('[data-role="year-select"]') as HTMLSelectElement;
253
- if (yearSelect) {
254
- yearSelect.addEventListener('change', (e) => {
255
- const y = parseInt((e.target as HTMLSelectElement).value, 10);
256
- this._currentMonth = new Date(y, this._currentMonth.getMonth(), 1);
257
- this.render();
258
- });
259
- }
260
-
261
- this.querySelectorAll('[data-date-index]').forEach((btn) => {
262
- btn.addEventListener('click', () => {
263
- const idx = parseInt(btn.getAttribute('data-date-index') || '0', 10);
264
- if (cells[idx]) {
265
- this._selectDate(cells[idx].date);
266
- }
267
- });
268
- });
269
- }
270
- }
271
-
272
- if (!customElements.get('surreal-calendar')) {
273
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-calendar')) {
274
- customElements.define('surreal-shadcn-calendar', SurrealShadcnCalendar);
275
- }
276
- }
277
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-calendar')) {
278
- customElements.define('surreal-minimalist-calendar', SurrealShadcnCalendar);
279
- }
280
-
281
- export default SurrealShadcnCalendar;
@@ -1,130 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-modern-card')) {
122
- customElements.define('surreal-modern-card', SurrealModernCard);
123
- }
124
- export { SurrealModernCard as MinimalistCard, SurrealModernCard };
125
-
126
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-card')) {
127
- customElements.define('surreal-minimalist-card', SurrealModernCard);
128
- }
129
-
130
- export default SurrealModernCard;
@@ -1,121 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-carousel')) {
112
- customElements.define('surreal-shadcn-carousel', SurrealShadcnCarousel);
113
- }
114
- }
115
- export { SurrealShadcnCarousel as MinimalistCarousel, SurrealShadcnCarousel };
116
-
117
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-carousel')) {
118
- customElements.define('surreal-minimalist-carousel', SurrealShadcnCarousel);
119
- }
120
-
121
- export default SurrealShadcnCarousel;
@@ -1,150 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-chart')) {
137
- customElements.define('surreal-shadcn-chart', SurrealShadcnChartContainer);
138
- }
139
- }
140
-
141
- if (!customElements.get('surreal-chart-tooltip')) {
142
- customElements.define('surreal-shadcn-chart', SurrealShadcnChartTooltip);
143
- }
144
- export { SurrealShadcnChartContainer as MinimalistChart, SurrealShadcnChartContainer };
145
-
146
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-chart')) {
147
- customElements.define('surreal-minimalist-chart', SurrealShadcnChartContainer);
148
- }
149
-
150
- export default SurrealShadcnChartContainer;