@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,101 @@
1
+ import { cn } from '@surreal-ui/core';
2
+
3
+ export class SurrealShadcnInput extends HTMLElement {
4
+ static get observedAttributes() {
5
+ return ['type', 'value', 'placeholder', 'disabled', 'class', 'name', 'aria-invalid'];
6
+ }
7
+
8
+ private inputElement: HTMLInputElement;
9
+
10
+ constructor() {
11
+ super();
12
+ this.attachShadow({ mode: 'open' });
13
+ this.inputElement = document.createElement('input');
14
+ this.shadowRoot?.appendChild(this.inputElement);
15
+ }
16
+
17
+ connectedCallback() {
18
+ this.render();
19
+ this.inputElement.addEventListener('input', this.handleInput);
20
+ this.inputElement.addEventListener('change', this.handleChange);
21
+ }
22
+
23
+ disconnectedCallback() {
24
+ this.inputElement.removeEventListener('input', this.handleInput);
25
+ this.inputElement.removeEventListener('change', this.handleChange);
26
+ }
27
+
28
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
29
+ if (oldValue !== newValue) {
30
+ this.render();
31
+ }
32
+ }
33
+
34
+ private handleInput = (e: Event) => {
35
+ const target = e.target as HTMLInputElement;
36
+ this.setAttribute('value', target.value);
37
+ this.dispatchEvent(
38
+ new CustomEvent('input', { detail: { value: target.value }, bubbles: true, composed: true }),
39
+ );
40
+ };
41
+
42
+ private handleChange = (e: Event) => {
43
+ const target = e.target as HTMLInputElement;
44
+ this.dispatchEvent(
45
+ new CustomEvent('change', {
46
+ detail: { value: target.value, files: target.files },
47
+ bubbles: true,
48
+ composed: true,
49
+ }),
50
+ );
51
+ };
52
+
53
+ get value(): string {
54
+ return this.inputElement.value;
55
+ }
56
+
57
+ set value(val: string) {
58
+ this.inputElement.value = val;
59
+ this.setAttribute('value', val);
60
+ }
61
+
62
+ get files(): FileList | null {
63
+ return this.inputElement.files;
64
+ }
65
+
66
+ render() {
67
+ const type = this.getAttribute('type') || 'text';
68
+ const value = this.getAttribute('value') ?? '';
69
+ const placeholder = this.getAttribute('placeholder') || '';
70
+ const disabled = this.hasAttribute('disabled');
71
+ const name = this.getAttribute('name') || '';
72
+ const ariaInvalid = this.getAttribute('aria-invalid');
73
+ const className = this.getAttribute('class') || '';
74
+
75
+ this.inputElement.type = type;
76
+ if (type !== 'file') {
77
+ this.inputElement.value = value;
78
+ }
79
+ this.inputElement.placeholder = placeholder;
80
+ this.inputElement.disabled = disabled;
81
+ if (name) this.inputElement.name = name;
82
+ if (ariaInvalid) {
83
+ this.inputElement.setAttribute('aria-invalid', ariaInvalid);
84
+ } else {
85
+ this.inputElement.removeAttribute('aria-invalid');
86
+ }
87
+ this.inputElement.setAttribute('data-slot', 'input');
88
+ this.inputElement.className = cn(
89
+ 'h-8 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
90
+ className,
91
+ );
92
+ }
93
+ }
94
+
95
+ if (!customElements.get('surreal-input')) {
96
+
97
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input')) {
98
+ customElements.define('surreal-shadcn-input', SurrealShadcnInput);
99
+ }
100
+ }
101
+ export default SurrealShadcnInput;
@@ -0,0 +1,89 @@
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
+
71
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input-group')) {
72
+ customElements.define('surreal-shadcn-input-group', InputGroupElement);
73
+ }
74
+ }
75
+ if (!customElements.get('input-group-addon')) {
76
+ customElements.define('surreal-shadcn-input-group', InputGroupAddonElement);
77
+ }
78
+ if (!customElements.get('input-group-button')) {
79
+ customElements.define('surreal-shadcn-input-group', InputGroupButtonElement);
80
+ }
81
+ if (!customElements.get('input-group-input')) {
82
+ customElements.define('surreal-shadcn-input-group', InputGroupInputElement);
83
+ }
84
+ if (!customElements.get('input-group-text')) {
85
+ customElements.define('surreal-shadcn-input-group', InputGroupTextElement);
86
+ };
87
+ export { InputGroupElement as ShadcnInputGroup, InputGroupElement };
88
+
89
+ export default InputGroupElement;
@@ -0,0 +1,151 @@
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
+
136
+ if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input-otp')) {
137
+ customElements.define('surreal-shadcn-input-otp', SurrealInputOTP);
138
+ }
139
+ }
140
+ if (!customElements.get('surreal-input-otp-group')) {
141
+ customElements.define('surreal-shadcn-input-otp', SurrealInputOTPGroup);
142
+ }
143
+ if (!customElements.get('surreal-input-otp-slot')) {
144
+ customElements.define('surreal-shadcn-input-otp', SurrealInputOTPSlot);
145
+ }
146
+ if (!customElements.get('surreal-input-otp-separator')) {
147
+ customElements.define('surreal-shadcn-input-otp', SurrealInputOTPSeparator);
148
+ };
149
+ export { SurrealInputOTP as ShadcnInputOtp, SurrealInputOTP };
150
+
151
+ export default SurrealInputOTP;
@@ -0,0 +1,156 @@
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 ShadcnItem, UIItem };
155
+
156
+ export default UIItem;
@@ -0,0 +1,34 @@
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
+ export default SurrealShadcnKbd;
@@ -0,0 +1,50 @@
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
+ export default SurrealShadcnLabel;
@@ -0,0 +1,78 @@
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 ShadcnMenubar, SurrealShadcnMenubar };
77
+
78
+ export default SurrealShadcnMenubar;