@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.
- package/LICENSE +21 -0
- package/dist/index.js +832 -6249
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +14 -0
- package/package.json +14 -3
- package/CHANGELOG.md +0 -149
- package/src/components/GlassmorphismAlert.ts +0 -115
- package/src/components/GlassmorphismButton.ts +0 -18
- package/src/components/GlassmorphismCard.ts +0 -36
- package/src/components/GlassmorphismEmptyState.ts +0 -35
- package/src/components/GlassmorphismInputGroup.ts +0 -205
- package/src/components/GlassmorphismMenubar.ts +0 -36
- package/src/components/GlassmorphismScrollArea.ts +0 -86
- package/src/components/GlassmorphismTable.ts +0 -52
- package/src/components/GlassmorphismTypography.ts +0 -70
- package/src/components/MinimalistAccordion.ts +0 -252
- package/src/components/MinimalistAlert.ts +0 -98
- package/src/components/MinimalistAlertDialog.ts +0 -102
- package/src/components/MinimalistAspectRatio.ts +0 -36
- package/src/components/MinimalistAvatar.ts +0 -97
- package/src/components/MinimalistBadge.ts +0 -70
- package/src/components/MinimalistBreadcrumb.ts +0 -92
- package/src/components/MinimalistButton.ts +0 -110
- package/src/components/MinimalistButtonGroup.ts +0 -112
- package/src/components/MinimalistCalendar.ts +0 -281
- package/src/components/MinimalistCard.ts +0 -130
- package/src/components/MinimalistCarousel.ts +0 -121
- package/src/components/MinimalistChart.ts +0 -150
- package/src/components/MinimalistCheckbox.ts +0 -178
- package/src/components/MinimalistCodeBlock.ts +0 -112
- package/src/components/MinimalistCollapsible.ts +0 -160
- package/src/components/MinimalistCommand.ts +0 -111
- package/src/components/MinimalistContextMenu.ts +0 -101
- package/src/components/MinimalistDialog.ts +0 -103
- package/src/components/MinimalistDrawer.ts +0 -222
- package/src/components/MinimalistDropdownMenu.ts +0 -125
- package/src/components/MinimalistEmpty.ts +0 -97
- package/src/components/MinimalistEmptyState.ts +0 -41
- package/src/components/MinimalistField.ts +0 -176
- package/src/components/MinimalistForm.ts +0 -102
- package/src/components/MinimalistHoverCard.ts +0 -149
- package/src/components/MinimalistInput.ts +0 -104
- package/src/components/MinimalistInputGroup.ts +0 -95
- package/src/components/MinimalistInputOtp.ts +0 -154
- package/src/components/MinimalistItem.ts +0 -159
- package/src/components/MinimalistKbd.ts +0 -37
- package/src/components/MinimalistLabel.ts +0 -53
- package/src/components/MinimalistMenubar.ts +0 -81
- package/src/components/MinimalistNativeSelect.ts +0 -149
- package/src/components/MinimalistNavigationMenu.ts +0 -103
- package/src/components/MinimalistPagination.ts +0 -140
- package/src/components/MinimalistPopover.ts +0 -112
- package/src/components/MinimalistProgress.ts +0 -70
- package/src/components/MinimalistRadioGroup.ts +0 -228
- package/src/components/MinimalistRangeCalendar.ts +0 -272
- package/src/components/MinimalistResizable.ts +0 -44
- package/src/components/MinimalistScrollArea.ts +0 -42
- package/src/components/MinimalistSelect.ts +0 -103
- package/src/components/MinimalistSeparator.ts +0 -52
- package/src/components/MinimalistSheet.ts +0 -165
- package/src/components/MinimalistSidebar.ts +0 -74
- package/src/components/MinimalistSkeleton.ts +0 -32
- package/src/components/MinimalistSlider.ts +0 -236
- package/src/components/MinimalistSonner.ts +0 -93
- package/src/components/MinimalistSpinner.ts +0 -52
- package/src/components/MinimalistSwitch.ts +0 -165
- package/src/components/MinimalistTable.ts +0 -35
- package/src/components/MinimalistTabs.ts +0 -97
- package/src/components/MinimalistTextarea.ts +0 -99
- package/src/components/MinimalistToggle.ts +0 -104
- package/src/components/MinimalistToggleGroup.ts +0 -177
- package/src/components/MinimalistTooltip.ts +0 -82
- package/src/components/MinimalistTypography.ts +0 -106
- package/src/components/NeubrutalismCard.ts +0 -35
- package/src/components/NeubrutalismItem.ts +0 -67
- package/src/components/ShadcnAccordion.ts +0 -248
- package/src/components/ShadcnAlertDialog.ts +0 -95
- package/src/components/ShadcnAspectRatio.ts +0 -29
- package/src/components/ShadcnAvatar.ts +0 -93
- package/src/components/ShadcnBadge.ts +0 -66
- package/src/components/ShadcnBreadcrumb.ts +0 -88
- package/src/components/ShadcnButton.ts +0 -106
- package/src/components/ShadcnButtonGroup.ts +0 -105
- package/src/components/ShadcnCalendar.ts +0 -277
- package/src/components/ShadcnCarousel.ts +0 -117
- package/src/components/ShadcnChart.ts +0 -146
- package/src/components/ShadcnCheckbox.ts +0 -174
- package/src/components/ShadcnCodeBlock.ts +0 -108
- package/src/components/ShadcnCollapsible.ts +0 -153
- package/src/components/ShadcnCommand.ts +0 -107
- package/src/components/ShadcnContextMenu.ts +0 -94
- package/src/components/ShadcnDialog.ts +0 -99
- package/src/components/ShadcnDrawer.ts +0 -218
- package/src/components/ShadcnDropdownMenu.ts +0 -118
- package/src/components/ShadcnEmpty.ts +0 -93
- package/src/components/ShadcnField.ts +0 -172
- package/src/components/ShadcnForm.ts +0 -98
- package/src/components/ShadcnHoverCard.ts +0 -145
- package/src/components/ShadcnInput.ts +0 -100
- package/src/components/ShadcnInputGroup.ts +0 -88
- package/src/components/ShadcnInputOtp.ts +0 -150
- package/src/components/ShadcnItem.ts +0 -155
- package/src/components/ShadcnKbd.ts +0 -33
- package/src/components/ShadcnLabel.ts +0 -49
- package/src/components/ShadcnMenubar.ts +0 -77
- package/src/components/ShadcnNativeSelect.ts +0 -142
- package/src/components/ShadcnNavigationMenu.ts +0 -96
- package/src/components/ShadcnPagination.ts +0 -136
- package/src/components/ShadcnPopover.ts +0 -108
- package/src/components/ShadcnProgress.ts +0 -66
- package/src/components/ShadcnRadioGroup.ts +0 -221
- package/src/components/ShadcnRangeCalendar.ts +0 -265
- package/src/components/ShadcnSelect.ts +0 -99
- package/src/components/ShadcnSeparator.ts +0 -48
- package/src/components/ShadcnSheet.ts +0 -161
- package/src/components/ShadcnSidebar.ts +0 -70
- package/src/components/ShadcnSkeleton.ts +0 -28
- package/src/components/ShadcnSlider.ts +0 -232
- package/src/components/ShadcnSonner.ts +0 -89
- package/src/components/ShadcnSpinner.ts +0 -48
- package/src/components/ShadcnSwitch.ts +0 -161
- package/src/components/ShadcnTabs.ts +0 -93
- package/src/components/ShadcnTextarea.ts +0 -95
- package/src/components/ShadcnToggle.ts +0 -100
- package/src/components/ShadcnToggleGroup.ts +0 -170
- package/src/components/ShadcnTooltip.ts +0 -78
- package/src/index.ts +0 -124
|
@@ -1,154 +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 MinimalistInputOtp, SurrealInputOTP };
|
|
149
|
-
|
|
150
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-input-otp')) {
|
|
151
|
-
customElements.define('surreal-minimalist-input-otp', SurrealInputOTP);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export default SurrealInputOTP;
|
|
@@ -1,159 +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 MinimalistItem, UIItem };
|
|
154
|
-
|
|
155
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-item')) {
|
|
156
|
-
customElements.define('surreal-minimalist-item', UIItem);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export default UIItem;
|
|
@@ -1,37 +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
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-kbd')) {
|
|
34
|
-
customElements.define('surreal-minimalist-kbd', SurrealShadcnKbd);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default SurrealShadcnKbd;
|
|
@@ -1,53 +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
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-label')) {
|
|
50
|
-
customElements.define('surreal-minimalist-label', SurrealShadcnLabel);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default SurrealShadcnLabel;
|
|
@@ -1,81 +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 MinimalistMenubar, SurrealShadcnMenubar };
|
|
76
|
-
|
|
77
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-menubar')) {
|
|
78
|
-
customElements.define('surreal-minimalist-menubar', SurrealShadcnMenubar);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default SurrealShadcnMenubar;
|
|
@@ -1,149 +0,0 @@
|
|
|
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
|
-
if (
|
|
136
|
-
typeof customElements !== 'undefined' &&
|
|
137
|
-
!customElements.get('surreal-shadcn-native-select')
|
|
138
|
-
) {
|
|
139
|
-
customElements.define('surreal-shadcn-native-select', SurrealShadcnNativeSelect);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (
|
|
143
|
-
typeof customElements !== 'undefined' &&
|
|
144
|
-
!customElements.get('surreal-minimalist-native-select')
|
|
145
|
-
) {
|
|
146
|
-
customElements.define('surreal-minimalist-native-select', SurrealShadcnNativeSelect);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export default SurrealShadcnNativeSelect;
|