@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,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viking-UI Tailwind CSS preset
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* Maps Tailwind utilities to canonical --viking-* CSS custom properties.
|
|
5
|
+
* Use with Tailwind v3/v4: presets: [require('@dataengineeringformachinelearning/viking-ui/tokens/tailwind.preset')]
|
|
6
|
+
*
|
|
7
|
+
* Load viking-ui.css or design-tokens.css before Tailwind so variables resolve.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('tailwindcss').Config} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
theme: {
|
|
13
|
+
extend: {
|
|
14
|
+
colors: {
|
|
15
|
+
viking: {
|
|
16
|
+
bg: "var(--viking-bg)",
|
|
17
|
+
surface: "var(--viking-surface)",
|
|
18
|
+
"surface-alt": "var(--viking-surface-alt)",
|
|
19
|
+
"surface-raised": "var(--viking-surface-raised)",
|
|
20
|
+
text: "var(--viking-text)",
|
|
21
|
+
"text-muted": "var(--viking-text-muted)",
|
|
22
|
+
"text-subtle": "var(--viking-text-subtle)",
|
|
23
|
+
"text-inverted": "var(--viking-text-inverted)",
|
|
24
|
+
border: "var(--viking-border)",
|
|
25
|
+
"border-strong": "var(--viking-border-strong)",
|
|
26
|
+
"border-subtle": "var(--viking-border-subtle)",
|
|
27
|
+
accent: "var(--viking-accent)",
|
|
28
|
+
"accent-hover": "var(--viking-accent-hover)",
|
|
29
|
+
"accent-content": "var(--viking-accent-content)",
|
|
30
|
+
"accent-soft": "var(--viking-accent-soft)",
|
|
31
|
+
"accent-strong": "var(--viking-accent-strong)",
|
|
32
|
+
"accent-secondary": "var(--viking-accent-secondary)",
|
|
33
|
+
"accent-secondary-hover": "var(--viking-accent-secondary-hover)",
|
|
34
|
+
"accent-secondary-content": "var(--viking-accent-secondary-content)",
|
|
35
|
+
"accent-secondary-soft": "var(--viking-accent-secondary-soft)",
|
|
36
|
+
success: "var(--viking-success)",
|
|
37
|
+
warning: "var(--viking-warning)",
|
|
38
|
+
danger: "var(--viking-danger)",
|
|
39
|
+
info: "var(--viking-info)",
|
|
40
|
+
ring: "var(--viking-ring)",
|
|
41
|
+
charcoal: {
|
|
42
|
+
950: "var(--viking-charcoal-950)",
|
|
43
|
+
900: "var(--viking-charcoal-900)",
|
|
44
|
+
800: "var(--viking-charcoal-800)",
|
|
45
|
+
700: "var(--viking-charcoal-700)",
|
|
46
|
+
600: "var(--viking-charcoal-600)",
|
|
47
|
+
500: "var(--viking-charcoal-500)",
|
|
48
|
+
},
|
|
49
|
+
metallic: {
|
|
50
|
+
600: "var(--viking-metallic-600)",
|
|
51
|
+
500: "var(--viking-metallic-500)",
|
|
52
|
+
400: "var(--viking-metallic-400)",
|
|
53
|
+
300: "var(--viking-metallic-300)",
|
|
54
|
+
200: "var(--viking-metallic-200)",
|
|
55
|
+
100: "var(--viking-metallic-100)",
|
|
56
|
+
},
|
|
57
|
+
electric: {
|
|
58
|
+
900: "var(--viking-electric-900)",
|
|
59
|
+
800: "var(--viking-electric-800)",
|
|
60
|
+
700: "var(--viking-electric-700)",
|
|
61
|
+
600: "var(--viking-electric-600)",
|
|
62
|
+
500: "var(--viking-electric-500)",
|
|
63
|
+
400: "var(--viking-electric-400)",
|
|
64
|
+
300: "var(--viking-electric-300)",
|
|
65
|
+
200: "var(--viking-electric-200)",
|
|
66
|
+
100: "var(--viking-electric-100)",
|
|
67
|
+
},
|
|
68
|
+
teal: {
|
|
69
|
+
700: "var(--viking-electric-700)",
|
|
70
|
+
600: "var(--viking-electric-600)",
|
|
71
|
+
500: "var(--viking-electric-500)",
|
|
72
|
+
400: "var(--viking-electric-400)",
|
|
73
|
+
300: "var(--viking-electric-300)",
|
|
74
|
+
},
|
|
75
|
+
crimson: {
|
|
76
|
+
700: "var(--viking-crimson-700)",
|
|
77
|
+
600: "var(--viking-crimson-600)",
|
|
78
|
+
500: "var(--viking-crimson-500)",
|
|
79
|
+
400: "var(--viking-crimson-400)",
|
|
80
|
+
},
|
|
81
|
+
series: {
|
|
82
|
+
1: "var(--viking-series-1)",
|
|
83
|
+
2: "var(--viking-series-2)",
|
|
84
|
+
3: "var(--viking-series-3)",
|
|
85
|
+
4: "var(--viking-series-4)",
|
|
86
|
+
5: "var(--viking-series-5)",
|
|
87
|
+
6: "var(--viking-series-6)",
|
|
88
|
+
7: "var(--viking-series-7)",
|
|
89
|
+
8: "var(--viking-series-8)",
|
|
90
|
+
DEFAULT: "var(--viking-series-default)",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
fontFamily: {
|
|
95
|
+
sans: ["var(--viking-font-family)"],
|
|
96
|
+
mono: ["var(--viking-font-family-mono)"],
|
|
97
|
+
},
|
|
98
|
+
fontSize: {
|
|
99
|
+
"viking-2xs": [
|
|
100
|
+
"var(--viking-font-size-2xs)",
|
|
101
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
102
|
+
],
|
|
103
|
+
"viking-xs": [
|
|
104
|
+
"var(--viking-font-size-xs)",
|
|
105
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
106
|
+
],
|
|
107
|
+
"viking-sm": [
|
|
108
|
+
"var(--viking-font-size-sm)",
|
|
109
|
+
{ lineHeight: "var(--viking-line-height-normal)" },
|
|
110
|
+
],
|
|
111
|
+
viking: [
|
|
112
|
+
"var(--viking-font-size)",
|
|
113
|
+
{ lineHeight: "var(--viking-line-height-relaxed)" },
|
|
114
|
+
],
|
|
115
|
+
"viking-md": [
|
|
116
|
+
"var(--viking-font-size-md)",
|
|
117
|
+
{ lineHeight: "var(--viking-line-height-relaxed)" },
|
|
118
|
+
],
|
|
119
|
+
"viking-lg": [
|
|
120
|
+
"var(--viking-font-size-lg)",
|
|
121
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
122
|
+
],
|
|
123
|
+
"viking-xl": [
|
|
124
|
+
"var(--viking-font-size-xl)",
|
|
125
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
126
|
+
],
|
|
127
|
+
"viking-2xl": [
|
|
128
|
+
"var(--viking-font-size-2xl)",
|
|
129
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
130
|
+
],
|
|
131
|
+
"viking-3xl": [
|
|
132
|
+
"var(--viking-font-size-3xl)",
|
|
133
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
134
|
+
],
|
|
135
|
+
"viking-4xl": [
|
|
136
|
+
"var(--viking-font-size-4xl)",
|
|
137
|
+
{ lineHeight: "var(--viking-line-height-tight)" },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
spacing: {
|
|
141
|
+
"viking-0": "var(--viking-space-0)",
|
|
142
|
+
"viking-px": "var(--viking-space-px)",
|
|
143
|
+
"viking-half": "var(--viking-space-half)",
|
|
144
|
+
"viking-1": "var(--viking-space-1)",
|
|
145
|
+
"viking-1.5": "var(--viking-space-1-5)",
|
|
146
|
+
"viking-2": "var(--viking-space-2)",
|
|
147
|
+
"viking-3": "var(--viking-space-3)",
|
|
148
|
+
"viking-4": "var(--viking-space-4)",
|
|
149
|
+
"viking-5": "var(--viking-space-5)",
|
|
150
|
+
"viking-6": "var(--viking-space-6)",
|
|
151
|
+
"viking-7": "var(--viking-space-7)",
|
|
152
|
+
"viking-8": "var(--viking-space-8)",
|
|
153
|
+
"viking-9": "var(--viking-space-9)",
|
|
154
|
+
"viking-10": "var(--viking-space-10)",
|
|
155
|
+
},
|
|
156
|
+
borderRadius: {
|
|
157
|
+
"viking-xs": "var(--viking-radius-xs)",
|
|
158
|
+
"viking-sm": "var(--viking-radius-sm)",
|
|
159
|
+
viking: "var(--viking-radius)",
|
|
160
|
+
"viking-md": "var(--viking-radius-md)",
|
|
161
|
+
"viking-lg": "var(--viking-radius-lg)",
|
|
162
|
+
"viking-xl": "var(--viking-radius-xl)",
|
|
163
|
+
"viking-pill": "var(--viking-radius-pill)",
|
|
164
|
+
},
|
|
165
|
+
boxShadow: {
|
|
166
|
+
"viking-xs": "var(--viking-shadow-xs)",
|
|
167
|
+
"viking-sm": "var(--viking-shadow-sm)",
|
|
168
|
+
"viking-md": "var(--viking-shadow-md)",
|
|
169
|
+
"viking-lg": "var(--viking-shadow-lg)",
|
|
170
|
+
"viking-inner": "var(--viking-shadow-inner)",
|
|
171
|
+
"viking-hover": "var(--viking-shadow-hover)",
|
|
172
|
+
},
|
|
173
|
+
transitionTimingFunction: {
|
|
174
|
+
viking: "var(--viking-ease-default)",
|
|
175
|
+
"viking-in": "var(--viking-ease-in)",
|
|
176
|
+
"viking-out": "var(--viking-ease-out)",
|
|
177
|
+
},
|
|
178
|
+
transitionDuration: {
|
|
179
|
+
"viking-fast": "var(--viking-duration-fast)",
|
|
180
|
+
viking: "var(--viking-duration)",
|
|
181
|
+
"viking-slow": "var(--viking-duration-slow)",
|
|
182
|
+
},
|
|
183
|
+
maxWidth: {
|
|
184
|
+
"viking-container": "var(--viking-container-max-width)",
|
|
185
|
+
},
|
|
186
|
+
height: {
|
|
187
|
+
"viking-control": "var(--viking-control-height)",
|
|
188
|
+
"viking-control-sm": "var(--viking-control-height-sm)",
|
|
189
|
+
"viking-control-xs": "var(--viking-control-height-xs)",
|
|
190
|
+
"viking-navbar": "var(--viking-navbar-height)",
|
|
191
|
+
},
|
|
192
|
+
width: {
|
|
193
|
+
"viking-sidebar": "var(--viking-sidebar-width)",
|
|
194
|
+
"viking-btn-min": "var(--viking-btn-min-width)",
|
|
195
|
+
},
|
|
196
|
+
zIndex: {
|
|
197
|
+
"viking-overlay": "var(--viking-z-overlay)",
|
|
198
|
+
"viking-toast": "var(--viking-z-toast)",
|
|
199
|
+
"viking-tooltip": "var(--viking-z-tooltip)",
|
|
200
|
+
},
|
|
201
|
+
outlineWidth: {
|
|
202
|
+
viking: "var(--viking-ring-width)",
|
|
203
|
+
},
|
|
204
|
+
outlineOffset: {
|
|
205
|
+
viking: "var(--viking-ring-offset)",
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { Component, signal } from "@angular/core";
|
|
2
|
+
import { TestBed, ComponentFixture } from "@angular/core/testing";
|
|
3
|
+
import { FormsModule } from "@angular/forms";
|
|
4
|
+
import {
|
|
5
|
+
VikingAccordion,
|
|
6
|
+
VikingAccordionItem,
|
|
7
|
+
VikingBadge,
|
|
8
|
+
VikingButton,
|
|
9
|
+
VikingCalendar,
|
|
10
|
+
VikingChart,
|
|
11
|
+
VikingCheckbox,
|
|
12
|
+
VikingFormPanel,
|
|
13
|
+
VikingFormSection,
|
|
14
|
+
VikingHeading,
|
|
15
|
+
VikingIcon,
|
|
16
|
+
VikingInput,
|
|
17
|
+
VikingField,
|
|
18
|
+
VikingPagination,
|
|
19
|
+
VikingProgress,
|
|
20
|
+
VikingSelect,
|
|
21
|
+
VikingSwitch,
|
|
22
|
+
VikingToastService,
|
|
23
|
+
VikingSelectOption,
|
|
24
|
+
} from "./public-api";
|
|
25
|
+
|
|
26
|
+
@Component({
|
|
27
|
+
imports: [VikingCheckbox, FormsModule],
|
|
28
|
+
template: `<viking-checkbox [(ngModel)]="accepted">Accept</viking-checkbox>`,
|
|
29
|
+
})
|
|
30
|
+
class CheckboxHost {
|
|
31
|
+
accepted = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Component({
|
|
35
|
+
imports: [VikingSelect],
|
|
36
|
+
template: `<viking-select
|
|
37
|
+
[options]="options"
|
|
38
|
+
[value]="value()"
|
|
39
|
+
(valueChange)="value.set($event)"
|
|
40
|
+
/>`,
|
|
41
|
+
})
|
|
42
|
+
class SelectHost {
|
|
43
|
+
readonly options: VikingSelectOption[] = [
|
|
44
|
+
{ label: "Alpha", value: "a" },
|
|
45
|
+
{ label: "Beta", value: "b" },
|
|
46
|
+
];
|
|
47
|
+
readonly value = signal<unknown>(null);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe("viking-ui", () => {
|
|
51
|
+
const render = async <T>(
|
|
52
|
+
component: new () => T,
|
|
53
|
+
): Promise<ComponentFixture<T>> => {
|
|
54
|
+
const fixture = TestBed.createComponent(component);
|
|
55
|
+
fixture.detectChanges();
|
|
56
|
+
await fixture.whenStable();
|
|
57
|
+
return fixture;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
it("renders compact buttons without min-width for form actions", async (): Promise<void> => {
|
|
61
|
+
const fixture = TestBed.createComponent(VikingButton);
|
|
62
|
+
fixture.componentRef.setInput("variant", "primary");
|
|
63
|
+
fixture.componentRef.setInput("compact", true);
|
|
64
|
+
fixture.detectChanges();
|
|
65
|
+
expect(fixture.nativeElement.classList.contains("viking-compact")).toBe(
|
|
66
|
+
true,
|
|
67
|
+
);
|
|
68
|
+
const wc = fixture.nativeElement.querySelector(
|
|
69
|
+
"viking-button-wc",
|
|
70
|
+
) as HTMLElement;
|
|
71
|
+
const button = wc?.shadowRoot?.querySelector("button") as HTMLButtonElement;
|
|
72
|
+
expect(button.classList.contains("viking-btn-primary")).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("renders button variants with accessible focus and disabled semantics", async (): Promise<void> => {
|
|
76
|
+
const fixture = TestBed.createComponent(VikingButton);
|
|
77
|
+
fixture.componentRef.setInput("variant", "primary");
|
|
78
|
+
fixture.componentRef.setInput("disabled", true);
|
|
79
|
+
fixture.detectChanges();
|
|
80
|
+
const wc = fixture.nativeElement.querySelector(
|
|
81
|
+
"viking-button-wc",
|
|
82
|
+
) as HTMLElement;
|
|
83
|
+
const button = wc?.shadowRoot?.querySelector("button") as HTMLButtonElement;
|
|
84
|
+
expect(button.classList.contains("viking-btn-primary")).toBe(true);
|
|
85
|
+
expect(button.disabled).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("renders an anchor with rel guard when href and target are set", async (): Promise<void> => {
|
|
89
|
+
const fixture = TestBed.createComponent(VikingButton);
|
|
90
|
+
fixture.componentRef.setInput("href", "https://deml.app");
|
|
91
|
+
fixture.componentRef.setInput("target", "_blank");
|
|
92
|
+
fixture.detectChanges();
|
|
93
|
+
const wc = fixture.nativeElement.querySelector(
|
|
94
|
+
"viking-button-wc",
|
|
95
|
+
) as HTMLElement;
|
|
96
|
+
const anchor = wc?.shadowRoot?.querySelector("a") as HTMLAnchorElement;
|
|
97
|
+
expect(anchor.getAttribute("rel")).toBe("noopener noreferrer");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("applies tone classes on badges", async (): Promise<void> => {
|
|
101
|
+
const fixture = TestBed.createComponent(VikingBadge);
|
|
102
|
+
fixture.componentRef.setInput("tone", "danger");
|
|
103
|
+
fixture.detectChanges();
|
|
104
|
+
expect(
|
|
105
|
+
fixture.nativeElement.classList.contains("viking-badge-danger"),
|
|
106
|
+
).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("exposes heading level via aria-level", async (): Promise<void> => {
|
|
110
|
+
const fixture = TestBed.createComponent(VikingHeading);
|
|
111
|
+
fixture.componentRef.setInput("level", 2);
|
|
112
|
+
fixture.detectChanges();
|
|
113
|
+
expect(fixture.nativeElement.getAttribute("aria-level")).toBe("2");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("integrates checkbox with ngModel (ControlValueAccessor)", async (): Promise<void> => {
|
|
117
|
+
const fixture = await render(CheckboxHost);
|
|
118
|
+
const input = fixture.nativeElement.querySelector(
|
|
119
|
+
"input",
|
|
120
|
+
) as HTMLInputElement;
|
|
121
|
+
input.click();
|
|
122
|
+
fixture.detectChanges();
|
|
123
|
+
await fixture.whenStable();
|
|
124
|
+
expect(fixture.componentInstance.accepted).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("toggles switch state on change", async (): Promise<void> => {
|
|
128
|
+
const fixture = TestBed.createComponent(VikingSwitch);
|
|
129
|
+
fixture.detectChanges();
|
|
130
|
+
const input = fixture.nativeElement.querySelector(
|
|
131
|
+
"input",
|
|
132
|
+
) as HTMLInputElement;
|
|
133
|
+
input.click();
|
|
134
|
+
fixture.detectChanges();
|
|
135
|
+
expect(fixture.componentInstance.checked()).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("opens the select listbox and picks an option", async (): Promise<void> => {
|
|
139
|
+
const fixture = await render(SelectHost);
|
|
140
|
+
const trigger = fixture.nativeElement.querySelector(
|
|
141
|
+
".viking-select-trigger",
|
|
142
|
+
) as HTMLButtonElement;
|
|
143
|
+
trigger.click();
|
|
144
|
+
fixture.detectChanges();
|
|
145
|
+
const options = fixture.nativeElement.querySelectorAll(
|
|
146
|
+
".viking-select-option",
|
|
147
|
+
);
|
|
148
|
+
expect(options.length).toBe(2);
|
|
149
|
+
(options[1] as HTMLElement).click();
|
|
150
|
+
fixture.detectChanges();
|
|
151
|
+
expect(fixture.componentInstance.value()).toBe("b");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("windows pagination with ellipses for long ranges", async (): Promise<void> => {
|
|
155
|
+
const fixture = TestBed.createComponent(VikingPagination);
|
|
156
|
+
fixture.componentRef.setInput("totalPages", 20);
|
|
157
|
+
fixture.componentRef.setInput("page", 10);
|
|
158
|
+
fixture.detectChanges();
|
|
159
|
+
const text = (fixture.nativeElement as HTMLElement).textContent ?? "";
|
|
160
|
+
expect(text).toContain("…");
|
|
161
|
+
expect(text).toContain("10");
|
|
162
|
+
expect(text).toContain("20");
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("clamps progress values into 0-100 and sets aria-valuenow", async (): Promise<void> => {
|
|
166
|
+
const fixture = TestBed.createComponent(VikingProgress);
|
|
167
|
+
fixture.componentRef.setInput("value", 140);
|
|
168
|
+
fixture.detectChanges();
|
|
169
|
+
const bar = fixture.nativeElement.querySelector(
|
|
170
|
+
'[role="progressbar"]',
|
|
171
|
+
) as HTMLElement;
|
|
172
|
+
expect(bar.getAttribute("aria-valuenow")).toBe("100");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("renders a 42-day calendar grid and selects a day", async (): Promise<void> => {
|
|
176
|
+
const fixture = TestBed.createComponent(VikingCalendar);
|
|
177
|
+
fixture.detectChanges();
|
|
178
|
+
const days = fixture.nativeElement.querySelectorAll(".viking-calendar-day");
|
|
179
|
+
expect(days.length).toBe(42);
|
|
180
|
+
(days[15] as HTMLElement).click();
|
|
181
|
+
fixture.detectChanges();
|
|
182
|
+
expect(fixture.componentInstance.value()).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("builds SVG paths for every chart series", async (): Promise<void> => {
|
|
186
|
+
const fixture = TestBed.createComponent(VikingChart);
|
|
187
|
+
fixture.componentRef.setInput("series", [
|
|
188
|
+
{ name: "p50", data: [1, 2, 3] },
|
|
189
|
+
{ name: "p95", tone: "warning", data: [2, 4, 6] },
|
|
190
|
+
]);
|
|
191
|
+
fixture.detectChanges();
|
|
192
|
+
const lines = fixture.nativeElement.querySelectorAll(".viking-chart-line");
|
|
193
|
+
expect(lines.length).toBe(2);
|
|
194
|
+
expect((lines[0] as SVGPathElement).getAttribute("d")).toContain("M");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("renders grouped and stacked bar rects", async (): Promise<void> => {
|
|
198
|
+
const grouped = TestBed.createComponent(VikingChart);
|
|
199
|
+
grouped.componentRef.setInput("kind", "grouped-bar");
|
|
200
|
+
grouped.componentRef.setInput("series", [
|
|
201
|
+
{ name: "A", tone: "accent", data: [4, 6, 5] },
|
|
202
|
+
{ name: "B", tone: "success", data: [3, 2, 4] },
|
|
203
|
+
]);
|
|
204
|
+
grouped.detectChanges();
|
|
205
|
+
expect(
|
|
206
|
+
grouped.nativeElement.querySelectorAll(".viking-chart-bar").length,
|
|
207
|
+
).toBe(6);
|
|
208
|
+
|
|
209
|
+
const stacked = TestBed.createComponent(VikingChart);
|
|
210
|
+
stacked.componentRef.setInput("kind", "stacked-bar");
|
|
211
|
+
stacked.componentRef.setInput("series", [
|
|
212
|
+
{ name: "Online", tone: "accent", data: [4, 3] },
|
|
213
|
+
{ name: "Retail", tone: "success", data: [2, 5] },
|
|
214
|
+
]);
|
|
215
|
+
stacked.detectChanges();
|
|
216
|
+
expect(
|
|
217
|
+
stacked.nativeElement.querySelectorAll(".viking-chart-bar").length,
|
|
218
|
+
).toBe(4);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("renders a minimum visible height for zero-value bars", async (): Promise<void> => {
|
|
222
|
+
const fixture = TestBed.createComponent(VikingChart);
|
|
223
|
+
fixture.componentRef.setInput("kind", "bar");
|
|
224
|
+
fixture.componentRef.setInput("series", [
|
|
225
|
+
{ name: "Revenue", data: [0, 5, 0] },
|
|
226
|
+
]);
|
|
227
|
+
fixture.componentRef.setInput("barMinHeight", 4);
|
|
228
|
+
fixture.detectChanges();
|
|
229
|
+
|
|
230
|
+
const bars = fixture.nativeElement.querySelectorAll(".viking-chart-bar");
|
|
231
|
+
expect(bars.length).toBe(3);
|
|
232
|
+
expect(Number((bars[0] as SVGRectElement).getAttribute("height"))).toBe(4);
|
|
233
|
+
expect(Number((bars[2] as SVGRectElement).getAttribute("height"))).toBe(4);
|
|
234
|
+
expect(
|
|
235
|
+
Number((bars[1] as SVGRectElement).getAttribute("height")),
|
|
236
|
+
).toBeGreaterThan(4);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("enforces exclusive accordion mode", async (): Promise<void> => {
|
|
240
|
+
@Component({
|
|
241
|
+
imports: [VikingAccordion, VikingAccordionItem],
|
|
242
|
+
template: `
|
|
243
|
+
<viking-accordion [exclusive]="true">
|
|
244
|
+
<viking-accordion-item heading="One">First</viking-accordion-item>
|
|
245
|
+
<viking-accordion-item heading="Two">Second</viking-accordion-item>
|
|
246
|
+
</viking-accordion>
|
|
247
|
+
`,
|
|
248
|
+
})
|
|
249
|
+
class AccordionHost {}
|
|
250
|
+
|
|
251
|
+
const fixture = await render(AccordionHost);
|
|
252
|
+
const triggers = fixture.nativeElement.querySelectorAll(
|
|
253
|
+
".viking-accordion-trigger",
|
|
254
|
+
);
|
|
255
|
+
(triggers[0] as HTMLElement).click();
|
|
256
|
+
fixture.detectChanges();
|
|
257
|
+
(triggers[1] as HTMLElement).click();
|
|
258
|
+
fixture.detectChanges();
|
|
259
|
+
const expanded = fixture.nativeElement.querySelectorAll(
|
|
260
|
+
'[aria-expanded="true"]',
|
|
261
|
+
);
|
|
262
|
+
expect(expanded.length).toBe(1);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("queues and auto-dismisses toasts via the service", (): void => {
|
|
266
|
+
const service = TestBed.inject(VikingToastService);
|
|
267
|
+
const id = service.show({
|
|
268
|
+
heading: "Saved",
|
|
269
|
+
text: "All good",
|
|
270
|
+
tone: "success",
|
|
271
|
+
duration: 0,
|
|
272
|
+
});
|
|
273
|
+
expect(service.toasts().length).toBe(1);
|
|
274
|
+
service.dismiss(id);
|
|
275
|
+
expect(service.toasts().length).toBe(0);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it("renders outline and filled Drakkar brand icons at 24×24 viewBox", async (): Promise<void> => {
|
|
279
|
+
const outline = TestBed.createComponent(VikingIcon);
|
|
280
|
+
outline.componentRef.setInput("name", "drakkar");
|
|
281
|
+
outline.componentRef.setInput("sizePreset", "lg");
|
|
282
|
+
outline.detectChanges();
|
|
283
|
+
const outlineSvg = outline.nativeElement.querySelector(
|
|
284
|
+
"svg",
|
|
285
|
+
) as SVGSVGElement;
|
|
286
|
+
expect(outlineSvg.getAttribute("viewBox")).toBe("0 0 24 24");
|
|
287
|
+
expect(outlineSvg.getAttribute("stroke")).toBe("currentColor");
|
|
288
|
+
expect(
|
|
289
|
+
outline.nativeElement.classList.contains("viking-icon-outline"),
|
|
290
|
+
).toBe(true);
|
|
291
|
+
expect(
|
|
292
|
+
outline.nativeElement.classList.contains("viking-icon-brand-drakkar"),
|
|
293
|
+
).toBe(true);
|
|
294
|
+
expect(outline.nativeElement.querySelector("g")?.innerHTML).toContain(
|
|
295
|
+
"M12 2v3",
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const filled = TestBed.createComponent(VikingIcon);
|
|
299
|
+
filled.componentRef.setInput("name", "drakkar");
|
|
300
|
+
filled.componentRef.setInput("variant", "filled");
|
|
301
|
+
filled.componentRef.setInput("size", 28);
|
|
302
|
+
filled.detectChanges();
|
|
303
|
+
const filledSvg = filled.nativeElement.querySelector(
|
|
304
|
+
"svg",
|
|
305
|
+
) as SVGSVGElement;
|
|
306
|
+
expect(filledSvg.getAttribute("fill")).toBe("currentColor");
|
|
307
|
+
expect(filledSvg.getAttribute("fill-rule")).toBe("evenodd");
|
|
308
|
+
expect(filledSvg.getAttribute("stroke")).toBe("none");
|
|
309
|
+
expect(filled.nativeElement.classList.contains("viking-icon-filled")).toBe(
|
|
310
|
+
true,
|
|
311
|
+
);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it("renders outline and filled DEML brand icons at 24×24 viewBox", async (): Promise<void> => {
|
|
315
|
+
const outline = TestBed.createComponent(VikingIcon);
|
|
316
|
+
outline.componentRef.setInput("name", "deml");
|
|
317
|
+
outline.componentRef.setInput("sizePreset", "lg");
|
|
318
|
+
outline.detectChanges();
|
|
319
|
+
const outlineSvg = outline.nativeElement.querySelector(
|
|
320
|
+
"svg",
|
|
321
|
+
) as SVGSVGElement;
|
|
322
|
+
expect(outlineSvg.getAttribute("viewBox")).toBe("0 0 24 24");
|
|
323
|
+
expect(outlineSvg.getAttribute("stroke")).toBe("currentColor");
|
|
324
|
+
expect(
|
|
325
|
+
outline.nativeElement.classList.contains("viking-icon-outline"),
|
|
326
|
+
).toBe(true);
|
|
327
|
+
|
|
328
|
+
const filled = TestBed.createComponent(VikingIcon);
|
|
329
|
+
filled.componentRef.setInput("name", "deml");
|
|
330
|
+
filled.componentRef.setInput("variant", "filled");
|
|
331
|
+
filled.componentRef.setInput("size", 28);
|
|
332
|
+
filled.detectChanges();
|
|
333
|
+
const filledSvg = filled.nativeElement.querySelector(
|
|
334
|
+
"svg",
|
|
335
|
+
) as SVGSVGElement;
|
|
336
|
+
expect(filledSvg.getAttribute("fill")).toBe("currentColor");
|
|
337
|
+
expect(filledSvg.getAttribute("fill-rule")).toBe("evenodd");
|
|
338
|
+
expect(filledSvg.getAttribute("stroke")).toBe("none");
|
|
339
|
+
expect(filled.nativeElement.classList.contains("viking-icon-filled")).toBe(
|
|
340
|
+
true,
|
|
341
|
+
);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it("maps size presets to pixel dimensions", async (): Promise<void> => {
|
|
345
|
+
const fixture = TestBed.createComponent(VikingIcon);
|
|
346
|
+
fixture.componentRef.setInput("name", "check");
|
|
347
|
+
fixture.componentRef.setInput("sizePreset", "sm");
|
|
348
|
+
fixture.detectChanges();
|
|
349
|
+
const svg = fixture.nativeElement.querySelector("svg") as SVGSVGElement;
|
|
350
|
+
expect(svg.style.width).toBe("16px");
|
|
351
|
+
expect(svg.style.height).toBe("16px");
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("resolves semantic color tokens to CSS custom properties", async (): Promise<void> => {
|
|
355
|
+
const fixture = TestBed.createComponent(VikingIcon);
|
|
356
|
+
fixture.componentRef.setInput("name", "shield");
|
|
357
|
+
fixture.componentRef.setInput("color", "accent");
|
|
358
|
+
fixture.detectChanges();
|
|
359
|
+
expect((fixture.nativeElement as HTMLElement).style.color).toBe(
|
|
360
|
+
"var(--viking-accent)",
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("renders Lucide-sourced search icon paths", async (): Promise<void> => {
|
|
365
|
+
const fixture = TestBed.createComponent(VikingIcon);
|
|
366
|
+
fixture.componentRef.setInput("name", "search");
|
|
367
|
+
fixture.detectChanges();
|
|
368
|
+
const svg = fixture.nativeElement.querySelector("svg") as SVGSVGElement;
|
|
369
|
+
expect(svg.innerHTML).toContain("circle");
|
|
370
|
+
expect(svg.getAttribute("stroke")).toBe("currentColor");
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it("renders form section headings and layout classes", async (): Promise<void> => {
|
|
374
|
+
@Component({
|
|
375
|
+
imports: [VikingFormSection, VikingField, VikingInput, FormsModule],
|
|
376
|
+
template: `
|
|
377
|
+
<viking-form-section heading="Update Email" icon="mail" layout="inline">
|
|
378
|
+
<viking-field label="Email">
|
|
379
|
+
<viking-input />
|
|
380
|
+
</viking-field>
|
|
381
|
+
<button type="button" vikingFormActions>Save</button>
|
|
382
|
+
</viking-form-section>
|
|
383
|
+
`,
|
|
384
|
+
})
|
|
385
|
+
class FormSectionHost {}
|
|
386
|
+
|
|
387
|
+
const fixture = await render(FormSectionHost);
|
|
388
|
+
const section = fixture.nativeElement.querySelector(
|
|
389
|
+
"viking-form-section",
|
|
390
|
+
) as HTMLElement;
|
|
391
|
+
expect(section.classList.contains("viking-form-section-inline")).toBe(true);
|
|
392
|
+
expect(
|
|
393
|
+
section.querySelector(".viking-form-section-title")?.textContent,
|
|
394
|
+
).toContain("Update Email");
|
|
395
|
+
expect(section.querySelector("[vikingFormActions]")).toBeTruthy();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("separates stacked form sections inside a panel", async (): Promise<void> => {
|
|
399
|
+
@Component({
|
|
400
|
+
imports: [VikingFormPanel, VikingFormSection],
|
|
401
|
+
template: `
|
|
402
|
+
<viking-form-panel>
|
|
403
|
+
<viking-form-section heading="One" layout="stack" />
|
|
404
|
+
<viking-form-section heading="Two" layout="stack" />
|
|
405
|
+
</viking-form-panel>
|
|
406
|
+
`,
|
|
407
|
+
})
|
|
408
|
+
class FormPanelHost {}
|
|
409
|
+
|
|
410
|
+
const fixture = await render(FormPanelHost);
|
|
411
|
+
const sections = fixture.nativeElement.querySelectorAll(
|
|
412
|
+
"viking-form-section",
|
|
413
|
+
);
|
|
414
|
+
expect(sections.length).toBe(2);
|
|
415
|
+
});
|
|
416
|
+
});
|