@sonny-ui/core 0.1.0-alpha.1
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/README.md +64 -0
- package/fesm2022/sonny-ui-core.mjs +2365 -0
- package/fesm2022/sonny-ui-core.mjs.map +1 -0
- package/package.json +51 -0
- package/schematics/collection.json +16 -0
- package/schematics/ng-add/index.d.ts +5 -0
- package/schematics/ng-add/index.js +26 -0
- package/schematics/ng-add/schema.json +19 -0
- package/schematics/ng-generate/component/index.d.ts +9 -0
- package/schematics/ng-generate/component/index.js +258 -0
- package/schematics/ng-generate/component/schema.json +32 -0
- package/src/styles/sonny-theme.css +126 -0
- package/types/sonny-ui-core.d.ts +738 -0
|
@@ -0,0 +1,2365 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
export { cva } from 'class-variance-authority';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { InjectionToken, makeEnvironmentProviders, inject, PLATFORM_ID, signal, computed, Injectable, input, Directive, Component, model, viewChild, ElementRef, HostListener, Injector } from '@angular/core';
|
|
7
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
8
|
+
import { Dialog, DialogRef } from '@angular/cdk/dialog';
|
|
9
|
+
import { createGlobalPositionStrategy } from '@angular/cdk/overlay';
|
|
10
|
+
|
|
11
|
+
function cn(...inputs) {
|
|
12
|
+
return twMerge(clsx(inputs));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DEFAULT_CONFIG = { prefix: 'sny', defaultTheme: 'light' };
|
|
16
|
+
const SNY_CONFIG = new InjectionToken('SNY_CONFIG', {
|
|
17
|
+
providedIn: 'root',
|
|
18
|
+
factory: () => DEFAULT_CONFIG,
|
|
19
|
+
});
|
|
20
|
+
function provideSonnyUI(config = {}) {
|
|
21
|
+
return makeEnvironmentProviders([
|
|
22
|
+
{ provide: SNY_CONFIG, useValue: { ...DEFAULT_CONFIG, ...config } },
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class ThemeService {
|
|
27
|
+
document = inject(DOCUMENT);
|
|
28
|
+
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
29
|
+
_theme = signal('light', ...(ngDevMode ? [{ debugName: "_theme" }] : /* istanbul ignore next */ []));
|
|
30
|
+
theme = this._theme.asReadonly();
|
|
31
|
+
isDark = computed(() => this._theme() === 'dark', ...(ngDevMode ? [{ debugName: "isDark" }] : /* istanbul ignore next */ []));
|
|
32
|
+
setTheme(theme) {
|
|
33
|
+
this._theme.set(theme);
|
|
34
|
+
if (!this.isBrowser)
|
|
35
|
+
return;
|
|
36
|
+
const root = this.document.documentElement;
|
|
37
|
+
root.classList.remove('dark');
|
|
38
|
+
root.removeAttribute('data-theme');
|
|
39
|
+
if (theme === 'dark') {
|
|
40
|
+
root.classList.add('dark');
|
|
41
|
+
root.setAttribute('data-theme', 'dark');
|
|
42
|
+
}
|
|
43
|
+
else if (theme !== 'light') {
|
|
44
|
+
root.setAttribute('data-theme', theme);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
toggleDark() {
|
|
48
|
+
this.setTheme(this._theme() === 'dark' ? 'light' : 'dark');
|
|
49
|
+
}
|
|
50
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
51
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: ThemeService, providedIn: 'root' });
|
|
52
|
+
}
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: ThemeService, decorators: [{
|
|
54
|
+
type: Injectable,
|
|
55
|
+
args: [{ providedIn: 'root' }]
|
|
56
|
+
}] });
|
|
57
|
+
|
|
58
|
+
const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', {
|
|
59
|
+
variants: {
|
|
60
|
+
variant: {
|
|
61
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
62
|
+
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
63
|
+
outline: 'border border-border bg-background hover:bg-accent hover:text-accent-foreground',
|
|
64
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
65
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
66
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
sm: 'h-9 rounded-sm px-3',
|
|
70
|
+
md: 'h-10 px-4 py-2',
|
|
71
|
+
lg: 'h-11 rounded-sm px-8',
|
|
72
|
+
icon: 'h-10 w-10',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
variant: 'default',
|
|
77
|
+
size: 'md',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
class SnyButtonDirective {
|
|
82
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
83
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
84
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
85
|
+
loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
86
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
87
|
+
computedClass = computed(() => cn(buttonVariants({ variant: this.variant(), size: this.size() }), this.loading() && 'relative cursor-wait', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
88
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
89
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyButtonDirective, isStandalone: true, selector: "button[snyBtn], a[snyBtn]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()", "attr.aria-disabled": "disabled() || loading() || null", "attr.disabled": "disabled() || loading() || null", "attr.tabindex": "(disabled() || loading()) ? -1 : null" } }, ngImport: i0 });
|
|
90
|
+
}
|
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyButtonDirective, decorators: [{
|
|
92
|
+
type: Directive,
|
|
93
|
+
args: [{
|
|
94
|
+
selector: 'button[snyBtn], a[snyBtn]',
|
|
95
|
+
standalone: true,
|
|
96
|
+
host: {
|
|
97
|
+
'[class]': 'computedClass()',
|
|
98
|
+
'[attr.aria-disabled]': 'disabled() || loading() || null',
|
|
99
|
+
'[attr.disabled]': 'disabled() || loading() || null',
|
|
100
|
+
'[attr.tabindex]': '(disabled() || loading()) ? -1 : null',
|
|
101
|
+
},
|
|
102
|
+
}]
|
|
103
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
104
|
+
|
|
105
|
+
const cardVariants = cva('rounded-sm text-card-foreground', {
|
|
106
|
+
variants: {
|
|
107
|
+
variant: {
|
|
108
|
+
default: 'bg-card border border-border',
|
|
109
|
+
outline: 'border-2 border-border bg-transparent',
|
|
110
|
+
elevated: 'bg-card shadow-lg',
|
|
111
|
+
ghost: 'bg-transparent',
|
|
112
|
+
},
|
|
113
|
+
padding: {
|
|
114
|
+
none: '',
|
|
115
|
+
sm: 'p-4',
|
|
116
|
+
md: 'p-6',
|
|
117
|
+
lg: 'p-8',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
defaultVariants: {
|
|
121
|
+
variant: 'default',
|
|
122
|
+
padding: 'none',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
class SnyCardDirective {
|
|
127
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
128
|
+
padding = input('none', ...(ngDevMode ? [{ debugName: "padding" }] : /* istanbul ignore next */ []));
|
|
129
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
130
|
+
computedClass = computed(() => cn(cardVariants({ variant: this.variant(), padding: this.padding() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
131
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
132
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardDirective, isStandalone: true, selector: "[snyCard]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, padding: { classPropertyName: "padding", publicName: "padding", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
133
|
+
}
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardDirective, decorators: [{
|
|
135
|
+
type: Directive,
|
|
136
|
+
args: [{
|
|
137
|
+
selector: '[snyCard]',
|
|
138
|
+
standalone: true,
|
|
139
|
+
host: { '[class]': 'computedClass()' },
|
|
140
|
+
}]
|
|
141
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], padding: [{ type: i0.Input, args: [{ isSignal: true, alias: "padding", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
142
|
+
class SnyCardHeaderDirective {
|
|
143
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
144
|
+
computedClass = computed(() => cn('flex flex-col space-y-1.5 p-6', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
145
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
146
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardHeaderDirective, isStandalone: true, selector: "[snyCardHeader]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
147
|
+
}
|
|
148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardHeaderDirective, decorators: [{
|
|
149
|
+
type: Directive,
|
|
150
|
+
args: [{
|
|
151
|
+
selector: '[snyCardHeader]',
|
|
152
|
+
standalone: true,
|
|
153
|
+
host: { '[class]': 'computedClass()' },
|
|
154
|
+
}]
|
|
155
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
156
|
+
class SnyCardTitleDirective {
|
|
157
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
158
|
+
computedClass = computed(() => cn('text-2xl font-semibold leading-none tracking-tight', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
159
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardTitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
160
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardTitleDirective, isStandalone: true, selector: "[snyCardTitle]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
161
|
+
}
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardTitleDirective, decorators: [{
|
|
163
|
+
type: Directive,
|
|
164
|
+
args: [{
|
|
165
|
+
selector: '[snyCardTitle]',
|
|
166
|
+
standalone: true,
|
|
167
|
+
host: { '[class]': 'computedClass()' },
|
|
168
|
+
}]
|
|
169
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
170
|
+
class SnyCardDescriptionDirective {
|
|
171
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
172
|
+
computedClass = computed(() => cn('text-sm text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
173
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardDescriptionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
174
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardDescriptionDirective, isStandalone: true, selector: "[snyCardDescription]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
175
|
+
}
|
|
176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardDescriptionDirective, decorators: [{
|
|
177
|
+
type: Directive,
|
|
178
|
+
args: [{
|
|
179
|
+
selector: '[snyCardDescription]',
|
|
180
|
+
standalone: true,
|
|
181
|
+
host: { '[class]': 'computedClass()' },
|
|
182
|
+
}]
|
|
183
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
184
|
+
class SnyCardContentDirective {
|
|
185
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
186
|
+
computedClass = computed(() => cn('p-6 pt-0', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
187
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
188
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardContentDirective, isStandalone: true, selector: "[snyCardContent]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
189
|
+
}
|
|
190
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardContentDirective, decorators: [{
|
|
191
|
+
type: Directive,
|
|
192
|
+
args: [{
|
|
193
|
+
selector: '[snyCardContent]',
|
|
194
|
+
standalone: true,
|
|
195
|
+
host: { '[class]': 'computedClass()' },
|
|
196
|
+
}]
|
|
197
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
198
|
+
class SnyCardFooterDirective {
|
|
199
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
200
|
+
computedClass = computed(() => cn('flex items-center p-6 pt-0', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
201
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardFooterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
202
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCardFooterDirective, isStandalone: true, selector: "[snyCardFooter]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
203
|
+
}
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCardFooterDirective, decorators: [{
|
|
205
|
+
type: Directive,
|
|
206
|
+
args: [{
|
|
207
|
+
selector: '[snyCardFooter]',
|
|
208
|
+
standalone: true,
|
|
209
|
+
host: { '[class]': 'computedClass()' },
|
|
210
|
+
}]
|
|
211
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
212
|
+
|
|
213
|
+
const inputVariants = cva('flex w-full rounded-sm border bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
|
|
214
|
+
variants: {
|
|
215
|
+
variant: {
|
|
216
|
+
default: 'border-input',
|
|
217
|
+
error: 'border-destructive focus-visible:ring-destructive',
|
|
218
|
+
success: 'border-green-500 focus-visible:ring-green-500',
|
|
219
|
+
},
|
|
220
|
+
inputSize: {
|
|
221
|
+
sm: 'h-9 text-xs',
|
|
222
|
+
md: 'h-10',
|
|
223
|
+
lg: 'h-11 text-base',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
defaultVariants: {
|
|
227
|
+
variant: 'default',
|
|
228
|
+
inputSize: 'md',
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', {
|
|
232
|
+
variants: {
|
|
233
|
+
variant: {
|
|
234
|
+
default: '',
|
|
235
|
+
error: 'text-destructive',
|
|
236
|
+
success: 'text-green-600',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
defaultVariants: {
|
|
240
|
+
variant: 'default',
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
class SnyInputDirective {
|
|
245
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
246
|
+
inputSize = input('md', ...(ngDevMode ? [{ debugName: "inputSize" }] : /* istanbul ignore next */ []));
|
|
247
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
248
|
+
ariaDescribedBy = input('', ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
249
|
+
computedClass = computed(() => cn(inputVariants({ variant: this.variant(), inputSize: this.inputSize() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
251
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyInputDirective, isStandalone: true, selector: "input[snyInput], textarea[snyInput]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, inputSize: { classPropertyName: "inputSize", publicName: "inputSize", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "ariaDescribedBy", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()", "attr.aria-invalid": "variant() === \"error\" || null", "attr.aria-describedby": "ariaDescribedBy() || null" } }, ngImport: i0 });
|
|
252
|
+
}
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyInputDirective, decorators: [{
|
|
254
|
+
type: Directive,
|
|
255
|
+
args: [{
|
|
256
|
+
selector: 'input[snyInput], textarea[snyInput]',
|
|
257
|
+
standalone: true,
|
|
258
|
+
host: {
|
|
259
|
+
'[class]': 'computedClass()',
|
|
260
|
+
'[attr.aria-invalid]': 'variant() === "error" || null',
|
|
261
|
+
'[attr.aria-describedby]': 'ariaDescribedBy() || null',
|
|
262
|
+
},
|
|
263
|
+
}]
|
|
264
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], inputSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputSize", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaDescribedBy", required: false }] }] } });
|
|
265
|
+
|
|
266
|
+
class SnyLabelDirective {
|
|
267
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
268
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
269
|
+
computedClass = computed(() => cn(labelVariants({ variant: this.variant() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
270
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyLabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
271
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyLabelDirective, isStandalone: true, selector: "label[snyLabel]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
272
|
+
}
|
|
273
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyLabelDirective, decorators: [{
|
|
274
|
+
type: Directive,
|
|
275
|
+
args: [{
|
|
276
|
+
selector: 'label[snyLabel]',
|
|
277
|
+
standalone: true,
|
|
278
|
+
host: { '[class]': 'computedClass()' },
|
|
279
|
+
}]
|
|
280
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
281
|
+
|
|
282
|
+
class SnyToastService {
|
|
283
|
+
_toasts = signal([], ...(ngDevMode ? [{ debugName: "_toasts" }] : /* istanbul ignore next */ []));
|
|
284
|
+
_timers = new Map();
|
|
285
|
+
_idCounter = 0;
|
|
286
|
+
toasts = this._toasts.asReadonly();
|
|
287
|
+
count = computed(() => this._toasts().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
288
|
+
show(config) {
|
|
289
|
+
const id = `sny-toast-${++this._idCounter}`;
|
|
290
|
+
const toast = {
|
|
291
|
+
id,
|
|
292
|
+
variant: 'default',
|
|
293
|
+
duration: 5000,
|
|
294
|
+
...config,
|
|
295
|
+
};
|
|
296
|
+
this._toasts.update(toasts => [...toasts, toast]);
|
|
297
|
+
if (toast.duration && toast.duration > 0) {
|
|
298
|
+
const timer = setTimeout(() => this.dismiss(id), toast.duration);
|
|
299
|
+
this._timers.set(id, timer);
|
|
300
|
+
}
|
|
301
|
+
return id;
|
|
302
|
+
}
|
|
303
|
+
dismiss(id) {
|
|
304
|
+
const timer = this._timers.get(id);
|
|
305
|
+
if (timer) {
|
|
306
|
+
clearTimeout(timer);
|
|
307
|
+
this._timers.delete(id);
|
|
308
|
+
}
|
|
309
|
+
this._toasts.update(toasts => toasts.filter(t => t.id !== id));
|
|
310
|
+
}
|
|
311
|
+
dismissAll() {
|
|
312
|
+
for (const timer of this._timers.values()) {
|
|
313
|
+
clearTimeout(timer);
|
|
314
|
+
}
|
|
315
|
+
this._timers.clear();
|
|
316
|
+
this._toasts.set([]);
|
|
317
|
+
}
|
|
318
|
+
success(title, description) {
|
|
319
|
+
return this.show({ title, description, variant: 'success' });
|
|
320
|
+
}
|
|
321
|
+
error(title, description) {
|
|
322
|
+
return this.show({ title, description, variant: 'destructive' });
|
|
323
|
+
}
|
|
324
|
+
warning(title, description) {
|
|
325
|
+
return this.show({ title, description, variant: 'warning' });
|
|
326
|
+
}
|
|
327
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
328
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToastService, providedIn: 'root' });
|
|
329
|
+
}
|
|
330
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToastService, decorators: [{
|
|
331
|
+
type: Injectable,
|
|
332
|
+
args: [{ providedIn: 'root' }]
|
|
333
|
+
}] });
|
|
334
|
+
|
|
335
|
+
const toastVariants = cva('group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-sm border p-6 pr-8 shadow-lg transition-all', {
|
|
336
|
+
variants: {
|
|
337
|
+
variant: {
|
|
338
|
+
default: 'bg-background border-border text-foreground',
|
|
339
|
+
destructive: 'bg-destructive border-destructive text-destructive-foreground',
|
|
340
|
+
success: 'bg-green-600 border-green-600 text-white',
|
|
341
|
+
warning: 'bg-yellow-500 border-yellow-500 text-white',
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
defaultVariants: {
|
|
345
|
+
variant: 'default',
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
class SnyToasterComponent {
|
|
350
|
+
toastService = inject(SnyToastService);
|
|
351
|
+
position = input('bottom-right', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
352
|
+
maxToasts = input(5, ...(ngDevMode ? [{ debugName: "maxToasts" }] : /* istanbul ignore next */ []));
|
|
353
|
+
visibleToasts = computed(() => this.toastService.toasts().slice(-this.maxToasts()), ...(ngDevMode ? [{ debugName: "visibleToasts" }] : /* istanbul ignore next */ []));
|
|
354
|
+
containerClass = computed(() => {
|
|
355
|
+
const pos = this.position();
|
|
356
|
+
const base = 'fixed z-[100] flex max-h-screen w-full flex-col-reverse gap-2 p-4 sm:max-w-[420px]';
|
|
357
|
+
const posMap = {
|
|
358
|
+
'top-right': 'top-0 right-0',
|
|
359
|
+
'top-left': 'top-0 left-0',
|
|
360
|
+
'bottom-right': 'bottom-0 right-0',
|
|
361
|
+
'bottom-left': 'bottom-0 left-0',
|
|
362
|
+
'top-center': 'top-0 left-1/2 -translate-x-1/2',
|
|
363
|
+
'bottom-center': 'bottom-0 left-1/2 -translate-x-1/2',
|
|
364
|
+
};
|
|
365
|
+
return cn(base, posMap[pos]);
|
|
366
|
+
}, ...(ngDevMode ? [{ debugName: "containerClass" }] : /* istanbul ignore next */ []));
|
|
367
|
+
/** Pre-computed toast classes by variant — avoids method calls in the template. */
|
|
368
|
+
toastClasses = {
|
|
369
|
+
default: cn(toastVariants({ variant: 'default' })),
|
|
370
|
+
destructive: cn(toastVariants({ variant: 'destructive' })),
|
|
371
|
+
success: cn(toastVariants({ variant: 'success' })),
|
|
372
|
+
warning: cn(toastVariants({ variant: 'warning' })),
|
|
373
|
+
};
|
|
374
|
+
dismiss(id) {
|
|
375
|
+
this.toastService.dismiss(id);
|
|
376
|
+
}
|
|
377
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToasterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
378
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SnyToasterComponent, isStandalone: true, selector: "sny-toaster", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, maxToasts: { classPropertyName: "maxToasts", publicName: "maxToasts", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
379
|
+
<div [class]="containerClass()" role="region" aria-label="Notifications" tabindex="-1">
|
|
380
|
+
@for (toast of visibleToasts(); track toast.id) {
|
|
381
|
+
<div
|
|
382
|
+
[class]="toastClasses[toast.variant ?? 'default']"
|
|
383
|
+
role="alert"
|
|
384
|
+
aria-live="polite"
|
|
385
|
+
>
|
|
386
|
+
<div class="grid gap-1">
|
|
387
|
+
<div class="text-sm font-semibold">{{ toast.title }}</div>
|
|
388
|
+
@if (toast.description) {
|
|
389
|
+
<div class="text-sm opacity-90">{{ toast.description }}</div>
|
|
390
|
+
}
|
|
391
|
+
</div>
|
|
392
|
+
<div class="flex items-center gap-2">
|
|
393
|
+
@if (toast.action) {
|
|
394
|
+
<button
|
|
395
|
+
class="inline-flex h-8 shrink-0 items-center justify-center rounded-sm border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary"
|
|
396
|
+
(click)="toast.action!.onClick()"
|
|
397
|
+
>
|
|
398
|
+
{{ toast.action!.label }}
|
|
399
|
+
</button>
|
|
400
|
+
}
|
|
401
|
+
<button
|
|
402
|
+
class="absolute right-2 top-2 rounded-sm p-1 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-100 focus:opacity-100"
|
|
403
|
+
aria-label="Close"
|
|
404
|
+
(click)="dismiss(toast.id)"
|
|
405
|
+
>
|
|
406
|
+
<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="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
407
|
+
</button>
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
}
|
|
411
|
+
</div>
|
|
412
|
+
`, isInline: true });
|
|
413
|
+
}
|
|
414
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToasterComponent, decorators: [{
|
|
415
|
+
type: Component,
|
|
416
|
+
args: [{
|
|
417
|
+
selector: 'sny-toaster',
|
|
418
|
+
standalone: true,
|
|
419
|
+
template: `
|
|
420
|
+
<div [class]="containerClass()" role="region" aria-label="Notifications" tabindex="-1">
|
|
421
|
+
@for (toast of visibleToasts(); track toast.id) {
|
|
422
|
+
<div
|
|
423
|
+
[class]="toastClasses[toast.variant ?? 'default']"
|
|
424
|
+
role="alert"
|
|
425
|
+
aria-live="polite"
|
|
426
|
+
>
|
|
427
|
+
<div class="grid gap-1">
|
|
428
|
+
<div class="text-sm font-semibold">{{ toast.title }}</div>
|
|
429
|
+
@if (toast.description) {
|
|
430
|
+
<div class="text-sm opacity-90">{{ toast.description }}</div>
|
|
431
|
+
}
|
|
432
|
+
</div>
|
|
433
|
+
<div class="flex items-center gap-2">
|
|
434
|
+
@if (toast.action) {
|
|
435
|
+
<button
|
|
436
|
+
class="inline-flex h-8 shrink-0 items-center justify-center rounded-sm border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary"
|
|
437
|
+
(click)="toast.action!.onClick()"
|
|
438
|
+
>
|
|
439
|
+
{{ toast.action!.label }}
|
|
440
|
+
</button>
|
|
441
|
+
}
|
|
442
|
+
<button
|
|
443
|
+
class="absolute right-2 top-2 rounded-sm p-1 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-100 focus:opacity-100"
|
|
444
|
+
aria-label="Close"
|
|
445
|
+
(click)="dismiss(toast.id)"
|
|
446
|
+
>
|
|
447
|
+
<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="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
448
|
+
</button>
|
|
449
|
+
</div>
|
|
450
|
+
</div>
|
|
451
|
+
}
|
|
452
|
+
</div>
|
|
453
|
+
`,
|
|
454
|
+
}]
|
|
455
|
+
}], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], maxToasts: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxToasts", required: false }] }] } });
|
|
456
|
+
|
|
457
|
+
class SnyDialogRef {
|
|
458
|
+
cdkRef;
|
|
459
|
+
constructor(cdkRef) {
|
|
460
|
+
this.cdkRef = cdkRef;
|
|
461
|
+
}
|
|
462
|
+
close(result) {
|
|
463
|
+
this.cdkRef.close(result);
|
|
464
|
+
}
|
|
465
|
+
get closed() {
|
|
466
|
+
return this.cdkRef.closed;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const DEFAULT_DIALOG_CONFIG = {
|
|
471
|
+
width: '28rem',
|
|
472
|
+
maxWidth: '90vw',
|
|
473
|
+
closeOnBackdrop: true,
|
|
474
|
+
closeOnEsc: true,
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
const SNY_DIALOG_DATA = new InjectionToken('SNY_DIALOG_DATA');
|
|
478
|
+
class SnyDialogService {
|
|
479
|
+
cdkDialog = inject(Dialog);
|
|
480
|
+
open(component, config = {}) {
|
|
481
|
+
const merged = { ...DEFAULT_DIALOG_CONFIG, ...config };
|
|
482
|
+
// CDK's disableClose controls both backdrop and ESC together.
|
|
483
|
+
// To support independent closeOnBackdrop / closeOnEsc, we disable both
|
|
484
|
+
// at the CDK level and handle them manually.
|
|
485
|
+
const disableClose = !merged.closeOnBackdrop || !merged.closeOnEsc;
|
|
486
|
+
const cdkRef = this.cdkDialog.open(component, {
|
|
487
|
+
width: merged.width,
|
|
488
|
+
maxWidth: merged.maxWidth,
|
|
489
|
+
disableClose,
|
|
490
|
+
hasBackdrop: true,
|
|
491
|
+
backdropClass: 'sny-dialog-backdrop',
|
|
492
|
+
panelClass: 'sny-dialog-panel',
|
|
493
|
+
ariaLabelledBy: merged.ariaLabelledBy,
|
|
494
|
+
ariaDescribedBy: merged.ariaDescribedBy,
|
|
495
|
+
data: merged.data,
|
|
496
|
+
providers: merged.data != null
|
|
497
|
+
? [{ provide: SNY_DIALOG_DATA, useValue: merged.data }]
|
|
498
|
+
: [],
|
|
499
|
+
});
|
|
500
|
+
// When CDK disableClose is true, manually handle backdrop/ESC based on config
|
|
501
|
+
if (disableClose) {
|
|
502
|
+
if (merged.closeOnBackdrop) {
|
|
503
|
+
const sub = cdkRef.backdropClick.subscribe(() => cdkRef.close());
|
|
504
|
+
cdkRef.closed.subscribe(() => sub.unsubscribe());
|
|
505
|
+
}
|
|
506
|
+
if (merged.closeOnEsc) {
|
|
507
|
+
const sub = cdkRef.keydownEvents.subscribe(event => {
|
|
508
|
+
if (event.key === 'Escape') {
|
|
509
|
+
cdkRef.close();
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
cdkRef.closed.subscribe(() => sub.unsubscribe());
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return new SnyDialogRef(cdkRef);
|
|
516
|
+
}
|
|
517
|
+
closeAll() {
|
|
518
|
+
this.cdkDialog.closeAll();
|
|
519
|
+
}
|
|
520
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
521
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogService, providedIn: 'root' });
|
|
522
|
+
}
|
|
523
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogService, decorators: [{
|
|
524
|
+
type: Injectable,
|
|
525
|
+
args: [{ providedIn: 'root' }]
|
|
526
|
+
}] });
|
|
527
|
+
|
|
528
|
+
class SnyDialogHeaderDirective {
|
|
529
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
530
|
+
computedClass = computed(() => cn('flex flex-col space-y-1.5 text-center sm:text-left', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
531
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
532
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogHeaderDirective, isStandalone: true, selector: "[snyDialogHeader]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
533
|
+
}
|
|
534
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogHeaderDirective, decorators: [{
|
|
535
|
+
type: Directive,
|
|
536
|
+
args: [{
|
|
537
|
+
selector: '[snyDialogHeader]',
|
|
538
|
+
standalone: true,
|
|
539
|
+
host: { '[class]': 'computedClass()' },
|
|
540
|
+
}]
|
|
541
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
542
|
+
class SnyDialogTitleDirective {
|
|
543
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
544
|
+
computedClass = computed(() => cn('text-lg font-semibold leading-none tracking-tight', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
545
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogTitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
546
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogTitleDirective, isStandalone: true, selector: "[snyDialogTitle]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
547
|
+
}
|
|
548
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogTitleDirective, decorators: [{
|
|
549
|
+
type: Directive,
|
|
550
|
+
args: [{
|
|
551
|
+
selector: '[snyDialogTitle]',
|
|
552
|
+
standalone: true,
|
|
553
|
+
host: { '[class]': 'computedClass()' },
|
|
554
|
+
}]
|
|
555
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
556
|
+
class SnyDialogDescriptionDirective {
|
|
557
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
558
|
+
computedClass = computed(() => cn('text-sm text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
559
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogDescriptionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
560
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogDescriptionDirective, isStandalone: true, selector: "[snyDialogDescription]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
561
|
+
}
|
|
562
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogDescriptionDirective, decorators: [{
|
|
563
|
+
type: Directive,
|
|
564
|
+
args: [{
|
|
565
|
+
selector: '[snyDialogDescription]',
|
|
566
|
+
standalone: true,
|
|
567
|
+
host: { '[class]': 'computedClass()' },
|
|
568
|
+
}]
|
|
569
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
570
|
+
class SnyDialogContentDirective {
|
|
571
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
572
|
+
computedClass = computed(() => cn('relative bg-background rounded-sm border border-border shadow-lg p-6 w-full max-w-lg mx-auto', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
573
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
574
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogContentDirective, isStandalone: true, selector: "[snyDialogContent]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
575
|
+
}
|
|
576
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogContentDirective, decorators: [{
|
|
577
|
+
type: Directive,
|
|
578
|
+
args: [{
|
|
579
|
+
selector: '[snyDialogContent]',
|
|
580
|
+
standalone: true,
|
|
581
|
+
host: { '[class]': 'computedClass()' },
|
|
582
|
+
}]
|
|
583
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
584
|
+
class SnyDialogFooterDirective {
|
|
585
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
586
|
+
computedClass = computed(() => cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
587
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogFooterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
588
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogFooterDirective, isStandalone: true, selector: "[snyDialogFooter]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
589
|
+
}
|
|
590
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogFooterDirective, decorators: [{
|
|
591
|
+
type: Directive,
|
|
592
|
+
args: [{
|
|
593
|
+
selector: '[snyDialogFooter]',
|
|
594
|
+
standalone: true,
|
|
595
|
+
host: { '[class]': 'computedClass()' },
|
|
596
|
+
}]
|
|
597
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
598
|
+
class SnyDialogCloseDirective {
|
|
599
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
600
|
+
computedClass = computed(() => cn('absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
601
|
+
dialogRef = inject(DialogRef, { optional: true });
|
|
602
|
+
onClick() {
|
|
603
|
+
this.dialogRef?.close();
|
|
604
|
+
}
|
|
605
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
606
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyDialogCloseDirective, isStandalone: true, selector: "[snyDialogClose]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
607
|
+
}
|
|
608
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyDialogCloseDirective, decorators: [{
|
|
609
|
+
type: Directive,
|
|
610
|
+
args: [{
|
|
611
|
+
selector: '[snyDialogClose]',
|
|
612
|
+
standalone: true,
|
|
613
|
+
host: {
|
|
614
|
+
'[class]': 'computedClass()',
|
|
615
|
+
'(click)': 'onClick()',
|
|
616
|
+
},
|
|
617
|
+
}]
|
|
618
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
619
|
+
|
|
620
|
+
const SNY_ACCORDION = new InjectionToken('SnyAccordion');
|
|
621
|
+
const SNY_ACCORDION_ITEM = new InjectionToken('SnyAccordionItem');
|
|
622
|
+
class SnyAccordionDirective {
|
|
623
|
+
multi = input(false, ...(ngDevMode ? [{ debugName: "multi" }] : /* istanbul ignore next */ []));
|
|
624
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
625
|
+
_openItems = signal(new Set(), ...(ngDevMode ? [{ debugName: "_openItems" }] : /* istanbul ignore next */ []));
|
|
626
|
+
computedClass = computed(() => cn('divide-y divide-border', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
627
|
+
isOpen(id) {
|
|
628
|
+
return this._openItems().has(id);
|
|
629
|
+
}
|
|
630
|
+
toggle(id) {
|
|
631
|
+
this._openItems.update(set => {
|
|
632
|
+
const next = new Set(set);
|
|
633
|
+
if (next.has(id)) {
|
|
634
|
+
next.delete(id);
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
if (!this.multi())
|
|
638
|
+
next.clear();
|
|
639
|
+
next.add(id);
|
|
640
|
+
}
|
|
641
|
+
return next;
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
645
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyAccordionDirective, isStandalone: true, selector: "[snyAccordion]", inputs: { multi: { classPropertyName: "multi", publicName: "multi", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, providers: [{ provide: SNY_ACCORDION, useExisting: SnyAccordionDirective }], ngImport: i0 });
|
|
646
|
+
}
|
|
647
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionDirective, decorators: [{
|
|
648
|
+
type: Directive,
|
|
649
|
+
args: [{
|
|
650
|
+
selector: '[snyAccordion]',
|
|
651
|
+
standalone: true,
|
|
652
|
+
providers: [{ provide: SNY_ACCORDION, useExisting: SnyAccordionDirective }],
|
|
653
|
+
host: { '[class]': 'computedClass()' },
|
|
654
|
+
}]
|
|
655
|
+
}], propDecorators: { multi: [{ type: i0.Input, args: [{ isSignal: true, alias: "multi", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
656
|
+
class SnyAccordionItemDirective {
|
|
657
|
+
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
658
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
659
|
+
accordion = inject(SNY_ACCORDION);
|
|
660
|
+
isOpen = computed(() => this.accordion.isOpen(this.value()), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
661
|
+
computedClass = computed(() => cn('', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
662
|
+
toggle() {
|
|
663
|
+
this.accordion.toggle(this.value());
|
|
664
|
+
}
|
|
665
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
666
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyAccordionItemDirective, isStandalone: true, selector: "[snyAccordionItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, providers: [{ provide: SNY_ACCORDION_ITEM, useExisting: SnyAccordionItemDirective }], ngImport: i0 });
|
|
667
|
+
}
|
|
668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionItemDirective, decorators: [{
|
|
669
|
+
type: Directive,
|
|
670
|
+
args: [{
|
|
671
|
+
selector: '[snyAccordionItem]',
|
|
672
|
+
standalone: true,
|
|
673
|
+
providers: [{ provide: SNY_ACCORDION_ITEM, useExisting: SnyAccordionItemDirective }],
|
|
674
|
+
host: { '[class]': 'computedClass()' },
|
|
675
|
+
}]
|
|
676
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
677
|
+
class SnyAccordionTriggerDirective {
|
|
678
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
679
|
+
item = inject(SNY_ACCORDION_ITEM);
|
|
680
|
+
computedClass = computed(() => cn('flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline cursor-pointer [&>svg]:transition-transform', this.item.isOpen() && '[&>svg]:rotate-180', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
681
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
682
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyAccordionTriggerDirective, isStandalone: true, selector: "[snyAccordionTrigger]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "item.toggle()" }, properties: { "class": "computedClass()", "attr.aria-expanded": "item.isOpen()" } }, ngImport: i0 });
|
|
683
|
+
}
|
|
684
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionTriggerDirective, decorators: [{
|
|
685
|
+
type: Directive,
|
|
686
|
+
args: [{
|
|
687
|
+
selector: '[snyAccordionTrigger]',
|
|
688
|
+
standalone: true,
|
|
689
|
+
host: {
|
|
690
|
+
'[class]': 'computedClass()',
|
|
691
|
+
'[attr.aria-expanded]': 'item.isOpen()',
|
|
692
|
+
'(click)': 'item.toggle()',
|
|
693
|
+
},
|
|
694
|
+
}]
|
|
695
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
696
|
+
class SnyAccordionContentDirective {
|
|
697
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
698
|
+
item = inject(SNY_ACCORDION_ITEM);
|
|
699
|
+
computedClass = computed(() => cn('grid transition-all duration-200', this.item.isOpen() ? 'grid-rows-[1fr] opacity-100 pb-4' : 'grid-rows-[0fr] opacity-0 overflow-hidden', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
700
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
701
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyAccordionContentDirective, isStandalone: true, selector: "[snyAccordionContent]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
702
|
+
}
|
|
703
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAccordionContentDirective, decorators: [{
|
|
704
|
+
type: Directive,
|
|
705
|
+
args: [{
|
|
706
|
+
selector: '[snyAccordionContent]',
|
|
707
|
+
standalone: true,
|
|
708
|
+
host: {
|
|
709
|
+
'[class]': 'computedClass()',
|
|
710
|
+
role: 'region',
|
|
711
|
+
},
|
|
712
|
+
}]
|
|
713
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
714
|
+
|
|
715
|
+
const avatarVariants = cva('relative inline-flex shrink-0 items-center justify-center overflow-hidden bg-muted', {
|
|
716
|
+
variants: {
|
|
717
|
+
size: {
|
|
718
|
+
sm: 'h-8 w-8 text-xs',
|
|
719
|
+
md: 'h-10 w-10 text-sm',
|
|
720
|
+
lg: 'h-12 w-12 text-base',
|
|
721
|
+
xl: 'h-16 w-16 text-lg',
|
|
722
|
+
},
|
|
723
|
+
variant: {
|
|
724
|
+
circle: 'rounded-full',
|
|
725
|
+
rounded: 'rounded-md',
|
|
726
|
+
},
|
|
727
|
+
},
|
|
728
|
+
defaultVariants: {
|
|
729
|
+
size: 'md',
|
|
730
|
+
variant: 'circle',
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
class SnyAvatarComponent {
|
|
735
|
+
src = input('', ...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
736
|
+
alt = input('', ...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
|
|
737
|
+
fallback = input('', ...(ngDevMode ? [{ debugName: "fallback" }] : /* istanbul ignore next */ []));
|
|
738
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
739
|
+
variant = input('circle', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
740
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
741
|
+
error = signal(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
742
|
+
fallbackText = computed(() => {
|
|
743
|
+
const fb = this.fallback();
|
|
744
|
+
if (fb)
|
|
745
|
+
return fb;
|
|
746
|
+
const a = this.alt();
|
|
747
|
+
if (a)
|
|
748
|
+
return a.split(' ').map(w => w[0]).join('').toUpperCase().slice(0, 2);
|
|
749
|
+
return '?';
|
|
750
|
+
}, ...(ngDevMode ? [{ debugName: "fallbackText" }] : /* istanbul ignore next */ []));
|
|
751
|
+
computedClass = computed(() => cn(avatarVariants({ size: this.size(), variant: this.variant() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
752
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
753
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SnyAvatarComponent, isStandalone: true, selector: "sny-avatar", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, fallback: { classPropertyName: "fallback", publicName: "fallback", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0, template: `
|
|
754
|
+
@if (src() && !error()) {
|
|
755
|
+
<img
|
|
756
|
+
[src]="src()"
|
|
757
|
+
[alt]="alt()"
|
|
758
|
+
class="aspect-square h-full w-full object-cover"
|
|
759
|
+
(error)="error.set(true)"
|
|
760
|
+
/>
|
|
761
|
+
} @else {
|
|
762
|
+
<span class="font-medium text-muted-foreground">{{ fallbackText() }}</span>
|
|
763
|
+
}
|
|
764
|
+
`, isInline: true });
|
|
765
|
+
}
|
|
766
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyAvatarComponent, decorators: [{
|
|
767
|
+
type: Component,
|
|
768
|
+
args: [{
|
|
769
|
+
selector: 'sny-avatar',
|
|
770
|
+
standalone: true,
|
|
771
|
+
host: { '[class]': 'computedClass()' },
|
|
772
|
+
template: `
|
|
773
|
+
@if (src() && !error()) {
|
|
774
|
+
<img
|
|
775
|
+
[src]="src()"
|
|
776
|
+
[alt]="alt()"
|
|
777
|
+
class="aspect-square h-full w-full object-cover"
|
|
778
|
+
(error)="error.set(true)"
|
|
779
|
+
/>
|
|
780
|
+
} @else {
|
|
781
|
+
<span class="font-medium text-muted-foreground">{{ fallbackText() }}</span>
|
|
782
|
+
}
|
|
783
|
+
`,
|
|
784
|
+
}]
|
|
785
|
+
}], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], alt: [{ type: i0.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], fallback: [{ type: i0.Input, args: [{ isSignal: true, alias: "fallback", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
786
|
+
|
|
787
|
+
const badgeVariants = cva('inline-flex items-center rounded-full border font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', {
|
|
788
|
+
variants: {
|
|
789
|
+
variant: {
|
|
790
|
+
default: 'border-transparent bg-primary text-primary-foreground',
|
|
791
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground',
|
|
792
|
+
outline: 'border-border text-foreground',
|
|
793
|
+
destructive: 'border-transparent bg-destructive text-destructive-foreground',
|
|
794
|
+
success: 'border-transparent bg-green-600 text-white dark:bg-green-500',
|
|
795
|
+
warning: 'border-transparent bg-yellow-500 text-white dark:bg-yellow-400 dark:text-black',
|
|
796
|
+
},
|
|
797
|
+
size: {
|
|
798
|
+
sm: 'px-2 py-0.5 text-[10px]',
|
|
799
|
+
md: 'px-2.5 py-0.5 text-xs',
|
|
800
|
+
lg: 'px-3 py-1 text-sm',
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
defaultVariants: {
|
|
804
|
+
variant: 'default',
|
|
805
|
+
size: 'md',
|
|
806
|
+
},
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
class SnyBadgeDirective {
|
|
810
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
811
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
812
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
813
|
+
computedClass = computed(() => cn(badgeVariants({ variant: this.variant(), size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
814
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBadgeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
815
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBadgeDirective, isStandalone: true, selector: "[snyBadge]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
816
|
+
}
|
|
817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBadgeDirective, decorators: [{
|
|
818
|
+
type: Directive,
|
|
819
|
+
args: [{
|
|
820
|
+
selector: '[snyBadge]',
|
|
821
|
+
standalone: true,
|
|
822
|
+
host: { '[class]': 'computedClass()' },
|
|
823
|
+
}]
|
|
824
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
825
|
+
|
|
826
|
+
class SnyBreadcrumbDirective {
|
|
827
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
828
|
+
computedClass = computed(() => cn('', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
829
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
830
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbDirective, isStandalone: true, selector: "nav[snyBreadcrumb]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-label": "Breadcrumb" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
831
|
+
}
|
|
832
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbDirective, decorators: [{
|
|
833
|
+
type: Directive,
|
|
834
|
+
args: [{
|
|
835
|
+
selector: 'nav[snyBreadcrumb]',
|
|
836
|
+
standalone: true,
|
|
837
|
+
host: {
|
|
838
|
+
'[class]': 'computedClass()',
|
|
839
|
+
'aria-label': 'Breadcrumb',
|
|
840
|
+
},
|
|
841
|
+
}]
|
|
842
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
843
|
+
class SnyBreadcrumbListDirective {
|
|
844
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
845
|
+
computedClass = computed(() => cn('flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
846
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
847
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbListDirective, isStandalone: true, selector: "ol[snyBreadcrumbList]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
848
|
+
}
|
|
849
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbListDirective, decorators: [{
|
|
850
|
+
type: Directive,
|
|
851
|
+
args: [{
|
|
852
|
+
selector: 'ol[snyBreadcrumbList]',
|
|
853
|
+
standalone: true,
|
|
854
|
+
host: { '[class]': 'computedClass()' },
|
|
855
|
+
}]
|
|
856
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
857
|
+
class SnyBreadcrumbItemDirective {
|
|
858
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
859
|
+
computedClass = computed(() => cn('inline-flex items-center gap-1.5', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
860
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
861
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbItemDirective, isStandalone: true, selector: "li[snyBreadcrumbItem]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
862
|
+
}
|
|
863
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbItemDirective, decorators: [{
|
|
864
|
+
type: Directive,
|
|
865
|
+
args: [{
|
|
866
|
+
selector: 'li[snyBreadcrumbItem]',
|
|
867
|
+
standalone: true,
|
|
868
|
+
host: { '[class]': 'computedClass()' },
|
|
869
|
+
}]
|
|
870
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
871
|
+
class SnyBreadcrumbLinkDirective {
|
|
872
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
873
|
+
computedClass = computed(() => cn('transition-colors hover:text-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
874
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbLinkDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
875
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbLinkDirective, isStandalone: true, selector: "[snyBreadcrumbLink]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
876
|
+
}
|
|
877
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbLinkDirective, decorators: [{
|
|
878
|
+
type: Directive,
|
|
879
|
+
args: [{
|
|
880
|
+
selector: '[snyBreadcrumbLink]',
|
|
881
|
+
standalone: true,
|
|
882
|
+
host: { '[class]': 'computedClass()' },
|
|
883
|
+
}]
|
|
884
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
885
|
+
class SnyBreadcrumbSeparatorDirective {
|
|
886
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
887
|
+
computedClass = computed(() => cn('[&>svg]:size-3.5', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
888
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbSeparatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
889
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbSeparatorDirective, isStandalone: true, selector: "[snyBreadcrumbSeparator]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "presentation" }, properties: { "aria-hidden": "true", "class": "computedClass()" } }, ngImport: i0 });
|
|
890
|
+
}
|
|
891
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbSeparatorDirective, decorators: [{
|
|
892
|
+
type: Directive,
|
|
893
|
+
args: [{
|
|
894
|
+
selector: '[snyBreadcrumbSeparator]',
|
|
895
|
+
standalone: true,
|
|
896
|
+
host: {
|
|
897
|
+
role: 'presentation',
|
|
898
|
+
'[aria-hidden]': 'true',
|
|
899
|
+
'[class]': 'computedClass()',
|
|
900
|
+
},
|
|
901
|
+
}]
|
|
902
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
903
|
+
class SnyBreadcrumbPageDirective {
|
|
904
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
905
|
+
computedClass = computed(() => cn('font-normal text-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
906
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbPageDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
907
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyBreadcrumbPageDirective, isStandalone: true, selector: "[snyBreadcrumbPage]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "link", "aria-disabled": "true" }, properties: { "attr.aria-current": "\"page\"", "class": "computedClass()" } }, ngImport: i0 });
|
|
908
|
+
}
|
|
909
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyBreadcrumbPageDirective, decorators: [{
|
|
910
|
+
type: Directive,
|
|
911
|
+
args: [{
|
|
912
|
+
selector: '[snyBreadcrumbPage]',
|
|
913
|
+
standalone: true,
|
|
914
|
+
host: {
|
|
915
|
+
role: 'link',
|
|
916
|
+
'aria-disabled': 'true',
|
|
917
|
+
'[attr.aria-current]': '"page"',
|
|
918
|
+
'[class]': 'computedClass()',
|
|
919
|
+
},
|
|
920
|
+
}]
|
|
921
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
922
|
+
|
|
923
|
+
const buttonGroupVariants = cva('inline-flex [&>*:not(:first-child):not(:last-child)]:rounded-none [&>*:first-child:not(:last-child)]:rounded-r-none [&>*:last-child:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:-ml-px', {
|
|
924
|
+
variants: {
|
|
925
|
+
orientation: {
|
|
926
|
+
horizontal: 'flex-row',
|
|
927
|
+
vertical: 'flex-col [&>*:not(:first-child):not(:last-child)]:rounded-none [&>*:first-child:not(:last-child)]:rounded-b-none [&>*:first-child:not(:last-child)]:rounded-r-sm [&>*:last-child:not(:first-child)]:rounded-t-none [&>*:last-child:not(:first-child)]:rounded-l-sm [&>*:not(:first-child)]:-mt-px [&>*:not(:first-child)]:ml-0',
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
defaultVariants: {
|
|
931
|
+
orientation: 'horizontal',
|
|
932
|
+
},
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
class SnyButtonGroupDirective {
|
|
936
|
+
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
937
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
938
|
+
computedClass = computed(() => cn(buttonGroupVariants({ orientation: this.orientation() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
939
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyButtonGroupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
940
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyButtonGroupDirective, isStandalone: true, selector: "[snyButtonGroup]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
941
|
+
}
|
|
942
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyButtonGroupDirective, decorators: [{
|
|
943
|
+
type: Directive,
|
|
944
|
+
args: [{
|
|
945
|
+
selector: '[snyButtonGroup]',
|
|
946
|
+
standalone: true,
|
|
947
|
+
host: {
|
|
948
|
+
role: 'group',
|
|
949
|
+
'[class]': 'computedClass()',
|
|
950
|
+
},
|
|
951
|
+
}]
|
|
952
|
+
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
953
|
+
|
|
954
|
+
const checkboxVariants = cva('peer appearance-none shrink-0 rounded-sm border border-border bg-background transition-colors checked:bg-primary checked:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
|
|
955
|
+
variants: {
|
|
956
|
+
size: {
|
|
957
|
+
sm: 'h-3.5 w-3.5',
|
|
958
|
+
md: 'h-4 w-4',
|
|
959
|
+
lg: 'h-5 w-5',
|
|
960
|
+
},
|
|
961
|
+
},
|
|
962
|
+
defaultVariants: {
|
|
963
|
+
size: 'md',
|
|
964
|
+
},
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
class SnyCheckboxDirective {
|
|
968
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
969
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
970
|
+
computedClass = computed(() => cn(checkboxVariants({ size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
971
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCheckboxDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
972
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyCheckboxDirective, isStandalone: true, selector: "input[type=\"checkbox\"][snyCheckbox]", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
973
|
+
}
|
|
974
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyCheckboxDirective, decorators: [{
|
|
975
|
+
type: Directive,
|
|
976
|
+
args: [{
|
|
977
|
+
selector: 'input[type="checkbox"][snyCheckbox]',
|
|
978
|
+
standalone: true,
|
|
979
|
+
host: { '[class]': 'computedClass()' },
|
|
980
|
+
}]
|
|
981
|
+
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
982
|
+
|
|
983
|
+
const comboboxTriggerVariants = cva('inline-flex w-full items-center justify-between whitespace-nowrap rounded-sm border border-border bg-background px-3 py-2 text-sm ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
|
|
984
|
+
variants: {
|
|
985
|
+
size: {
|
|
986
|
+
sm: 'h-9 text-xs',
|
|
987
|
+
md: 'h-10 text-sm',
|
|
988
|
+
lg: 'h-11 text-base',
|
|
989
|
+
},
|
|
990
|
+
},
|
|
991
|
+
defaultVariants: {
|
|
992
|
+
size: 'md',
|
|
993
|
+
},
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
class SnyComboboxComponent {
|
|
997
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
998
|
+
placeholder = input('Select...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
999
|
+
searchPlaceholder = input('Search...', ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
|
|
1000
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1001
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1002
|
+
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1003
|
+
open = signal(false, ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
1004
|
+
query = signal('', ...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
1005
|
+
activeIndex = signal(0, ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
1006
|
+
triggerRef = viewChild('triggerEl', ...(ngDevMode ? [{ debugName: "triggerRef" }] : /* istanbul ignore next */ []));
|
|
1007
|
+
searchRef = viewChild('searchEl', ...(ngDevMode ? [{ debugName: "searchRef" }] : /* istanbul ignore next */ []));
|
|
1008
|
+
dropdownRef = viewChild('dropdownEl', ...(ngDevMode ? [{ debugName: "dropdownRef" }] : /* istanbul ignore next */ []));
|
|
1009
|
+
elRef = inject(ElementRef);
|
|
1010
|
+
scrollHandler = null;
|
|
1011
|
+
resizeHandler = null;
|
|
1012
|
+
selectedLabel = computed(() => {
|
|
1013
|
+
const v = this.value();
|
|
1014
|
+
if (!v)
|
|
1015
|
+
return '';
|
|
1016
|
+
const opt = this.options().find(o => o.value === v);
|
|
1017
|
+
return opt?.label ?? '';
|
|
1018
|
+
}, ...(ngDevMode ? [{ debugName: "selectedLabel" }] : /* istanbul ignore next */ []));
|
|
1019
|
+
filtered = computed(() => {
|
|
1020
|
+
const q = this.query().toLowerCase();
|
|
1021
|
+
if (!q)
|
|
1022
|
+
return this.options();
|
|
1023
|
+
return this.options().filter(o => o.label.toLowerCase().includes(q));
|
|
1024
|
+
}, ...(ngDevMode ? [{ debugName: "filtered" }] : /* istanbul ignore next */ []));
|
|
1025
|
+
triggerClass = computed(() => cn(comboboxTriggerVariants({ size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "triggerClass" }] : /* istanbul ignore next */ []));
|
|
1026
|
+
optionClass(index) {
|
|
1027
|
+
const base = 'relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors';
|
|
1028
|
+
const active = index === this.activeIndex() ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50';
|
|
1029
|
+
return cn(base, active);
|
|
1030
|
+
}
|
|
1031
|
+
updateDropdownPosition() {
|
|
1032
|
+
const trigger = this.triggerRef()?.nativeElement;
|
|
1033
|
+
if (!trigger)
|
|
1034
|
+
return;
|
|
1035
|
+
const rect = trigger.getBoundingClientRect();
|
|
1036
|
+
const dropdown = this.dropdownRef()?.nativeElement;
|
|
1037
|
+
if (dropdown) {
|
|
1038
|
+
dropdown.style.top = `${rect.bottom + 4}px`;
|
|
1039
|
+
dropdown.style.left = `${rect.left}px`;
|
|
1040
|
+
dropdown.style.width = `${rect.width}px`;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
addGlobalListeners() {
|
|
1044
|
+
this.removeGlobalListeners();
|
|
1045
|
+
this.scrollHandler = () => {
|
|
1046
|
+
requestAnimationFrame(() => this.updateDropdownPosition());
|
|
1047
|
+
};
|
|
1048
|
+
this.resizeHandler = () => {
|
|
1049
|
+
requestAnimationFrame(() => this.updateDropdownPosition());
|
|
1050
|
+
};
|
|
1051
|
+
document.addEventListener('scroll', this.scrollHandler, { capture: true, passive: true });
|
|
1052
|
+
window.addEventListener('resize', this.resizeHandler, { passive: true });
|
|
1053
|
+
}
|
|
1054
|
+
removeGlobalListeners() {
|
|
1055
|
+
if (this.scrollHandler) {
|
|
1056
|
+
document.removeEventListener('scroll', this.scrollHandler, { capture: true });
|
|
1057
|
+
this.scrollHandler = null;
|
|
1058
|
+
}
|
|
1059
|
+
if (this.resizeHandler) {
|
|
1060
|
+
window.removeEventListener('resize', this.resizeHandler);
|
|
1061
|
+
this.resizeHandler = null;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
ngOnDestroy() {
|
|
1065
|
+
this.removeGlobalListeners();
|
|
1066
|
+
}
|
|
1067
|
+
toggle() {
|
|
1068
|
+
if (this.open()) {
|
|
1069
|
+
this.close();
|
|
1070
|
+
}
|
|
1071
|
+
else {
|
|
1072
|
+
this.updateDropdownPosition();
|
|
1073
|
+
this.open.set(true);
|
|
1074
|
+
this.query.set('');
|
|
1075
|
+
this.activeIndex.set(0);
|
|
1076
|
+
this.addGlobalListeners();
|
|
1077
|
+
setTimeout(() => {
|
|
1078
|
+
this.updateDropdownPosition();
|
|
1079
|
+
this.searchRef()?.nativeElement.focus();
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
close() {
|
|
1084
|
+
this.open.set(false);
|
|
1085
|
+
this.query.set('');
|
|
1086
|
+
this.removeGlobalListeners();
|
|
1087
|
+
}
|
|
1088
|
+
onSearchInput(event) {
|
|
1089
|
+
const val = event.target.value;
|
|
1090
|
+
this.query.set(val);
|
|
1091
|
+
this.activeIndex.set(0);
|
|
1092
|
+
}
|
|
1093
|
+
select(opt) {
|
|
1094
|
+
this.value.set(opt.value);
|
|
1095
|
+
this.close();
|
|
1096
|
+
}
|
|
1097
|
+
onKeydown(event) {
|
|
1098
|
+
const items = this.filtered();
|
|
1099
|
+
switch (event.key) {
|
|
1100
|
+
case 'ArrowDown':
|
|
1101
|
+
event.preventDefault();
|
|
1102
|
+
this.activeIndex.update(i => Math.min(i + 1, items.length - 1));
|
|
1103
|
+
break;
|
|
1104
|
+
case 'ArrowUp':
|
|
1105
|
+
event.preventDefault();
|
|
1106
|
+
this.activeIndex.update(i => Math.max(i - 1, 0));
|
|
1107
|
+
break;
|
|
1108
|
+
case 'Enter':
|
|
1109
|
+
event.preventDefault();
|
|
1110
|
+
if (items[this.activeIndex()]) {
|
|
1111
|
+
this.select(items[this.activeIndex()]);
|
|
1112
|
+
}
|
|
1113
|
+
break;
|
|
1114
|
+
case 'Escape':
|
|
1115
|
+
this.close();
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
onDocumentClick(event) {
|
|
1120
|
+
if (!this.elRef.nativeElement.contains(event.target)) {
|
|
1121
|
+
this.close();
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyComboboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1125
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SnyComboboxComponent, isStandalone: true, selector: "sny-combobox", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "document:click": "onDocumentClick($event)" }, classAttribute: "relative inline-block w-full" }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["triggerEl"], descendants: true, isSignal: true }, { propertyName: "searchRef", first: true, predicate: ["searchEl"], descendants: true, isSignal: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdownEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1126
|
+
<!-- Trigger button -->
|
|
1127
|
+
<button
|
|
1128
|
+
#triggerEl
|
|
1129
|
+
type="button"
|
|
1130
|
+
role="combobox"
|
|
1131
|
+
[attr.aria-expanded]="open()"
|
|
1132
|
+
aria-haspopup="listbox"
|
|
1133
|
+
[class]="triggerClass()"
|
|
1134
|
+
(click)="toggle()"
|
|
1135
|
+
>
|
|
1136
|
+
<span [class]="selectedLabel() ? '' : 'text-muted-foreground'">
|
|
1137
|
+
{{ selectedLabel() || placeholder() }}
|
|
1138
|
+
</span>
|
|
1139
|
+
<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="shrink-0 opacity-50"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>
|
|
1140
|
+
</button>
|
|
1141
|
+
|
|
1142
|
+
<!-- Dropdown popover -->
|
|
1143
|
+
@if (open()) {
|
|
1144
|
+
<div
|
|
1145
|
+
#dropdownEl
|
|
1146
|
+
class="fixed z-50 rounded-sm border border-border bg-popover text-popover-foreground shadow-md"
|
|
1147
|
+
>
|
|
1148
|
+
<!-- Search input -->
|
|
1149
|
+
<div class="flex items-center border-b border-border px-3">
|
|
1150
|
+
<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="mr-2 shrink-0 opacity-50"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
|
1151
|
+
<input
|
|
1152
|
+
#searchEl
|
|
1153
|
+
type="text"
|
|
1154
|
+
class="flex h-10 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground"
|
|
1155
|
+
[placeholder]="searchPlaceholder()"
|
|
1156
|
+
[value]="query()"
|
|
1157
|
+
(input)="onSearchInput($event)"
|
|
1158
|
+
(keydown)="onKeydown($event)"
|
|
1159
|
+
/>
|
|
1160
|
+
</div>
|
|
1161
|
+
|
|
1162
|
+
<!-- Options list -->
|
|
1163
|
+
@if (filtered().length > 0) {
|
|
1164
|
+
<ul role="listbox" class="max-h-60 overflow-auto p-1">
|
|
1165
|
+
@for (opt of filtered(); track opt.value; let i = $index) {
|
|
1166
|
+
<li
|
|
1167
|
+
role="option"
|
|
1168
|
+
[id]="'sny-cb-opt-' + opt.value"
|
|
1169
|
+
[attr.aria-selected]="value() === opt.value"
|
|
1170
|
+
[class]="optionClass(i)"
|
|
1171
|
+
(mousedown)="select(opt); $event.preventDefault()"
|
|
1172
|
+
(mouseenter)="activeIndex.set(i)"
|
|
1173
|
+
>
|
|
1174
|
+
<svg
|
|
1175
|
+
xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
|
|
1176
|
+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
1177
|
+
[class]="value() === opt.value ? 'mr-2 shrink-0 opacity-100' : 'mr-2 shrink-0 opacity-0'"
|
|
1178
|
+
><path d="M20 6 9 17l-5-5"/></svg>
|
|
1179
|
+
{{ opt.label }}
|
|
1180
|
+
</li>
|
|
1181
|
+
}
|
|
1182
|
+
</ul>
|
|
1183
|
+
} @else {
|
|
1184
|
+
<div class="py-6 text-center text-sm text-muted-foreground">No results found.</div>
|
|
1185
|
+
}
|
|
1186
|
+
</div>
|
|
1187
|
+
}
|
|
1188
|
+
`, isInline: true });
|
|
1189
|
+
}
|
|
1190
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyComboboxComponent, decorators: [{
|
|
1191
|
+
type: Component,
|
|
1192
|
+
args: [{
|
|
1193
|
+
selector: 'sny-combobox',
|
|
1194
|
+
standalone: true,
|
|
1195
|
+
host: {
|
|
1196
|
+
class: 'relative inline-block w-full',
|
|
1197
|
+
},
|
|
1198
|
+
template: `
|
|
1199
|
+
<!-- Trigger button -->
|
|
1200
|
+
<button
|
|
1201
|
+
#triggerEl
|
|
1202
|
+
type="button"
|
|
1203
|
+
role="combobox"
|
|
1204
|
+
[attr.aria-expanded]="open()"
|
|
1205
|
+
aria-haspopup="listbox"
|
|
1206
|
+
[class]="triggerClass()"
|
|
1207
|
+
(click)="toggle()"
|
|
1208
|
+
>
|
|
1209
|
+
<span [class]="selectedLabel() ? '' : 'text-muted-foreground'">
|
|
1210
|
+
{{ selectedLabel() || placeholder() }}
|
|
1211
|
+
</span>
|
|
1212
|
+
<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="shrink-0 opacity-50"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>
|
|
1213
|
+
</button>
|
|
1214
|
+
|
|
1215
|
+
<!-- Dropdown popover -->
|
|
1216
|
+
@if (open()) {
|
|
1217
|
+
<div
|
|
1218
|
+
#dropdownEl
|
|
1219
|
+
class="fixed z-50 rounded-sm border border-border bg-popover text-popover-foreground shadow-md"
|
|
1220
|
+
>
|
|
1221
|
+
<!-- Search input -->
|
|
1222
|
+
<div class="flex items-center border-b border-border px-3">
|
|
1223
|
+
<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="mr-2 shrink-0 opacity-50"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
|
1224
|
+
<input
|
|
1225
|
+
#searchEl
|
|
1226
|
+
type="text"
|
|
1227
|
+
class="flex h-10 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground"
|
|
1228
|
+
[placeholder]="searchPlaceholder()"
|
|
1229
|
+
[value]="query()"
|
|
1230
|
+
(input)="onSearchInput($event)"
|
|
1231
|
+
(keydown)="onKeydown($event)"
|
|
1232
|
+
/>
|
|
1233
|
+
</div>
|
|
1234
|
+
|
|
1235
|
+
<!-- Options list -->
|
|
1236
|
+
@if (filtered().length > 0) {
|
|
1237
|
+
<ul role="listbox" class="max-h-60 overflow-auto p-1">
|
|
1238
|
+
@for (opt of filtered(); track opt.value; let i = $index) {
|
|
1239
|
+
<li
|
|
1240
|
+
role="option"
|
|
1241
|
+
[id]="'sny-cb-opt-' + opt.value"
|
|
1242
|
+
[attr.aria-selected]="value() === opt.value"
|
|
1243
|
+
[class]="optionClass(i)"
|
|
1244
|
+
(mousedown)="select(opt); $event.preventDefault()"
|
|
1245
|
+
(mouseenter)="activeIndex.set(i)"
|
|
1246
|
+
>
|
|
1247
|
+
<svg
|
|
1248
|
+
xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
|
|
1249
|
+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
1250
|
+
[class]="value() === opt.value ? 'mr-2 shrink-0 opacity-100' : 'mr-2 shrink-0 opacity-0'"
|
|
1251
|
+
><path d="M20 6 9 17l-5-5"/></svg>
|
|
1252
|
+
{{ opt.label }}
|
|
1253
|
+
</li>
|
|
1254
|
+
}
|
|
1255
|
+
</ul>
|
|
1256
|
+
} @else {
|
|
1257
|
+
<div class="py-6 text-center text-sm text-muted-foreground">No results found.</div>
|
|
1258
|
+
}
|
|
1259
|
+
</div>
|
|
1260
|
+
}
|
|
1261
|
+
`,
|
|
1262
|
+
}]
|
|
1263
|
+
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], triggerRef: [{ type: i0.ViewChild, args: ['triggerEl', { isSignal: true }] }], searchRef: [{ type: i0.ViewChild, args: ['searchEl', { isSignal: true }] }], dropdownRef: [{ type: i0.ViewChild, args: ['dropdownEl', { isSignal: true }] }], onDocumentClick: [{
|
|
1264
|
+
type: HostListener,
|
|
1265
|
+
args: ['document:click', ['$event']]
|
|
1266
|
+
}] } });
|
|
1267
|
+
|
|
1268
|
+
const skeletonVariants = cva('animate-pulse bg-muted block', {
|
|
1269
|
+
variants: {
|
|
1270
|
+
variant: {
|
|
1271
|
+
line: 'rounded-sm',
|
|
1272
|
+
circular: 'rounded-full aspect-square',
|
|
1273
|
+
rounded: 'rounded-lg',
|
|
1274
|
+
},
|
|
1275
|
+
size: {
|
|
1276
|
+
sm: 'h-4',
|
|
1277
|
+
md: 'h-6',
|
|
1278
|
+
lg: 'h-8',
|
|
1279
|
+
xl: 'h-12',
|
|
1280
|
+
},
|
|
1281
|
+
},
|
|
1282
|
+
defaultVariants: {
|
|
1283
|
+
variant: 'line',
|
|
1284
|
+
size: 'md',
|
|
1285
|
+
},
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
class SnySkeletonDirective {
|
|
1289
|
+
variant = input('line', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
1290
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1291
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1292
|
+
computedClass = computed(() => cn(skeletonVariants({ variant: this.variant(), size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1293
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySkeletonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1294
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySkeletonDirective, isStandalone: true, selector: "[snySkeleton]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
1295
|
+
}
|
|
1296
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySkeletonDirective, decorators: [{
|
|
1297
|
+
type: Directive,
|
|
1298
|
+
args: [{
|
|
1299
|
+
selector: '[snySkeleton]',
|
|
1300
|
+
standalone: true,
|
|
1301
|
+
host: { '[class]': 'computedClass()' },
|
|
1302
|
+
}]
|
|
1303
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1304
|
+
|
|
1305
|
+
const radioVariants = cva('appearance-none rounded-full border border-border bg-background transition-colors checked:border-primary checked:shadow-[inset_0_0_0_3px] checked:shadow-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
|
|
1306
|
+
variants: {
|
|
1307
|
+
size: {
|
|
1308
|
+
sm: 'h-3.5 w-3.5',
|
|
1309
|
+
md: 'h-4 w-4',
|
|
1310
|
+
lg: 'h-5 w-5',
|
|
1311
|
+
},
|
|
1312
|
+
},
|
|
1313
|
+
defaultVariants: {
|
|
1314
|
+
size: 'md',
|
|
1315
|
+
},
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
class SnyRadioDirective {
|
|
1319
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1320
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1321
|
+
computedClass = computed(() => cn(radioVariants({ size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1322
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyRadioDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1323
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyRadioDirective, isStandalone: true, selector: "input[type=\"radio\"][snyRadio]", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
1324
|
+
}
|
|
1325
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyRadioDirective, decorators: [{
|
|
1326
|
+
type: Directive,
|
|
1327
|
+
args: [{
|
|
1328
|
+
selector: 'input[type="radio"][snyRadio]',
|
|
1329
|
+
standalone: true,
|
|
1330
|
+
host: { '[class]': 'computedClass()' },
|
|
1331
|
+
}]
|
|
1332
|
+
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1333
|
+
|
|
1334
|
+
const switchTrackVariants = cva('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
|
|
1335
|
+
variants: {
|
|
1336
|
+
size: {
|
|
1337
|
+
sm: 'h-5 w-9',
|
|
1338
|
+
md: 'h-6 w-11',
|
|
1339
|
+
lg: 'h-7 w-14',
|
|
1340
|
+
},
|
|
1341
|
+
},
|
|
1342
|
+
defaultVariants: {
|
|
1343
|
+
size: 'md',
|
|
1344
|
+
},
|
|
1345
|
+
});
|
|
1346
|
+
const switchThumbSize = {
|
|
1347
|
+
sm: 'h-4 w-4',
|
|
1348
|
+
md: 'h-5 w-5',
|
|
1349
|
+
lg: 'h-6 w-6',
|
|
1350
|
+
};
|
|
1351
|
+
const switchThumbTranslate = {
|
|
1352
|
+
sm: 'translate-x-4',
|
|
1353
|
+
md: 'translate-x-5',
|
|
1354
|
+
lg: 'translate-x-7',
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
class SnySwitchComponent {
|
|
1358
|
+
checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
1359
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1360
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1361
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1362
|
+
trackClass = computed(() => cn(switchTrackVariants({ size: this.size() }), this.checked() ? 'bg-primary' : 'bg-input', this.class()), ...(ngDevMode ? [{ debugName: "trackClass" }] : /* istanbul ignore next */ []));
|
|
1363
|
+
thumbClass = computed(() => cn('pointer-events-none block rounded-full bg-background shadow-lg ring-0 transition-transform', switchThumbSize[this.size()], this.checked() ? switchThumbTranslate[this.size()] : 'translate-x-0'), ...(ngDevMode ? [{ debugName: "thumbClass" }] : /* istanbul ignore next */ []));
|
|
1364
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1365
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.5", type: SnySwitchComponent, isStandalone: true, selector: "sny-switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { classAttribute: "inline-flex" }, ngImport: i0, template: `
|
|
1366
|
+
<button
|
|
1367
|
+
type="button"
|
|
1368
|
+
role="switch"
|
|
1369
|
+
[attr.aria-checked]="checked()"
|
|
1370
|
+
[disabled]="disabled()"
|
|
1371
|
+
[class]="trackClass()"
|
|
1372
|
+
(click)="checked.set(!checked())"
|
|
1373
|
+
>
|
|
1374
|
+
<span [class]="thumbClass()"></span>
|
|
1375
|
+
</button>
|
|
1376
|
+
`, isInline: true });
|
|
1377
|
+
}
|
|
1378
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySwitchComponent, decorators: [{
|
|
1379
|
+
type: Component,
|
|
1380
|
+
args: [{
|
|
1381
|
+
selector: 'sny-switch',
|
|
1382
|
+
standalone: true,
|
|
1383
|
+
host: { class: 'inline-flex' },
|
|
1384
|
+
template: `
|
|
1385
|
+
<button
|
|
1386
|
+
type="button"
|
|
1387
|
+
role="switch"
|
|
1388
|
+
[attr.aria-checked]="checked()"
|
|
1389
|
+
[disabled]="disabled()"
|
|
1390
|
+
[class]="trackClass()"
|
|
1391
|
+
(click)="checked.set(!checked())"
|
|
1392
|
+
>
|
|
1393
|
+
<span [class]="thumbClass()"></span>
|
|
1394
|
+
</button>
|
|
1395
|
+
`,
|
|
1396
|
+
}]
|
|
1397
|
+
}], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1398
|
+
|
|
1399
|
+
const toggleVariants = cva('inline-flex items-center justify-center rounded-sm text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
|
|
1400
|
+
variants: {
|
|
1401
|
+
variant: {
|
|
1402
|
+
default: 'bg-transparent hover:bg-muted hover:text-muted-foreground',
|
|
1403
|
+
outline: 'border border-border bg-transparent hover:bg-accent hover:text-accent-foreground',
|
|
1404
|
+
},
|
|
1405
|
+
size: {
|
|
1406
|
+
sm: 'h-9 px-2.5',
|
|
1407
|
+
md: 'h-10 px-3',
|
|
1408
|
+
lg: 'h-11 px-5',
|
|
1409
|
+
},
|
|
1410
|
+
},
|
|
1411
|
+
defaultVariants: {
|
|
1412
|
+
variant: 'default',
|
|
1413
|
+
size: 'md',
|
|
1414
|
+
},
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
class SnyToggleDirective {
|
|
1418
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
1419
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1420
|
+
pressed = model(false, ...(ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []));
|
|
1421
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1422
|
+
computedClass = computed(() => cn(toggleVariants({ variant: this.variant(), size: this.size() }), this.pressed() ? 'bg-accent text-accent-foreground' : '', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1423
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToggleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1424
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyToggleDirective, isStandalone: true, selector: "button[snyToggle]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pressed: "pressedChange" }, host: { listeners: { "click": "pressed.set(!pressed())" }, properties: { "class": "computedClass()", "attr.aria-pressed": "pressed()" } }, ngImport: i0 });
|
|
1425
|
+
}
|
|
1426
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyToggleDirective, decorators: [{
|
|
1427
|
+
type: Directive,
|
|
1428
|
+
args: [{
|
|
1429
|
+
selector: 'button[snyToggle]',
|
|
1430
|
+
standalone: true,
|
|
1431
|
+
host: {
|
|
1432
|
+
'[class]': 'computedClass()',
|
|
1433
|
+
'[attr.aria-pressed]': 'pressed()',
|
|
1434
|
+
'(click)': 'pressed.set(!pressed())',
|
|
1435
|
+
},
|
|
1436
|
+
}]
|
|
1437
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressed", required: false }] }, { type: i0.Output, args: ["pressedChange"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1438
|
+
|
|
1439
|
+
const sliderTrackVariants = cva('relative w-full rounded-full bg-secondary cursor-pointer', {
|
|
1440
|
+
variants: {
|
|
1441
|
+
size: {
|
|
1442
|
+
sm: 'h-1.5',
|
|
1443
|
+
md: 'h-2',
|
|
1444
|
+
lg: 'h-3',
|
|
1445
|
+
},
|
|
1446
|
+
},
|
|
1447
|
+
defaultVariants: {
|
|
1448
|
+
size: 'md',
|
|
1449
|
+
},
|
|
1450
|
+
});
|
|
1451
|
+
const sliderThumbSize = {
|
|
1452
|
+
sm: 'h-4 w-4',
|
|
1453
|
+
md: 'h-5 w-5',
|
|
1454
|
+
lg: 'h-6 w-6',
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
class SnySliderComponent {
|
|
1458
|
+
value = model(0, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1459
|
+
min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
1460
|
+
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
1461
|
+
step = input(1, ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
1462
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1463
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1464
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1465
|
+
trackRef = viewChild('trackEl', ...(ngDevMode ? [{ debugName: "trackRef" }] : /* istanbul ignore next */ []));
|
|
1466
|
+
moveHandler = null;
|
|
1467
|
+
upHandler = null;
|
|
1468
|
+
percentage = computed(() => {
|
|
1469
|
+
const range = this.max() - this.min();
|
|
1470
|
+
if (range <= 0)
|
|
1471
|
+
return 0;
|
|
1472
|
+
return ((this.value() - this.min()) / range) * 100;
|
|
1473
|
+
}, ...(ngDevMode ? [{ debugName: "percentage" }] : /* istanbul ignore next */ []));
|
|
1474
|
+
trackClass = computed(() => cn(sliderTrackVariants({ size: this.size() }), this.disabled() && 'opacity-50 cursor-not-allowed', this.class()), ...(ngDevMode ? [{ debugName: "trackClass" }] : /* istanbul ignore next */ []));
|
|
1475
|
+
thumbClass = computed(() => cn('absolute top-1/2 -translate-x-1/2 -translate-y-1/2 block rounded-full border-2 border-primary bg-background shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', sliderThumbSize[this.size()]), ...(ngDevMode ? [{ debugName: "thumbClass" }] : /* istanbul ignore next */ []));
|
|
1476
|
+
updateValueFromPosition(clientX) {
|
|
1477
|
+
if (this.disabled())
|
|
1478
|
+
return;
|
|
1479
|
+
const track = this.trackRef()?.nativeElement;
|
|
1480
|
+
if (!track)
|
|
1481
|
+
return;
|
|
1482
|
+
const rect = track.getBoundingClientRect();
|
|
1483
|
+
const percent = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
1484
|
+
const raw = this.min() + percent * (this.max() - this.min());
|
|
1485
|
+
const stepped = Math.round(raw / this.step()) * this.step();
|
|
1486
|
+
this.value.set(Math.max(this.min(), Math.min(this.max(), stepped)));
|
|
1487
|
+
}
|
|
1488
|
+
onTrackMousedown(event) {
|
|
1489
|
+
if (this.disabled())
|
|
1490
|
+
return;
|
|
1491
|
+
event.preventDefault();
|
|
1492
|
+
this.updateValueFromPosition(event.clientX);
|
|
1493
|
+
this.moveHandler = (e) => {
|
|
1494
|
+
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1495
|
+
this.updateValueFromPosition(clientX);
|
|
1496
|
+
};
|
|
1497
|
+
this.upHandler = () => this.removeListeners();
|
|
1498
|
+
document.addEventListener('mousemove', this.moveHandler);
|
|
1499
|
+
document.addEventListener('mouseup', this.upHandler);
|
|
1500
|
+
}
|
|
1501
|
+
onTrackTouchstart(event) {
|
|
1502
|
+
if (this.disabled())
|
|
1503
|
+
return;
|
|
1504
|
+
this.updateValueFromPosition(event.touches[0].clientX);
|
|
1505
|
+
this.moveHandler = (e) => {
|
|
1506
|
+
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1507
|
+
this.updateValueFromPosition(clientX);
|
|
1508
|
+
};
|
|
1509
|
+
this.upHandler = () => this.removeListeners();
|
|
1510
|
+
document.addEventListener('touchmove', this.moveHandler, { passive: true });
|
|
1511
|
+
document.addEventListener('touchend', this.upHandler);
|
|
1512
|
+
}
|
|
1513
|
+
onKeydown(event) {
|
|
1514
|
+
if (this.disabled())
|
|
1515
|
+
return;
|
|
1516
|
+
const step = this.step();
|
|
1517
|
+
switch (event.key) {
|
|
1518
|
+
case 'ArrowRight':
|
|
1519
|
+
case 'ArrowUp':
|
|
1520
|
+
event.preventDefault();
|
|
1521
|
+
this.value.set(Math.min(this.max(), this.value() + step));
|
|
1522
|
+
break;
|
|
1523
|
+
case 'ArrowLeft':
|
|
1524
|
+
case 'ArrowDown':
|
|
1525
|
+
event.preventDefault();
|
|
1526
|
+
this.value.set(Math.max(this.min(), this.value() - step));
|
|
1527
|
+
break;
|
|
1528
|
+
case 'Home':
|
|
1529
|
+
event.preventDefault();
|
|
1530
|
+
this.value.set(this.min());
|
|
1531
|
+
break;
|
|
1532
|
+
case 'End':
|
|
1533
|
+
event.preventDefault();
|
|
1534
|
+
this.value.set(this.max());
|
|
1535
|
+
break;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
removeListeners() {
|
|
1539
|
+
if (this.moveHandler) {
|
|
1540
|
+
document.removeEventListener('mousemove', this.moveHandler);
|
|
1541
|
+
document.removeEventListener('touchmove', this.moveHandler);
|
|
1542
|
+
this.moveHandler = null;
|
|
1543
|
+
}
|
|
1544
|
+
if (this.upHandler) {
|
|
1545
|
+
document.removeEventListener('mouseup', this.upHandler);
|
|
1546
|
+
document.removeEventListener('touchend', this.upHandler);
|
|
1547
|
+
this.upHandler = null;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
ngOnDestroy() {
|
|
1551
|
+
this.removeListeners();
|
|
1552
|
+
}
|
|
1553
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySliderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1554
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.5", type: SnySliderComponent, isStandalone: true, selector: "sny-slider", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "keydown": "onKeydown($event)" }, classAttribute: "block" }, viewQueries: [{ propertyName: "trackRef", first: true, predicate: ["trackEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1555
|
+
<div
|
|
1556
|
+
#trackEl
|
|
1557
|
+
[class]="trackClass()"
|
|
1558
|
+
(mousedown)="onTrackMousedown($event)"
|
|
1559
|
+
(touchstart)="onTrackTouchstart($event)"
|
|
1560
|
+
>
|
|
1561
|
+
<div class="absolute h-full rounded-full bg-primary" [style.width.%]="percentage()"></div>
|
|
1562
|
+
<button
|
|
1563
|
+
type="button"
|
|
1564
|
+
role="slider"
|
|
1565
|
+
[attr.aria-valuemin]="min()"
|
|
1566
|
+
[attr.aria-valuemax]="max()"
|
|
1567
|
+
[attr.aria-valuenow]="value()"
|
|
1568
|
+
[disabled]="disabled()"
|
|
1569
|
+
[class]="thumbClass()"
|
|
1570
|
+
[style.left.%]="percentage()"
|
|
1571
|
+
tabindex="0"
|
|
1572
|
+
></button>
|
|
1573
|
+
</div>
|
|
1574
|
+
`, isInline: true });
|
|
1575
|
+
}
|
|
1576
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySliderComponent, decorators: [{
|
|
1577
|
+
type: Component,
|
|
1578
|
+
args: [{
|
|
1579
|
+
selector: 'sny-slider',
|
|
1580
|
+
standalone: true,
|
|
1581
|
+
host: {
|
|
1582
|
+
class: 'block',
|
|
1583
|
+
'(keydown)': 'onKeydown($event)',
|
|
1584
|
+
},
|
|
1585
|
+
template: `
|
|
1586
|
+
<div
|
|
1587
|
+
#trackEl
|
|
1588
|
+
[class]="trackClass()"
|
|
1589
|
+
(mousedown)="onTrackMousedown($event)"
|
|
1590
|
+
(touchstart)="onTrackTouchstart($event)"
|
|
1591
|
+
>
|
|
1592
|
+
<div class="absolute h-full rounded-full bg-primary" [style.width.%]="percentage()"></div>
|
|
1593
|
+
<button
|
|
1594
|
+
type="button"
|
|
1595
|
+
role="slider"
|
|
1596
|
+
[attr.aria-valuemin]="min()"
|
|
1597
|
+
[attr.aria-valuemax]="max()"
|
|
1598
|
+
[attr.aria-valuenow]="value()"
|
|
1599
|
+
[disabled]="disabled()"
|
|
1600
|
+
[class]="thumbClass()"
|
|
1601
|
+
[style.left.%]="percentage()"
|
|
1602
|
+
tabindex="0"
|
|
1603
|
+
></button>
|
|
1604
|
+
</div>
|
|
1605
|
+
`,
|
|
1606
|
+
}]
|
|
1607
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], trackRef: [{ type: i0.ViewChild, args: ['trackEl', { isSignal: true }] }] } });
|
|
1608
|
+
|
|
1609
|
+
const loaderVariants = cva('inline-flex items-center justify-center text-current', {
|
|
1610
|
+
variants: {
|
|
1611
|
+
size: {
|
|
1612
|
+
sm: 'h-4 w-4',
|
|
1613
|
+
md: 'h-6 w-6',
|
|
1614
|
+
lg: 'h-8 w-8',
|
|
1615
|
+
xl: 'h-12 w-12',
|
|
1616
|
+
},
|
|
1617
|
+
},
|
|
1618
|
+
defaultVariants: {
|
|
1619
|
+
size: 'md',
|
|
1620
|
+
},
|
|
1621
|
+
});
|
|
1622
|
+
|
|
1623
|
+
class SnyLoaderComponent {
|
|
1624
|
+
variant = input('spinner', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
1625
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1626
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1627
|
+
computedClass = computed(() => cn(loaderVariants({ size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1628
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1629
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SnyLoaderComponent, isStandalone: true, selector: "sny-loader", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "status" }, properties: { "class": "computedClass()", "attr.aria-label": "\"Loading\"" } }, ngImport: i0, template: `
|
|
1630
|
+
@switch (variant()) {
|
|
1631
|
+
@case ('spinner') {
|
|
1632
|
+
<svg class="animate-spin h-full w-full" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
1633
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
1634
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
1635
|
+
</svg>
|
|
1636
|
+
}
|
|
1637
|
+
@case ('dots') {
|
|
1638
|
+
<span class="flex items-center gap-1">
|
|
1639
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.3s]"></span>
|
|
1640
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.15s]"></span>
|
|
1641
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce"></span>
|
|
1642
|
+
</span>
|
|
1643
|
+
}
|
|
1644
|
+
@case ('bars') {
|
|
1645
|
+
<span class="flex items-end gap-0.5 h-full">
|
|
1646
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.3s]" style="height:60%"></span>
|
|
1647
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.15s]" style="height:100%"></span>
|
|
1648
|
+
<span class="w-1 bg-current animate-pulse rounded-sm" style="height:40%"></span>
|
|
1649
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.2s]" style="height:80%"></span>
|
|
1650
|
+
</span>
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
`, isInline: true });
|
|
1654
|
+
}
|
|
1655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyLoaderComponent, decorators: [{
|
|
1656
|
+
type: Component,
|
|
1657
|
+
args: [{
|
|
1658
|
+
selector: 'sny-loader',
|
|
1659
|
+
standalone: true,
|
|
1660
|
+
host: {
|
|
1661
|
+
'[class]': 'computedClass()',
|
|
1662
|
+
role: 'status',
|
|
1663
|
+
'[attr.aria-label]': '"Loading"',
|
|
1664
|
+
},
|
|
1665
|
+
template: `
|
|
1666
|
+
@switch (variant()) {
|
|
1667
|
+
@case ('spinner') {
|
|
1668
|
+
<svg class="animate-spin h-full w-full" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
1669
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
1670
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
1671
|
+
</svg>
|
|
1672
|
+
}
|
|
1673
|
+
@case ('dots') {
|
|
1674
|
+
<span class="flex items-center gap-1">
|
|
1675
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.3s]"></span>
|
|
1676
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.15s]"></span>
|
|
1677
|
+
<span class="h-1.5 w-1.5 rounded-full bg-current animate-bounce"></span>
|
|
1678
|
+
</span>
|
|
1679
|
+
}
|
|
1680
|
+
@case ('bars') {
|
|
1681
|
+
<span class="flex items-end gap-0.5 h-full">
|
|
1682
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.3s]" style="height:60%"></span>
|
|
1683
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.15s]" style="height:100%"></span>
|
|
1684
|
+
<span class="w-1 bg-current animate-pulse rounded-sm" style="height:40%"></span>
|
|
1685
|
+
<span class="w-1 bg-current animate-pulse rounded-sm [animation-delay:-0.2s]" style="height:80%"></span>
|
|
1686
|
+
</span>
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
`,
|
|
1690
|
+
}]
|
|
1691
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1692
|
+
|
|
1693
|
+
const SNY_TABS = new InjectionToken('SnyTabs');
|
|
1694
|
+
class SnyTabsDirective {
|
|
1695
|
+
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1696
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1697
|
+
computedClass = computed(() => cn('', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1698
|
+
select(value) {
|
|
1699
|
+
this.value.set(value);
|
|
1700
|
+
}
|
|
1701
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1702
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTabsDirective, isStandalone: true, selector: "[snyTabs]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "class": "computedClass()" } }, providers: [{ provide: SNY_TABS, useExisting: SnyTabsDirective }], ngImport: i0 });
|
|
1703
|
+
}
|
|
1704
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsDirective, decorators: [{
|
|
1705
|
+
type: Directive,
|
|
1706
|
+
args: [{
|
|
1707
|
+
selector: '[snyTabs]',
|
|
1708
|
+
standalone: true,
|
|
1709
|
+
providers: [{ provide: SNY_TABS, useExisting: SnyTabsDirective }],
|
|
1710
|
+
host: { '[class]': 'computedClass()' },
|
|
1711
|
+
}]
|
|
1712
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1713
|
+
class SnyTabsListDirective {
|
|
1714
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1715
|
+
computedClass = computed(() => cn('inline-flex h-10 items-center justify-center rounded-sm bg-muted p-1 text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1716
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1717
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTabsListDirective, isStandalone: true, selector: "[snyTabsList]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tablist" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
1718
|
+
}
|
|
1719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsListDirective, decorators: [{
|
|
1720
|
+
type: Directive,
|
|
1721
|
+
args: [{
|
|
1722
|
+
selector: '[snyTabsList]',
|
|
1723
|
+
standalone: true,
|
|
1724
|
+
host: {
|
|
1725
|
+
role: 'tablist',
|
|
1726
|
+
'[class]': 'computedClass()',
|
|
1727
|
+
},
|
|
1728
|
+
}]
|
|
1729
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1730
|
+
class SnyTabsTriggerDirective {
|
|
1731
|
+
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1732
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1733
|
+
tabs = inject(SNY_TABS);
|
|
1734
|
+
isActive = computed(() => this.tabs.value() === this.value(), ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
1735
|
+
computedClass = computed(() => cn('inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer', this.isActive()
|
|
1736
|
+
? 'bg-background text-foreground shadow-sm'
|
|
1737
|
+
: 'hover:bg-background/50', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1738
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1739
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTabsTriggerDirective, isStandalone: true, selector: "[snyTabsTrigger]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tab" }, listeners: { "click": "tabs.select(value())" }, properties: { "class": "computedClass()", "attr.aria-selected": "isActive()" } }, ngImport: i0 });
|
|
1740
|
+
}
|
|
1741
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsTriggerDirective, decorators: [{
|
|
1742
|
+
type: Directive,
|
|
1743
|
+
args: [{
|
|
1744
|
+
selector: '[snyTabsTrigger]',
|
|
1745
|
+
standalone: true,
|
|
1746
|
+
host: {
|
|
1747
|
+
role: 'tab',
|
|
1748
|
+
'[class]': 'computedClass()',
|
|
1749
|
+
'[attr.aria-selected]': 'isActive()',
|
|
1750
|
+
'(click)': 'tabs.select(value())',
|
|
1751
|
+
},
|
|
1752
|
+
}]
|
|
1753
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1754
|
+
class SnyTabsContentDirective {
|
|
1755
|
+
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1756
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1757
|
+
tabs = inject(SNY_TABS);
|
|
1758
|
+
isActive = computed(() => this.tabs.value() === this.value(), ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
1759
|
+
computedClass = computed(() => cn('mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
1760
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1761
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTabsContentDirective, isStandalone: true, selector: "[snyTabsContent]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tabpanel" }, properties: { "class": "computedClass()", "style.display": "isActive() ? null : \"none\"" } }, ngImport: i0 });
|
|
1762
|
+
}
|
|
1763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTabsContentDirective, decorators: [{
|
|
1764
|
+
type: Directive,
|
|
1765
|
+
args: [{
|
|
1766
|
+
selector: '[snyTabsContent]',
|
|
1767
|
+
standalone: true,
|
|
1768
|
+
host: {
|
|
1769
|
+
role: 'tabpanel',
|
|
1770
|
+
'[class]': 'computedClass()',
|
|
1771
|
+
'[style.display]': 'isActive() ? null : "none"',
|
|
1772
|
+
},
|
|
1773
|
+
}]
|
|
1774
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1775
|
+
|
|
1776
|
+
const tabsListVariants = cva('inline-flex h-10 items-center justify-center rounded-sm bg-muted p-1 text-muted-foreground', {
|
|
1777
|
+
variants: {},
|
|
1778
|
+
defaultVariants: {},
|
|
1779
|
+
});
|
|
1780
|
+
const tabsTriggerVariants = cva('inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
|
|
1781
|
+
variants: {},
|
|
1782
|
+
defaultVariants: {},
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
const selectTriggerVariants = cva('inline-flex w-full items-center justify-between whitespace-nowrap rounded-sm border border-border bg-background px-3 py-2 text-sm ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
|
|
1786
|
+
variants: {
|
|
1787
|
+
size: {
|
|
1788
|
+
sm: 'h-9 text-xs',
|
|
1789
|
+
md: 'h-10 text-sm',
|
|
1790
|
+
lg: 'h-11 text-base',
|
|
1791
|
+
},
|
|
1792
|
+
},
|
|
1793
|
+
defaultVariants: {
|
|
1794
|
+
size: 'md',
|
|
1795
|
+
},
|
|
1796
|
+
});
|
|
1797
|
+
|
|
1798
|
+
class SnySelectComponent {
|
|
1799
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
1800
|
+
placeholder = input('Select...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
1801
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1802
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1803
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
1804
|
+
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1805
|
+
open = signal(false, ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
1806
|
+
activeIndex = signal(0, ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
1807
|
+
triggerRef = viewChild('triggerEl', ...(ngDevMode ? [{ debugName: "triggerRef" }] : /* istanbul ignore next */ []));
|
|
1808
|
+
dropdownRef = viewChild('dropdownEl', ...(ngDevMode ? [{ debugName: "dropdownRef" }] : /* istanbul ignore next */ []));
|
|
1809
|
+
elRef = inject(ElementRef);
|
|
1810
|
+
scrollHandler = null;
|
|
1811
|
+
resizeHandler = null;
|
|
1812
|
+
selectedLabel = computed(() => {
|
|
1813
|
+
const v = this.value();
|
|
1814
|
+
if (!v)
|
|
1815
|
+
return '';
|
|
1816
|
+
const opt = this.options().find(o => o.value === v);
|
|
1817
|
+
return opt?.label ?? '';
|
|
1818
|
+
}, ...(ngDevMode ? [{ debugName: "selectedLabel" }] : /* istanbul ignore next */ []));
|
|
1819
|
+
triggerClass = computed(() => cn(selectTriggerVariants({ size: this.size() }), this.class()), ...(ngDevMode ? [{ debugName: "triggerClass" }] : /* istanbul ignore next */ []));
|
|
1820
|
+
optionClass(index) {
|
|
1821
|
+
const base = 'relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors';
|
|
1822
|
+
const active = index === this.activeIndex() ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50';
|
|
1823
|
+
return cn(base, active);
|
|
1824
|
+
}
|
|
1825
|
+
updateDropdownPosition() {
|
|
1826
|
+
const trigger = this.triggerRef()?.nativeElement;
|
|
1827
|
+
if (!trigger)
|
|
1828
|
+
return;
|
|
1829
|
+
const rect = trigger.getBoundingClientRect();
|
|
1830
|
+
const dropdown = this.dropdownRef()?.nativeElement;
|
|
1831
|
+
if (dropdown) {
|
|
1832
|
+
dropdown.style.top = `${rect.bottom + 4}px`;
|
|
1833
|
+
dropdown.style.left = `${rect.left}px`;
|
|
1834
|
+
dropdown.style.width = `${rect.width}px`;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
addGlobalListeners() {
|
|
1838
|
+
this.removeGlobalListeners();
|
|
1839
|
+
this.scrollHandler = () => {
|
|
1840
|
+
requestAnimationFrame(() => this.updateDropdownPosition());
|
|
1841
|
+
};
|
|
1842
|
+
this.resizeHandler = () => {
|
|
1843
|
+
requestAnimationFrame(() => this.updateDropdownPosition());
|
|
1844
|
+
};
|
|
1845
|
+
document.addEventListener('scroll', this.scrollHandler, { capture: true, passive: true });
|
|
1846
|
+
window.addEventListener('resize', this.resizeHandler, { passive: true });
|
|
1847
|
+
}
|
|
1848
|
+
removeGlobalListeners() {
|
|
1849
|
+
if (this.scrollHandler) {
|
|
1850
|
+
document.removeEventListener('scroll', this.scrollHandler, { capture: true });
|
|
1851
|
+
this.scrollHandler = null;
|
|
1852
|
+
}
|
|
1853
|
+
if (this.resizeHandler) {
|
|
1854
|
+
window.removeEventListener('resize', this.resizeHandler);
|
|
1855
|
+
this.resizeHandler = null;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
ngOnDestroy() {
|
|
1859
|
+
this.removeGlobalListeners();
|
|
1860
|
+
}
|
|
1861
|
+
toggle() {
|
|
1862
|
+
if (this.open()) {
|
|
1863
|
+
this.close();
|
|
1864
|
+
}
|
|
1865
|
+
else {
|
|
1866
|
+
this.open.set(true);
|
|
1867
|
+
this.activeIndex.set(Math.max(0, this.options().findIndex(o => o.value === this.value())));
|
|
1868
|
+
this.addGlobalListeners();
|
|
1869
|
+
setTimeout(() => this.updateDropdownPosition());
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
close() {
|
|
1873
|
+
this.open.set(false);
|
|
1874
|
+
this.removeGlobalListeners();
|
|
1875
|
+
}
|
|
1876
|
+
select(opt) {
|
|
1877
|
+
this.value.set(opt.value);
|
|
1878
|
+
this.close();
|
|
1879
|
+
}
|
|
1880
|
+
onTriggerKeydown(event) {
|
|
1881
|
+
const items = this.options();
|
|
1882
|
+
if (!this.open()) {
|
|
1883
|
+
if (event.key === 'ArrowDown' || event.key === 'Enter' || event.key === ' ') {
|
|
1884
|
+
event.preventDefault();
|
|
1885
|
+
this.toggle();
|
|
1886
|
+
}
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
switch (event.key) {
|
|
1890
|
+
case 'ArrowDown':
|
|
1891
|
+
event.preventDefault();
|
|
1892
|
+
this.activeIndex.update(i => Math.min(i + 1, items.length - 1));
|
|
1893
|
+
break;
|
|
1894
|
+
case 'ArrowUp':
|
|
1895
|
+
event.preventDefault();
|
|
1896
|
+
this.activeIndex.update(i => Math.max(i - 1, 0));
|
|
1897
|
+
break;
|
|
1898
|
+
case 'Enter':
|
|
1899
|
+
case ' ':
|
|
1900
|
+
event.preventDefault();
|
|
1901
|
+
if (items[this.activeIndex()]) {
|
|
1902
|
+
this.select(items[this.activeIndex()]);
|
|
1903
|
+
}
|
|
1904
|
+
break;
|
|
1905
|
+
case 'Escape':
|
|
1906
|
+
this.close();
|
|
1907
|
+
break;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
onDocumentClick(event) {
|
|
1911
|
+
if (!this.elRef.nativeElement.contains(event.target)) {
|
|
1912
|
+
this.close();
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1916
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SnySelectComponent, isStandalone: true, selector: "sny-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "document:click": "onDocumentClick($event)" }, classAttribute: "relative inline-block w-full" }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["triggerEl"], descendants: true, isSignal: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdownEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1917
|
+
<button
|
|
1918
|
+
#triggerEl
|
|
1919
|
+
type="button"
|
|
1920
|
+
role="combobox"
|
|
1921
|
+
[attr.aria-expanded]="open()"
|
|
1922
|
+
aria-haspopup="listbox"
|
|
1923
|
+
[disabled]="disabled()"
|
|
1924
|
+
[class]="triggerClass()"
|
|
1925
|
+
(click)="toggle()"
|
|
1926
|
+
(keydown)="onTriggerKeydown($event)"
|
|
1927
|
+
>
|
|
1928
|
+
<span [class]="selectedLabel() ? '' : 'text-muted-foreground'">
|
|
1929
|
+
{{ selectedLabel() || placeholder() }}
|
|
1930
|
+
</span>
|
|
1931
|
+
<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="shrink-0 opacity-50"><path d="m6 9 6 6 6-6"/></svg>
|
|
1932
|
+
</button>
|
|
1933
|
+
|
|
1934
|
+
@if (open()) {
|
|
1935
|
+
<div
|
|
1936
|
+
#dropdownEl
|
|
1937
|
+
class="fixed z-50 rounded-sm border border-border bg-popover text-popover-foreground shadow-md"
|
|
1938
|
+
>
|
|
1939
|
+
<ul role="listbox" class="max-h-60 overflow-auto p-1">
|
|
1940
|
+
@for (opt of options(); track opt.value; let i = $index) {
|
|
1941
|
+
<li
|
|
1942
|
+
role="option"
|
|
1943
|
+
[attr.aria-selected]="value() === opt.value"
|
|
1944
|
+
[class]="optionClass(i)"
|
|
1945
|
+
(mousedown)="select(opt); $event.preventDefault()"
|
|
1946
|
+
(mouseenter)="activeIndex.set(i)"
|
|
1947
|
+
>
|
|
1948
|
+
<svg
|
|
1949
|
+
xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
|
|
1950
|
+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
1951
|
+
[class]="value() === opt.value ? 'mr-2 shrink-0 opacity-100' : 'mr-2 shrink-0 opacity-0'"
|
|
1952
|
+
><path d="M20 6 9 17l-5-5"/></svg>
|
|
1953
|
+
{{ opt.label }}
|
|
1954
|
+
</li>
|
|
1955
|
+
}
|
|
1956
|
+
</ul>
|
|
1957
|
+
</div>
|
|
1958
|
+
}
|
|
1959
|
+
`, isInline: true });
|
|
1960
|
+
}
|
|
1961
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySelectComponent, decorators: [{
|
|
1962
|
+
type: Component,
|
|
1963
|
+
args: [{
|
|
1964
|
+
selector: 'sny-select',
|
|
1965
|
+
standalone: true,
|
|
1966
|
+
host: {
|
|
1967
|
+
class: 'relative inline-block w-full',
|
|
1968
|
+
},
|
|
1969
|
+
template: `
|
|
1970
|
+
<button
|
|
1971
|
+
#triggerEl
|
|
1972
|
+
type="button"
|
|
1973
|
+
role="combobox"
|
|
1974
|
+
[attr.aria-expanded]="open()"
|
|
1975
|
+
aria-haspopup="listbox"
|
|
1976
|
+
[disabled]="disabled()"
|
|
1977
|
+
[class]="triggerClass()"
|
|
1978
|
+
(click)="toggle()"
|
|
1979
|
+
(keydown)="onTriggerKeydown($event)"
|
|
1980
|
+
>
|
|
1981
|
+
<span [class]="selectedLabel() ? '' : 'text-muted-foreground'">
|
|
1982
|
+
{{ selectedLabel() || placeholder() }}
|
|
1983
|
+
</span>
|
|
1984
|
+
<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="shrink-0 opacity-50"><path d="m6 9 6 6 6-6"/></svg>
|
|
1985
|
+
</button>
|
|
1986
|
+
|
|
1987
|
+
@if (open()) {
|
|
1988
|
+
<div
|
|
1989
|
+
#dropdownEl
|
|
1990
|
+
class="fixed z-50 rounded-sm border border-border bg-popover text-popover-foreground shadow-md"
|
|
1991
|
+
>
|
|
1992
|
+
<ul role="listbox" class="max-h-60 overflow-auto p-1">
|
|
1993
|
+
@for (opt of options(); track opt.value; let i = $index) {
|
|
1994
|
+
<li
|
|
1995
|
+
role="option"
|
|
1996
|
+
[attr.aria-selected]="value() === opt.value"
|
|
1997
|
+
[class]="optionClass(i)"
|
|
1998
|
+
(mousedown)="select(opt); $event.preventDefault()"
|
|
1999
|
+
(mouseenter)="activeIndex.set(i)"
|
|
2000
|
+
>
|
|
2001
|
+
<svg
|
|
2002
|
+
xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
|
|
2003
|
+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
2004
|
+
[class]="value() === opt.value ? 'mr-2 shrink-0 opacity-100' : 'mr-2 shrink-0 opacity-0'"
|
|
2005
|
+
><path d="M20 6 9 17l-5-5"/></svg>
|
|
2006
|
+
{{ opt.label }}
|
|
2007
|
+
</li>
|
|
2008
|
+
}
|
|
2009
|
+
</ul>
|
|
2010
|
+
</div>
|
|
2011
|
+
}
|
|
2012
|
+
`,
|
|
2013
|
+
}]
|
|
2014
|
+
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], triggerRef: [{ type: i0.ViewChild, args: ['triggerEl', { isSignal: true }] }], dropdownRef: [{ type: i0.ViewChild, args: ['dropdownEl', { isSignal: true }] }], onDocumentClick: [{
|
|
2015
|
+
type: HostListener,
|
|
2016
|
+
args: ['document:click', ['$event']]
|
|
2017
|
+
}] } });
|
|
2018
|
+
|
|
2019
|
+
const tableVariants = cva('w-full caption-bottom text-sm border-collapse', {
|
|
2020
|
+
variants: {
|
|
2021
|
+
variant: {
|
|
2022
|
+
default: '',
|
|
2023
|
+
striped: '[&_tbody_tr:nth-child(even)]:bg-muted/50',
|
|
2024
|
+
bordered: 'border border-border [&_th]:border [&_th]:border-border [&_td]:border [&_td]:border-border',
|
|
2025
|
+
},
|
|
2026
|
+
},
|
|
2027
|
+
defaultVariants: {
|
|
2028
|
+
variant: 'default',
|
|
2029
|
+
},
|
|
2030
|
+
});
|
|
2031
|
+
const tableCellVariants = cva('', {
|
|
2032
|
+
variants: {
|
|
2033
|
+
density: {
|
|
2034
|
+
compact: 'px-2 py-1 text-xs',
|
|
2035
|
+
normal: 'px-4 py-3 text-sm',
|
|
2036
|
+
comfortable: 'px-6 py-4 text-base',
|
|
2037
|
+
},
|
|
2038
|
+
},
|
|
2039
|
+
defaultVariants: {
|
|
2040
|
+
density: 'normal',
|
|
2041
|
+
},
|
|
2042
|
+
});
|
|
2043
|
+
|
|
2044
|
+
const SNY_TABLE = new InjectionToken('SnyTable');
|
|
2045
|
+
class SnyTableDirective {
|
|
2046
|
+
variant = input('default', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
2047
|
+
density = input('normal', ...(ngDevMode ? [{ debugName: "density" }] : /* istanbul ignore next */ []));
|
|
2048
|
+
hoverable = input(false, ...(ngDevMode ? [{ debugName: "hoverable" }] : /* istanbul ignore next */ []));
|
|
2049
|
+
stickyHeader = input(false, ...(ngDevMode ? [{ debugName: "stickyHeader" }] : /* istanbul ignore next */ []));
|
|
2050
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2051
|
+
computedClass = computed(() => cn(tableVariants({ variant: this.variant() }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2052
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2053
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableDirective, isStandalone: true, selector: "table[snyTable]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, density: { classPropertyName: "density", publicName: "density", isSignal: true, isRequired: false, transformFunction: null }, hoverable: { classPropertyName: "hoverable", publicName: "hoverable", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, providers: [{ provide: SNY_TABLE, useExisting: SnyTableDirective }], ngImport: i0 });
|
|
2054
|
+
}
|
|
2055
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableDirective, decorators: [{
|
|
2056
|
+
type: Directive,
|
|
2057
|
+
args: [{
|
|
2058
|
+
selector: 'table[snyTable]',
|
|
2059
|
+
standalone: true,
|
|
2060
|
+
providers: [{ provide: SNY_TABLE, useExisting: SnyTableDirective }],
|
|
2061
|
+
host: { '[class]': 'computedClass()' },
|
|
2062
|
+
}]
|
|
2063
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], density: [{ type: i0.Input, args: [{ isSignal: true, alias: "density", required: false }] }], hoverable: [{ type: i0.Input, args: [{ isSignal: true, alias: "hoverable", required: false }] }], stickyHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyHeader", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2064
|
+
class SnyTableHeaderDirective {
|
|
2065
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2066
|
+
table = inject(SNY_TABLE, { optional: true });
|
|
2067
|
+
computedClass = computed(() => cn('[&_tr]:border-b', this.table?.stickyHeader() ? 'sticky top-0 z-10 bg-background' : '', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2068
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2069
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableHeaderDirective, isStandalone: true, selector: "thead[snyTableHeader]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2070
|
+
}
|
|
2071
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableHeaderDirective, decorators: [{
|
|
2072
|
+
type: Directive,
|
|
2073
|
+
args: [{
|
|
2074
|
+
selector: 'thead[snyTableHeader]',
|
|
2075
|
+
standalone: true,
|
|
2076
|
+
host: { '[class]': 'computedClass()' },
|
|
2077
|
+
}]
|
|
2078
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2079
|
+
class SnyTableBodyDirective {
|
|
2080
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2081
|
+
computedClass = computed(() => cn('[&_tr:last-child]:border-0', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2082
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableBodyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2083
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableBodyDirective, isStandalone: true, selector: "tbody[snyTableBody]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2084
|
+
}
|
|
2085
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableBodyDirective, decorators: [{
|
|
2086
|
+
type: Directive,
|
|
2087
|
+
args: [{
|
|
2088
|
+
selector: 'tbody[snyTableBody]',
|
|
2089
|
+
standalone: true,
|
|
2090
|
+
host: { '[class]': 'computedClass()' },
|
|
2091
|
+
}]
|
|
2092
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2093
|
+
class SnyTableRowDirective {
|
|
2094
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2095
|
+
table = inject(SNY_TABLE, { optional: true });
|
|
2096
|
+
computedClass = computed(() => cn('border-b border-border transition-colors data-[state=selected]:bg-muted', this.table?.hoverable() ? 'hover:bg-muted/50' : '', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2097
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableRowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2098
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableRowDirective, isStandalone: true, selector: "tr[snyTableRow]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2099
|
+
}
|
|
2100
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableRowDirective, decorators: [{
|
|
2101
|
+
type: Directive,
|
|
2102
|
+
args: [{
|
|
2103
|
+
selector: 'tr[snyTableRow]',
|
|
2104
|
+
standalone: true,
|
|
2105
|
+
host: { '[class]': 'computedClass()' },
|
|
2106
|
+
}]
|
|
2107
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2108
|
+
class SnyTableHeadDirective {
|
|
2109
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2110
|
+
table = inject(SNY_TABLE, { optional: true });
|
|
2111
|
+
computedClass = computed(() => cn('text-left font-medium text-muted-foreground [&[align=center]]:text-center [&[align=right]]:text-right', tableCellVariants({ density: this.table?.density() ?? 'normal' }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2112
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableHeadDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2113
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableHeadDirective, isStandalone: true, selector: "th[snyTableHead]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2114
|
+
}
|
|
2115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableHeadDirective, decorators: [{
|
|
2116
|
+
type: Directive,
|
|
2117
|
+
args: [{
|
|
2118
|
+
selector: 'th[snyTableHead]',
|
|
2119
|
+
standalone: true,
|
|
2120
|
+
host: { '[class]': 'computedClass()' },
|
|
2121
|
+
}]
|
|
2122
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2123
|
+
class SnyTableCellDirective {
|
|
2124
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2125
|
+
table = inject(SNY_TABLE, { optional: true });
|
|
2126
|
+
computedClass = computed(() => cn('[&[align=center]]:text-center [&[align=right]]:text-right', tableCellVariants({ density: this.table?.density() ?? 'normal' }), this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2127
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2128
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableCellDirective, isStandalone: true, selector: "td[snyTableCell]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2129
|
+
}
|
|
2130
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableCellDirective, decorators: [{
|
|
2131
|
+
type: Directive,
|
|
2132
|
+
args: [{
|
|
2133
|
+
selector: 'td[snyTableCell]',
|
|
2134
|
+
standalone: true,
|
|
2135
|
+
host: { '[class]': 'computedClass()' },
|
|
2136
|
+
}]
|
|
2137
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2138
|
+
class SnyTableFooterDirective {
|
|
2139
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2140
|
+
computedClass = computed(() => cn('border-t border-border font-medium [&>tr]:last:border-b-0', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2141
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableFooterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2142
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableFooterDirective, isStandalone: true, selector: "tfoot[snyTableFooter]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2143
|
+
}
|
|
2144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableFooterDirective, decorators: [{
|
|
2145
|
+
type: Directive,
|
|
2146
|
+
args: [{
|
|
2147
|
+
selector: 'tfoot[snyTableFooter]',
|
|
2148
|
+
standalone: true,
|
|
2149
|
+
host: { '[class]': 'computedClass()' },
|
|
2150
|
+
}]
|
|
2151
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2152
|
+
class SnyTableCaptionDirective {
|
|
2153
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2154
|
+
computedClass = computed(() => cn('mt-4 text-sm text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2155
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableCaptionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2156
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnyTableCaptionDirective, isStandalone: true, selector: "caption[snyTableCaption]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2157
|
+
}
|
|
2158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnyTableCaptionDirective, decorators: [{
|
|
2159
|
+
type: Directive,
|
|
2160
|
+
args: [{
|
|
2161
|
+
selector: 'caption[snyTableCaption]',
|
|
2162
|
+
standalone: true,
|
|
2163
|
+
host: { '[class]': 'computedClass()' },
|
|
2164
|
+
}]
|
|
2165
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2166
|
+
|
|
2167
|
+
class SnySheetRef {
|
|
2168
|
+
cdkRef;
|
|
2169
|
+
constructor(cdkRef) {
|
|
2170
|
+
this.cdkRef = cdkRef;
|
|
2171
|
+
}
|
|
2172
|
+
close(result) {
|
|
2173
|
+
this.cdkRef.close(result);
|
|
2174
|
+
}
|
|
2175
|
+
get closed() {
|
|
2176
|
+
return this.cdkRef.closed;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
const DEFAULT_SHEET_CONFIG = {
|
|
2181
|
+
side: 'right',
|
|
2182
|
+
closeOnBackdrop: true,
|
|
2183
|
+
closeOnEsc: true,
|
|
2184
|
+
};
|
|
2185
|
+
const SHEET_PANEL_CLASS = {
|
|
2186
|
+
right: 'sny-sheet-right',
|
|
2187
|
+
left: 'sny-sheet-left',
|
|
2188
|
+
top: 'sny-sheet-top',
|
|
2189
|
+
bottom: 'sny-sheet-bottom',
|
|
2190
|
+
};
|
|
2191
|
+
|
|
2192
|
+
const SNY_SHEET_DATA = new InjectionToken('SNY_SHEET_DATA');
|
|
2193
|
+
class SnySheetService {
|
|
2194
|
+
cdkDialog = inject(Dialog);
|
|
2195
|
+
injector = inject(Injector);
|
|
2196
|
+
open(component, config = {}) {
|
|
2197
|
+
const merged = { ...DEFAULT_SHEET_CONFIG, ...config };
|
|
2198
|
+
const side = merged.side ?? 'right';
|
|
2199
|
+
const disableClose = !merged.closeOnBackdrop || !merged.closeOnEsc;
|
|
2200
|
+
const overlay = this._getOverlayConfig(side);
|
|
2201
|
+
const cdkRef = this.cdkDialog.open(component, {
|
|
2202
|
+
disableClose,
|
|
2203
|
+
hasBackdrop: true,
|
|
2204
|
+
backdropClass: 'sny-dialog-backdrop',
|
|
2205
|
+
panelClass: ['sny-sheet-panel', SHEET_PANEL_CLASS[side]],
|
|
2206
|
+
positionStrategy: overlay.positionStrategy,
|
|
2207
|
+
width: overlay.width,
|
|
2208
|
+
maxWidth: overlay.maxWidth,
|
|
2209
|
+
height: overlay.height,
|
|
2210
|
+
maxHeight: overlay.maxHeight,
|
|
2211
|
+
ariaLabelledBy: merged.ariaLabelledBy,
|
|
2212
|
+
ariaDescribedBy: merged.ariaDescribedBy,
|
|
2213
|
+
data: merged.data,
|
|
2214
|
+
providers: merged.data != null
|
|
2215
|
+
? [{ provide: SNY_SHEET_DATA, useValue: merged.data }]
|
|
2216
|
+
: [],
|
|
2217
|
+
});
|
|
2218
|
+
if (disableClose) {
|
|
2219
|
+
if (merged.closeOnBackdrop) {
|
|
2220
|
+
const sub = cdkRef.backdropClick.subscribe(() => cdkRef.close());
|
|
2221
|
+
cdkRef.closed.subscribe(() => sub.unsubscribe());
|
|
2222
|
+
}
|
|
2223
|
+
if (merged.closeOnEsc) {
|
|
2224
|
+
const sub = cdkRef.keydownEvents.subscribe(event => {
|
|
2225
|
+
if (event.key === 'Escape')
|
|
2226
|
+
cdkRef.close();
|
|
2227
|
+
});
|
|
2228
|
+
cdkRef.closed.subscribe(() => sub.unsubscribe());
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
return new SnySheetRef(cdkRef);
|
|
2232
|
+
}
|
|
2233
|
+
closeAll() {
|
|
2234
|
+
this.cdkDialog.closeAll();
|
|
2235
|
+
}
|
|
2236
|
+
_getOverlayConfig(side) {
|
|
2237
|
+
const strategy = createGlobalPositionStrategy(this.injector);
|
|
2238
|
+
switch (side) {
|
|
2239
|
+
case 'right':
|
|
2240
|
+
return {
|
|
2241
|
+
positionStrategy: strategy.top('0').right('0'),
|
|
2242
|
+
width: '75%',
|
|
2243
|
+
maxWidth: '24rem',
|
|
2244
|
+
height: '100vh',
|
|
2245
|
+
maxHeight: '100vh',
|
|
2246
|
+
};
|
|
2247
|
+
case 'left':
|
|
2248
|
+
return {
|
|
2249
|
+
positionStrategy: strategy.top('0').left('0'),
|
|
2250
|
+
width: '75%',
|
|
2251
|
+
maxWidth: '24rem',
|
|
2252
|
+
height: '100vh',
|
|
2253
|
+
maxHeight: '100vh',
|
|
2254
|
+
};
|
|
2255
|
+
case 'top':
|
|
2256
|
+
return {
|
|
2257
|
+
positionStrategy: strategy.top('0').centerHorizontally(),
|
|
2258
|
+
width: '100vw',
|
|
2259
|
+
maxWidth: '100vw',
|
|
2260
|
+
};
|
|
2261
|
+
case 'bottom':
|
|
2262
|
+
return {
|
|
2263
|
+
positionStrategy: strategy.bottom('0').centerHorizontally(),
|
|
2264
|
+
width: '100vw',
|
|
2265
|
+
maxWidth: '100vw',
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2270
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetService, providedIn: 'root' });
|
|
2271
|
+
}
|
|
2272
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetService, decorators: [{
|
|
2273
|
+
type: Injectable,
|
|
2274
|
+
args: [{ providedIn: 'root' }]
|
|
2275
|
+
}] });
|
|
2276
|
+
|
|
2277
|
+
class SnySheetHeaderDirective {
|
|
2278
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2279
|
+
computedClass = computed(() => cn('flex flex-col space-y-2', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2280
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2281
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySheetHeaderDirective, isStandalone: true, selector: "[snySheetHeader]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2282
|
+
}
|
|
2283
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetHeaderDirective, decorators: [{
|
|
2284
|
+
type: Directive,
|
|
2285
|
+
args: [{
|
|
2286
|
+
selector: '[snySheetHeader]',
|
|
2287
|
+
standalone: true,
|
|
2288
|
+
host: { '[class]': 'computedClass()' },
|
|
2289
|
+
}]
|
|
2290
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2291
|
+
class SnySheetTitleDirective {
|
|
2292
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2293
|
+
computedClass = computed(() => cn('text-lg font-semibold text-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2294
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetTitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2295
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySheetTitleDirective, isStandalone: true, selector: "[snySheetTitle]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2296
|
+
}
|
|
2297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetTitleDirective, decorators: [{
|
|
2298
|
+
type: Directive,
|
|
2299
|
+
args: [{
|
|
2300
|
+
selector: '[snySheetTitle]',
|
|
2301
|
+
standalone: true,
|
|
2302
|
+
host: { '[class]': 'computedClass()' },
|
|
2303
|
+
}]
|
|
2304
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2305
|
+
class SnySheetDescriptionDirective {
|
|
2306
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2307
|
+
computedClass = computed(() => cn('text-sm text-muted-foreground', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2308
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetDescriptionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2309
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySheetDescriptionDirective, isStandalone: true, selector: "[snySheetDescription]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2310
|
+
}
|
|
2311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetDescriptionDirective, decorators: [{
|
|
2312
|
+
type: Directive,
|
|
2313
|
+
args: [{
|
|
2314
|
+
selector: '[snySheetDescription]',
|
|
2315
|
+
standalone: true,
|
|
2316
|
+
host: { '[class]': 'computedClass()' },
|
|
2317
|
+
}]
|
|
2318
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2319
|
+
class SnySheetContentDirective {
|
|
2320
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2321
|
+
computedClass = computed(() => cn('py-4', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2322
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2323
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySheetContentDirective, isStandalone: true, selector: "[snySheetContent]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2324
|
+
}
|
|
2325
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetContentDirective, decorators: [{
|
|
2326
|
+
type: Directive,
|
|
2327
|
+
args: [{
|
|
2328
|
+
selector: '[snySheetContent]',
|
|
2329
|
+
standalone: true,
|
|
2330
|
+
host: { '[class]': 'computedClass()' },
|
|
2331
|
+
}]
|
|
2332
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2333
|
+
class SnySheetCloseDirective {
|
|
2334
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
2335
|
+
computedClass = computed(() => cn('absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', this.class()), ...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
2336
|
+
dialogRef = inject(DialogRef, { optional: true });
|
|
2337
|
+
onClick() {
|
|
2338
|
+
this.dialogRef?.close();
|
|
2339
|
+
}
|
|
2340
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2341
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SnySheetCloseDirective, isStandalone: true, selector: "[snySheetClose]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()" }, properties: { "class": "computedClass()" } }, ngImport: i0 });
|
|
2342
|
+
}
|
|
2343
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SnySheetCloseDirective, decorators: [{
|
|
2344
|
+
type: Directive,
|
|
2345
|
+
args: [{
|
|
2346
|
+
selector: '[snySheetClose]',
|
|
2347
|
+
standalone: true,
|
|
2348
|
+
host: {
|
|
2349
|
+
'[class]': 'computedClass()',
|
|
2350
|
+
'(click)': 'onClick()',
|
|
2351
|
+
},
|
|
2352
|
+
}]
|
|
2353
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2354
|
+
|
|
2355
|
+
/*
|
|
2356
|
+
* Public API Surface of @sonny-ui/core
|
|
2357
|
+
*/
|
|
2358
|
+
// Utils
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Generated bundle index. Do not edit.
|
|
2362
|
+
*/
|
|
2363
|
+
|
|
2364
|
+
export { SNY_ACCORDION, SNY_ACCORDION_ITEM, SNY_CONFIG, SNY_DIALOG_DATA, SNY_SHEET_DATA, SNY_TABLE, SNY_TABS, SnyAccordionContentDirective, SnyAccordionDirective, SnyAccordionItemDirective, SnyAccordionTriggerDirective, SnyAvatarComponent, SnyBadgeDirective, SnyBreadcrumbDirective, SnyBreadcrumbItemDirective, SnyBreadcrumbLinkDirective, SnyBreadcrumbListDirective, SnyBreadcrumbPageDirective, SnyBreadcrumbSeparatorDirective, SnyButtonDirective, SnyButtonGroupDirective, SnyCardContentDirective, SnyCardDescriptionDirective, SnyCardDirective, SnyCardFooterDirective, SnyCardHeaderDirective, SnyCardTitleDirective, SnyCheckboxDirective, SnyComboboxComponent, SnyDialogCloseDirective, SnyDialogContentDirective, SnyDialogDescriptionDirective, SnyDialogFooterDirective, SnyDialogHeaderDirective, SnyDialogRef, SnyDialogService, SnyDialogTitleDirective, SnyInputDirective, SnyLabelDirective, SnyLoaderComponent, SnyRadioDirective, SnySelectComponent, SnySheetCloseDirective, SnySheetContentDirective, SnySheetDescriptionDirective, SnySheetHeaderDirective, SnySheetRef, SnySheetService, SnySheetTitleDirective, SnySkeletonDirective, SnySliderComponent, SnySwitchComponent, SnyTableBodyDirective, SnyTableCaptionDirective, SnyTableCellDirective, SnyTableDirective, SnyTableFooterDirective, SnyTableHeadDirective, SnyTableHeaderDirective, SnyTableRowDirective, SnyTabsContentDirective, SnyTabsDirective, SnyTabsListDirective, SnyTabsTriggerDirective, SnyToastService, SnyToasterComponent, SnyToggleDirective, ThemeService, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, cardVariants, checkboxVariants, cn, comboboxTriggerVariants, inputVariants, labelVariants, loaderVariants, provideSonnyUI, radioVariants, selectTriggerVariants, skeletonVariants, sliderTrackVariants, switchTrackVariants, tableCellVariants, tableVariants, tabsListVariants, tabsTriggerVariants, toastVariants, toggleVariants };
|
|
2365
|
+
//# sourceMappingURL=sonny-ui-core.mjs.map
|