@dataengineeringformachinelearning/viking-ui 3.0.0-alpha.2 → 3.0.0-alpha.4
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 +201 -0
- package/README.md +52 -12
- package/dist/core/brand-icons.d.ts +29 -0
- package/dist/core/icons.d.ts +132 -0
- package/dist/core/integration-brand-icons.d.ts +18 -0
- package/dist/core/lucide-paths.generated.d.ts +90 -0
- package/dist/core/types.d.ts +56 -0
- package/dist/core/uid.d.ts +2 -0
- package/dist/lib/accordion/accordion.d.ts +19 -0
- package/dist/lib/app-header/app-header.d.ts +8 -0
- package/dist/lib/app-sidebar/app-sidebar.d.ts +10 -0
- package/dist/lib/auth-panel/auth-panel.d.ts +13 -0
- package/dist/lib/autocomplete/autocomplete.d.ts +25 -0
- package/dist/lib/avatar/avatar.d.ts +14 -0
- package/dist/lib/badge/badge.d.ts +16 -0
- package/dist/lib/bar/bar.d.ts +4 -0
- package/dist/lib/brand/brand.d.ts +8 -0
- package/dist/lib/breadcrumbs/breadcrumbs.d.ts +10 -0
- package/dist/lib/button/button-group.d.ts +6 -0
- package/dist/lib/button/button.d.ts +25 -0
- package/dist/lib/calendar/calendar.d.ts +22 -0
- package/dist/lib/callout/callout.d.ts +14 -0
- package/dist/lib/card/card-title.d.ts +12 -0
- package/dist/lib/card/card.d.ts +19 -0
- package/dist/lib/carousel/carousel.d.ts +13 -0
- package/dist/lib/chart/chart-zoom.d.ts +14 -0
- package/dist/lib/chart/chart.d.ts +119 -0
- package/dist/lib/chart-card-header/chart-card-header.d.ts +10 -0
- package/dist/lib/chart-empty-state/chart-empty-state.d.ts +13 -0
- package/dist/lib/chart-panel/chart-panel.d.ts +10 -0
- package/dist/lib/checkbox/checkbox.d.ts +13 -0
- package/dist/lib/color-picker/color-picker.d.ts +16 -0
- package/dist/lib/command/command.d.ts +23 -0
- package/dist/lib/composer/composer.d.ts +15 -0
- package/dist/lib/confirm-dialog/confirm-dialog.d.ts +18 -0
- package/dist/lib/confirm-dialog/dialog.service.d.ts +28 -0
- package/dist/lib/context/context.d.ts +17 -0
- package/dist/lib/core/cva.d.ts +15 -0
- package/dist/lib/date-picker/date-picker.d.ts +18 -0
- package/dist/lib/dropdown/dropdown.d.ts +29 -0
- package/dist/lib/editor/editor.d.ts +26 -0
- package/dist/lib/empty-state/empty-state.d.ts +9 -0
- package/dist/lib/fab/fab.d.ts +9 -0
- package/dist/lib/field/field.d.ts +14 -0
- package/dist/lib/file-upload/file-upload.d.ts +19 -0
- package/dist/lib/footer/footer.d.ts +6 -0
- package/dist/lib/form-section/form-section.d.ts +15 -0
- package/dist/lib/gauge-arc/gauge-arc.d.ts +8 -0
- package/dist/lib/hud-panel/hud-panel.d.ts +5 -0
- package/dist/lib/icon/icon.d.ts +44 -0
- package/dist/lib/icon-badge/icon-badge.d.ts +14 -0
- package/dist/lib/icon-heading/icon-heading.d.ts +9 -0
- package/dist/lib/icon-text/icon-text.d.ts +12 -0
- package/dist/lib/input/input.d.ts +23 -0
- package/dist/lib/kanban/kanban.d.ts +16 -0
- package/dist/lib/kbd/kbd.d.ts +5 -0
- package/dist/lib/label/label.d.ts +7 -0
- package/dist/lib/loading-overlay/loading-overlay.d.ts +10 -0
- package/dist/lib/menubar/menubar.d.ts +10 -0
- package/dist/lib/metric-card/metric-card.d.ts +9 -0
- package/dist/lib/modal/modal.d.ts +13 -0
- package/dist/lib/native-select/native-select.d.ts +17 -0
- package/dist/lib/navbar/navbar.d.ts +13 -0
- package/dist/lib/navigation-menu/navigation-menu.d.ts +13 -0
- package/dist/lib/otp-input/otp-input.d.ts +23 -0
- package/dist/lib/page-back-link/page-back-link.d.ts +11 -0
- package/dist/lib/page-header/page-header.d.ts +15 -0
- package/dist/lib/pagination/pagination.d.ts +10 -0
- package/dist/lib/pillbox/pillbox.d.ts +15 -0
- package/dist/lib/popover/popover.d.ts +15 -0
- package/dist/lib/profile/profile.d.ts +11 -0
- package/dist/lib/progress/progress.d.ts +12 -0
- package/dist/lib/radio/radio.d.ts +16 -0
- package/dist/lib/ring-gauge/ring-gauge.d.ts +8 -0
- package/dist/lib/scroll-area/scroll-area.d.ts +7 -0
- package/dist/lib/search-palette/search-palette.d.ts +16 -0
- package/dist/lib/select/select.d.ts +26 -0
- package/dist/lib/separator/separator.d.ts +8 -0
- package/dist/lib/sheet/sheet.d.ts +13 -0
- package/dist/lib/sidebar-nav/sidebar-nav.d.ts +46 -0
- package/dist/lib/site-drakkar/site-footer.d.ts +18 -0
- package/dist/lib/site-drakkar/site-navbar.d.ts +25 -0
- package/dist/lib/skeleton/skeleton.d.ts +8 -0
- package/dist/lib/slider/slider.d.ts +17 -0
- package/dist/lib/spinner/spinner.d.ts +7 -0
- package/dist/lib/status-metric-row/status-metric-row.d.ts +9 -0
- package/dist/lib/suite-search-palette/suite-search-palette.d.ts +25 -0
- package/dist/lib/switch/switch.d.ts +12 -0
- package/dist/lib/table/table.d.ts +10 -0
- package/dist/lib/tabs/tab-panel.d.ts +12 -0
- package/dist/lib/tabs/tab.d.ts +14 -0
- package/dist/lib/tabs/tabs.d.ts +10 -0
- package/dist/lib/textarea/textarea.d.ts +16 -0
- package/dist/lib/theme-toggle/theme-toggle.d.ts +9 -0
- package/dist/lib/time-picker/time-picker.d.ts +21 -0
- package/dist/lib/timeline/timeline.d.ts +14 -0
- package/dist/lib/toast/toast.d.ts +21 -0
- package/dist/lib/toggle/toggle-group.d.ts +9 -0
- package/dist/lib/toggle/toggle.d.ts +15 -0
- package/dist/lib/tooltip/tooltip.d.ts +20 -0
- package/dist/lib/typography/heading.d.ts +9 -0
- package/dist/lib/typography/text.d.ts +11 -0
- package/dist/lib/uptime-bar/uptime-bar.d.ts +6 -0
- package/dist/lib/verification-code-field/verification-code-field.d.ts +19 -0
- package/dist/lib/whitepaper-cta/whitepaper-cta.d.ts +15 -0
- package/dist/lib/wizard/wizard.d.ts +13 -0
- package/dist/public-api.d.ts +109 -0
- package/dist/tokens/series-presets.d.ts +4 -0
- package/package.json +1 -1
- package/src/assets/drakkar-favicon.svg +17 -0
- package/src/core/brand/deml-lockup.svg +5 -0
- package/src/core/brand/deml-mark-compact.svg +4 -0
- package/src/core/brand/deml-mark-filled.svg +3 -0
- package/src/core/brand/deml-mark-outline.svg +4 -0
- package/src/core/brand-icons.ts +62 -0
- package/src/core/icons.spec.ts +52 -0
- package/src/core/icons.ts +206 -0
- package/src/core/integration-brand-icons.ts +77 -0
- package/src/core/lucide-paths.generated.ts +130 -0
- package/src/core/types.ts +85 -0
- package/src/core/uid.ts +7 -0
- package/src/lib/accordion/accordion.ts +126 -0
- package/src/lib/app-header/app-header.scss +274 -0
- package/src/lib/app-header/app-header.ts +43 -0
- package/src/lib/app-sidebar/app-sidebar.scss +415 -0
- package/src/lib/app-sidebar/app-sidebar.ts +29 -0
- package/src/lib/auth-panel/auth-panel.spec.ts +132 -0
- package/src/lib/auth-panel/auth-panel.ts +228 -0
- package/src/lib/autocomplete/autocomplete.ts +223 -0
- package/src/lib/avatar/avatar.ts +126 -0
- package/src/lib/badge/badge.ts +182 -0
- package/src/lib/bar/bar.ts +31 -0
- package/src/lib/brand/brand.ts +60 -0
- package/src/lib/breadcrumbs/breadcrumbs.ts +81 -0
- package/src/lib/button/button-group.ts +40 -0
- package/src/lib/button/button.scss +96 -0
- package/src/lib/button/button.ts +98 -0
- package/src/lib/calendar/calendar.ts +253 -0
- package/src/lib/callout/callout.ts +211 -0
- package/src/lib/card/card-title.spec.ts +27 -0
- package/src/lib/card/card-title.ts +50 -0
- package/src/lib/card/card.ts +170 -0
- package/src/lib/carousel/carousel.ts +206 -0
- package/src/lib/chart/chart-zoom.spec.ts +65 -0
- package/src/lib/chart/chart-zoom.ts +71 -0
- package/src/lib/chart/chart.ts +1257 -0
- package/src/lib/chart-card-header/chart-card-header.ts +80 -0
- package/src/lib/chart-empty-state/chart-empty-state.ts +146 -0
- package/src/lib/chart-panel/chart-panel.ts +133 -0
- package/src/lib/checkbox/checkbox.ts +139 -0
- package/src/lib/color-picker/color-picker.ts +148 -0
- package/src/lib/command/command.ts +260 -0
- package/src/lib/composer/composer.ts +180 -0
- package/src/lib/confirm-dialog/confirm-dialog.ts +163 -0
- package/src/lib/confirm-dialog/dialog.service.ts +79 -0
- package/src/lib/context/context.ts +75 -0
- package/src/lib/core/cva.ts +33 -0
- package/src/lib/date-picker/date-picker.ts +139 -0
- package/src/lib/dropdown/dropdown.ts +188 -0
- package/src/lib/editor/editor.ts +170 -0
- package/src/lib/empty-state/empty-state.ts +100 -0
- package/src/lib/fab/fab.ts +76 -0
- package/src/lib/field/field.ts +111 -0
- package/src/lib/file-upload/file-upload.ts +208 -0
- package/src/lib/footer/footer.scss +155 -0
- package/src/lib/footer/footer.ts +28 -0
- package/src/lib/form-section/form-section.ts +200 -0
- package/src/lib/forms.spec.ts +92 -0
- package/src/lib/gauge-arc/gauge-arc.ts +85 -0
- package/src/lib/hud-panel/hud-panel.ts +27 -0
- package/src/lib/icon/icon.ts +284 -0
- package/src/lib/icon-badge/icon-badge.ts +87 -0
- package/src/lib/icon-heading/icon-heading.spec.ts +32 -0
- package/src/lib/icon-heading/icon-heading.ts +38 -0
- package/src/lib/icon-text/icon-text.ts +120 -0
- package/src/lib/input/input.ts +119 -0
- package/src/lib/kanban/kanban.ts +211 -0
- package/src/lib/kbd/kbd.ts +32 -0
- package/src/lib/label/label.ts +39 -0
- package/src/lib/loading-overlay/loading-overlay.ts +80 -0
- package/src/lib/menubar/menubar.ts +77 -0
- package/src/lib/metric-card/metric-card.ts +33 -0
- package/src/lib/modal/modal.ts +207 -0
- package/src/lib/native-select/native-select.ts +124 -0
- package/src/lib/navbar/navbar.ts +124 -0
- package/src/lib/navigation-menu/navigation-menu.ts +116 -0
- package/src/lib/otp-input/otp-input.ts +164 -0
- package/src/lib/page-back-link/page-back-link.ts +74 -0
- package/src/lib/page-header/page-header.ts +70 -0
- package/src/lib/pagination/pagination.ts +157 -0
- package/src/lib/pillbox/pillbox.ts +157 -0
- package/src/lib/popover/popover.ts +92 -0
- package/src/lib/profile/profile.ts +73 -0
- package/src/lib/progress/progress.ts +123 -0
- package/src/lib/radio/radio.ts +132 -0
- package/src/lib/ring-gauge/ring-gauge.ts +75 -0
- package/src/lib/scroll-area/scroll-area.ts +57 -0
- package/src/lib/search-palette/search-palette.scss +288 -0
- package/src/lib/search-palette/search-palette.ts +114 -0
- package/src/lib/select/select.ts +292 -0
- package/src/lib/separator/separator.ts +59 -0
- package/src/lib/sheet/sheet.ts +192 -0
- package/src/lib/sidebar-nav/sidebar-nav.scss +218 -0
- package/src/lib/sidebar-nav/sidebar-nav.ts +158 -0
- package/src/lib/site-drakkar/site-footer.ts +129 -0
- package/src/lib/site-drakkar/site-navbar.scss +2 -0
- package/src/lib/site-drakkar/site-navbar.ts +267 -0
- package/src/lib/site-drakkar/suite-search-items.spec.ts +61 -0
- package/src/lib/skeleton/skeleton.ts +51 -0
- package/src/lib/slider/slider.ts +133 -0
- package/src/lib/spinner/spinner.ts +75 -0
- package/src/lib/status-metric-row/status-metric-row.ts +74 -0
- package/src/lib/suite-search-palette/suite-search-palette.ts +95 -0
- package/src/lib/switch/switch.ts +131 -0
- package/src/lib/table/table.ts +137 -0
- package/src/lib/tabs/tab-panel.ts +61 -0
- package/src/lib/tabs/tab.ts +107 -0
- package/src/lib/tabs/tabs.ts +109 -0
- package/src/lib/textarea/textarea.ts +103 -0
- package/src/lib/theme-toggle/theme-toggle.spec.ts +40 -0
- package/src/lib/theme-toggle/theme-toggle.ts +39 -0
- package/src/lib/time-picker/time-picker.ts +197 -0
- package/src/lib/timeline/timeline.ts +152 -0
- package/src/lib/toast/toast.ts +196 -0
- package/src/lib/toggle/toggle-group.ts +60 -0
- package/src/lib/toggle/toggle.ts +101 -0
- package/src/lib/tooltip/tooltip.ts +119 -0
- package/src/lib/typography/heading.ts +52 -0
- package/src/lib/typography/text.ts +51 -0
- package/src/lib/uptime-bar/uptime-bar.ts +55 -0
- package/src/lib/verification-code-field/verification-code-field.ts +149 -0
- package/src/lib/whitepaper-cta/whitepaper-cta.scss +130 -0
- package/src/lib/whitepaper-cta/whitepaper-cta.ts +78 -0
- package/src/lib/wizard/wizard.ts +80 -0
- package/src/public-api.ts +172 -0
- package/src/tokens/series-presets.ts +15 -0
- package/src/tokens/tailwind.preset.js +209 -0
- package/src/viking-ui.spec.ts +416 -0
- package/src/web/web-components.spec.ts +297 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
CUSTOM_ELEMENTS_SCHEMA,
|
|
5
|
+
computed,
|
|
6
|
+
input,
|
|
7
|
+
output,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
import { VikingIcon } from "../icon/icon";
|
|
10
|
+
import { VikingIconName } from "../../core/icons";
|
|
11
|
+
import { VikingSize } from "../../core/types";
|
|
12
|
+
import { registerVikingElements } from "../../web/index";
|
|
13
|
+
|
|
14
|
+
registerVikingElements();
|
|
15
|
+
|
|
16
|
+
export type VikingButtonVariant =
|
|
17
|
+
| "outline"
|
|
18
|
+
| "primary"
|
|
19
|
+
| "secondary"
|
|
20
|
+
| "filled"
|
|
21
|
+
| "danger"
|
|
22
|
+
| "ghost"
|
|
23
|
+
| "subtle";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* viking-button — thin Angular wrapper around `viking-button-wc`.
|
|
27
|
+
* Variants: outline (default), primary, filled, danger, ghost, subtle.
|
|
28
|
+
*/
|
|
29
|
+
@Component({
|
|
30
|
+
selector: "viking-button",
|
|
31
|
+
imports: [VikingIcon],
|
|
32
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
33
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
34
|
+
host: {
|
|
35
|
+
"[style.pointer-events]": "disabled() ? 'none' : null",
|
|
36
|
+
"[class.viking-full]": "fullWidth()",
|
|
37
|
+
"[class.viking-compact]": "compact()",
|
|
38
|
+
},
|
|
39
|
+
template: `
|
|
40
|
+
<viking-button-wc
|
|
41
|
+
[attr.variant]="variant()"
|
|
42
|
+
[attr.size]="size() === 'base' ? null : size()"
|
|
43
|
+
[attr.type]="type()"
|
|
44
|
+
[attr.disabled]="disabled() || loading() ? '' : null"
|
|
45
|
+
[attr.aria-busy]="loading() ? 'true' : null"
|
|
46
|
+
[attr.href]="href()"
|
|
47
|
+
[attr.target]="target()"
|
|
48
|
+
[attr.aria-label]="label() || null"
|
|
49
|
+
[attr.square]="square() ? '' : null"
|
|
50
|
+
[attr.full-width]="fullWidth() ? '' : null"
|
|
51
|
+
[attr.compact]="compact() ? '' : null"
|
|
52
|
+
(viking-press)="onPress($event)"
|
|
53
|
+
>
|
|
54
|
+
@if (loading()) {
|
|
55
|
+
<viking-icon name="loader" [size]="iconSize()" [spin]="true" />
|
|
56
|
+
} @else if (icon()) {
|
|
57
|
+
<viking-icon [name]="icon()!" [size]="iconSize()" />
|
|
58
|
+
}
|
|
59
|
+
<span class="viking-btn-label"><ng-content /></span>
|
|
60
|
+
@if (iconTrailing()) {
|
|
61
|
+
<viking-icon [name]="iconTrailing()!" [size]="iconSize()" />
|
|
62
|
+
}
|
|
63
|
+
@if (kbd()) {
|
|
64
|
+
<kbd class="viking-btn-kbd">{{ kbd() }}</kbd>
|
|
65
|
+
}
|
|
66
|
+
</viking-button-wc>
|
|
67
|
+
`,
|
|
68
|
+
styleUrl: "./button.scss",
|
|
69
|
+
})
|
|
70
|
+
export class VikingButton {
|
|
71
|
+
readonly variant = input<VikingButtonVariant>("outline");
|
|
72
|
+
readonly size = input<VikingSize>("base");
|
|
73
|
+
readonly type = input<"button" | "submit">("button");
|
|
74
|
+
readonly icon = input<VikingIconName | null>(null);
|
|
75
|
+
readonly iconTrailing = input<VikingIconName | null>(null);
|
|
76
|
+
readonly disabled = input<boolean>(false);
|
|
77
|
+
readonly loading = input<boolean>(false);
|
|
78
|
+
readonly square = input<boolean>(false);
|
|
79
|
+
readonly fullWidth = input<boolean>(false);
|
|
80
|
+
readonly compact = input<boolean>(false);
|
|
81
|
+
readonly href = input<string | null>(null);
|
|
82
|
+
readonly target = input<string | null>(null);
|
|
83
|
+
readonly kbd = input<string | null>(null);
|
|
84
|
+
readonly label = input<string>("");
|
|
85
|
+
|
|
86
|
+
readonly pressed = output<MouseEvent>();
|
|
87
|
+
|
|
88
|
+
protected readonly iconSize = computed(() =>
|
|
89
|
+
this.size() === "base" ? 22 : 18,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
protected onPress = (event: Event): void => {
|
|
93
|
+
const detail = (event as CustomEvent<MouseEvent>).detail;
|
|
94
|
+
if (detail) {
|
|
95
|
+
this.pressed.emit(detail);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
model,
|
|
6
|
+
signal,
|
|
7
|
+
} from "@angular/core";
|
|
8
|
+
import { VikingControl, provideVikingCva } from "../core/cva";
|
|
9
|
+
import { VikingIcon } from "../icon/icon";
|
|
10
|
+
|
|
11
|
+
interface CalendarDay {
|
|
12
|
+
iso: string;
|
|
13
|
+
day: number;
|
|
14
|
+
inMonth: boolean;
|
|
15
|
+
isToday: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const MONTHS = [
|
|
19
|
+
"January",
|
|
20
|
+
"February",
|
|
21
|
+
"March",
|
|
22
|
+
"April",
|
|
23
|
+
"May",
|
|
24
|
+
"June",
|
|
25
|
+
"July",
|
|
26
|
+
"August",
|
|
27
|
+
"September",
|
|
28
|
+
"October",
|
|
29
|
+
"November",
|
|
30
|
+
"December",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
34
|
+
|
|
35
|
+
const toIso = (date: Date): string =>
|
|
36
|
+
`${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* viking-calendar — month-grid date selection.
|
|
40
|
+
* Value is an ISO date string (YYYY-MM-DD). ControlValueAccessor-compatible.
|
|
41
|
+
*/
|
|
42
|
+
@Component({
|
|
43
|
+
selector: "viking-calendar",
|
|
44
|
+
imports: [VikingIcon],
|
|
45
|
+
providers: [provideVikingCva(VikingCalendar)],
|
|
46
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
47
|
+
template: `
|
|
48
|
+
<div class="viking-calendar">
|
|
49
|
+
<div class="viking-calendar-header">
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
class="viking-calendar-nav"
|
|
53
|
+
aria-label="Previous month"
|
|
54
|
+
(click)="move(-1)"
|
|
55
|
+
>
|
|
56
|
+
<viking-icon name="chevron-left" [size]="18" />
|
|
57
|
+
</button>
|
|
58
|
+
<span class="viking-calendar-title" aria-live="polite">{{
|
|
59
|
+
title()
|
|
60
|
+
}}</span>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
class="viking-calendar-nav"
|
|
64
|
+
aria-label="Next month"
|
|
65
|
+
(click)="move(1)"
|
|
66
|
+
>
|
|
67
|
+
<viking-icon name="chevron-right" [size]="18" />
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
<div
|
|
71
|
+
class="viking-calendar-grid"
|
|
72
|
+
role="group"
|
|
73
|
+
[attr.aria-label]="title()"
|
|
74
|
+
>
|
|
75
|
+
@for (weekday of weekdays; track weekday) {
|
|
76
|
+
<span class="viking-calendar-weekday" aria-hidden="true">{{
|
|
77
|
+
weekday
|
|
78
|
+
}}</span>
|
|
79
|
+
}
|
|
80
|
+
@for (day of days(); track day.iso) {
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="viking-calendar-day"
|
|
84
|
+
[class.viking-outside]="!day.inMonth"
|
|
85
|
+
[class.viking-today]="day.isToday"
|
|
86
|
+
[class.viking-selected]="day.iso === value()"
|
|
87
|
+
[attr.aria-label]="day.iso"
|
|
88
|
+
[attr.aria-pressed]="day.iso === value()"
|
|
89
|
+
(click)="pick(day)"
|
|
90
|
+
>
|
|
91
|
+
{{ day.day }}
|
|
92
|
+
</button>
|
|
93
|
+
}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
`,
|
|
97
|
+
styles: [
|
|
98
|
+
`
|
|
99
|
+
.viking-calendar {
|
|
100
|
+
display: inline-block;
|
|
101
|
+
padding: var(--viking-space-2);
|
|
102
|
+
background: var(--viking-surface);
|
|
103
|
+
border: 1px solid var(--viking-border);
|
|
104
|
+
border-radius: var(--viking-radius);
|
|
105
|
+
font-family: var(--viking-font-family);
|
|
106
|
+
}
|
|
107
|
+
.viking-calendar-header {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
gap: var(--viking-space-1);
|
|
112
|
+
margin-bottom: var(--viking-space-1);
|
|
113
|
+
}
|
|
114
|
+
.viking-calendar-title {
|
|
115
|
+
font-size: var(--viking-font-size);
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
color: var(--viking-text);
|
|
118
|
+
}
|
|
119
|
+
.viking-calendar-nav {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
min-width: var(--viking-touch-target-comfort);
|
|
124
|
+
min-height: var(--viking-touch-target-comfort);
|
|
125
|
+
border: 1px solid var(--viking-border);
|
|
126
|
+
background: transparent;
|
|
127
|
+
color: var(--viking-text-muted);
|
|
128
|
+
border-radius: var(--viking-radius-sm);
|
|
129
|
+
padding: var(--viking-space-half);
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
transition: var(--viking-transition-interactive);
|
|
132
|
+
-webkit-tap-highlight-color: transparent;
|
|
133
|
+
}
|
|
134
|
+
.viking-calendar-nav:hover {
|
|
135
|
+
color: var(--viking-text);
|
|
136
|
+
border-color: var(--viking-accent-strong);
|
|
137
|
+
background: var(--viking-accent-soft);
|
|
138
|
+
}
|
|
139
|
+
.viking-calendar-nav:active {
|
|
140
|
+
transform: scale(var(--viking-state-active-scale));
|
|
141
|
+
}
|
|
142
|
+
.viking-calendar-nav:focus-visible {
|
|
143
|
+
outline: var(--viking-ring-width) solid var(--viking-ring);
|
|
144
|
+
outline-offset: var(--viking-ring-offset);
|
|
145
|
+
}
|
|
146
|
+
.viking-calendar-grid {
|
|
147
|
+
display: grid;
|
|
148
|
+
grid-template-columns: repeat(7, 1fr);
|
|
149
|
+
gap: var(--viking-space-half);
|
|
150
|
+
}
|
|
151
|
+
.viking-calendar-weekday {
|
|
152
|
+
text-align: center;
|
|
153
|
+
font-size: var(--viking-font-size);
|
|
154
|
+
color: var(--viking-text-muted);
|
|
155
|
+
padding: calc(var(--viking-space-1) / 2);
|
|
156
|
+
}
|
|
157
|
+
.viking-calendar-day {
|
|
158
|
+
width: 100%;
|
|
159
|
+
aspect-ratio: 1;
|
|
160
|
+
min-width: var(--viking-control-height-sm);
|
|
161
|
+
min-height: var(--viking-control-height-sm);
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
165
|
+
border: 1px solid transparent;
|
|
166
|
+
background: transparent;
|
|
167
|
+
color: var(--viking-text);
|
|
168
|
+
border-radius: var(--viking-radius-sm);
|
|
169
|
+
font-family: var(--viking-font-family);
|
|
170
|
+
font-size: var(--viking-font-size-sm);
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
transition: var(--viking-transition-interactive);
|
|
173
|
+
font-variant-numeric: tabular-nums;
|
|
174
|
+
-webkit-tap-highlight-color: transparent;
|
|
175
|
+
}
|
|
176
|
+
.viking-calendar-day:hover:not(.viking-selected) {
|
|
177
|
+
background: var(--viking-accent-soft);
|
|
178
|
+
}
|
|
179
|
+
.viking-calendar-day:active:not(.viking-selected) {
|
|
180
|
+
transform: scale(var(--viking-state-active-scale));
|
|
181
|
+
}
|
|
182
|
+
.viking-calendar-day:focus-visible {
|
|
183
|
+
outline: var(--viking-ring-width) solid var(--viking-ring);
|
|
184
|
+
outline-offset: var(--viking-ring-offset);
|
|
185
|
+
}
|
|
186
|
+
.viking-outside {
|
|
187
|
+
color: var(--viking-text-muted);
|
|
188
|
+
}
|
|
189
|
+
.viking-today {
|
|
190
|
+
border-color: var(--viking-accent-strong);
|
|
191
|
+
}
|
|
192
|
+
.viking-selected {
|
|
193
|
+
background: var(--viking-accent);
|
|
194
|
+
color: var(--viking-accent-content);
|
|
195
|
+
font-weight: 600;
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
],
|
|
199
|
+
})
|
|
200
|
+
export class VikingCalendar extends VikingControl<string | null> {
|
|
201
|
+
readonly value = model<string | null>(null);
|
|
202
|
+
|
|
203
|
+
protected readonly weekdays = WEEKDAYS;
|
|
204
|
+
protected readonly viewDate = signal(new Date());
|
|
205
|
+
|
|
206
|
+
protected readonly title = computed(() => {
|
|
207
|
+
const view = this.viewDate();
|
|
208
|
+
return `${MONTHS[view.getMonth()]} ${view.getFullYear()}`;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
protected readonly days = computed<CalendarDay[]>(() => {
|
|
212
|
+
const view = this.viewDate();
|
|
213
|
+
const year = view.getFullYear();
|
|
214
|
+
const month = view.getMonth();
|
|
215
|
+
const firstOfMonth = new Date(year, month, 1);
|
|
216
|
+
const start = new Date(year, month, 1 - firstOfMonth.getDay());
|
|
217
|
+
const todayIso = toIso(new Date());
|
|
218
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
219
|
+
const date = new Date(
|
|
220
|
+
start.getFullYear(),
|
|
221
|
+
start.getMonth(),
|
|
222
|
+
start.getDate() + index,
|
|
223
|
+
);
|
|
224
|
+
const iso = toIso(date);
|
|
225
|
+
return {
|
|
226
|
+
iso,
|
|
227
|
+
day: date.getDate(),
|
|
228
|
+
inMonth: date.getMonth() === month,
|
|
229
|
+
isToday: iso === todayIso,
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
writeValue(value: string | null): void {
|
|
235
|
+
this.value.set(value);
|
|
236
|
+
if (value) {
|
|
237
|
+
const [year, month] = value.split("-").map(Number);
|
|
238
|
+
this.viewDate.set(new Date(year, month - 1, 1));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
protected move = (delta: number): void => {
|
|
243
|
+
this.viewDate.update(
|
|
244
|
+
(view) => new Date(view.getFullYear(), view.getMonth() + delta, 1),
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
protected pick = (day: CalendarDay): void => {
|
|
249
|
+
this.value.set(day.iso);
|
|
250
|
+
this.onChange(day.iso);
|
|
251
|
+
this.onTouched();
|
|
252
|
+
};
|
|
253
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
input,
|
|
6
|
+
output,
|
|
7
|
+
signal,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
import { VikingIcon } from "../icon/icon";
|
|
10
|
+
import { VikingIconName } from "../../core/icons";
|
|
11
|
+
import { VikingTone } from "../../core/types";
|
|
12
|
+
|
|
13
|
+
const TONE_ICONS: Record<string, VikingIconName> = {
|
|
14
|
+
accent: "info",
|
|
15
|
+
secondary: "info",
|
|
16
|
+
success: "check-circle",
|
|
17
|
+
warning: "alert-triangle",
|
|
18
|
+
danger: "alert-circle",
|
|
19
|
+
info: "info",
|
|
20
|
+
muted: "info",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* viking-callout — highlighted message block.
|
|
25
|
+
*/
|
|
26
|
+
@Component({
|
|
27
|
+
selector: "viking-callout",
|
|
28
|
+
imports: [VikingIcon],
|
|
29
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
30
|
+
host: {
|
|
31
|
+
role: "note",
|
|
32
|
+
"[class]": "'viking-callout-' + tone()",
|
|
33
|
+
"[style.display]": "dismissed() ? 'none' : null",
|
|
34
|
+
},
|
|
35
|
+
template: `
|
|
36
|
+
<viking-icon
|
|
37
|
+
class="viking-callout-icon"
|
|
38
|
+
[name]="resolvedIcon()"
|
|
39
|
+
[size]="22"
|
|
40
|
+
/>
|
|
41
|
+
<div class="viking-callout-body">
|
|
42
|
+
@if (heading()) {
|
|
43
|
+
<p class="viking-callout-heading">{{ heading() }}</p>
|
|
44
|
+
}
|
|
45
|
+
<div class="viking-callout-text"><ng-content /></div>
|
|
46
|
+
</div>
|
|
47
|
+
@if (dismissible()) {
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
class="viking-callout-close"
|
|
51
|
+
aria-label="Dismiss"
|
|
52
|
+
(click)="dismiss()"
|
|
53
|
+
>
|
|
54
|
+
<viking-icon name="x" [size]="18" />
|
|
55
|
+
</button>
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
styles: [
|
|
59
|
+
`
|
|
60
|
+
:host {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: flex-start;
|
|
63
|
+
gap: var(--viking-space-2);
|
|
64
|
+
padding: var(--viking-space-2);
|
|
65
|
+
border-radius: var(--viking-radius-lg);
|
|
66
|
+
border: 1px solid var(--viking-border);
|
|
67
|
+
border-left-width: 3px;
|
|
68
|
+
background: var(--viking-surface-alt);
|
|
69
|
+
color: var(--viking-text);
|
|
70
|
+
font-family: var(--viking-font-family);
|
|
71
|
+
font-size: var(--viking-font-size-sm);
|
|
72
|
+
box-shadow: var(--viking-shadow-sm);
|
|
73
|
+
animation: viking-fade-in var(--viking-duration)
|
|
74
|
+
var(--viking-ease-default);
|
|
75
|
+
}
|
|
76
|
+
.viking-callout-icon {
|
|
77
|
+
margin-top: 2px;
|
|
78
|
+
color: var(--viking-text-muted);
|
|
79
|
+
}
|
|
80
|
+
:host(.viking-callout-accent) {
|
|
81
|
+
border-color: var(--viking-accent);
|
|
82
|
+
border-left-color: var(--viking-accent);
|
|
83
|
+
background: var(--viking-accent-soft);
|
|
84
|
+
}
|
|
85
|
+
:host(.viking-callout-accent) .viking-callout-icon {
|
|
86
|
+
color: var(--viking-accent);
|
|
87
|
+
}
|
|
88
|
+
:host(.viking-callout-secondary) {
|
|
89
|
+
border-color: color-mix(
|
|
90
|
+
in srgb,
|
|
91
|
+
var(--viking-accent-secondary) 45%,
|
|
92
|
+
transparent
|
|
93
|
+
);
|
|
94
|
+
border-left-color: var(--viking-accent-secondary);
|
|
95
|
+
background: var(--viking-accent-secondary-soft);
|
|
96
|
+
}
|
|
97
|
+
:host(.viking-callout-secondary) .viking-callout-icon {
|
|
98
|
+
color: var(--viking-accent-secondary);
|
|
99
|
+
}
|
|
100
|
+
:host(.viking-callout-info) {
|
|
101
|
+
border-color: color-mix(in srgb, var(--viking-info) 45%, transparent);
|
|
102
|
+
border-left-color: var(--viking-info);
|
|
103
|
+
background: color-mix(
|
|
104
|
+
in srgb,
|
|
105
|
+
var(--viking-info) 10%,
|
|
106
|
+
var(--viking-surface)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
:host(.viking-callout-info) .viking-callout-icon {
|
|
110
|
+
color: var(--viking-info);
|
|
111
|
+
}
|
|
112
|
+
:host(.viking-callout-success) {
|
|
113
|
+
border-color: color-mix(
|
|
114
|
+
in srgb,
|
|
115
|
+
var(--viking-success) 45%,
|
|
116
|
+
transparent
|
|
117
|
+
);
|
|
118
|
+
border-left-color: var(--viking-success);
|
|
119
|
+
background: color-mix(
|
|
120
|
+
in srgb,
|
|
121
|
+
var(--viking-success) 10%,
|
|
122
|
+
var(--viking-surface)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
:host(.viking-callout-success) .viking-callout-icon {
|
|
126
|
+
color: var(--viking-success);
|
|
127
|
+
}
|
|
128
|
+
:host(.viking-callout-warning) {
|
|
129
|
+
border-color: color-mix(
|
|
130
|
+
in srgb,
|
|
131
|
+
var(--viking-warning) 45%,
|
|
132
|
+
transparent
|
|
133
|
+
);
|
|
134
|
+
border-left-color: var(--viking-warning);
|
|
135
|
+
background: color-mix(
|
|
136
|
+
in srgb,
|
|
137
|
+
var(--viking-warning) 12%,
|
|
138
|
+
var(--viking-surface)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
:host(.viking-callout-warning) .viking-callout-icon {
|
|
142
|
+
color: var(--viking-warning);
|
|
143
|
+
}
|
|
144
|
+
:host(.viking-callout-danger) {
|
|
145
|
+
border-color: var(--viking-danger);
|
|
146
|
+
border-left-color: var(--viking-danger);
|
|
147
|
+
background: color-mix(
|
|
148
|
+
in srgb,
|
|
149
|
+
var(--viking-crimson-600) 22%,
|
|
150
|
+
var(--viking-surface)
|
|
151
|
+
);
|
|
152
|
+
color: var(--viking-white);
|
|
153
|
+
}
|
|
154
|
+
:host(.viking-callout-danger) .viking-callout-icon {
|
|
155
|
+
color: var(--viking-crimson-400);
|
|
156
|
+
}
|
|
157
|
+
:host(.viking-callout-danger) .viking-callout-text {
|
|
158
|
+
color: var(--viking-white);
|
|
159
|
+
}
|
|
160
|
+
.viking-callout-body {
|
|
161
|
+
flex: 1;
|
|
162
|
+
min-width: 0;
|
|
163
|
+
}
|
|
164
|
+
.viking-callout-heading {
|
|
165
|
+
margin: 0 0 calc(var(--viking-space-1) / 2);
|
|
166
|
+
font-size: var(--viking-font-size-ui);
|
|
167
|
+
font-weight: 700;
|
|
168
|
+
}
|
|
169
|
+
.viking-callout-text {
|
|
170
|
+
color: var(--viking-text);
|
|
171
|
+
line-height: 1.55;
|
|
172
|
+
}
|
|
173
|
+
.viking-callout-close {
|
|
174
|
+
border: none;
|
|
175
|
+
background: transparent;
|
|
176
|
+
color: var(--viking-text-muted);
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
padding: var(--viking-space-half);
|
|
179
|
+
border-radius: var(--viking-radius);
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
transition: var(--viking-transition-interactive);
|
|
182
|
+
}
|
|
183
|
+
.viking-callout-close:hover {
|
|
184
|
+
color: var(--viking-text);
|
|
185
|
+
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
186
|
+
}
|
|
187
|
+
.viking-callout-close:focus-visible {
|
|
188
|
+
outline: var(--viking-ring-width) solid var(--viking-ring);
|
|
189
|
+
outline-offset: 1px;
|
|
190
|
+
}
|
|
191
|
+
`,
|
|
192
|
+
],
|
|
193
|
+
})
|
|
194
|
+
export class VikingCallout {
|
|
195
|
+
readonly tone = input<VikingTone>("accent");
|
|
196
|
+
readonly heading = input<string>("");
|
|
197
|
+
readonly icon = input<VikingIconName | null>(null);
|
|
198
|
+
readonly dismissible = input<boolean>(false);
|
|
199
|
+
|
|
200
|
+
readonly closed = output<void>();
|
|
201
|
+
|
|
202
|
+
protected readonly dismissed = signal(false);
|
|
203
|
+
protected readonly resolvedIcon = computed<VikingIconName>(
|
|
204
|
+
() => this.icon() ?? TONE_ICONS[this.tone()] ?? "info",
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
protected dismiss = (): void => {
|
|
208
|
+
this.dismissed.set(true);
|
|
209
|
+
this.closed.emit();
|
|
210
|
+
};
|
|
211
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component } from "@angular/core";
|
|
2
|
+
import { TestBed } from "@angular/core/testing";
|
|
3
|
+
import { VikingCardTitle } from "./card-title";
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
imports: [VikingCardTitle],
|
|
7
|
+
template: `<viking-card-title icon="shield">Security</viking-card-title>`,
|
|
8
|
+
})
|
|
9
|
+
class HostComponent {}
|
|
10
|
+
|
|
11
|
+
describe("VikingCardTitle", () => {
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports: [HostComponent],
|
|
15
|
+
}).compileComponents();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("renders icon badge and heading text", () => {
|
|
19
|
+
const fixture = TestBed.createComponent(HostComponent);
|
|
20
|
+
fixture.detectChanges();
|
|
21
|
+
const host = fixture.nativeElement.querySelector(
|
|
22
|
+
"viking-card-title",
|
|
23
|
+
) as HTMLElement;
|
|
24
|
+
expect(host.querySelector("viking-icon-badge")).toBeTruthy();
|
|
25
|
+
expect(host.textContent).toContain("Security");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from "@angular/core";
|
|
2
|
+
import { VikingIconBadge, VikingIconBadgeTone } from "../icon-badge/icon-badge";
|
|
3
|
+
import { VikingIconName } from "../../core/icons";
|
|
4
|
+
import { VikingHeading } from "../typography/heading";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* viking-card-title — card header title row with tokenized icon badge + heading.
|
|
8
|
+
* Compose inside viking-card-header for premium, consistent section titles.
|
|
9
|
+
*/
|
|
10
|
+
@Component({
|
|
11
|
+
selector: "viking-card-title",
|
|
12
|
+
imports: [VikingIconBadge, VikingHeading],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: { class: "viking-card-title" },
|
|
15
|
+
template: `
|
|
16
|
+
<viking-icon-badge [icon]="icon()" [tone]="tone()" [size]="iconSize()" />
|
|
17
|
+
<viking-heading [level]="level()" [size]="size()">
|
|
18
|
+
<ng-content />
|
|
19
|
+
</viking-heading>
|
|
20
|
+
`,
|
|
21
|
+
styles: [
|
|
22
|
+
`
|
|
23
|
+
:host {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--viking-space-1);
|
|
27
|
+
flex: 1 1 auto;
|
|
28
|
+
min-width: 0;
|
|
29
|
+
margin: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host ::ng-deep viking-heading {
|
|
33
|
+
display: block;
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
margin: 0;
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
export class VikingCardTitle {
|
|
45
|
+
readonly icon = input.required<VikingIconName>();
|
|
46
|
+
readonly tone = input<VikingIconBadgeTone>("default");
|
|
47
|
+
readonly level = input<1 | 2 | 3 | 4>(2);
|
|
48
|
+
readonly size = input<"sm" | "base" | "lg" | "xl">("xl");
|
|
49
|
+
readonly iconSize = input<number>(20);
|
|
50
|
+
}
|