@dataengineeringformachinelearning/viking-ui 3.0.0-alpha.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +55 -12
  3. package/dist/LICENSE +201 -0
  4. package/dist/README.md +251 -0
  5. package/dist/fesm2022/dataengineeringformachinelearning-viking-ui.mjs +13751 -0
  6. package/dist/fesm2022/dataengineeringformachinelearning-viking-ui.mjs.map +1 -0
  7. package/dist/index.js +1 -4051
  8. package/dist/package.json +87 -0
  9. package/dist/scripts/build-web-components.mjs +37 -0
  10. package/dist/src/tokens/series-presets.ts +15 -0
  11. package/dist/src/tokens/tailwind.preset.js +209 -0
  12. package/dist/src/tokens/viking-tokens.json +318 -0
  13. package/dist/src/web/badge/viking-badge-wc.ts +116 -0
  14. package/dist/src/web/button/viking-button-wc.ts +165 -0
  15. package/dist/src/web/callout/viking-callout-wc.ts +105 -0
  16. package/dist/src/web/card/viking-card-wc.ts +66 -0
  17. package/dist/src/web/core/base.ts +56 -0
  18. package/dist/src/web/core/dom.ts +53 -0
  19. package/dist/src/web/core/icons-inline.ts +44 -0
  20. package/dist/src/web/core/styles.ts +1138 -0
  21. package/dist/src/web/core/types.ts +19 -0
  22. package/dist/src/web/field/viking-field-wc.ts +154 -0
  23. package/dist/src/web/index.ts +73 -0
  24. package/dist/src/web/input/viking-input-wc.ts +211 -0
  25. package/dist/src/web/modal/viking-modal-wc.ts +187 -0
  26. package/dist/src/web/search-palette/viking-search-palette-wc.ts +494 -0
  27. package/dist/src/web/select/viking-select-wc.ts +218 -0
  28. package/dist/src/web/suite-header/viking-suite-header-wc.ts +714 -0
  29. package/dist/src/web/suite-search-palette/viking-suite-search-palette-wc.ts +234 -0
  30. package/dist/src/web/theme-toggle/viking-theme-toggle-wc.ts +139 -0
  31. package/dist/src/web/types.ts +37 -0
  32. package/dist/src/web/web-components.spec.ts +297 -0
  33. package/dist/types/dataengineeringformachinelearning-viking-ui.d.ts +2658 -0
  34. package/dist/viking.manifest.json +271 -0
  35. package/dist/web-components.js +2427 -126
  36. package/package.json +25 -11
  37. package/src/assets/drakkar-favicon.svg +17 -0
  38. package/src/core/brand/deml-lockup.svg +5 -0
  39. package/src/core/brand/deml-mark-compact.svg +4 -0
  40. package/src/core/brand/deml-mark-filled.svg +3 -0
  41. package/src/core/brand/deml-mark-outline.svg +4 -0
  42. package/src/core/brand-icons.ts +62 -0
  43. package/src/core/icons.spec.ts +52 -0
  44. package/src/core/icons.ts +206 -0
  45. package/src/core/integration-brand-icons.ts +77 -0
  46. package/src/core/lucide-paths.generated.ts +130 -0
  47. package/src/core/types.ts +85 -0
  48. package/src/core/uid.ts +7 -0
  49. package/src/lib/accordion/accordion.ts +126 -0
  50. package/src/lib/app-header/app-header.scss +274 -0
  51. package/src/lib/app-header/app-header.ts +43 -0
  52. package/src/lib/app-sidebar/app-sidebar.scss +415 -0
  53. package/src/lib/app-sidebar/app-sidebar.ts +29 -0
  54. package/src/lib/auth-panel/auth-panel.spec.ts +132 -0
  55. package/src/lib/auth-panel/auth-panel.ts +228 -0
  56. package/src/lib/autocomplete/autocomplete.ts +223 -0
  57. package/src/lib/avatar/avatar.ts +126 -0
  58. package/src/lib/badge/badge.ts +182 -0
  59. package/src/lib/bar/bar.ts +31 -0
  60. package/src/lib/brand/brand.ts +60 -0
  61. package/src/lib/breadcrumbs/breadcrumbs.ts +81 -0
  62. package/src/lib/button/button-group.ts +40 -0
  63. package/src/lib/button/button.scss +96 -0
  64. package/src/lib/button/button.ts +98 -0
  65. package/src/lib/calendar/calendar.ts +253 -0
  66. package/src/lib/callout/callout.ts +211 -0
  67. package/src/lib/card/card-title.spec.ts +27 -0
  68. package/src/lib/card/card-title.ts +50 -0
  69. package/src/lib/card/card.ts +170 -0
  70. package/src/lib/carousel/carousel.ts +206 -0
  71. package/src/lib/chart/chart-zoom.spec.ts +65 -0
  72. package/src/lib/chart/chart-zoom.ts +71 -0
  73. package/src/lib/chart/chart.ts +1257 -0
  74. package/src/lib/chart-card-header/chart-card-header.ts +80 -0
  75. package/src/lib/chart-empty-state/chart-empty-state.ts +146 -0
  76. package/src/lib/chart-panel/chart-panel.ts +133 -0
  77. package/src/lib/checkbox/checkbox.ts +139 -0
  78. package/src/lib/color-picker/color-picker.ts +148 -0
  79. package/src/lib/command/command.ts +260 -0
  80. package/src/lib/composer/composer.ts +180 -0
  81. package/src/lib/confirm-dialog/confirm-dialog.ts +163 -0
  82. package/src/lib/confirm-dialog/dialog.service.ts +79 -0
  83. package/src/lib/context/context.ts +75 -0
  84. package/src/lib/core/cva.ts +33 -0
  85. package/src/lib/date-picker/date-picker.ts +139 -0
  86. package/src/lib/dropdown/dropdown.ts +188 -0
  87. package/src/lib/editor/editor.ts +170 -0
  88. package/src/lib/empty-state/empty-state.ts +100 -0
  89. package/src/lib/fab/fab.ts +76 -0
  90. package/src/lib/field/field.ts +111 -0
  91. package/src/lib/file-upload/file-upload.ts +208 -0
  92. package/src/lib/footer/footer.scss +155 -0
  93. package/src/lib/footer/footer.ts +28 -0
  94. package/src/lib/form-section/form-section.ts +200 -0
  95. package/src/lib/forms.spec.ts +92 -0
  96. package/src/lib/gauge-arc/gauge-arc.ts +85 -0
  97. package/src/lib/hud-panel/hud-panel.ts +27 -0
  98. package/src/lib/icon/icon.ts +284 -0
  99. package/src/lib/icon-badge/icon-badge.ts +87 -0
  100. package/src/lib/icon-heading/icon-heading.spec.ts +32 -0
  101. package/src/lib/icon-heading/icon-heading.ts +38 -0
  102. package/src/lib/icon-text/icon-text.ts +120 -0
  103. package/src/lib/input/input.ts +119 -0
  104. package/src/lib/kanban/kanban.ts +211 -0
  105. package/src/lib/kbd/kbd.ts +32 -0
  106. package/src/lib/label/label.ts +39 -0
  107. package/src/lib/loading-overlay/loading-overlay.ts +80 -0
  108. package/src/lib/menubar/menubar.ts +77 -0
  109. package/src/lib/metric-card/metric-card.ts +33 -0
  110. package/src/lib/modal/modal.ts +207 -0
  111. package/src/lib/native-select/native-select.ts +124 -0
  112. package/src/lib/navbar/navbar.ts +124 -0
  113. package/src/lib/navigation-menu/navigation-menu.ts +116 -0
  114. package/src/lib/otp-input/otp-input.ts +164 -0
  115. package/src/lib/page-back-link/page-back-link.ts +74 -0
  116. package/src/lib/page-header/page-header.ts +70 -0
  117. package/src/lib/pagination/pagination.ts +157 -0
  118. package/src/lib/pillbox/pillbox.ts +157 -0
  119. package/src/lib/popover/popover.ts +92 -0
  120. package/src/lib/profile/profile.ts +73 -0
  121. package/src/lib/progress/progress.ts +123 -0
  122. package/src/lib/radio/radio.ts +132 -0
  123. package/src/lib/ring-gauge/ring-gauge.ts +75 -0
  124. package/src/lib/scroll-area/scroll-area.ts +57 -0
  125. package/src/lib/search-palette/search-palette.scss +288 -0
  126. package/src/lib/search-palette/search-palette.ts +114 -0
  127. package/src/lib/select/select.ts +292 -0
  128. package/src/lib/separator/separator.ts +59 -0
  129. package/src/lib/sheet/sheet.ts +192 -0
  130. package/src/lib/sidebar-nav/sidebar-nav.scss +218 -0
  131. package/src/lib/sidebar-nav/sidebar-nav.ts +158 -0
  132. package/src/lib/site-drakkar/site-footer.ts +129 -0
  133. package/src/lib/site-drakkar/site-navbar.scss +2 -0
  134. package/src/lib/site-drakkar/site-navbar.ts +267 -0
  135. package/src/lib/site-drakkar/suite-search-items.spec.ts +61 -0
  136. package/src/lib/skeleton/skeleton.ts +51 -0
  137. package/src/lib/slider/slider.ts +133 -0
  138. package/src/lib/spinner/spinner.ts +75 -0
  139. package/src/lib/status-metric-row/status-metric-row.ts +74 -0
  140. package/src/lib/suite-search-palette/suite-search-palette.ts +95 -0
  141. package/src/lib/switch/switch.ts +131 -0
  142. package/src/lib/table/table.ts +137 -0
  143. package/src/lib/tabs/tab-panel.ts +61 -0
  144. package/src/lib/tabs/tab.ts +107 -0
  145. package/src/lib/tabs/tabs.ts +109 -0
  146. package/src/lib/textarea/textarea.ts +103 -0
  147. package/src/lib/theme-toggle/theme-toggle.spec.ts +40 -0
  148. package/src/lib/theme-toggle/theme-toggle.ts +39 -0
  149. package/src/lib/time-picker/time-picker.ts +197 -0
  150. package/src/lib/timeline/timeline.ts +152 -0
  151. package/src/lib/toast/toast.ts +196 -0
  152. package/src/lib/toggle/toggle-group.ts +60 -0
  153. package/src/lib/toggle/toggle.ts +101 -0
  154. package/src/lib/tooltip/tooltip.ts +119 -0
  155. package/src/lib/typography/heading.ts +52 -0
  156. package/src/lib/typography/text.ts +51 -0
  157. package/src/lib/uptime-bar/uptime-bar.ts +55 -0
  158. package/src/lib/verification-code-field/verification-code-field.ts +149 -0
  159. package/src/lib/whitepaper-cta/whitepaper-cta.scss +130 -0
  160. package/src/lib/whitepaper-cta/whitepaper-cta.ts +78 -0
  161. package/src/lib/wizard/wizard.ts +80 -0
  162. package/src/public-api.ts +172 -0
  163. package/src/tokens/series-presets.ts +15 -0
  164. package/src/tokens/tailwind.preset.js +209 -0
  165. package/src/viking-ui.spec.ts +416 -0
  166. package/src/web/web-components.spec.ts +297 -0
  167. package/dist/elements/button/viking-button.d.ts +0 -14
  168. package/dist/elements/card/viking-card.d.ts +0 -8
  169. package/dist/elements/core/dom.d.ts +0 -4
  170. package/dist/elements/core/styles.d.ts +0 -2
  171. package/dist/elements/modal/viking-modal.d.ts +0 -15
  172. package/dist/index.d.ts +0 -1
  173. package/dist/lib/core/brand-icons.d.ts +0 -29
  174. package/dist/lib/core/icons.d.ts +0 -132
  175. package/dist/lib/core/integration-brand-icons.d.ts +0 -18
  176. package/dist/lib/core/lucide-paths.generated.d.ts +0 -90
  177. package/dist/lib/site-drakkar/site-drakkar.config.d.ts +0 -50
  178. package/dist/lib/site-drakkar/suite-search-items.d.ts +0 -17
  179. package/dist/web/badge/viking-badge-wc.d.ts +0 -28
  180. package/dist/web/button/viking-button-wc.d.ts +0 -28
  181. package/dist/web/callout/viking-callout-wc.d.ts +0 -27
  182. package/dist/web/card/viking-card-wc.d.ts +0 -29
  183. package/dist/web/core/base.d.ts +0 -12
  184. package/dist/web/core/dom.d.ts +0 -11
  185. package/dist/web/core/icons-inline.d.ts +0 -7
  186. package/dist/web/core/styles.d.ts +0 -12
  187. package/dist/web/core/types.d.ts +0 -10
  188. package/dist/web/field/viking-field-wc.d.ts +0 -32
  189. package/dist/web/index.d.ts +0 -15
  190. package/dist/web/input/viking-input-wc.d.ts +0 -32
  191. package/dist/web/modal/viking-modal-wc.d.ts +0 -50
  192. package/dist/web/search-palette/viking-search-palette-wc.d.ts +0 -64
  193. package/dist/web/select/viking-select-wc.d.ts +0 -48
  194. package/dist/web/suite-header/viking-suite-header-wc.d.ts +0 -36
  195. package/dist/web/suite-search-palette/viking-suite-search-palette-wc.d.ts +0 -39
  196. package/dist/web/theme-toggle/viking-theme-toggle-wc.d.ts +0 -19
  197. package/dist/web/types.d.ts +0 -40
  198. package/dist/web-components/index.d.ts +0 -1
