@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,176 +0,0 @@
|
|
|
1
|
-
import { cn, cva } from '@surreal-ui/core';
|
|
2
|
-
|
|
3
|
-
const fieldVariants = cva('gap-2 data-[invalid=true]:text-destructive group/field flex w-full', {
|
|
4
|
-
variants: {
|
|
5
|
-
orientation: {
|
|
6
|
-
vertical: 'cn-field-orientation-vertical flex-col [&>*]:w-full [&>.sr-only]:w-auto',
|
|
7
|
-
horizontal:
|
|
8
|
-
'cn-field-orientation-horizontal flex-row items-center has-[>[data-slot=field-content]]:items-start [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
9
|
-
responsive:
|
|
10
|
-
'cn-field-orientation-responsive flex-col @md/field-group:flex-row @md/field-group:items-center @md/field-group:has-[>[data-slot=field-content]]:items-start [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px'
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
defaultVariants: {
|
|
14
|
-
orientation: 'vertical'
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export class UIField extends HTMLElement {
|
|
19
|
-
static get observedAttributes() {
|
|
20
|
-
return ['orientation', 'invalid', 'class'];
|
|
21
|
-
}
|
|
22
|
-
connectedCallback() {
|
|
23
|
-
this.render();
|
|
24
|
-
}
|
|
25
|
-
attributeChangedCallback() {
|
|
26
|
-
this.render();
|
|
27
|
-
}
|
|
28
|
-
render() {
|
|
29
|
-
const orientation = (this.getAttribute('orientation') || 'vertical') as
|
|
30
|
-
'vertical' | 'horizontal' | 'responsive';
|
|
31
|
-
const invalid = this.hasAttribute('invalid') && this.getAttribute('invalid') !== 'false';
|
|
32
|
-
const userClass = this.getAttribute('class') || '';
|
|
33
|
-
this.setAttribute('role', 'group');
|
|
34
|
-
this.setAttribute('data-slot', 'field');
|
|
35
|
-
this.setAttribute('data-orientation', orientation);
|
|
36
|
-
if (invalid) {
|
|
37
|
-
this.setAttribute('data-invalid', 'true');
|
|
38
|
-
} else {
|
|
39
|
-
this.removeAttribute('data-invalid');
|
|
40
|
-
}
|
|
41
|
-
this.className = cn(fieldVariants({ orientation }), userClass);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!customElements.get('ui-field'))
|
|
45
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-field')) {
|
|
46
|
-
customElements.define('surreal-shadcn-field', UIField);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class UIFieldGroup extends HTMLElement {
|
|
50
|
-
connectedCallback() {
|
|
51
|
-
this.setAttribute('data-slot', 'field-group');
|
|
52
|
-
this.className = cn(
|
|
53
|
-
'gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 group/field-group @container/field-group flex w-full flex-col',
|
|
54
|
-
this.getAttribute('class') || ''
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (!customElements.get('ui-field-group'))
|
|
59
|
-
customElements.define('surreal-shadcn-field', UIFieldGroup);
|
|
60
|
-
|
|
61
|
-
export class UIFieldSet extends HTMLElement {
|
|
62
|
-
connectedCallback() {
|
|
63
|
-
this.setAttribute('data-slot', 'field-set');
|
|
64
|
-
this.className = cn(
|
|
65
|
-
'gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col border-0 p-0 m-0',
|
|
66
|
-
this.getAttribute('class') || ''
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (!customElements.get('ui-field-set')) customElements.define('surreal-shadcn-field', UIFieldSet);
|
|
71
|
-
|
|
72
|
-
export class UIFieldContent extends HTMLElement {
|
|
73
|
-
connectedCallback() {
|
|
74
|
-
this.setAttribute('data-slot', 'field-content');
|
|
75
|
-
this.className = cn(
|
|
76
|
-
'gap-0.5 group/field-content flex flex-1 flex-col leading-snug',
|
|
77
|
-
this.getAttribute('class') || ''
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!customElements.get('ui-field-content'))
|
|
82
|
-
customElements.define('surreal-shadcn-field', UIFieldContent);
|
|
83
|
-
|
|
84
|
-
export class UIFieldLabel extends HTMLElement {
|
|
85
|
-
connectedCallback() {
|
|
86
|
-
this.setAttribute('data-slot', 'field-label');
|
|
87
|
-
this.className = cn(
|
|
88
|
-
'gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 group/field-label peer/field-label flex w-fit cursor-pointer text-sm font-medium text-foreground has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
|
|
89
|
-
this.getAttribute('class') || ''
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (!customElements.get('ui-field-label'))
|
|
94
|
-
customElements.define('surreal-shadcn-field', UIFieldLabel);
|
|
95
|
-
|
|
96
|
-
export class UIFieldLegend extends HTMLElement {
|
|
97
|
-
static get observedAttributes() {
|
|
98
|
-
return ['variant', 'class'];
|
|
99
|
-
}
|
|
100
|
-
connectedCallback() {
|
|
101
|
-
this.render();
|
|
102
|
-
}
|
|
103
|
-
attributeChangedCallback() {
|
|
104
|
-
this.render();
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
const variant = this.getAttribute('variant') || 'legend';
|
|
108
|
-
this.setAttribute('data-slot', 'field-legend');
|
|
109
|
-
this.setAttribute('data-variant', variant);
|
|
110
|
-
this.className = cn(
|
|
111
|
-
'mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base text-foreground block',
|
|
112
|
-
this.getAttribute('class') || ''
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!customElements.get('ui-field-legend'))
|
|
117
|
-
customElements.define('surreal-shadcn-field', UIFieldLegend);
|
|
118
|
-
|
|
119
|
-
export class UIFieldTitle extends HTMLElement {
|
|
120
|
-
connectedCallback() {
|
|
121
|
-
this.setAttribute('data-slot', 'field-label');
|
|
122
|
-
this.className = cn(
|
|
123
|
-
'gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center text-foreground',
|
|
124
|
-
this.getAttribute('class') || ''
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (!customElements.get('ui-field-title'))
|
|
129
|
-
customElements.define('surreal-shadcn-field', UIFieldTitle);
|
|
130
|
-
|
|
131
|
-
export class UIFieldDescription extends HTMLElement {
|
|
132
|
-
connectedCallback() {
|
|
133
|
-
this.setAttribute('data-slot', 'field-description');
|
|
134
|
-
this.className = cn(
|
|
135
|
-
'text-left text-sm text-muted-foreground [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance last:mt-0 nth-last-2:-mt-1 [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary block',
|
|
136
|
-
this.getAttribute('class') || ''
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (!customElements.get('ui-field-description'))
|
|
141
|
-
customElements.define('surreal-shadcn-field', UIFieldDescription);
|
|
142
|
-
|
|
143
|
-
export class UIFieldError extends HTMLElement {
|
|
144
|
-
connectedCallback() {
|
|
145
|
-
this.setAttribute('role', 'alert');
|
|
146
|
-
this.setAttribute('data-slot', 'field-error');
|
|
147
|
-
this.className = cn(
|
|
148
|
-
'text-sm text-destructive font-normal block',
|
|
149
|
-
this.getAttribute('class') || ''
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (!customElements.get('ui-field-error'))
|
|
154
|
-
customElements.define('surreal-shadcn-field', UIFieldError);
|
|
155
|
-
|
|
156
|
-
export class UIFieldSeparator extends HTMLElement {
|
|
157
|
-
connectedCallback() {
|
|
158
|
-
this.setAttribute('data-slot', 'field-separator');
|
|
159
|
-
const content = this.innerHTML.trim();
|
|
160
|
-
this.className = cn(
|
|
161
|
-
'-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative flex items-center justify-center',
|
|
162
|
-
this.getAttribute('class') || ''
|
|
163
|
-
);
|
|
164
|
-
this.innerHTML = `
|
|
165
|
-
<div class="absolute inset-0 top-1/2 -translate-y-1/2 border-t border-border w-full"></div>
|
|
166
|
-
${content ? `<span class="px-2 text-muted-foreground relative bg-background text-xs uppercase tracking-wider" data-slot="field-separator-content">${content}</span>` : ''}
|
|
167
|
-
`;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (!customElements.get('ui-field-separator'))
|
|
171
|
-
customElements.define('surreal-shadcn-field', UIFieldSeparator);
|
|
172
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-field')) {
|
|
173
|
-
customElements.define('surreal-minimalist-field', UIField);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export default UIField;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { cn } from '@surreal-ui/core';
|
|
2
|
-
|
|
3
|
-
export class FormElement extends HTMLElement {
|
|
4
|
-
connectedCallback() {
|
|
5
|
-
this.className = cn('block space-y-6', this.className);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class FormItemElement extends HTMLElement {
|
|
10
|
-
connectedCallback() {
|
|
11
|
-
this.className = cn('block space-y-2', this.className);
|
|
12
|
-
this.setAttribute('data-slot', 'form-item');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class FormLabelElement extends HTMLElement {
|
|
17
|
-
connectedCallback() {
|
|
18
|
-
const isError = this.hasAttribute('error');
|
|
19
|
-
this.className = cn(
|
|
20
|
-
'block text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
|
|
21
|
-
isError && 'text-destructive',
|
|
22
|
-
this.className
|
|
23
|
-
);
|
|
24
|
-
this.setAttribute('data-slot', 'form-label');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class FormDescriptionElement extends HTMLElement {
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
this.className = cn('block text-sm text-muted-foreground', this.className);
|
|
31
|
-
this.setAttribute('data-slot', 'form-description');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class FormMessageElement extends HTMLElement {
|
|
36
|
-
connectedCallback() {
|
|
37
|
-
this.className = cn('block text-sm font-medium text-destructive', this.className);
|
|
38
|
-
this.setAttribute('data-slot', 'form-message');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class FormFieldsetElement extends HTMLElement {
|
|
43
|
-
connectedCallback() {
|
|
44
|
-
this.className = cn('block space-y-2 border-0 p-0 m-0', this.className);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class FormLegendElement extends HTMLElement {
|
|
49
|
-
connectedCallback() {
|
|
50
|
-
const isError = this.hasAttribute('error');
|
|
51
|
-
this.className = cn(
|
|
52
|
-
'block text-sm leading-none font-medium',
|
|
53
|
-
isError && 'text-destructive',
|
|
54
|
-
this.className
|
|
55
|
-
);
|
|
56
|
-
this.setAttribute('data-slot', 'form-legend');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class FormButtonElement extends HTMLElement {
|
|
61
|
-
connectedCallback() {
|
|
62
|
-
const variant = this.getAttribute('variant') || 'default';
|
|
63
|
-
this.className = cn(
|
|
64
|
-
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 h-9 px-4 py-2 shadow cursor-pointer',
|
|
65
|
-
variant === 'default' && 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
66
|
-
variant === 'destructive' &&
|
|
67
|
-
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
68
|
-
variant === 'outline' &&
|
|
69
|
-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
70
|
-
variant === 'secondary' && 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
71
|
-
variant === 'ghost' && 'hover:bg-accent hover:text-accent-foreground',
|
|
72
|
-
variant === 'link' && 'text-primary underline-offset-4 hover:underline',
|
|
73
|
-
this.className
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (typeof customElements !== 'undefined') {
|
|
79
|
-
if (!customElements.get('ui-form'))
|
|
80
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-form')) {
|
|
81
|
-
customElements.define('surreal-shadcn-form', FormElement);
|
|
82
|
-
}
|
|
83
|
-
if (!customElements.get('ui-form-item'))
|
|
84
|
-
customElements.define('surreal-shadcn-form', FormItemElement);
|
|
85
|
-
if (!customElements.get('ui-form-label'))
|
|
86
|
-
customElements.define('surreal-shadcn-form', FormLabelElement);
|
|
87
|
-
if (!customElements.get('ui-form-description'))
|
|
88
|
-
customElements.define('surreal-shadcn-form', FormDescriptionElement);
|
|
89
|
-
if (!customElements.get('ui-form-message'))
|
|
90
|
-
customElements.define('surreal-shadcn-form', FormMessageElement);
|
|
91
|
-
if (!customElements.get('ui-form-fieldset'))
|
|
92
|
-
customElements.define('surreal-shadcn-form', FormFieldsetElement);
|
|
93
|
-
if (!customElements.get('ui-form-legend'))
|
|
94
|
-
customElements.define('surreal-shadcn-form', FormLegendElement);
|
|
95
|
-
if (!customElements.get('ui-form-button'))
|
|
96
|
-
customElements.define('surreal-shadcn-form', FormButtonElement);
|
|
97
|
-
}
|
|
98
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-form')) {
|
|
99
|
-
customElements.define('surreal-minimalist-form', FormElement);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export default FormElement;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
class SurrealShadcnHoverCard extends HTMLElement {
|
|
2
|
-
private openTimeout: number | null = null;
|
|
3
|
-
private closeTimeout: number | null = null;
|
|
4
|
-
private openDelay = 300;
|
|
5
|
-
private closeDelay = 300;
|
|
6
|
-
private isOpen = false;
|
|
7
|
-
|
|
8
|
-
static get observedAttributes() {
|
|
9
|
-
return ['open-delay', 'close-delay', 'open'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.attachShadow({ mode: 'open' });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
connectedCallback() {
|
|
18
|
-
if (this.hasAttribute('open-delay')) {
|
|
19
|
-
this.openDelay = parseInt(this.getAttribute('open-delay') || '300', 10);
|
|
20
|
-
}
|
|
21
|
-
if (this.hasAttribute('close-delay')) {
|
|
22
|
-
this.closeDelay = parseInt(this.getAttribute('close-delay') || '300', 10);
|
|
23
|
-
}
|
|
24
|
-
this.render();
|
|
25
|
-
this.attachListeners();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
this.clearTimeouts();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
|
|
33
|
-
if (oldValue === newValue) return;
|
|
34
|
-
if (name === 'open-delay') {
|
|
35
|
-
this.openDelay = parseInt(newValue || '300', 10);
|
|
36
|
-
} else if (name === 'close-delay') {
|
|
37
|
-
this.closeDelay = parseInt(newValue || '300', 10);
|
|
38
|
-
} else if (name === 'open') {
|
|
39
|
-
this.isOpen = newValue !== null && newValue !== 'false';
|
|
40
|
-
this.updateState();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private clearTimeouts() {
|
|
45
|
-
if (this.openTimeout) clearTimeout(this.openTimeout);
|
|
46
|
-
if (this.closeTimeout) clearTimeout(this.closeTimeout);
|
|
47
|
-
this.openTimeout = null;
|
|
48
|
-
this.closeTimeout = null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private show() {
|
|
52
|
-
this.clearTimeouts();
|
|
53
|
-
this.openTimeout = window.setTimeout(() => {
|
|
54
|
-
this.isOpen = true;
|
|
55
|
-
this.setAttribute('open', '');
|
|
56
|
-
this.updateState();
|
|
57
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: true } }));
|
|
58
|
-
}, this.openDelay);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private hide() {
|
|
62
|
-
this.clearTimeouts();
|
|
63
|
-
this.closeTimeout = window.setTimeout(() => {
|
|
64
|
-
this.isOpen = false;
|
|
65
|
-
this.removeAttribute('open');
|
|
66
|
-
this.updateState();
|
|
67
|
-
this.dispatchEvent(new CustomEvent('openchange', { detail: { open: false } }));
|
|
68
|
-
}, this.closeDelay);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private updateState() {
|
|
72
|
-
const content = this.shadowRoot?.querySelector("[data-slot='hover-card-content']");
|
|
73
|
-
if (content) {
|
|
74
|
-
if (this.isOpen) {
|
|
75
|
-
content.classList.remove('hidden');
|
|
76
|
-
content.setAttribute('data-state', 'open');
|
|
77
|
-
} else {
|
|
78
|
-
content.classList.add('hidden');
|
|
79
|
-
content.setAttribute('data-state', 'closed');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private attachListeners() {
|
|
85
|
-
this.addEventListener('mouseenter', () => this.show());
|
|
86
|
-
this.addEventListener('mouseleave', () => this.hide());
|
|
87
|
-
this.addEventListener('focusin', () => this.show());
|
|
88
|
-
this.addEventListener('focusout', () => this.hide());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private render() {
|
|
92
|
-
if (!this.shadowRoot) return;
|
|
93
|
-
this.shadowRoot.innerHTML = `
|
|
94
|
-
<style>
|
|
95
|
-
:host {
|
|
96
|
-
display: inline-block;
|
|
97
|
-
position: relative;
|
|
98
|
-
}
|
|
99
|
-
.hidden {
|
|
100
|
-
display: none !important;
|
|
101
|
-
}
|
|
102
|
-
.hover-card-content {
|
|
103
|
-
position: absolute;
|
|
104
|
-
top: calc(100% + 4px);
|
|
105
|
-
left: 50%;
|
|
106
|
-
transform: translateX(-50%);
|
|
107
|
-
z-index: 50;
|
|
108
|
-
width: 16rem;
|
|
109
|
-
border-radius: 0.5rem;
|
|
110
|
-
background-color: var(--color-popover, #ffffff);
|
|
111
|
-
color: var(--color-popover-foreground, #09090b);
|
|
112
|
-
padding: 0.625rem;
|
|
113
|
-
font-size: 0.875rem;
|
|
114
|
-
line-height: 1.25rem;
|
|
115
|
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
116
|
-
outline: 1px solid rgb(0 0 0 / 0.1);
|
|
117
|
-
animation: fadeIn 100ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
118
|
-
}
|
|
119
|
-
@keyframes fadeIn {
|
|
120
|
-
from { opacity: 0; transform: translate(-50%, -4px) scale(0.95); }
|
|
121
|
-
to { opacity: 1; transform: translate(-50%, 0) scale(1); }
|
|
122
|
-
}
|
|
123
|
-
</style>
|
|
124
|
-
<div data-slot="hover-card-trigger">
|
|
125
|
-
<slot name="trigger"></slot>
|
|
126
|
-
</div>
|
|
127
|
-
<div
|
|
128
|
-
data-slot="hover-card-content"
|
|
129
|
-
class="hover-card-content ${this.isOpen ? '' : 'hidden'}"
|
|
130
|
-
data-state="${this.isOpen ? 'open' : 'closed'}"
|
|
131
|
-
>
|
|
132
|
-
<slot></slot>
|
|
133
|
-
</div>
|
|
134
|
-
`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (!customElements.get('surreal-hover-card')) {
|
|
139
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-hover-card')) {
|
|
140
|
-
customElements.define('surreal-shadcn-hover-card', SurrealShadcnHoverCard);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { SurrealShadcnHoverCard };
|
|
145
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-hover-card')) {
|
|
146
|
-
customElements.define('surreal-minimalist-hover-card', SurrealShadcnHoverCard);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export default SurrealShadcnHoverCard;
|
|
@@ -1,104 +0,0 @@
|
|
|
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
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-shadcn-input')) {
|
|
97
|
-
customElements.define('surreal-shadcn-input', SurrealShadcnInput);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (typeof customElements !== 'undefined' && !customElements.get('surreal-minimalist-input')) {
|
|
101
|
-
customElements.define('surreal-minimalist-input', SurrealShadcnInput);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default SurrealShadcnInput;
|
|
@@ -1,95 +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 MinimalistInputGroup, InputGroupElement };
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
typeof customElements !== 'undefined' &&
|
|
90
|
-
!customElements.get('surreal-minimalist-input-group')
|
|
91
|
-
) {
|
|
92
|
-
customElements.define('surreal-minimalist-input-group', InputGroupElement);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export default InputGroupElement;
|