@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,36 +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
- if (
30
- typeof customElements !== 'undefined' &&
31
- !customElements.get('surreal-minimalist-aspect-ratio')
32
- ) {
33
- customElements.define('surreal-minimalist-aspect-ratio', AspectRatioElement);
34
- }
35
-
36
- export default AspectRatioElement;
@@ -1,97 +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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-avatar')) {
94
- customElements.define('surreal-minimalist-avatar', SurrealShadcnAvatar);
95
- }
96
-
97
- export default SurrealShadcnAvatar;
@@ -1,70 +0,0 @@
1
- import { cn, cva } from '@surreal-ui/core';
2
-
3
- const badgeVariants = cva(
4
- 'h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none',
5
- {
6
- variants: {
7
- variant: {
8
- default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
9
- secondary: 'bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80',
10
- destructive:
11
- 'bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20',
12
- outline: 'border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground',
13
- ghost: 'hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50',
14
- link: 'text-primary underline-offset-4 hover:underline'
15
- }
16
- },
17
- defaultVariants: {
18
- variant: 'default'
19
- }
20
- }
21
- );
22
-
23
- export class UiBadge extends HTMLElement {
24
- static get observedAttributes() {
25
- return ['variant', 'href', 'class'];
26
- }
27
-
28
- private _element: HTMLElement | null = null;
29
-
30
- connectedCallback() {
31
- this.render();
32
- }
33
-
34
- attributeChangedCallback() {
35
- this.render();
36
- }
37
-
38
- private render() {
39
- const href = this.getAttribute('href');
40
- const variant = (this.getAttribute('variant') || 'default') as any;
41
- const customClass = this.getAttribute('class') || '';
42
-
43
- const tagName = href ? 'a' : 'span';
44
- if (!this._element || this._element.tagName.toLowerCase() !== tagName) {
45
- this.innerHTML = '';
46
- this._element = document.createElement(tagName);
47
- this._element.setAttribute('data-slot', 'badge');
48
- const slot = document.createElement('slot');
49
- this._element.appendChild(slot);
50
- this.appendChild(this._element);
51
- }
52
-
53
- if (href && this._element instanceof HTMLAnchorElement) {
54
- this._element.href = href;
55
- }
56
-
57
- this._element.className = cn(badgeVariants({ variant }), customClass);
58
- }
59
- }
60
-
61
- if (!customElements.get('ui-badge')) {
62
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-badge')) {
63
- customElements.define('surreal-shadcn-badge', UiBadge);
64
- }
65
- }
66
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-badge')) {
67
- customElements.define('surreal-minimalist-badge', UiBadge);
68
- }
69
-
70
- export default UiBadge;
@@ -1,92 +0,0 @@
1
- import { cn } from '@surreal-ui/core';
2
-
3
- export class BreadcrumbRoot extends HTMLElement {
4
- connectedCallback() {
5
- this.setAttribute('data-slot', 'breadcrumb');
6
- this.setAttribute('aria-label', 'breadcrumb');
7
- this.className = cn('cn-breadcrumb block', this.className);
8
- }
9
- }
10
-
11
- export class BreadcrumbList extends HTMLElement {
12
- connectedCallback() {
13
- this.setAttribute('data-slot', 'breadcrumb-list');
14
- this.className = cn(
15
- 'gap-1.5 text-sm text-muted-foreground flex flex-wrap items-center wrap-break-word list-none p-0 m-0',
16
- this.className
17
- );
18
- }
19
- }
20
-
21
- export class BreadcrumbItem extends HTMLElement {
22
- connectedCallback() {
23
- this.setAttribute('data-slot', 'breadcrumb-item');
24
- this.className = cn('gap-1 inline-flex items-center', this.className);
25
- }
26
- }
27
-
28
- export class BreadcrumbLink extends HTMLElement {
29
- connectedCallback() {
30
- this.setAttribute('data-slot', 'breadcrumb-link');
31
- const href = this.getAttribute('href') || '#';
32
- const content = this.innerHTML;
33
- this.innerHTML = `<a href="${href}" class="${cn('transition-colors hover:text-foreground text-inherit no-underline', this.getAttribute('link-class') || '')}">${content}</a>`;
34
- }
35
- }
36
-
37
- export class BreadcrumbPage extends HTMLElement {
38
- connectedCallback() {
39
- this.setAttribute('data-slot', 'breadcrumb-page');
40
- this.setAttribute('role', 'link');
41
- this.setAttribute('aria-disabled', 'true');
42
- this.setAttribute('aria-current', 'page');
43
- this.className = cn('font-normal text-foreground', this.className);
44
- }
45
- }
46
-
47
- export class BreadcrumbSeparator extends HTMLElement {
48
- connectedCallback() {
49
- this.setAttribute('data-slot', 'breadcrumb-separator');
50
- this.setAttribute('role', 'presentation');
51
- this.setAttribute('aria-hidden', 'true');
52
- this.className = cn(
53
- '[&>svg]:size-3.5 inline-flex items-center text-muted-foreground',
54
- this.className
55
- );
56
- if (!this.innerHTML.trim()) {
57
- this.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-3.5"><path d="m9 18 6-6-6-6"/></svg>`;
58
- }
59
- }
60
- }
61
-
62
- export class BreadcrumbEllipsis extends HTMLElement {
63
- connectedCallback() {
64
- this.setAttribute('data-slot', 'breadcrumb-ellipsis');
65
- this.setAttribute('role', 'presentation');
66
- this.setAttribute('aria-hidden', 'true');
67
- this.className = cn('size-5 [&>svg]:size-4 flex items-center justify-center', this.className);
68
- this.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg><span class="sr-only">More</span>`;
69
- }
70
- }
71
-
72
- if (!customElements.get('ui-breadcrumb'))
73
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-breadcrumb')) {
74
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbRoot);
75
- }
76
- if (!customElements.get('ui-breadcrumb-list'))
77
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbList);
78
- if (!customElements.get('ui-breadcrumb-item'))
79
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbItem);
80
- if (!customElements.get('ui-breadcrumb-link'))
81
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbLink);
82
- if (!customElements.get('ui-breadcrumb-page'))
83
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbPage);
84
- if (!customElements.get('ui-breadcrumb-separator'))
85
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbSeparator);
86
- if (!customElements.get('ui-breadcrumb-ellipsis'))
87
- customElements.define('surreal-shadcn-breadcrumb', BreadcrumbEllipsis);
88
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-breadcrumb')) {
89
- customElements.define('surreal-minimalist-breadcrumb', BreadcrumbRoot);
90
- }
91
-
92
- export default BreadcrumbRoot;
@@ -1,110 +0,0 @@
1
- import { cn, cva } from '@surreal-ui/core';
2
-
3
- const buttonVariants = cva(
4
- "rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
5
- {
6
- variants: {
7
- variant: {
8
- default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
9
- outline:
10
- 'border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',
11
- secondary:
12
- 'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
13
- ghost:
14
- 'hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50',
15
- destructive:
16
- 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40',
17
- link: 'text-primary underline-offset-4 hover:underline'
18
- },
19
- size: {
20
- default:
21
- 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
22
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
23
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
24
- lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
25
- icon: 'size-8',
26
- 'icon-xs':
27
- "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
28
- 'icon-sm':
29
- 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
30
- 'icon-lg': 'size-9'
31
- }
32
- },
33
- defaultVariants: {
34
- variant: 'default',
35
- size: 'default'
36
- }
37
- }
38
- );
39
-
40
- export class SurrealShadcnButton extends HTMLElement {
41
- static get observedAttributes() {
42
- return ['variant', 'size', 'href', 'disabled', 'type', 'class'];
43
- }
44
-
45
- private element: HTMLButtonElement | HTMLAnchorElement | null = null;
46
-
47
- connectedCallback() {
48
- this.render();
49
- }
50
-
51
- attributeChangedCallback() {
52
- this.render();
53
- }
54
-
55
- private render() {
56
- const variant = (this.getAttribute('variant') || 'default') as any;
57
- const size = (this.getAttribute('size') || 'default') as any;
58
- const href = this.getAttribute('href');
59
- const disabled = this.hasAttribute('disabled');
60
- const type = this.getAttribute('type') || 'button';
61
- const customClass = this.getAttribute('class') || '';
62
- const classes = cn(buttonVariants({ variant, size }), customClass);
63
-
64
- const isAnchor = Boolean(href);
65
- const tagName = isAnchor ? 'a' : 'button';
66
-
67
- if (!this.element || this.element.tagName.toLowerCase() !== tagName) {
68
- this.innerHTML = '';
69
- this.element = document.createElement(tagName);
70
- this.element.setAttribute('data-slot', 'button');
71
-
72
- while (this.childNodes.length > 0) {
73
- this.element.appendChild(this.childNodes[0]);
74
- }
75
- this.appendChild(this.element);
76
- }
77
-
78
- this.element.className = classes;
79
-
80
- if (isAnchor) {
81
- const anchor = this.element as HTMLAnchorElement;
82
- if (disabled) {
83
- anchor.removeAttribute('href');
84
- anchor.setAttribute('aria-disabled', 'true');
85
- anchor.setAttribute('role', 'link');
86
- anchor.setAttribute('tabindex', '-1');
87
- } else {
88
- anchor.setAttribute('href', href!);
89
- anchor.removeAttribute('aria-disabled');
90
- anchor.removeAttribute('role');
91
- anchor.removeAttribute('tabindex');
92
- }
93
- } else {
94
- const btn = this.element as HTMLButtonElement;
95
- btn.type = type;
96
- btn.disabled = disabled;
97
- }
98
- }
99
- }
100
-
101
- if (!customElements.get('surreal-button')) {
102
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-button')) {
103
- customElements.define('surreal-shadcn-button', SurrealShadcnButton);
104
- }
105
- }
106
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-button')) {
107
- customElements.define('surreal-minimalist-button', SurrealShadcnButton);
108
- }
109
-
110
- export default SurrealShadcnButton;
@@ -1,112 +0,0 @@
1
- import { cn, cva } from '@surreal-ui/core';
2
-
3
- const buttonGroupVariants = cva(
4
- "has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg flex w-fit items-stretch [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
5
- {
6
- variants: {
7
- orientation: {
8
- horizontal:
9
- '[&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]]:rounded-r-none [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0',
10
- vertical:
11
- '[&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! flex-col [&>[data-slot]]:rounded-b-none [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0'
12
- }
13
- },
14
- defaultVariants: {
15
- orientation: 'horizontal'
16
- }
17
- }
18
- );
19
-
20
- export class ButtonGroupElement extends HTMLElement {
21
- static get observedAttributes() {
22
- return ['orientation', 'class'];
23
- }
24
-
25
- connectedCallback() {
26
- this.setAttribute('role', 'group');
27
- this.setAttribute('data-slot', 'button-group');
28
- this.render();
29
- }
30
-
31
- attributeChangedCallback() {
32
- this.render();
33
- }
34
-
35
- render() {
36
- const orientation =
37
- (this.getAttribute('orientation') as 'horizontal' | 'vertical') || 'horizontal';
38
- this.setAttribute('data-orientation', orientation);
39
- const customClass = this.getAttribute('class') || '';
40
- this.className = cn(buttonGroupVariants({ orientation }), customClass);
41
- }
42
- }
43
-
44
- export class ButtonGroupSeparatorElement extends HTMLElement {
45
- static get observedAttributes() {
46
- return ['orientation', 'class'];
47
- }
48
-
49
- connectedCallback() {
50
- this.setAttribute('role', 'separator');
51
- this.setAttribute('data-slot', 'button-group-separator');
52
- this.render();
53
- }
54
-
55
- attributeChangedCallback() {
56
- this.render();
57
- }
58
-
59
- render() {
60
- const orientation = this.getAttribute('orientation') || 'vertical';
61
- this.setAttribute('data-orientation', orientation);
62
- this.setAttribute('aria-orientation', orientation);
63
- const customClass = this.getAttribute('class') || '';
64
- this.className = cn(
65
- 'bg-input relative self-stretch data-[orientation=horizontal]:mx-px data-[orientation=horizontal]:w-auto data-[orientation=vertical]:my-px data-[orientation=vertical]:h-auto',
66
- customClass
67
- );
68
- }
69
- }
70
-
71
- export class ButtonGroupTextElement extends HTMLElement {
72
- static get observedAttributes() {
73
- return ['class'];
74
- }
75
-
76
- connectedCallback() {
77
- this.setAttribute('data-slot', 'button-group-text');
78
- this.render();
79
- }
80
-
81
- attributeChangedCallback() {
82
- this.render();
83
- }
84
-
85
- render() {
86
- const customClass = this.getAttribute('class') || '';
87
- this.className = cn(
88
- "gap-2 rounded-lg border bg-muted px-2.5 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
89
- customClass
90
- );
91
- }
92
- }
93
-
94
- if (!customElements.get('surreal-button-group')) {
95
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-button-group')) {
96
- customElements.define('surreal-shadcn-button-group', ButtonGroupElement);
97
- }
98
- }
99
- if (!customElements.get('surreal-button-group-separator')) {
100
- customElements.define('surreal-shadcn-button-group', ButtonGroupSeparatorElement);
101
- }
102
- if (!customElements.get('surreal-button-group-text')) {
103
- customElements.define('surreal-shadcn-button-group', ButtonGroupTextElement);
104
- }
105
- if (
106
- typeof customElements !== 'undefined' &&
107
- !customElements.get('surreal-minimalist-button-group')
108
- ) {
109
- customElements.define('surreal-minimalist-button-group', ButtonGroupElement);
110
- }
111
-
112
- export default ButtonGroupElement;