@@ -0,0 +1,196 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ Injectable,
5
+ input,
6
+ signal,
7
+ } from "@angular/core";
8
+ import { VikingIcon } from "../icon/icon";
9
+ import { VikingIconName } from "../../core/icons";
10
+ import { VikingToastInstance, VikingToastOptions } from "../../core/types";
11
+
12
+ const TONE_ICONS: Record<string, VikingIconName> = {
13
+ accent: "info",
14
+ success: "check-circle",
15
+ warning: "alert-triangle",
16
+ danger: "alert-circle",
17
+ muted: "info",
18
+ };
19
+
20
+ /**
21
+ * VikingToastService — imperative toast API.
22
+ * Render a single <viking-toaster> outlet near the app root.
23
+ */
24
+ @Injectable({ providedIn: "root" })
25
+ export class VikingToastService {
26
+ private nextId = 1;
27
+ readonly toasts = signal<VikingToastInstance[]>([]);
28
+
29
+ readonly show = (options: VikingToastOptions): number => {
30
+ const toast: VikingToastInstance = {
31
+ id: this.nextId++,
32
+ heading: options.heading ?? "",
33
+ text: options.text,
34
+ tone: options.tone ?? "accent",
35
+ duration: options.duration ?? 4500,
36
+ };
37
+ this.toasts.update((list) => [...list, toast]);
38
+ if (toast.duration > 0) {
39
+ setTimeout(() => this.dismiss(toast.id), toast.duration);
40
+ }
41
+ return toast.id;
42
+ };
43
+
44
+ readonly dismiss = (id: number): void => {
45
+ this.toasts.update((list) => list.filter((toast) => toast.id !== id));
46
+ };
47
+ }
48
+
49
+ /**
50
+ * viking-toaster — fixed-position outlet that renders active toasts.
51
+ */
52
+ @Component({
53
+ selector: "viking-toaster",
54
+ imports: [VikingIcon],
55
+ changeDetection: ChangeDetectionStrategy.OnPush,
56
+ host: { "[class.viking-toaster-top]": "position() === 'top-end'" },
57
+ template: `
58
+ @for (toast of service.toasts(); track toast.id) {
59
+ <div
60
+ class="viking-toast"
61
+ [class]="'viking-toast-' + toast.tone"
62
+ role="status"
63
+ >
64
+ <viking-icon
65
+ class="viking-toast-icon"
66
+ [name]="toneIcon(toast.tone)"
67
+ [size]="20"
68
+ />
69
+ <div class="viking-toast-body">
70
+ @if (toast.heading) {
71
+ <p class="viking-toast-heading">{{ toast.heading }}</p>
72
+ }
73
+ <p class="viking-toast-text">{{ toast.text }}</p>
74
+ </div>
75
+ <button
76
+ type="button"
77
+ class="viking-toast-close"
78
+ aria-label="Dismiss notification"
79
+ (click)="service.dismiss(toast.id)"
80
+ >
81
+ <viking-icon name="x" [size]="16" />
82
+ </button>
83
+ </div>
84
+ }
85
+ `,
86
+ styles: [
87
+ `
88
+ :host {
89
+ position: fixed;
90
+ bottom: var(--viking-space-3);
91
+ right: var(--viking-space-3);
92
+ display: flex;
93
+ flex-direction: column;
94
+ gap: var(--viking-space-1);
95
+ z-index: var(--viking-z-toast);
96
+ max-width: min(414px, calc(100vw - var(--viking-space-4)));
97
+ }
98
+ @media (max-width: 767px) {
99
+ :host {
100
+ bottom: var(--viking-space-2);
101
+ right: var(--viking-space-2);
102
+ left: var(--viking-space-2);
103
+ max-width: none;
104
+ }
105
+ }
106
+ :host(.viking-toaster-top) {
107
+ bottom: auto;
108
+ top: var(--viking-space-3);
109
+ }
110
+ .viking-toast {
111
+ display: flex;
112
+ align-items: flex-start;
113
+ gap: var(--viking-space-1);
114
+ padding: var(--viking-space-2);
115
+ background: var(--viking-surface);
116
+ border: 1px solid var(--viking-border-strong);
117
+ border-radius: var(--viking-radius);
118
+ box-shadow: var(--viking-shadow-md);
119
+ font-family: var(--viking-font-family);
120
+ animation: viking-toast-in var(--viking-duration) var(--viking-ease-out);
121
+ }
122
+ @keyframes viking-toast-in {
123
+ from {
124
+ transform: translateY(var(--viking-space-1));
125
+ opacity: 0;
126
+ }
127
+ to {
128
+ transform: translateY(0);
129
+ opacity: 1;
130
+ }
131
+ }
132
+ @media (prefers-reduced-motion: reduce) {
133
+ .viking-toast {
134
+ animation: none;
135
+ }
136
+ }
137
+ .viking-toast-icon {
138
+ margin-top: 2px;
139
+ }
140
+ .viking-toast-accent .viking-toast-icon {
141
+ color: var(--viking-accent);
142
+ }
143
+ .viking-toast-success .viking-toast-icon {
144
+ color: var(--viking-success);
145
+ }
146
+ .viking-toast-warning .viking-toast-icon {
147
+ color: var(--viking-warning);
148
+ }
149
+ .viking-toast-danger .viking-toast-icon {
150
+ color: var(--viking-danger);
151
+ }
152
+ .viking-toast-body {
153
+ flex: 1;
154
+ min-width: 0;
155
+ }
156
+ .viking-toast-heading {
157
+ margin: 0;
158
+ font-size: var(--viking-font-size);
159
+ font-weight: 600;
160
+ color: var(--viking-text);
161
+ }
162
+ .viking-toast-text {
163
+ margin: 0;
164
+ font-size: var(--viking-font-size);
165
+ color: var(--viking-text-muted);
166
+ line-height: 1.45;
167
+ }
168
+ .viking-toast-close {
169
+ display: inline-flex;
170
+ border: none;
171
+ background: transparent;
172
+ color: var(--viking-text-muted);
173
+ cursor: pointer;
174
+ padding: var(--viking-space-half);
175
+ border-radius: var(--viking-radius-pill);
176
+ transition: var(--viking-transition-interactive);
177
+ }
178
+ .viking-toast-close:hover {
179
+ color: var(--viking-text);
180
+ background: var(--viking-accent-soft);
181
+ }
182
+ .viking-toast-close:focus-visible {
183
+ outline: var(--viking-ring-width) solid var(--viking-ring);
184
+ outline-offset: 1px;
185
+ }
186
+ `,
187
+ ],
188
+ })
189
+ export class VikingToaster {
190
+ readonly position = input<"bottom-end" | "top-end">("bottom-end");
191
+
192
+ constructor(protected readonly service: VikingToastService) {}
193
+
194
+ protected toneIcon = (tone: string): VikingIconName =>
195
+ TONE_ICONS[tone] ?? "info";
196
+ }
@@ -0,0 +1,60 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ InjectionToken,
5
+ model,
6
+ } from "@angular/core";
7
+
8
+ export const VIKING_TOGGLE_GROUP = new InjectionToken<VikingToggleGroup>(
9
+ "VIKING_TOGGLE_GROUP",
10
+ );
11
+
12
+ /**
13
+ * viking-toggle-group — exclusive or multi toggle cluster.
14
+ */
15
+ @Component({
16
+ selector: "viking-toggle-group",
17
+ changeDetection: ChangeDetectionStrategy.OnPush,
18
+ providers: [{ provide: VIKING_TOGGLE_GROUP, useExisting: VikingToggleGroup }],
19
+ host: {
20
+ role: "group",
21
+ class: "viking-toggle-group",
22
+ "[class.viking-exclusive]": "exclusive()",
23
+ },
24
+ template: `<ng-content />`,
25
+ styles: [
26
+ `
27
+ :host {
28
+ display: inline-flex;
29
+ flex-wrap: wrap;
30
+ gap: 0;
31
+ border: 1px solid var(--viking-border-strong);
32
+ border-radius: var(--viking-radius);
33
+ overflow: hidden;
34
+ box-shadow: var(--viking-shadow-sm);
35
+ }
36
+ :host ::ng-deep viking-toggle:not(:first-child) .viking-toggle {
37
+ border-left: none;
38
+ margin-left: -1px;
39
+ border-radius: 0;
40
+ }
41
+ :host ::ng-deep viking-toggle:first-child .viking-toggle {
42
+ border-top-right-radius: 0;
43
+ border-bottom-right-radius: 0;
44
+ }
45
+ :host ::ng-deep viking-toggle:last-child .viking-toggle {
46
+ border-top-left-radius: 0;
47
+ border-bottom-left-radius: 0;
48
+ }
49
+ :host ::ng-deep viking-toggle .viking-toggle {
50
+ min-width: var(--viking-btn-min-width, 120px);
51
+ border-radius: 0;
52
+ box-shadow: none;
53
+ }
54
+ `,
55
+ ],
56
+ })
57
+ export class VikingToggleGroup {
58
+ readonly value = model<string>("");
59
+ readonly exclusive = model(true);
60
+ }
@@ -0,0 +1,101 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ Optional,
5
+ input,
6
+ model,
7
+ output,
8
+ } from "@angular/core";
9
+ import { VIKING_TOGGLE_GROUP, VikingToggleGroup } from "./toggle-group";
10
+
11
+ /**
12
+ * viking-toggle — pressed-state button toggle.
13
+ */
14
+ @Component({
15
+ selector: "viking-toggle",
16
+ changeDetection: ChangeDetectionStrategy.OnPush,
17
+ template: `
18
+ <button
19
+ type="button"
20
+ class="viking-toggle"
21
+ [class.viking-pressed]="isPressed()"
22
+ [attr.aria-pressed]="isPressed()"
23
+ [disabled]="disabled()"
24
+ [attr.aria-label]="label() || null"
25
+ (click)="toggle()"
26
+ >
27
+ <ng-content />
28
+ </button>
29
+ `,
30
+ styles: [
31
+ `
32
+ :host {
33
+ display: inline-flex;
34
+ }
35
+ .viking-toggle {
36
+ font-family: var(--viking-font-family);
37
+ font-size: var(--viking-font-size-ui);
38
+ font-weight: 700;
39
+ display: inline-flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ gap: var(--viking-space-1);
43
+ min-height: var(--viking-control-height-sm);
44
+ min-width: var(--viking-btn-min-width, 120px);
45
+ padding: 0 var(--viking-space-2);
46
+ border: 1px solid var(--viking-border-strong);
47
+ border-radius: var(--viking-radius);
48
+ background: var(--viking-surface);
49
+ color: var(--viking-text);
50
+ cursor: pointer;
51
+ transition: var(--viking-transition);
52
+ }
53
+ .viking-toggle:hover:not(:disabled) {
54
+ border-color: var(--viking-accent-strong);
55
+ background: var(--viking-accent-soft);
56
+ }
57
+ .viking-toggle:focus-visible {
58
+ outline: var(--viking-ring-width) solid var(--viking-ring);
59
+ outline-offset: var(--viking-ring-offset);
60
+ }
61
+ .viking-toggle.viking-pressed {
62
+ background: var(--viking-accent);
63
+ border-color: var(--viking-accent);
64
+ color: var(--viking-accent-content);
65
+ }
66
+ .viking-toggle:disabled {
67
+ opacity: var(--viking-state-disabled-opacity);
68
+ cursor: not-allowed;
69
+ }
70
+ `,
71
+ ],
72
+ })
73
+ export class VikingToggle {
74
+ constructor(@Optional() private readonly group: VikingToggleGroup | null) {}
75
+
76
+ readonly pressed = model(false);
77
+ readonly value = input<string>("");
78
+ readonly disabled = input(false);
79
+ readonly label = input("");
80
+
81
+ readonly toggled = output<boolean>();
82
+
83
+ protected isPressed = (): boolean => {
84
+ if (this.group && this.value()) {
85
+ return this.group.value() === this.value();
86
+ }
87
+ return this.pressed();
88
+ };
89
+
90
+ protected toggle = (): void => {
91
+ if (this.disabled()) return;
92
+ if (this.group && this.value()) {
93
+ this.group.value.set(this.value());
94
+ this.toggled.emit(true);
95
+ return;
96
+ }
97
+ const next = !this.pressed();
98
+ this.pressed.set(next);
99
+ this.toggled.emit(next);
100
+ };
101
+ }
@@ -0,0 +1,119 @@
1
+ import {
2
+ DOCUMENT,
3
+ Directive,
4
+ ElementRef,
5
+ Inject,
6
+ OnDestroy,
7
+ input,
8
+ } from "@angular/core";
9
+
10
+ let tooltipIdCounter = 0;
11
+
12
+ /**
13
+ * vikingTooltip — attribute directive tooltip.
14
+ * Shows on hover and keyboard focus; positions itself relative to the host.
15
+ */
16
+ @Directive({
17
+ selector: "[vikingTooltip]",
18
+ host: {
19
+ class: "viking-tooltip-host viking-focus-ring",
20
+ "(mouseenter)": "show()",
21
+ "(mouseleave)": "hide()",
22
+ "(focusin)": "show()",
23
+ "(focusout)": "hide()",
24
+ "(keydown.escape)": "hide()",
25
+ "[attr.aria-describedby]": "visible() ? tooltipId : null",
26
+ },
27
+ })
28
+ export class VikingTooltip implements OnDestroy {
29
+ constructor(
30
+ private readonly host: ElementRef<HTMLElement>,
31
+ @Inject(DOCUMENT) private readonly document: Document,
32
+ ) {}
33
+
34
+ readonly vikingTooltip = input.required<string>();
35
+ readonly tooltipPosition = input<"top" | "bottom" | "left" | "right">("top");
36
+ readonly tooltipKbd = input<string>("");
37
+
38
+ protected readonly tooltipId = `viking-tooltip-${++tooltipIdCounter}`;
39
+
40
+ private element: HTMLElement | null = null;
41
+
42
+ protected visible = (): boolean => this.element !== null;
43
+
44
+ protected show = (): void => {
45
+ if (this.element || !this.vikingTooltip()) {
46
+ return;
47
+ }
48
+ const tip = this.document.createElement("div");
49
+ tip.id = this.tooltipId;
50
+ tip.setAttribute("role", "tooltip");
51
+ tip.className = "viking-tooltip";
52
+
53
+ const text = this.document.createElement("span");
54
+ text.className = "viking-tooltip-text";
55
+ text.textContent = this.vikingTooltip();
56
+ tip.appendChild(text);
57
+
58
+ if (this.tooltipKbd()) {
59
+ const kbd = this.document.createElement("kbd");
60
+ kbd.className = "viking-tooltip-kbd";
61
+ kbd.textContent = this.tooltipKbd();
62
+ tip.appendChild(kbd);
63
+ }
64
+
65
+ this.document.body.appendChild(tip);
66
+ this.position(tip);
67
+ this.element = tip;
68
+ };
69
+
70
+ private position = (tip: HTMLElement): void => {
71
+ const anchor = this.host.nativeElement.getBoundingClientRect();
72
+ const rect = tip.getBoundingClientRect();
73
+ const gap =
74
+ parseInt(
75
+ getComputedStyle(this.document.documentElement).getPropertyValue(
76
+ "--viking-space-1",
77
+ ),
78
+ 10,
79
+ ) || 8;
80
+ const edge =
81
+ parseInt(
82
+ getComputedStyle(this.document.documentElement).getPropertyValue(
83
+ "--viking-space-1",
84
+ ),
85
+ 10,
86
+ ) || 8;
87
+
88
+ let left = anchor.left + anchor.width / 2 - rect.width / 2;
89
+ let top = anchor.top - rect.height - gap;
90
+
91
+ switch (this.tooltipPosition()) {
92
+ case "bottom":
93
+ top = anchor.bottom + gap;
94
+ break;
95
+ case "left":
96
+ left = anchor.left - rect.width - gap;
97
+ top = anchor.top + anchor.height / 2 - rect.height / 2;
98
+ break;
99
+ case "right":
100
+ left = anchor.right + gap;
101
+ top = anchor.top + anchor.height / 2 - rect.height / 2;
102
+ break;
103
+ default:
104
+ break;
105
+ }
106
+
107
+ tip.style.left = `${Math.max(edge, Math.min(left, window.innerWidth - rect.width - edge))}px`;
108
+ tip.style.top = `${Math.max(edge, top)}px`;
109
+ };
110
+
111
+ protected hide = (): void => {
112
+ this.element?.remove();
113
+ this.element = null;
114
+ };
115
+
116
+ ngOnDestroy(): void {
117
+ this.hide();
118
+ }
119
+ }
@@ -0,0 +1,52 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ computed,
5
+ input,
6
+ } from "@angular/core";
7
+
8
+ /**
9
+ * viking-heading — consistent heading sizes.
10
+ */
11
+ @Component({
12
+ selector: "viking-heading",
13
+ changeDetection: ChangeDetectionStrategy.OnPush,
14
+ host: {
15
+ role: "heading",
16
+ "[attr.aria-level]": "ariaLevel()",
17
+ "[class]": "hostClass()",
18
+ },
19
+ template: `<ng-content />`,
20
+ styles: [
21
+ `
22
+ :host {
23
+ display: block;
24
+ font-family: var(--viking-font-family);
25
+ font-weight: 600;
26
+ color: var(--viking-text);
27
+ letter-spacing: var(--header-letter-spacing, -0.02em);
28
+ font-size: var(--viking-font-size-ui);
29
+ line-height: 1.25;
30
+ }
31
+ :host(.viking-heading-sm) {
32
+ font-size: var(--viking-font-size-sm);
33
+ }
34
+ :host(.viking-heading-lg) {
35
+ font-size: var(--viking-font-size);
36
+ }
37
+ :host(.viking-heading-xl) {
38
+ font-size: var(--viking-font-size-lg);
39
+ font-weight: 700;
40
+ }
41
+ `,
42
+ ],
43
+ })
44
+ export class VikingHeading {
45
+ readonly size = input<"sm" | "base" | "lg" | "xl">("base");
46
+ readonly level = input<1 | 2 | 3 | 4>(3);
47
+
48
+ protected readonly ariaLevel = computed(() => this.level());
49
+ protected readonly hostClass = computed(
50
+ () => `viking-heading-${this.size()}`,
51
+ );
52
+ }
@@ -0,0 +1,51 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ computed,
5
+ input,
6
+ } from "@angular/core";
7
+
8
+ /**
9
+ * viking-text — body text with semantic variants.
10
+ */
11
+ @Component({
12
+ selector: "viking-text",
13
+ changeDetection: ChangeDetectionStrategy.OnPush,
14
+ host: { "[class]": "hostClass()" },
15
+ template: `<ng-content />`,
16
+ styles: [
17
+ `
18
+ :host {
19
+ display: block;
20
+ font-family: var(--viking-font-family);
21
+ font-size: var(--viking-font-size);
22
+ line-height: 1.65;
23
+ color: var(--viking-text);
24
+ }
25
+ :host(.viking-text-inline) {
26
+ display: inline;
27
+ }
28
+ :host(.viking-text-muted) {
29
+ color: var(--viking-text-muted);
30
+ }
31
+ :host(.viking-text-strong) {
32
+ font-weight: 600;
33
+ }
34
+ :host(.viking-text-accent) {
35
+ color: var(--viking-accent);
36
+ font-weight: 500;
37
+ }
38
+ `,
39
+ ],
40
+ })
41
+ export class VikingText {
42
+ readonly variant = input<"default" | "muted" | "strong" | "accent">(
43
+ "default",
44
+ );
45
+ readonly inline = input<boolean>(false);
46
+
47
+ protected readonly hostClass = computed(() => ({
48
+ [`viking-text-${this.variant()}`]: this.variant() !== "default",
49
+ "viking-text-inline": this.inline(),
50
+ }));
51
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ computed,
5
+ input,
6
+ } from "@angular/core";
7
+
8
+ export type VikingUptimeStatus =
9
+ | "operational"
10
+ | "partial_outage"
11
+ | "major_outage"
12
+ | "no_data";
13
+
14
+ /** viking-uptime-bar — timeline bar for uptime history visualizations. */
15
+ @Component({
16
+ selector: "viking-uptime-bar",
17
+ changeDetection: ChangeDetectionStrategy.OnPush,
18
+ host: {
19
+ class: "viking-uptime-bar",
20
+ "[class.viking-uptime-partial]": "status() === 'partial_outage'",
21
+ "[class.viking-uptime-major]": "status() === 'major_outage'",
22
+ "[class.viking-uptime-nodata]": "status() === 'no_data'",
23
+ "[attr.title]": "title()",
24
+ },
25
+ template: "",
26
+ styles: [
27
+ `
28
+ :host {
29
+ display: block;
30
+ width: 100%;
31
+ height: 100%;
32
+ border-radius: var(--viking-radius);
33
+ background: var(--viking-success);
34
+ }
35
+ :host(.viking-uptime-partial) {
36
+ height: 70%;
37
+ align-self: flex-end;
38
+ background: var(--viking-warning);
39
+ }
40
+ :host(.viking-uptime-major) {
41
+ height: 40%;
42
+ align-self: flex-end;
43
+ background: var(--viking-danger);
44
+ }
45
+ :host(.viking-uptime-nodata) {
46
+ background: var(--viking-text-muted);
47
+ opacity: 0.35;
48
+ }
49
+ `,
50
+ ],
51
+ })
52
+ export class VikingUptimeBar {
53
+ readonly status = input<VikingUptimeStatus>("operational");
54
+ readonly title = input<string>("");
55
+ }