@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,160 @@
1
+ const itemVariantMap = {
2
+ default: 'border-transparent',
3
+ outline: 'border-border',
4
+ muted: 'border-transparent bg-muted/50',
5
+ };
6
+
7
+ const itemSizeMap = {
8
+ default: 'gap-2.5 px-3 py-2.5',
9
+ sm: 'gap-2.5 px-3 py-2.5',
10
+ xs: 'gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0',
11
+ };
12
+
13
+ const itemMediaVariantMap = {
14
+ default: 'bg-transparent',
15
+ icon: "[&_svg:not([class*='size-'])]:size-4",
16
+ image:
17
+ 'size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover',
18
+ };
19
+
20
+ class UIItem extends HTMLElement {
21
+ static get observedAttributes() {
22
+ return ['variant', 'size', 'class'];
23
+ }
24
+
25
+ connectedCallback() {
26
+ this.render();
27
+ }
28
+
29
+ attributeChangedCallback() {
30
+ this.render();
31
+ }
32
+
33
+ render() {
34
+ const variant = (this.getAttribute('variant') || 'default') as keyof typeof itemVariantMap;
35
+ const size = (this.getAttribute('size') || 'default') as keyof typeof itemSizeMap;
36
+ const customClass = this.getAttribute('class') || '';
37
+ this.setAttribute('data-slot', 'item');
38
+ this.setAttribute('data-variant', variant);
39
+ this.setAttribute('data-size', size);
40
+ this.className =
41
+ `rounded-lg border text-sm [a]:hover:bg-muted group/item flex w-full flex-wrap items-center transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors ${itemVariantMap[variant] || itemVariantMap.default} ${itemSizeMap[size] || itemSizeMap.default} ${customClass}`.trim();
42
+ }
43
+ }
44
+
45
+ class UIItemGroup extends HTMLElement {
46
+ connectedCallback() {
47
+ this.setAttribute('role', 'list');
48
+ this.setAttribute('data-slot', 'item-group');
49
+ const customClass = this.getAttribute('class') || '';
50
+ this.className =
51
+ `gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2 group/item-group flex w-full flex-col ${customClass}`.trim();
52
+ }
53
+ }
54
+
55
+ class UIItemHeader extends HTMLElement {
56
+ connectedCallback() {
57
+ this.setAttribute('data-slot', 'item-header');
58
+ const customClass = this.getAttribute('class') || '';
59
+ this.className = `gap-2 flex basis-full items-center justify-between ${customClass}`.trim();
60
+ }
61
+ }
62
+
63
+ class UIItemFooter extends HTMLElement {
64
+ connectedCallback() {
65
+ this.setAttribute('data-slot', 'item-footer');
66
+ const customClass = this.getAttribute('class') || '';
67
+ this.className = `gap-2 flex basis-full items-center justify-between ${customClass}`.trim();
68
+ }
69
+ }
70
+
71
+ class UIItemContent extends HTMLElement {
72
+ connectedCallback() {
73
+ this.setAttribute('data-slot', 'item-content');
74
+ const customClass = this.getAttribute('class') || '';
75
+ this.className =
76
+ `gap-1 group-data-[size=xs]/item:gap-0 flex flex-1 flex-col [&+[data-slot=item-content]]:flex-none ${customClass}`.trim();
77
+ }
78
+ }
79
+
80
+ class UIItemTitle extends HTMLElement {
81
+ connectedCallback() {
82
+ this.setAttribute('data-slot', 'item-title');
83
+ const customClass = this.getAttribute('class') || '';
84
+ this.className =
85
+ `gap-2 text-sm leading-snug font-medium underline-offset-4 line-clamp-1 flex w-fit items-center ${customClass}`.trim();
86
+ }
87
+ }
88
+
89
+ class UIItemDescription extends HTMLElement {
90
+ connectedCallback() {
91
+ this.setAttribute('data-slot', 'item-description');
92
+ const customClass = this.getAttribute('class') || '';
93
+ this.className =
94
+ `text-left text-sm leading-normal text-muted-foreground group-data-[size=xs]/item:text-xs line-clamp-2 font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary ${customClass}`.trim();
95
+ }
96
+ }
97
+
98
+ class UIItemActions extends HTMLElement {
99
+ connectedCallback() {
100
+ this.setAttribute('data-slot', 'item-actions');
101
+ const customClass = this.getAttribute('class') || '';
102
+ this.className = `gap-2 flex items-center ${customClass}`.trim();
103
+ }
104
+ }
105
+
106
+ class UIItemMedia extends HTMLElement {
107
+ static get observedAttributes() {
108
+ return ['variant', 'class'];
109
+ }
110
+
111
+ connectedCallback() {
112
+ this.render();
113
+ }
114
+
115
+ attributeChangedCallback() {
116
+ this.render();
117
+ }
118
+
119
+ render() {
120
+ const variant = (this.getAttribute('variant') || 'default') as keyof typeof itemMediaVariantMap;
121
+ const customClass = this.getAttribute('class') || '';
122
+ this.setAttribute('data-slot', 'item-media');
123
+ this.setAttribute('data-variant', variant);
124
+ this.className =
125
+ `gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start flex shrink-0 items-center justify-center [&_svg]:pointer-events-none ${itemMediaVariantMap[variant] || itemMediaVariantMap.default} ${customClass}`.trim();
126
+ }
127
+ }
128
+
129
+ class UIItemSeparator extends HTMLElement {
130
+ connectedCallback() {
131
+ this.setAttribute('role', 'separator');
132
+ this.setAttribute('aria-orientation', 'horizontal');
133
+ this.setAttribute('data-slot', 'item-separator');
134
+ const customClass = this.getAttribute('class') || '';
135
+ this.className = `my-2 h-px w-full shrink-0 bg-border ${customClass}`.trim();
136
+ }
137
+ }
138
+
139
+ if (!customElements.get('ui-item')) {
140
+
141
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-item')) {
142
+ customElements.define('surreal-shadcn-item', UIItem);
143
+ }
144
+ customElements.define('surreal-shadcn-item', UIItemGroup);
145
+ customElements.define('surreal-shadcn-item', UIItemHeader);
146
+ customElements.define('surreal-shadcn-item', UIItemFooter);
147
+ customElements.define('surreal-shadcn-item', UIItemContent);
148
+ customElements.define('surreal-shadcn-item', UIItemTitle);
149
+ customElements.define('surreal-shadcn-item', UIItemDescription);
150
+ customElements.define('surreal-shadcn-item', UIItemActions);
151
+ customElements.define('surreal-shadcn-item', UIItemMedia);
152
+ customElements.define('surreal-shadcn-item', UIItemSeparator);
153
+ };
154
+ export { UIItem as MinimalistItem, UIItem };
155
+
156
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-item')) {
157
+ customElements.define('surreal-minimalist-item', UIItem);
158
+ }
159
+
160
+ export default UIItem;
@@ -0,0 +1,38 @@
1
+ import { cn } from '@surreal-ui/core';
2
+
3
+ export class SurrealShadcnKbd extends HTMLElement {
4
+ connectedCallback() {
5
+ const existingSlot = this.getAttribute('data-slot');
6
+ if (!existingSlot) {
7
+ this.setAttribute('data-slot', 'kbd');
8
+ }
9
+ const className = this.getAttribute('class') || '';
10
+ this.className = cn(
11
+ "h-5 w-fit min-w-5 gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none",
12
+ className,
13
+ );
14
+ }
15
+ }
16
+
17
+ export class SurrealShadcnKbdGroup extends HTMLElement {
18
+ connectedCallback() {
19
+ this.setAttribute('data-slot', 'kbd-group');
20
+ const className = this.getAttribute('class') || '';
21
+ this.className = cn('gap-1 inline-flex items-center', className);
22
+ }
23
+ }
24
+
25
+ if (!customElements.get('surreal-kbd')) {
26
+
27
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-kbd')) {
28
+ customElements.define('surreal-shadcn-kbd', SurrealShadcnKbd);
29
+ }
30
+ }
31
+ if (!customElements.get('surreal-kbd-group')) {
32
+ customElements.define('surreal-shadcn-kbd', SurrealShadcnKbdGroup);
33
+ }
34
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-kbd')) {
35
+ customElements.define('surreal-minimalist-kbd', SurrealShadcnKbd);
36
+ }
37
+
38
+ export default SurrealShadcnKbd;
@@ -0,0 +1,54 @@
1
+ import { cn } from '@surreal-ui/core';
2
+
3
+ export class SurrealShadcnLabel extends HTMLElement {
4
+ static get observedAttributes() {
5
+ return ['for', 'class'];
6
+ }
7
+
8
+ private labelEl: HTMLLabelElement;
9
+
10
+ constructor() {
11
+ super();
12
+ this.labelEl = document.createElement('label');
13
+ this.labelEl.setAttribute('data-slot', 'label');
14
+ }
15
+
16
+ connectedCallback() {
17
+ this.updateAttributes();
18
+ while (this.firstChild) {
19
+ this.labelEl.appendChild(this.firstChild);
20
+ }
21
+ this.appendChild(this.labelEl);
22
+ }
23
+
24
+ attributeChangedCallback() {
25
+ this.updateAttributes();
26
+ }
27
+
28
+ private updateAttributes() {
29
+ const forAttr = this.getAttribute('for');
30
+ if (forAttr) {
31
+ this.labelEl.setAttribute('for', forAttr);
32
+ } else {
33
+ this.labelEl.removeAttribute('for');
34
+ }
35
+
36
+ const customClass = this.getAttribute('class') || '';
37
+ this.labelEl.className = cn(
38
+ 'gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed',
39
+ customClass,
40
+ );
41
+ }
42
+ }
43
+
44
+ if (!customElements.get('surreal-label')) {
45
+
46
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-label')) {
47
+ customElements.define('surreal-shadcn-label', SurrealShadcnLabel);
48
+ }
49
+ }
50
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-label')) {
51
+ customElements.define('surreal-minimalist-label', SurrealShadcnLabel);
52
+ }
53
+
54
+ export default SurrealShadcnLabel;
@@ -0,0 +1,82 @@
1
+ class SurrealShadcnMenubar extends HTMLElement {
2
+ private _activeMenu: HTMLElement | null = null;
3
+
4
+ connectedCallback() {
5
+ this.setAttribute('role', 'menubar');
6
+ this.setAttribute('data-slot', 'menubar');
7
+ this.className = `h-8 gap-0.5 rounded-lg border border-border bg-background p-[3px] flex items-center shadow-xs text-foreground ${this.getAttribute('class') || ''}`;
8
+ this.addEventListener('click', this.handleClick.bind(this));
9
+ document.addEventListener('click', this.handleDocumentClick.bind(this));
10
+ }
11
+
12
+ disconnectedCallback() {
13
+ document.removeEventListener('click', this.handleDocumentClick.bind(this));
14
+ }
15
+
16
+ private handleClick(e: MouseEvent) {
17
+ const trigger = (e.target as HTMLElement).closest('[data-slot="menubar-trigger"]');
18
+ if (trigger) {
19
+ const menu = trigger.closest('surreal-menubar-menu');
20
+ if (menu) {
21
+ const content = menu.querySelector('[data-slot="menubar-content"]');
22
+ if (content) {
23
+ const isOpen = !content.classList.contains('hidden');
24
+ this.closeAll();
25
+ if (!isOpen) {
26
+ content.classList.remove('hidden');
27
+ trigger.setAttribute('aria-expanded', 'true');
28
+ this._activeMenu = menu as HTMLElement;
29
+ }
30
+ }
31
+ }
32
+ return;
33
+ }
34
+
35
+ const item = (e.target as HTMLElement).closest(
36
+ '[data-slot="menubar-item"], [data-slot="menubar-checkbox-item"], [data-slot="menubar-radio-item"]',
37
+ );
38
+ if (item) {
39
+ this.closeAll();
40
+ }
41
+ }
42
+
43
+ private handleDocumentClick(e: MouseEvent) {
44
+ if (!this.contains(e.target as Node)) {
45
+ this.closeAll();
46
+ }
47
+ }
48
+
49
+ private closeAll() {
50
+ this.querySelectorAll('[data-slot="menubar-content"]').forEach((el) =>
51
+ el.classList.add('hidden'),
52
+ );
53
+ this.querySelectorAll('[data-slot="menubar-trigger"]').forEach((el) =>
54
+ el.setAttribute('aria-expanded', 'false'),
55
+ );
56
+ this._activeMenu = null;
57
+ }
58
+ }
59
+
60
+ class SurrealShadcnMenubarMenu extends HTMLElement {
61
+ connectedCallback() {
62
+ this.setAttribute('data-slot', 'menubar-menu');
63
+ this.className = `relative inline-block ${this.getAttribute('class') || ''}`;
64
+ }
65
+ }
66
+
67
+ if (!customElements.get('surreal-menubar')) {
68
+
69
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-menubar')) {
70
+ customElements.define('surreal-shadcn-menubar', SurrealShadcnMenubar);
71
+ }
72
+ }
73
+ if (!customElements.get('surreal-menubar-menu')) {
74
+ customElements.define('surreal-shadcn-menubar', SurrealShadcnMenubarMenu);
75
+ };
76
+ export { SurrealShadcnMenubar as MinimalistMenubar, SurrealShadcnMenubar };
77
+
78
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-menubar')) {
79
+ customElements.define('surreal-minimalist-menubar', SurrealShadcnMenubar);
80
+ }
81
+
82
+ export default SurrealShadcnMenubar;
@@ -0,0 +1,144 @@
1
+ export class SurrealShadcnNativeSelect extends HTMLElement {
2
+ static get observedAttributes() {
3
+ return ['size', 'disabled', 'value', 'name'];
4
+ }
5
+
6
+ private wrapper: HTMLDivElement;
7
+ private selectEl: HTMLSelectElement;
8
+
9
+ constructor() {
10
+ super();
11
+ this.attachShadow({ mode: 'open' });
12
+
13
+ this.wrapper = document.createElement('div');
14
+ this.wrapper.setAttribute('data-slot', 'native-select-wrapper');
15
+ this.wrapper.className = 'wrapper';
16
+
17
+ this.selectEl = document.createElement('select');
18
+ this.selectEl.setAttribute('data-slot', 'native-select');
19
+
20
+ const slot = document.createElement('slot');
21
+ this.selectEl.appendChild(slot);
22
+
23
+ const icon = document.createElement('div');
24
+ icon.className = 'icon';
25
+ icon.setAttribute('aria-hidden', 'true');
26
+ icon.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"><path d="m6 9 6 6 6-6"/></svg>`;
27
+
28
+ const style = document.createElement('style');
29
+ style.textContent = `
30
+ :host {
31
+ display: inline-block;
32
+ }
33
+ .wrapper {
34
+ position: relative;
35
+ width: fit-content;
36
+ display: inline-flex;
37
+ align-items: center;
38
+ }
39
+ .wrapper[data-disabled="true"] {
40
+ opacity: 0.5;
41
+ pointer-events: none;
42
+ }
43
+ select {
44
+ height: 2rem;
45
+ width: 100%;
46
+ min-width: 0;
47
+ appearance: none;
48
+ -webkit-appearance: none;
49
+ border-radius: var(--radius, 0.5rem);
50
+ border: 1px solid var(--input, #e4e4e7);
51
+ background-color: transparent;
52
+ padding: 0.25rem 2rem 0.25rem 0.625rem;
53
+ font-size: 0.875rem;
54
+ line-height: 1.25rem;
55
+ color: var(--foreground, #09090b);
56
+ outline: none;
57
+ box-sizing: border-box;
58
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
59
+ cursor: pointer;
60
+ user-select: none;
61
+ }
62
+ .wrapper[data-size="sm"] select {
63
+ height: 1.75rem;
64
+ padding-top: 0.125rem;
65
+ padding-bottom: 0.125rem;
66
+ }
67
+ select:focus-visible {
68
+ border-color: var(--ring, #18181b);
69
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring, #18181b) 50%, transparent);
70
+ }
71
+ select:disabled {
72
+ cursor: not-allowed;
73
+ pointer-events: none;
74
+ }
75
+ .icon {
76
+ position: absolute;
77
+ right: 0.625rem;
78
+ top: 50%;
79
+ transform: translateY(-50%);
80
+ width: 1rem;
81
+ height: 1rem;
82
+ pointer-events: none;
83
+ color: var(--muted-foreground, #71717a);
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ }
88
+ ::slotted(option) {
89
+ background: Canvas;
90
+ color: CanvasText;
91
+ }
92
+ `;
93
+
94
+ this.wrapper.appendChild(this.selectEl);
95
+ this.wrapper.appendChild(icon);
96
+ this.shadowRoot!.appendChild(style);
97
+ this.shadowRoot!.appendChild(this.wrapper);
98
+
99
+ this.selectEl.addEventListener('change', (e) => {
100
+ this.dispatchEvent(
101
+ new CustomEvent('change', {
102
+ detail: { value: this.selectEl.value },
103
+ bubbles: true,
104
+ composed: true,
105
+ }),
106
+ );
107
+ });
108
+ }
109
+
110
+ get value() {
111
+ return this.selectEl.value;
112
+ }
113
+
114
+ set value(val: string) {
115
+ this.selectEl.value = val;
116
+ }
117
+
118
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
119
+ if (name === 'size') {
120
+ this.wrapper.setAttribute('data-size', newValue || 'default');
121
+ this.selectEl.setAttribute('data-size', newValue || 'default');
122
+ } else if (name === 'disabled') {
123
+ const isDisabled = newValue !== null;
124
+ this.selectEl.disabled = isDisabled;
125
+ this.wrapper.setAttribute('data-disabled', String(isDisabled));
126
+ } else if (name === 'value' && newValue !== null) {
127
+ this.selectEl.value = newValue;
128
+ } else if (name === 'name' && newValue !== null) {
129
+ this.selectEl.name = newValue;
130
+ }
131
+ }
132
+ }
133
+
134
+ if (!customElements.get('surreal-native-select')) {
135
+
136
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-native-select')) {
137
+ customElements.define('surreal-shadcn-native-select', SurrealShadcnNativeSelect);
138
+ }
139
+ }
140
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-native-select')) {
141
+ customElements.define('surreal-minimalist-native-select', SurrealShadcnNativeSelect);
142
+ }
143
+
144
+ export default SurrealShadcnNativeSelect;
@@ -0,0 +1,98 @@
1
+ class NavigationMenuElement extends HTMLElement {
2
+ private _openItem: string | null = null;
3
+
4
+ connectedCallback() {
5
+ this.setAttribute('data-slot', 'navigation-menu');
6
+ this.className =
7
+ 'max-w-max group/navigation-menu relative flex flex-1 items-center justify-center ' +
8
+ (this.getAttribute('class') || '');
9
+
10
+ this.addEventListener('click', this.handleClick.bind(this));
11
+ document.addEventListener('click', this.handleOutsideClick.bind(this));
12
+ }
13
+
14
+ disconnectedCallback() {
15
+ document.removeEventListener('click', this.handleOutsideClick.bind(this));
16
+ }
17
+
18
+ private handleClick(e: Event) {
19
+ const target = (e.target as HTMLElement).closest(
20
+ '[data-slot="navigation-menu-trigger"]',
21
+ ) as HTMLElement | null;
22
+ if (!target) return;
23
+
24
+ const item = target.closest('[data-slot="navigation-menu-item"]') as HTMLElement | null;
25
+ if (!item) return;
26
+
27
+ const itemId =
28
+ item.getAttribute('data-value') ||
29
+ item.id ||
30
+ Array.from(this.querySelectorAll('[data-slot="navigation-menu-item"]'))
31
+ .indexOf(item)
32
+ .toString();
33
+
34
+ if (this._openItem === itemId) {
35
+ this.closeAll();
36
+ } else {
37
+ this.open(itemId);
38
+ }
39
+ }
40
+
41
+ private handleOutsideClick(e: Event) {
42
+ if (!this.contains(e.target as Node)) {
43
+ this.closeAll();
44
+ }
45
+ }
46
+
47
+ private open(itemId: string) {
48
+ this._openItem = itemId;
49
+ const items = this.querySelectorAll('[data-slot="navigation-menu-item"]');
50
+ items.forEach((item, idx) => {
51
+ const id = item.getAttribute('data-value') || item.id || idx.toString();
52
+ const trigger = item.querySelector('[data-slot="navigation-menu-trigger"]');
53
+ const content = item.querySelector('[data-slot="navigation-menu-content"]');
54
+ const isOpen = id === itemId;
55
+
56
+ if (trigger) {
57
+ trigger.setAttribute('data-state', isOpen ? 'open' : 'closed');
58
+ trigger.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
59
+ }
60
+ if (content) {
61
+ content.setAttribute('data-state', isOpen ? 'open' : 'closed');
62
+ if (isOpen) {
63
+ content.classList.remove('hidden');
64
+ } else {
65
+ content.classList.add('hidden');
66
+ }
67
+ }
68
+ });
69
+ }
70
+
71
+ private closeAll() {
72
+ this._openItem = null;
73
+ const triggers = this.querySelectorAll('[data-slot="navigation-menu-trigger"]');
74
+ const contents = this.querySelectorAll('[data-slot="navigation-menu-content"]');
75
+ triggers.forEach((t) => {
76
+ t.setAttribute('data-state', 'closed');
77
+ t.setAttribute('aria-expanded', 'false');
78
+ });
79
+ contents.forEach((c) => {
80
+ c.setAttribute('data-state', 'closed');
81
+ c.classList.add('hidden');
82
+ });
83
+ }
84
+ }
85
+
86
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-navigation-menu')) {
87
+
88
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-navigation-menu')) {
89
+ customElements.define('surreal-shadcn-navigation-menu', NavigationMenuElement);
90
+ }
91
+ };
92
+ export { NavigationMenuElement as MinimalistNavigationMenu, NavigationMenuElement };
93
+
94
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-navigation-menu')) {
95
+ customElements.define('surreal-minimalist-navigation-menu', NavigationMenuElement);
96
+ }
97
+
98
+ export default NavigationMenuElement;