@surreal-ui/web 0.8.1 → 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 -149
  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,88 +0,0 @@
1
- class InputGroupElement extends HTMLElement {
2
- connectedCallback() {
3
- this.setAttribute('data-slot', 'input-group');
4
- this.setAttribute('role', 'group');
5
- this.className =
6
- `group/input-group h-8 rounded-lg border border-input transition-colors in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto ${this.getAttribute('class') || ''}`.trim();
7
- }
8
- }
9
-
10
- class InputGroupAddonElement extends HTMLElement {
11
- connectedCallback() {
12
- const align = this.getAttribute('align') || 'inline-start';
13
- this.setAttribute('data-slot', 'input-group-addon');
14
- this.setAttribute('data-align', align);
15
- this.setAttribute('role', 'group');
16
-
17
- const alignClasses =
18
- {
19
- 'inline-start': 'pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first',
20
- 'inline-end': 'pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last',
21
- 'block-start':
22
- 'px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start',
23
- 'block-end':
24
- 'px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start'
25
- }[align] || 'pl-2 order-first';
26
-
27
- this.className =
28
- `h-auto gap-2 py-1.5 text-sm font-medium text-muted-foreground group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none ${alignClasses} ${this.getAttribute('class') || ''}`.trim();
29
-
30
- this.onclick = (e) => {
31
- if ((e.target as HTMLElement).closest('button')) return;
32
- this.parentElement?.querySelector('input, textarea')?.focus();
33
- };
34
- }
35
- }
36
-
37
- class InputGroupButtonElement extends HTMLElement {
38
- connectedCallback() {
39
- const size = this.getAttribute('size') || 'xs';
40
- const sizeClasses =
41
- {
42
- xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
43
- sm: 'h-7 gap-1.5 rounded-md px-2 text-xs',
44
- 'icon-xs': 'size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0',
45
- 'icon-sm': 'size-8 p-0 has-[>svg]:p-0'
46
- }[size] || '';
47
-
48
- this.setAttribute('data-size', size);
49
- this.className =
50
- `gap-2 text-sm flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 shadow-none hover:bg-accent hover:text-accent-foreground ${sizeClasses} ${this.getAttribute('class') || ''}`.trim();
51
- }
52
- }
53
-
54
- class InputGroupInputElement extends HTMLElement {
55
- connectedCallback() {
56
- this.setAttribute('data-slot', 'input-group-control');
57
- this.className =
58
- `flex-1 rounded-none border-0 bg-transparent px-2.5 py-1 text-sm shadow-none ring-0 outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent ${this.getAttribute('class') || ''}`.trim();
59
- }
60
- }
61
-
62
- class InputGroupTextElement extends HTMLElement {
63
- connectedCallback() {
64
- this.className =
65
- `gap-2 text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none ${this.getAttribute('class') || ''}`.trim();
66
- }
67
- }
68
-
69
- if (!customElements.get('input-group')) {
70
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input-group')) {
71
- customElements.define('surreal-shadcn-input-group', InputGroupElement);
72
- }
73
- }
74
- if (!customElements.get('input-group-addon')) {
75
- customElements.define('surreal-shadcn-input-group', InputGroupAddonElement);
76
- }
77
- if (!customElements.get('input-group-button')) {
78
- customElements.define('surreal-shadcn-input-group', InputGroupButtonElement);
79
- }
80
- if (!customElements.get('input-group-input')) {
81
- customElements.define('surreal-shadcn-input-group', InputGroupInputElement);
82
- }
83
- if (!customElements.get('input-group-text')) {
84
- customElements.define('surreal-shadcn-input-group', InputGroupTextElement);
85
- }
86
- export { InputGroupElement as ShadcnInputGroup, InputGroupElement };
87
-
88
- export default InputGroupElement;
@@ -1,150 +0,0 @@
1
- class SurrealInputOTP extends HTMLElement {
2
- private _value = '';
3
- private _maxLength = 6;
4
- private _disabled = false;
5
- private _inputEl: HTMLInputElement | null = null;
6
- private _isFocused = false;
7
-
8
- static get observedAttributes() {
9
- return ['value', 'maxlength', 'disabled'];
10
- }
11
-
12
- connectedCallback() {
13
- this.setAttribute('data-slot', 'input-otp');
14
- this.className =
15
- 'relative inline-flex items-center gap-2 has-disabled:opacity-50 select-none ' +
16
- (this.getAttribute('class') || '');
17
- this.render();
18
- }
19
-
20
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
21
- if (oldValue === newValue) return;
22
- if (name === 'value') {
23
- this._value = newValue || '';
24
- this.syncSlots();
25
- } else if (name === 'maxlength') {
26
- this._maxLength = parseInt(newValue || '6', 10);
27
- } else if (name === 'disabled') {
28
- this._disabled = newValue !== null;
29
- if (this._inputEl) this._inputEl.disabled = this._disabled;
30
- }
31
- }
32
-
33
- get value(): string {
34
- return this._value;
35
- }
36
-
37
- set value(val: string) {
38
- this._value = val || '';
39
- this.setAttribute('value', this._value);
40
- if (this._inputEl) this._inputEl.value = this._value;
41
- this.syncSlots();
42
- }
43
-
44
- private render() {
45
- if (this.querySelector('input[data-otp-input]')) return;
46
- const input = document.createElement('input');
47
- input.type = 'text';
48
- input.inputMode = 'numeric';
49
- input.autocomplete = 'one-time-code';
50
- input.maxLength = this._maxLength;
51
- input.value = this._value;
52
- input.disabled = this._disabled;
53
- input.setAttribute('data-otp-input', '');
54
- input.className =
55
- 'absolute inset-0 h-full w-full opacity-0 cursor-pointer disabled:cursor-not-allowed z-20';
56
-
57
- input.addEventListener('input', () => {
58
- this._value = input.value.slice(0, this._maxLength);
59
- this.dispatchEvent(
60
- new CustomEvent('change', { detail: { value: this._value }, bubbles: true })
61
- );
62
- if (this._value.length === this._maxLength) {
63
- this.dispatchEvent(
64
- new CustomEvent('complete', { detail: { value: this._value }, bubbles: true })
65
- );
66
- }
67
- this.syncSlots();
68
- });
69
-
70
- input.addEventListener('focus', () => {
71
- this._isFocused = true;
72
- this.syncSlots();
73
- });
74
-
75
- input.addEventListener('blur', () => {
76
- this._isFocused = false;
77
- this.syncSlots();
78
- });
79
-
80
- this._inputEl = input;
81
- this.prepend(input);
82
- this.syncSlots();
83
- }
84
-
85
- public syncSlots() {
86
- const activeIndex = this._isFocused ? Math.min(this._value.length, this._maxLength - 1) : -1;
87
- const slots = this.querySelectorAll('surreal-input-otp-slot, [data-slot="input-otp-slot"]');
88
- slots.forEach((slotEl, idx) => {
89
- const char = this._value[idx] || '';
90
- const isActive = this._isFocused && activeIndex === idx;
91
- slotEl.textContent = char;
92
- if (isActive) {
93
- slotEl.setAttribute('data-active', '');
94
- slotEl.classList.add('ring-1', 'ring-ring', 'border-ring');
95
- } else {
96
- slotEl.removeAttribute('data-active');
97
- slotEl.classList.remove('ring-1', 'ring-ring', 'border-ring');
98
- }
99
- });
100
- }
101
- }
102
-
103
- class SurrealInputOTPGroup extends HTMLElement {
104
- connectedCallback() {
105
- this.setAttribute('data-slot', 'input-otp-group');
106
- this.className = 'flex items-center ' + (this.getAttribute('class') || '');
107
- }
108
- }
109
-
110
- class SurrealInputOTPSlot extends HTMLElement {
111
- connectedCallback() {
112
- this.setAttribute('data-slot', 'input-otp-slot');
113
- this.setAttribute('role', 'presentation');
114
- this.className =
115
- 'relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-xs transition-all first:rounded-l-md border-l-0 first:border-l last:rounded-r-md ' +
116
- (this.getAttribute('class') || '');
117
- }
118
- }
119
-
120
- class SurrealInputOTPSeparator extends HTMLElement {
121
- connectedCallback() {
122
- this.setAttribute('data-slot', 'input-otp-separator');
123
- this.setAttribute('role', 'separator');
124
- this.className =
125
- 'text-muted-foreground px-1 flex items-center justify-center ' +
126
- (this.getAttribute('class') || '');
127
- if (!this.innerHTML.trim()) {
128
- this.innerHTML =
129
- '<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"><path d="M5 12h14"/></svg>';
130
- }
131
- }
132
- }
133
-
134
- if (!customElements.get('surreal-input-otp')) {
135
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input-otp')) {
136
- customElements.define('surreal-shadcn-input-otp', SurrealInputOTP);
137
- }
138
- }
139
- if (!customElements.get('surreal-input-otp-group')) {
140
- customElements.define('surreal-shadcn-input-otp', SurrealInputOTPGroup);
141
- }
142
- if (!customElements.get('surreal-input-otp-slot')) {
143
- customElements.define('surreal-shadcn-input-otp', SurrealInputOTPSlot);
144
- }
145
- if (!customElements.get('surreal-input-otp-separator')) {
146
- customElements.define('surreal-shadcn-input-otp', SurrealInputOTPSeparator);
147
- }
148
- export { SurrealInputOTP as ShadcnInputOtp, SurrealInputOTP };
149
-
150
- export default SurrealInputOTP;
@@ -1,155 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-item')) {
141
- customElements.define('surreal-shadcn-item', UIItem);
142
- }
143
- customElements.define('surreal-shadcn-item', UIItemGroup);
144
- customElements.define('surreal-shadcn-item', UIItemHeader);
145
- customElements.define('surreal-shadcn-item', UIItemFooter);
146
- customElements.define('surreal-shadcn-item', UIItemContent);
147
- customElements.define('surreal-shadcn-item', UIItemTitle);
148
- customElements.define('surreal-shadcn-item', UIItemDescription);
149
- customElements.define('surreal-shadcn-item', UIItemActions);
150
- customElements.define('surreal-shadcn-item', UIItemMedia);
151
- customElements.define('surreal-shadcn-item', UIItemSeparator);
152
- }
153
- export { UIItem as ShadcnItem, UIItem };
154
-
155
- export default UIItem;
@@ -1,33 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-kbd')) {
27
- customElements.define('surreal-shadcn-kbd', SurrealShadcnKbd);
28
- }
29
- }
30
- if (!customElements.get('surreal-kbd-group')) {
31
- customElements.define('surreal-shadcn-kbd', SurrealShadcnKbdGroup);
32
- }
33
- export default SurrealShadcnKbd;
@@ -1,49 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-label')) {
46
- customElements.define('surreal-shadcn-label', SurrealShadcnLabel);
47
- }
48
- }
49
- export default SurrealShadcnLabel;
@@ -1,77 +0,0 @@
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
- if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-menubar')) {
69
- customElements.define('surreal-shadcn-menubar', SurrealShadcnMenubar);
70
- }
71
- }
72
- if (!customElements.get('surreal-menubar-menu')) {
73
- customElements.define('surreal-shadcn-menubar', SurrealShadcnMenubarMenu);
74
- }
75
- export { SurrealShadcnMenubar as ShadcnMenubar, SurrealShadcnMenubar };
76
-
77
- export default SurrealShadcnMenubar;