@styloviz/core 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 StyloViz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @styloviz/core
2
+
3
+ > Core utilities, services, directives and design tokens shared by every StyloViz component.
4
+
5
+ Part of the **StyloViz UI Kit** — a premium Angular 21 + Tailwind CSS 4 dashboard component library.
6
+
7
+ `@styloviz/core` is a **required peer dependency** of every free and Pro component. Install it once alongside any component — you rarely import from it directly.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @styloviz/core
13
+ ```
14
+
15
+ Requires `@angular/core` and `@angular/common` >= 21.
16
+
17
+ ## Documentation
18
+
19
+ https://styloviz.dev/docs
20
+
21
+ ## License
22
+
23
+ MIT
@@ -0,0 +1,245 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, inject, signal, effect, Injectable, ElementRef, Directive } from '@angular/core';
3
+
4
+ // ─── Token ────────────────────────────────────────────────────────────────────
5
+ const STYLOVIZ_CONFIG = new InjectionToken('StyloVizConfig');
6
+ // ─── Provider factory ─────────────────────────────────────────────────────────
7
+ /**
8
+ * Register StyloViz in your root app config.
9
+ *
10
+ * @example
11
+ * // app.config.ts
12
+ * import { provideStylviz } from '@styloviz/core';
13
+ *
14
+ * export const appConfig: ApplicationConfig = {
15
+ * providers: [
16
+ * provideStylviz({ licenseKey: 'SVZ-XXXX-XXXX-XXXX' })
17
+ * ]
18
+ * };
19
+ */
20
+ function provideStylviz(config = {}) {
21
+ return makeEnvironmentProviders([
22
+ { provide: STYLOVIZ_CONFIG, useValue: config },
23
+ ]);
24
+ }
25
+
26
+ const STORAGE_KEY = 'styloviz-theme';
27
+ /**
28
+ * ThemeService — Dark/Light mode manager for StyloViz components.
29
+ *
30
+ * Priority order on init: localStorage → provideStylviz colorScheme → OS preference → light.
31
+ *
32
+ * Usage:
33
+ * const theme = inject(ThemeService);
34
+ * theme.toggleTheme();
35
+ * theme.isDark(); // signal
36
+ */
37
+ class ThemeService {
38
+ config = inject(STYLOVIZ_CONFIG, { optional: true });
39
+ isDark = signal(this.resolveInitialTheme() === 'dark', ...(ngDevMode ? [{ debugName: "isDark" }] : /* istanbul ignore next */ []));
40
+ constructor() {
41
+ effect(() => {
42
+ this.applyTheme(this.isDark() ? 'dark' : 'light');
43
+ });
44
+ }
45
+ toggleTheme() {
46
+ this.setTheme(this.isDark() ? 'light' : 'dark');
47
+ }
48
+ setTheme(theme) {
49
+ if (theme === (this.isDark() ? 'dark' : 'light'))
50
+ return;
51
+ const doc = typeof document !== 'undefined'
52
+ ? document
53
+ : undefined;
54
+ const startViewTransition = doc?.startViewTransition;
55
+ // Instant switch when the API is unavailable or reduced motion is
56
+ // requested; the cross-fade itself adds no per-element transitions.
57
+ if (!startViewTransition || this.prefersReducedMotion()) {
58
+ this.isDark.set(theme === 'dark');
59
+ return;
60
+ }
61
+ startViewTransition.call(doc, () => {
62
+ this.isDark.set(theme === 'dark');
63
+ this.applyTheme(theme);
64
+ });
65
+ }
66
+ prefersReducedMotion() {
67
+ return (typeof window !== 'undefined' &&
68
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches);
69
+ }
70
+ resolveInitialTheme() {
71
+ if (typeof window === 'undefined')
72
+ return 'light';
73
+ // 1. localStorage (user's last explicit choice)
74
+ const stored = localStorage.getItem(STORAGE_KEY);
75
+ if (stored === 'dark' || stored === 'light')
76
+ return stored;
77
+ // 2. provideStylviz colorScheme config
78
+ const scheme = this.config?.colorScheme;
79
+ if (scheme === 'dark')
80
+ return 'dark';
81
+ if (scheme === 'light')
82
+ return 'light';
83
+ // 3. OS preference
84
+ return window.matchMedia('(prefers-color-scheme: dark)').matches
85
+ ? 'dark'
86
+ : 'light';
87
+ }
88
+ applyTheme(theme) {
89
+ if (typeof document === 'undefined')
90
+ return;
91
+ const html = document.documentElement;
92
+ html.classList.toggle('dark', theme === 'dark');
93
+ html.classList.toggle('light', theme === 'light');
94
+ localStorage.setItem(STORAGE_KEY, theme);
95
+ }
96
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
97
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ThemeService, providedIn: 'root' });
98
+ }
99
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ThemeService, decorators: [{
100
+ type: Injectable,
101
+ args: [{ providedIn: 'root' }]
102
+ }], ctorParameters: () => [] });
103
+
104
+ // ─── Service ─────────────────────────────────────────────────────────────────
105
+ let _idCounter = 0;
106
+ class ToastService {
107
+ toasts = signal([], ...(ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []));
108
+ /** Active auto-dismiss timers keyed by toast id (enables pause/resume). */
109
+ timers = new Map();
110
+ success(message, opts) {
111
+ return this.show('success', message, opts);
112
+ }
113
+ error(message, opts) {
114
+ return this.show('error', message, { duration: 6000, ...opts });
115
+ }
116
+ warning(message, opts) {
117
+ return this.show('warning', message, opts);
118
+ }
119
+ info(message, opts) {
120
+ return this.show('info', message, opts);
121
+ }
122
+ show(variant, message, opts = {}) {
123
+ const id = `svz-toast-${++_idCounter}`;
124
+ const toast = {
125
+ id,
126
+ variant,
127
+ message,
128
+ title: opts.title,
129
+ duration: opts.duration ?? 4000,
130
+ dismissible: opts.dismissible ?? true,
131
+ action: opts.action,
132
+ position: opts.position ?? 'top-right',
133
+ };
134
+ this.toasts.update(list => [...list, toast]);
135
+ if (toast.duration > 0) {
136
+ this.startTimer(id, toast.duration);
137
+ }
138
+ return id;
139
+ }
140
+ dismiss(id) {
141
+ this.clearTimer(id);
142
+ this.toasts.update(list => list.filter(t => t.id !== id));
143
+ }
144
+ dismissAll() {
145
+ this.timers.forEach(t => clearTimeout(t.handle));
146
+ this.timers.clear();
147
+ this.toasts.set([]);
148
+ }
149
+ /**
150
+ * Pause a toast's auto-dismiss countdown (e.g. while the pointer hovers the
151
+ * stack), preserving the time that was left. No-op for persistent toasts.
152
+ */
153
+ pause(id) {
154
+ const timer = this.timers.get(id);
155
+ if (!timer)
156
+ return;
157
+ clearTimeout(timer.handle);
158
+ timer.remaining -= Date.now() - timer.startedAt;
159
+ // Keep the entry (with no live handle) so resume() can restart it.
160
+ this.timers.set(id, { ...timer, handle: undefined });
161
+ }
162
+ /** Resume a previously paused auto-dismiss countdown with its remaining time. */
163
+ resume(id) {
164
+ const timer = this.timers.get(id);
165
+ if (!timer || timer.handle)
166
+ return;
167
+ this.startTimer(id, Math.max(timer.remaining, 0));
168
+ }
169
+ // ── Internal timer helpers ──────────────────────────────────────────────────
170
+ startTimer(id, duration) {
171
+ const handle = setTimeout(() => this.dismiss(id), duration);
172
+ this.timers.set(id, { handle, remaining: duration, startedAt: Date.now() });
173
+ }
174
+ clearTimer(id) {
175
+ const timer = this.timers.get(id);
176
+ if (timer?.handle)
177
+ clearTimeout(timer.handle);
178
+ this.timers.delete(id);
179
+ }
180
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
181
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ToastService, providedIn: 'root' });
182
+ }
183
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: ToastService, decorators: [{
184
+ type: Injectable,
185
+ args: [{ providedIn: 'root' }]
186
+ }] });
187
+
188
+ /**
189
+ * SvChartAnimDirective — Viewport-aware chart animation trigger.
190
+ *
191
+ * Attach `svChartAnim` to the root wrapper of any StyloViz chart.
192
+ * Uses IntersectionObserver to add `.sv-animate` once the chart
193
+ * enters the viewport (threshold 10%), triggering CSS bar-grow animations.
194
+ *
195
+ * @example
196
+ * ```html
197
+ * <div svChartAnim class="flex flex-col gap-3">
198
+ * <!-- chart content -->
199
+ * </div>
200
+ * ```
201
+ */
202
+ class SvChartAnimDirective {
203
+ el = inject((ElementRef));
204
+ observer;
205
+ ngOnInit() {
206
+ this.observer = new IntersectionObserver((entries) => {
207
+ entries.forEach((entry) => {
208
+ if (entry.isIntersecting) {
209
+ requestAnimationFrame(() => {
210
+ entry.target.classList.add('sv-animate');
211
+ });
212
+ this.observer?.unobserve(entry.target);
213
+ }
214
+ });
215
+ }, { threshold: 0.1 });
216
+ this.observer.observe(this.el.nativeElement);
217
+ }
218
+ ngOnDestroy() {
219
+ this.observer?.disconnect();
220
+ }
221
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: SvChartAnimDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
222
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.13", type: SvChartAnimDirective, isStandalone: true, selector: "[svChartAnim]", ngImport: i0 });
223
+ }
224
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: SvChartAnimDirective, decorators: [{
225
+ type: Directive,
226
+ args: [{
227
+ selector: '[svChartAnim]',
228
+ standalone: true,
229
+ }]
230
+ }] });
231
+
232
+ /**
233
+ * @styloviz/core — Public API
234
+ *
235
+ * All exports from this file are part of the public API surface.
236
+ * Do not import from internal paths — always use '@styloviz/core'.
237
+ */
238
+ // Token + provider
239
+
240
+ /**
241
+ * Generated bundle index. Do not edit.
242
+ */
243
+
244
+ export { STYLOVIZ_CONFIG, SvChartAnimDirective, ThemeService, ToastService, provideStylviz };
245
+ //# sourceMappingURL=styloviz-core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styloviz-core.mjs","sources":["../../../../projects/core/src/lib/tokens/styloviz.token.ts","../../../../projects/core/src/lib/services/theme.service.ts","../../../../projects/core/src/lib/services/toast.service.ts","../../../../projects/core/src/lib/directives/chart-animate.directive.ts","../../../../projects/core/src/public-api.ts","../../../../projects/core/src/styloviz-core.ts"],"sourcesContent":["import {\n InjectionToken,\n makeEnvironmentProviders,\n EnvironmentProviders,\n} from '@angular/core';\n\n// ─── Config interface ─────────────────────────────────────────────────────────\n\nexport interface StyloVizConfig {\n /**\n * License key — required for premium components.\n * Obtain from https://styloviz.dev/license after purchase.\n */\n readonly licenseKey?: string;\n\n /**\n * Default color scheme applied on app start.\n * Defaults to 'system' (reads OS preference).\n */\n readonly colorScheme?: 'light' | 'dark' | 'system';\n}\n\n// ─── Token ────────────────────────────────────────────────────────────────────\n\nexport const STYLOVIZ_CONFIG = new InjectionToken<StyloVizConfig>(\n 'StyloVizConfig'\n);\n\n// ─── Provider factory ─────────────────────────────────────────────────────────\n\n/**\n * Register StyloViz in your root app config.\n *\n * @example\n * // app.config.ts\n * import { provideStylviz } from '@styloviz/core';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideStylviz({ licenseKey: 'SVZ-XXXX-XXXX-XXXX' })\n * ]\n * };\n */\nexport function provideStylviz(config: StyloVizConfig = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: STYLOVIZ_CONFIG, useValue: config },\n ]);\n}\n","import { Injectable, signal, effect, inject } from '@angular/core';\nimport { STYLOVIZ_CONFIG } from '../tokens/styloviz.token';\n\nexport type Theme = 'light' | 'dark';\n\nconst STORAGE_KEY = 'styloviz-theme';\n\n/** Minimal typing for the View Transitions API (not yet in lib.dom). */\ntype ViewTransitionDocument = Document & {\n readonly startViewTransition?: (callback: () => void) => unknown;\n};\n\n/**\n * ThemeService — Dark/Light mode manager for StyloViz components.\n *\n * Priority order on init: localStorage → provideStylviz colorScheme → OS preference → light.\n *\n * Usage:\n * const theme = inject(ThemeService);\n * theme.toggleTheme();\n * theme.isDark(); // signal\n */\n@Injectable({ providedIn: 'root' })\nexport class ThemeService {\n private readonly config = inject(STYLOVIZ_CONFIG, { optional: true });\n\n readonly isDark = signal<boolean>(this.resolveInitialTheme() === 'dark');\n\n constructor() {\n effect(() => {\n this.applyTheme(this.isDark() ? 'dark' : 'light');\n });\n }\n\n toggleTheme(): void {\n this.setTheme(this.isDark() ? 'light' : 'dark');\n }\n\n setTheme(theme: Theme): void {\n if (theme === (this.isDark() ? 'dark' : 'light')) return;\n\n const doc =\n typeof document !== 'undefined'\n ? (document as ViewTransitionDocument)\n : undefined;\n const startViewTransition = doc?.startViewTransition;\n\n // Instant switch when the API is unavailable or reduced motion is\n // requested; the cross-fade itself adds no per-element transitions.\n if (!startViewTransition || this.prefersReducedMotion()) {\n this.isDark.set(theme === 'dark');\n return;\n }\n\n startViewTransition.call(doc, () => {\n this.isDark.set(theme === 'dark');\n this.applyTheme(theme);\n });\n }\n\n private prefersReducedMotion(): boolean {\n return (\n typeof window !== 'undefined' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n }\n\n private resolveInitialTheme(): Theme {\n if (typeof window === 'undefined') return 'light';\n\n // 1. localStorage (user's last explicit choice)\n const stored = localStorage.getItem(STORAGE_KEY) as Theme | null;\n if (stored === 'dark' || stored === 'light') return stored;\n\n // 2. provideStylviz colorScheme config\n const scheme = this.config?.colorScheme;\n if (scheme === 'dark') return 'dark';\n if (scheme === 'light') return 'light';\n\n // 3. OS preference\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n }\n\n private applyTheme(theme: Theme): void {\n if (typeof document === 'undefined') return;\n\n const html = document.documentElement;\n html.classList.toggle('dark', theme === 'dark');\n html.classList.toggle('light', theme === 'light');\n\n localStorage.setItem(STORAGE_KEY, theme);\n }\n}\n","import { Injectable, signal } from '@angular/core';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport type ToastVariant = 'success' | 'error' | 'warning' | 'info';\nexport type ToastPosition =\n | 'top-right' | 'top-left' | 'top-center'\n | 'bottom-right' | 'bottom-left' | 'bottom-center';\n\nexport interface ToastAction {\n readonly label: string;\n readonly callback: () => void;\n}\n\nexport interface Toast {\n readonly id: string;\n readonly variant: ToastVariant;\n readonly title?: string;\n readonly message: string;\n readonly duration: number; // ms — 0 = persist until dismissed\n readonly dismissible: boolean;\n readonly action?: ToastAction;\n readonly position: ToastPosition;\n}\n\nexport interface ToastOptions {\n readonly title?: string;\n readonly duration?: number;\n readonly dismissible?: boolean;\n readonly action?: ToastAction;\n readonly position?: ToastPosition;\n}\n\n// ─── Service ─────────────────────────────────────────────────────────────────\n\nlet _idCounter = 0;\n\n/**\n * ToastService — Imperative notification API.\n *\n * Inject anywhere and call convenience methods:\n * toast.success('Saved!');\n * toast.error('Failed', { title: 'Error', duration: 0 });\n *\n * Pair with `<sv-toast-host>` from `@styloviz/toast` in your root layout.\n */\ninterface ToastTimer {\n handle: ReturnType<typeof setTimeout>;\n /** ms remaining when the timer was last (re)started. */\n remaining: number;\n /** wall-clock time the timer was last started. */\n startedAt: number;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class ToastService {\n readonly toasts = signal<Toast[]>([]);\n\n /** Active auto-dismiss timers keyed by toast id (enables pause/resume). */\n private readonly timers = new Map<string, ToastTimer>();\n\n success(message: string, opts?: ToastOptions): string {\n return this.show('success', message, opts);\n }\n\n error(message: string, opts?: ToastOptions): string {\n return this.show('error', message, { duration: 6000, ...opts });\n }\n\n warning(message: string, opts?: ToastOptions): string {\n return this.show('warning', message, opts);\n }\n\n info(message: string, opts?: ToastOptions): string {\n return this.show('info', message, opts);\n }\n\n show(variant: ToastVariant, message: string, opts: ToastOptions = {}): string {\n const id = `svz-toast-${++_idCounter}`;\n const toast: Toast = {\n id,\n variant,\n message,\n title: opts.title,\n duration: opts.duration ?? 4000,\n dismissible: opts.dismissible ?? true,\n action: opts.action,\n position: opts.position ?? 'top-right',\n };\n\n this.toasts.update(list => [...list, toast]);\n\n if (toast.duration > 0) {\n this.startTimer(id, toast.duration);\n }\n\n return id;\n }\n\n dismiss(id: string): void {\n this.clearTimer(id);\n this.toasts.update(list => list.filter(t => t.id !== id));\n }\n\n dismissAll(): void {\n this.timers.forEach(t => clearTimeout(t.handle));\n this.timers.clear();\n this.toasts.set([]);\n }\n\n /**\n * Pause a toast's auto-dismiss countdown (e.g. while the pointer hovers the\n * stack), preserving the time that was left. No-op for persistent toasts.\n */\n pause(id: string): void {\n const timer = this.timers.get(id);\n if (!timer) return;\n clearTimeout(timer.handle);\n timer.remaining -= Date.now() - timer.startedAt;\n // Keep the entry (with no live handle) so resume() can restart it.\n this.timers.set(id, { ...timer, handle: undefined as unknown as ReturnType<typeof setTimeout> });\n }\n\n /** Resume a previously paused auto-dismiss countdown with its remaining time. */\n resume(id: string): void {\n const timer = this.timers.get(id);\n if (!timer || timer.handle) return;\n this.startTimer(id, Math.max(timer.remaining, 0));\n }\n\n // ── Internal timer helpers ──────────────────────────────────────────────────\n\n private startTimer(id: string, duration: number): void {\n const handle = setTimeout(() => this.dismiss(id), duration);\n this.timers.set(id, { handle, remaining: duration, startedAt: Date.now() });\n }\n\n private clearTimer(id: string): void {\n const timer = this.timers.get(id);\n if (timer?.handle) clearTimeout(timer.handle);\n this.timers.delete(id);\n }\n}\n","import {\n Directive,\n ElementRef,\n OnDestroy,\n OnInit,\n inject,\n} from '@angular/core';\n\n/**\n * SvChartAnimDirective — Viewport-aware chart animation trigger.\n *\n * Attach `svChartAnim` to the root wrapper of any StyloViz chart.\n * Uses IntersectionObserver to add `.sv-animate` once the chart\n * enters the viewport (threshold 10%), triggering CSS bar-grow animations.\n *\n * @example\n * ```html\n * <div svChartAnim class=\"flex flex-col gap-3\">\n * <!-- chart content -->\n * </div>\n * ```\n */\n@Directive({\n selector: '[svChartAnim]',\n standalone: true,\n})\nexport class SvChartAnimDirective implements OnInit, OnDestroy {\n private readonly el = inject(ElementRef<HTMLElement>);\n private observer?: IntersectionObserver;\n\n ngOnInit(): void {\n this.observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n requestAnimationFrame(() => {\n (entry.target as HTMLElement).classList.add('sv-animate');\n });\n this.observer?.unobserve(entry.target);\n }\n });\n },\n { threshold: 0.1 }\n );\n\n this.observer.observe(this.el.nativeElement);\n }\n\n ngOnDestroy(): void {\n this.observer?.disconnect();\n }\n}\n","/**\n * @styloviz/core — Public API\n *\n * All exports from this file are part of the public API surface.\n * Do not import from internal paths — always use '@styloviz/core'.\n */\n\n// Token + provider\nexport { STYLOVIZ_CONFIG, provideStylviz } from './lib/tokens/styloviz.token';\nexport type { StyloVizConfig } from './lib/tokens/styloviz.token';\n\n// Services\nexport { ThemeService } from './lib/services/theme.service';\nexport type { Theme } from './lib/services/theme.service';\n\nexport { ToastService } from './lib/services/toast.service';\nexport type {\n Toast,\n ToastVariant,\n ToastPosition,\n ToastAction,\n ToastOptions,\n} from './lib/services/toast.service';\n\n// Directives\nexport { SvChartAnimDirective } from './lib/directives/chart-animate.directive';\n\n// Models\nexport type {\n NavChild,\n NavChildGroup,\n MenuItem,\n MenuGroup,\n} from './lib/models/nav.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAsBA;MAEa,eAAe,GAAG,IAAI,cAAc,CAC/C,gBAAgB;AAGlB;AAEA;;;;;;;;;;;;AAYG;AACG,SAAU,cAAc,CAAC,MAAA,GAAyB,EAAE,EAAA;AACxD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC/C,KAAA,CAAC;AACJ;;AC1CA,MAAM,WAAW,GAAG,gBAAgB;AAOpC;;;;;;;;;AASG;MAEU,YAAY,CAAA;IACN,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAE5D,MAAM,GAAG,MAAM,CAAU,IAAI,CAAC,mBAAmB,EAAE,KAAK,MAAM,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,QAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAExE,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC;AACnD,QAAA,CAAC,CAAC;IACJ;IAEA,WAAW,GAAA;AACT,QAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,GAAG,MAAM,CAAC;IACjD;AAEA,IAAA,QAAQ,CAAC,KAAY,EAAA;AACnB,QAAA,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC;YAAE;AAElD,QAAA,MAAM,GAAG,GACP,OAAO,QAAQ,KAAK;AAClB,cAAG;cACD,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AA,CAAA;;4FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;;;ACzBD;;;;;AAKG;AAEH;;ACPA;;AAEG;;;;"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@styloviz/core",
3
+ "version": "0.1.1",
4
+ "description": "StyloViz UI Kit — core utilities, services, directives and design tokens shared by every component.",
5
+ "keywords": [
6
+ "angular",
7
+ "tailwind",
8
+ "ui-kit",
9
+ "dashboard",
10
+ "styloviz"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "sazzad-bs23",
14
+ "homepage": "https://styloviz.dev",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/rhossain/angular-tailwind-dashboard-components.git",
18
+ "directory": "projects/core"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/rhossain/angular-tailwind-dashboard-components/issues"
22
+ },
23
+ "peerDependencies": {
24
+ "@angular/common": ">=21.0.0",
25
+ "@angular/core": ">=21.0.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "engines": {
31
+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"
32
+ },
33
+ "sideEffects": false,
34
+ "module": "fesm2022/styloviz-core.mjs",
35
+ "typings": "types/styloviz-core.d.ts",
36
+ "exports": {
37
+ "./package.json": {
38
+ "default": "./package.json"
39
+ },
40
+ ".": {
41
+ "types": "./types/styloviz-core.d.ts",
42
+ "default": "./fesm2022/styloviz-core.mjs"
43
+ }
44
+ },
45
+ "type": "module",
46
+ "dependencies": {
47
+ "tslib": "^2.3.0"
48
+ }
49
+ }
@@ -0,0 +1,161 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders, OnInit, OnDestroy } from '@angular/core';
3
+
4
+ interface StyloVizConfig {
5
+ /**
6
+ * License key — required for premium components.
7
+ * Obtain from https://styloviz.dev/license after purchase.
8
+ */
9
+ readonly licenseKey?: string;
10
+ /**
11
+ * Default color scheme applied on app start.
12
+ * Defaults to 'system' (reads OS preference).
13
+ */
14
+ readonly colorScheme?: 'light' | 'dark' | 'system';
15
+ }
16
+ declare const STYLOVIZ_CONFIG: InjectionToken<StyloVizConfig>;
17
+ /**
18
+ * Register StyloViz in your root app config.
19
+ *
20
+ * @example
21
+ * // app.config.ts
22
+ * import { provideStylviz } from '@styloviz/core';
23
+ *
24
+ * export const appConfig: ApplicationConfig = {
25
+ * providers: [
26
+ * provideStylviz({ licenseKey: 'SVZ-XXXX-XXXX-XXXX' })
27
+ * ]
28
+ * };
29
+ */
30
+ declare function provideStylviz(config?: StyloVizConfig): EnvironmentProviders;
31
+
32
+ type Theme = 'light' | 'dark';
33
+ /**
34
+ * ThemeService — Dark/Light mode manager for StyloViz components.
35
+ *
36
+ * Priority order on init: localStorage → provideStylviz colorScheme → OS preference → light.
37
+ *
38
+ * Usage:
39
+ * const theme = inject(ThemeService);
40
+ * theme.toggleTheme();
41
+ * theme.isDark(); // signal
42
+ */
43
+ declare class ThemeService {
44
+ private readonly config;
45
+ readonly isDark: i0.WritableSignal<boolean>;
46
+ constructor();
47
+ toggleTheme(): void;
48
+ setTheme(theme: Theme): void;
49
+ private prefersReducedMotion;
50
+ private resolveInitialTheme;
51
+ private applyTheme;
52
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
53
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
54
+ }
55
+
56
+ type ToastVariant = 'success' | 'error' | 'warning' | 'info';
57
+ type ToastPosition = 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center';
58
+ interface ToastAction {
59
+ readonly label: string;
60
+ readonly callback: () => void;
61
+ }
62
+ interface Toast {
63
+ readonly id: string;
64
+ readonly variant: ToastVariant;
65
+ readonly title?: string;
66
+ readonly message: string;
67
+ readonly duration: number;
68
+ readonly dismissible: boolean;
69
+ readonly action?: ToastAction;
70
+ readonly position: ToastPosition;
71
+ }
72
+ interface ToastOptions {
73
+ readonly title?: string;
74
+ readonly duration?: number;
75
+ readonly dismissible?: boolean;
76
+ readonly action?: ToastAction;
77
+ readonly position?: ToastPosition;
78
+ }
79
+ declare class ToastService {
80
+ readonly toasts: i0.WritableSignal<Toast[]>;
81
+ /** Active auto-dismiss timers keyed by toast id (enables pause/resume). */
82
+ private readonly timers;
83
+ success(message: string, opts?: ToastOptions): string;
84
+ error(message: string, opts?: ToastOptions): string;
85
+ warning(message: string, opts?: ToastOptions): string;
86
+ info(message: string, opts?: ToastOptions): string;
87
+ show(variant: ToastVariant, message: string, opts?: ToastOptions): string;
88
+ dismiss(id: string): void;
89
+ dismissAll(): void;
90
+ /**
91
+ * Pause a toast's auto-dismiss countdown (e.g. while the pointer hovers the
92
+ * stack), preserving the time that was left. No-op for persistent toasts.
93
+ */
94
+ pause(id: string): void;
95
+ /** Resume a previously paused auto-dismiss countdown with its remaining time. */
96
+ resume(id: string): void;
97
+ private startTimer;
98
+ private clearTimer;
99
+ static ɵfac: i0.ɵɵFactoryDeclaration<ToastService, never>;
100
+ static ɵprov: i0.ɵɵInjectableDeclaration<ToastService>;
101
+ }
102
+
103
+ /**
104
+ * SvChartAnimDirective — Viewport-aware chart animation trigger.
105
+ *
106
+ * Attach `svChartAnim` to the root wrapper of any StyloViz chart.
107
+ * Uses IntersectionObserver to add `.sv-animate` once the chart
108
+ * enters the viewport (threshold 10%), triggering CSS bar-grow animations.
109
+ *
110
+ * @example
111
+ * ```html
112
+ * <div svChartAnim class="flex flex-col gap-3">
113
+ * <!-- chart content -->
114
+ * </div>
115
+ * ```
116
+ */
117
+ declare class SvChartAnimDirective implements OnInit, OnDestroy {
118
+ private readonly el;
119
+ private observer?;
120
+ ngOnInit(): void;
121
+ ngOnDestroy(): void;
122
+ static ɵfac: i0.ɵɵFactoryDeclaration<SvChartAnimDirective, never>;
123
+ static ɵdir: i0.ɵɵDirectiveDeclaration<SvChartAnimDirective, "[svChartAnim]", never, {}, {}, never, never, true, never>;
124
+ }
125
+
126
+ /**
127
+ * Navigation models — shared types for sidebar and topbar components.
128
+ */
129
+ /** A single leaf item inside a child-navigation group. */
130
+ interface NavChild {
131
+ readonly id: string;
132
+ readonly label: string;
133
+ }
134
+ /** A named group of leaf items used for sidebar sub-navigation. */
135
+ interface NavChildGroup {
136
+ readonly label: string;
137
+ readonly items: NavChild[];
138
+ }
139
+ interface MenuItem {
140
+ /** Display label shown in the sidebar */
141
+ readonly label: string;
142
+ /** Angular router path (e.g., '/analytics') */
143
+ readonly route: string;
144
+ /** SVG icon path (`d` attribute) */
145
+ readonly icon: string;
146
+ /** Optional badge text shown next to the label (e.g. "New", "3") */
147
+ readonly badge?: string;
148
+ /** Badge color variant */
149
+ readonly badgeColor?: 'primary' | 'accent' | 'warning' | 'danger';
150
+ /** Optional sub-navigation groups rendered below this item when active */
151
+ readonly childGroups?: NavChildGroup[];
152
+ }
153
+ interface MenuGroup {
154
+ /** Group heading displayed above the menu items */
155
+ readonly groupLabel: string;
156
+ /** Menu items within this group */
157
+ readonly items: MenuItem[];
158
+ }
159
+
160
+ export { STYLOVIZ_CONFIG, SvChartAnimDirective, ThemeService, ToastService, provideStylviz };
161
+ export type { MenuGroup, MenuItem, NavChild, NavChildGroup, StyloVizConfig, Theme, Toast, ToastAction, ToastOptions, ToastPosition, ToastVariant };