@dataengineeringformachinelearning/viking-ui 4.0.3 → 4.0.5

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 (246) hide show
  1. package/README.md +35 -11
  2. package/dist/README.md +35 -11
  3. package/dist/design-tokens.css +300 -85
  4. package/dist/fesm2022/dataengineeringformachinelearning-viking-ui.mjs +135 -70
  5. package/dist/fesm2022/dataengineeringformachinelearning-viking-ui.mjs.map +1 -1
  6. package/dist/icons.js +306 -0
  7. package/dist/package.json +24 -5
  8. package/{src/lib/site-drakkar/site-drakkar.config.ts → dist/site-drakkar.js} +64 -130
  9. package/dist/src/tokens/viking-tokens.json +9 -7
  10. package/dist/types/dataengineeringformachinelearning-viking-ui.d.ts +98 -4
  11. package/dist/viking-components.css +161 -70
  12. package/dist/viking-tokens.json +9 -7
  13. package/dist/viking-ui-elements.js +45 -33
  14. package/dist/viking-ui.css +1 -1
  15. package/dist/web-components.js +46 -36
  16. package/package.json +30 -8
  17. package/dist/scripts/build-web-components.mjs +0 -37
  18. package/dist/src/web/badge/viking-badge-wc.ts +0 -116
  19. package/dist/src/web/button/viking-button-wc.ts +0 -165
  20. package/dist/src/web/callout/viking-callout-wc.ts +0 -105
  21. package/dist/src/web/card/viking-card-wc.ts +0 -70
  22. package/dist/src/web/core/base.ts +0 -56
  23. package/dist/src/web/core/dom.ts +0 -53
  24. package/dist/src/web/core/icons-inline.ts +0 -44
  25. package/dist/src/web/core/styles.ts +0 -1261
  26. package/dist/src/web/core/types.ts +0 -19
  27. package/dist/src/web/field/viking-field-wc.ts +0 -154
  28. package/dist/src/web/index.ts +0 -73
  29. package/dist/src/web/input/viking-input-wc.ts +0 -211
  30. package/dist/src/web/modal/viking-modal-wc.ts +0 -187
  31. package/dist/src/web/search-palette/viking-search-palette-wc.ts +0 -494
  32. package/dist/src/web/select/viking-select-wc.ts +0 -218
  33. package/dist/src/web/suite-header/viking-suite-header-wc.ts +0 -729
  34. package/dist/src/web/suite-search-palette/viking-suite-search-palette-wc.ts +0 -234
  35. package/dist/src/web/theme-toggle/viking-theme-toggle-wc.ts +0 -139
  36. package/dist/src/web/types.ts +0 -37
  37. package/dist/src/web/web-components.spec.ts +0 -297
  38. package/src/assets/drakkar-favicon.svg +0 -17
  39. package/src/assets/fonts/inter/InterVariable-Italic.woff2 +0 -0
  40. package/src/assets/fonts/inter/InterVariable.woff2 +0 -0
  41. package/src/core/brand/deml-lockup.svg +0 -5
  42. package/src/core/brand/deml-mark-compact.svg +0 -4
  43. package/src/core/brand/deml-mark-filled.svg +0 -3
  44. package/src/core/brand/deml-mark-outline.svg +0 -4
  45. package/src/core/brand-icons.ts +0 -62
  46. package/src/core/icons.spec.ts +0 -52
  47. package/src/core/icons.ts +0 -206
  48. package/src/core/integration-brand-icons.ts +0 -77
  49. package/src/core/lucide-paths.generated.ts +0 -130
  50. package/src/core/types.ts +0 -85
  51. package/src/core/uid.ts +0 -7
  52. package/src/elements/button/viking-button.ts +0 -201
  53. package/src/elements/card/viking-card.ts +0 -60
  54. package/src/elements/core/dom.ts +0 -33
  55. package/src/elements/core/styles.ts +0 -28
  56. package/src/elements/modal/viking-modal.ts +0 -154
  57. package/src/index.ts +0 -1
  58. package/src/lib/accordion/accordion.ts +0 -126
  59. package/src/lib/app-header/app-header.scss +0 -274
  60. package/src/lib/app-header/app-header.ts +0 -43
  61. package/src/lib/app-sidebar/app-sidebar.scss +0 -415
  62. package/src/lib/app-sidebar/app-sidebar.ts +0 -29
  63. package/src/lib/auth-panel/auth-panel.spec.ts +0 -132
  64. package/src/lib/auth-panel/auth-panel.ts +0 -228
  65. package/src/lib/autocomplete/autocomplete.ts +0 -223
  66. package/src/lib/avatar/avatar.ts +0 -126
  67. package/src/lib/badge/badge.ts +0 -182
  68. package/src/lib/bar/bar.ts +0 -31
  69. package/src/lib/brand/brand.ts +0 -60
  70. package/src/lib/breadcrumbs/breadcrumbs.ts +0 -81
  71. package/src/lib/button/button-group.ts +0 -40
  72. package/src/lib/button/button.scss +0 -119
  73. package/src/lib/button/button.ts +0 -98
  74. package/src/lib/calendar/calendar.ts +0 -253
  75. package/src/lib/callout/callout.ts +0 -211
  76. package/src/lib/card/card-title.spec.ts +0 -27
  77. package/src/lib/card/card-title.ts +0 -50
  78. package/src/lib/card/card.ts +0 -198
  79. package/src/lib/carousel/carousel.ts +0 -206
  80. package/src/lib/chart/chart-zoom.spec.ts +0 -65
  81. package/src/lib/chart/chart-zoom.ts +0 -71
  82. package/src/lib/chart/chart.ts +0 -1257
  83. package/src/lib/chart-card-header/chart-card-header.ts +0 -80
  84. package/src/lib/chart-empty-state/chart-empty-state.ts +0 -146
  85. package/src/lib/chart-panel/chart-panel.ts +0 -133
  86. package/src/lib/checkbox/checkbox.ts +0 -139
  87. package/src/lib/color-picker/color-picker.ts +0 -148
  88. package/src/lib/command/command.ts +0 -260
  89. package/src/lib/composer/composer.ts +0 -180
  90. package/src/lib/confirm-dialog/confirm-dialog.ts +0 -163
  91. package/src/lib/confirm-dialog/dialog.service.ts +0 -79
  92. package/src/lib/context/context.ts +0 -75
  93. package/src/lib/core/brand-icons.ts +0 -62
  94. package/src/lib/core/cva.ts +0 -33
  95. package/src/lib/core/icons.ts +0 -206
  96. package/src/lib/core/integration-brand-icons.ts +0 -77
  97. package/src/lib/core/lucide-paths.generated.ts +0 -130
  98. package/src/lib/date-picker/date-picker.ts +0 -139
  99. package/src/lib/dropdown/dropdown.ts +0 -188
  100. package/src/lib/editor/editor.ts +0 -170
  101. package/src/lib/empty-state/empty-state.ts +0 -100
  102. package/src/lib/fab/fab.ts +0 -76
  103. package/src/lib/field/field.ts +0 -111
  104. package/src/lib/file-upload/file-upload.ts +0 -208
  105. package/src/lib/footer/footer.scss +0 -155
  106. package/src/lib/footer/footer.ts +0 -28
  107. package/src/lib/form-section/form-section.ts +0 -200
  108. package/src/lib/forms.spec.ts +0 -92
  109. package/src/lib/gauge-arc/gauge-arc.ts +0 -85
  110. package/src/lib/hud-panel/hud-panel.ts +0 -27
  111. package/src/lib/icon/icon.ts +0 -284
  112. package/src/lib/icon-badge/icon-badge.ts +0 -87
  113. package/src/lib/icon-heading/icon-heading.spec.ts +0 -32
  114. package/src/lib/icon-heading/icon-heading.ts +0 -38
  115. package/src/lib/icon-text/icon-text.ts +0 -120
  116. package/src/lib/input/input.ts +0 -119
  117. package/src/lib/kanban/kanban.ts +0 -211
  118. package/src/lib/kbd/kbd.ts +0 -32
  119. package/src/lib/label/label.ts +0 -39
  120. package/src/lib/loading-overlay/loading-overlay.ts +0 -80
  121. package/src/lib/menubar/menubar.ts +0 -77
  122. package/src/lib/metric-card/metric-card.ts +0 -33
  123. package/src/lib/modal/modal.ts +0 -207
  124. package/src/lib/native-select/native-select.ts +0 -124
  125. package/src/lib/navbar/navbar.ts +0 -124
  126. package/src/lib/navigation-menu/navigation-menu.ts +0 -116
  127. package/src/lib/otp-input/otp-input.ts +0 -164
  128. package/src/lib/page-back-link/page-back-link.ts +0 -74
  129. package/src/lib/page-header/page-header.ts +0 -70
  130. package/src/lib/pagination/pagination.ts +0 -157
  131. package/src/lib/pillbox/pillbox.ts +0 -157
  132. package/src/lib/popover/popover.ts +0 -92
  133. package/src/lib/profile/profile.ts +0 -73
  134. package/src/lib/progress/progress.ts +0 -123
  135. package/src/lib/radio/radio.ts +0 -132
  136. package/src/lib/ring-gauge/ring-gauge.ts +0 -75
  137. package/src/lib/scroll-area/scroll-area.ts +0 -57
  138. package/src/lib/search-palette/search-palette.scss +0 -288
  139. package/src/lib/search-palette/search-palette.ts +0 -114
  140. package/src/lib/select/select.ts +0 -292
  141. package/src/lib/separator/separator.ts +0 -59
  142. package/src/lib/sheet/sheet.ts +0 -192
  143. package/src/lib/sidebar-nav/sidebar-nav.scss +0 -218
  144. package/src/lib/sidebar-nav/sidebar-nav.ts +0 -158
  145. package/src/lib/site-drakkar/site-footer.ts +0 -129
  146. package/src/lib/site-drakkar/site-navbar.scss +0 -2
  147. package/src/lib/site-drakkar/site-navbar.ts +0 -277
  148. package/src/lib/site-drakkar/suite-search-items.spec.ts +0 -61
  149. package/src/lib/site-drakkar/suite-search-items.ts +0 -246
  150. package/src/lib/skeleton/skeleton.ts +0 -51
  151. package/src/lib/slider/slider.ts +0 -133
  152. package/src/lib/spinner/spinner.ts +0 -75
  153. package/src/lib/status-metric-row/status-metric-row.ts +0 -74
  154. package/src/lib/suite-search-palette/suite-search-palette.ts +0 -95
  155. package/src/lib/switch/switch.ts +0 -131
  156. package/src/lib/table/table.ts +0 -137
  157. package/src/lib/tabs/tab-panel.ts +0 -61
  158. package/src/lib/tabs/tab.ts +0 -107
  159. package/src/lib/tabs/tabs.ts +0 -109
  160. package/src/lib/textarea/textarea.ts +0 -103
  161. package/src/lib/theme-toggle/theme-toggle.spec.ts +0 -40
  162. package/src/lib/theme-toggle/theme-toggle.ts +0 -39
  163. package/src/lib/time-picker/time-picker.ts +0 -197
  164. package/src/lib/timeline/timeline.ts +0 -152
  165. package/src/lib/toast/toast.ts +0 -196
  166. package/src/lib/toggle/toggle-group.ts +0 -60
  167. package/src/lib/toggle/toggle.ts +0 -101
  168. package/src/lib/tooltip/tooltip.ts +0 -119
  169. package/src/lib/typography/heading.ts +0 -52
  170. package/src/lib/typography/text.ts +0 -51
  171. package/src/lib/uptime-bar/uptime-bar.ts +0 -55
  172. package/src/lib/verification-code-field/verification-code-field.ts +0 -149
  173. package/src/lib/whitepaper-cta/whitepaper-cta.scss +0 -130
  174. package/src/lib/whitepaper-cta/whitepaper-cta.ts +0 -78
  175. package/src/lib/wizard/wizard.ts +0 -80
  176. package/src/public-api.ts +0 -172
  177. package/src/styles/_buttons.scss +0 -386
  178. package/src/styles/_component-primitives.scss +0 -183
  179. package/src/styles/_drakkar-buttons.scss +0 -85
  180. package/src/styles/_fonts.scss +0 -22
  181. package/src/styles/_forms.scss +0 -66
  182. package/src/styles/_input.scss +0 -106
  183. package/src/styles/_layout-enforcement.scss +0 -229
  184. package/src/styles/_layout-rhythm.scss +0 -158
  185. package/src/styles/_legacy-aliases.scss +0 -212
  186. package/src/styles/_series-colors.scss +0 -24
  187. package/src/styles/_static-primitives.scss +0 -857
  188. package/src/styles/_typography.scss +0 -87
  189. package/src/styles/_variables.scss +0 -527
  190. package/src/styles/components/a11y.scss +0 -90
  191. package/src/styles/components/badges.scss +0 -102
  192. package/src/styles/components/extracted-utilities.scss +0 -459
  193. package/src/styles/components/footer.scss +0 -155
  194. package/src/styles/components/icon-heading.scss +0 -47
  195. package/src/styles/components/icon-inline.scss +0 -101
  196. package/src/styles/components/layout.scss +0 -59
  197. package/src/styles/components/utilities.scss +0 -131
  198. package/src/styles/components/viking-inspired.scss +0 -204
  199. package/src/styles/components/whitepaper-cta.scss +0 -130
  200. package/src/styles/components-bundle.scss +0 -9
  201. package/src/styles/components.scss +0 -442
  202. package/src/styles/deml-components.scss +0 -10
  203. package/src/styles/index.scss +0 -8
  204. package/src/styles/layout-shell.scss +0 -111
  205. package/src/styles/page-shell.scss +0 -859
  206. package/src/styles/static-navbar.scss +0 -1215
  207. package/src/styles/surfaces/backend.scss +0 -154
  208. package/src/styles/surfaces/docs-global.scss +0 -73
  209. package/src/styles/surfaces/docs-shell.scss +0 -437
  210. package/src/styles/surfaces/docs-showcase.scss +0 -1153
  211. package/src/styles/surfaces/marketing-cta.scss +0 -62
  212. package/src/styles/surfaces/marketing-docs-bento.scss +0 -67
  213. package/src/styles/surfaces/marketing-global.scss +0 -748
  214. package/src/styles/surfaces/marketing-landing.scss +0 -1526
  215. package/src/styles/surfaces/marketing-publication.scss +0 -535
  216. package/src/styles/surfaces/marketing-theme.scss +0 -14
  217. package/src/styles/surfaces/swagger-ui.scss +0 -922
  218. package/src/styles/tokens-export.scss +0 -18
  219. package/src/styles/tokens.scss +0 -5
  220. package/src/styles/viking-ui-bundle.scss +0 -23
  221. package/src/styles/viking-ui.scss +0 -270
  222. package/src/tokens/series-presets.ts +0 -15
  223. package/src/tokens/tailwind.preset.js +0 -209
  224. package/src/tokens/viking-tokens.json +0 -318
  225. package/src/viking-ui.spec.ts +0 -416
  226. package/src/web/badge/viking-badge-wc.ts +0 -116
  227. package/src/web/button/viking-button-wc.ts +0 -165
  228. package/src/web/callout/viking-callout-wc.ts +0 -105
  229. package/src/web/card/viking-card-wc.ts +0 -70
  230. package/src/web/core/base.ts +0 -56
  231. package/src/web/core/dom.ts +0 -53
  232. package/src/web/core/icons-inline.ts +0 -44
  233. package/src/web/core/styles.ts +0 -1261
  234. package/src/web/core/types.ts +0 -19
  235. package/src/web/field/viking-field-wc.ts +0 -154
  236. package/src/web/index.ts +0 -73
  237. package/src/web/input/viking-input-wc.ts +0 -211
  238. package/src/web/modal/viking-modal-wc.ts +0 -187
  239. package/src/web/search-palette/viking-search-palette-wc.ts +0 -494
  240. package/src/web/select/viking-select-wc.ts +0 -218
  241. package/src/web/suite-header/viking-suite-header-wc.ts +0 -729
  242. package/src/web/suite-search-palette/viking-suite-search-palette-wc.ts +0 -234
  243. package/src/web/theme-toggle/viking-theme-toggle-wc.ts +0 -139
  244. package/src/web/types.ts +0 -37
  245. package/src/web/web-components.spec.ts +0 -297
  246. package/src/web-components/index.ts +0 -1
@@ -1,260 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- ElementRef,
5
- computed,
6
- effect,
7
- input,
8
- model,
9
- output,
10
- signal,
11
- viewChild,
12
- } from "@angular/core";
13
- import { VikingIcon } from "../icon/icon";
14
- import { VikingCommandItem } from "../../core/types";
15
-
16
- /**
17
- * viking-command — command palette.
18
- * Toggle with the `open` model; emits `executed` when an item is chosen.
19
- */
20
- @Component({
21
- selector: "viking-command",
22
- imports: [VikingIcon],
23
- changeDetection: ChangeDetectionStrategy.OnPush,
24
- host: { "(keydown.escape)": "open.set(false)" },
25
- template: `
26
- @if (open()) {
27
- <button
28
- type="button"
29
- class="viking-command-backdrop"
30
- aria-label="Close command palette"
31
- (click)="open.set(false)"
32
- ></button>
33
- <div class="viking-command" role="dialog" aria-label="Command palette">
34
- <div class="viking-command-search">
35
- <viking-icon name="search" [size]="20" />
36
- <input
37
- #queryInput
38
- type="text"
39
- [placeholder]="placeholder()"
40
- [value]="query()"
41
- aria-label="Search commands"
42
- (input)="onQuery($event)"
43
- (keydown)="onKeydown($event)"
44
- />
45
- <kbd>esc</kbd>
46
- </div>
47
- <div class="viking-command-list" role="listbox">
48
- @for (group of groups(); track group.name) {
49
- <p class="viking-command-group">{{ group.name }}</p>
50
- @for (item of group.items; track item.id) {
51
- <button
52
- type="button"
53
- role="option"
54
- class="viking-command-item"
55
- [class.viking-active]="item.id === activeId()"
56
- [attr.aria-selected]="item.id === activeId()"
57
- (click)="run(item)"
58
- (mouseenter)="activeId.set(item.id)"
59
- >
60
- @if (item.icon) {
61
- <viking-icon [name]="item.icon" [size]="18" />
62
- }
63
- <span class="viking-command-label">{{ item.label }}</span>
64
- @if (item.kbd) {
65
- <kbd>{{ item.kbd }}</kbd>
66
- }
67
- </button>
68
- }
69
- }
70
- @if (filtered().length === 0) {
71
- <p class="viking-command-empty">No results for “{{ query() }}”</p>
72
- }
73
- </div>
74
- </div>
75
- }
76
- `,
77
- styles: [
78
- `
79
- .viking-command-backdrop {
80
- position: fixed;
81
- inset: 0;
82
- border: none;
83
- background: var(--viking-overlay-backdrop, rgba(49, 57, 60, 0.55));
84
- backdrop-filter: blur(4px);
85
- z-index: var(--viking-z-overlay);
86
- cursor: default;
87
- }
88
- .viking-command {
89
- position: fixed;
90
- top: 12vh;
91
- left: 50%;
92
- transform: translateX(-50%);
93
- width: min(576px, calc(100vw - var(--viking-space-4)));
94
- background: var(--viking-surface);
95
- border: 1px solid var(--viking-border-strong);
96
- border-radius: var(--viking-radius);
97
- box-shadow: var(--viking-shadow-md);
98
- z-index: calc(var(--viking-z-overlay) + 1);
99
- font-family: var(--viking-font-family);
100
- overflow: hidden;
101
- }
102
- .viking-command-search {
103
- display: flex;
104
- align-items: center;
105
- gap: var(--viking-space-1);
106
- padding: var(--viking-space-2);
107
- border-bottom: 1px solid var(--viking-border);
108
- color: var(--viking-text-muted);
109
- transition: var(--viking-transition-colors);
110
- }
111
- .viking-command-search:focus-within {
112
- border-bottom-color: var(--viking-accent);
113
- box-shadow: inset 0 -2px 0 var(--viking-accent-soft);
114
- }
115
- .viking-command-search input {
116
- flex: 1;
117
- min-width: 0;
118
- border: none;
119
- outline: none;
120
- background: transparent;
121
- color: var(--viking-text);
122
- font-family: var(--viking-font-family);
123
- font-size: var(--viking-font-size);
124
- }
125
- kbd {
126
- font-family: var(--viking-font-family);
127
- font-size: var(--viking-font-size);
128
- color: var(--viking-text-muted);
129
- background: var(--viking-surface-alt);
130
- border: 1px solid var(--viking-border);
131
- border-radius: calc(var(--viking-radius) / 2);
132
- padding: 0 var(--viking-space-1);
133
- line-height: 1.4;
134
- }
135
- .viking-command-list {
136
- max-height: 342px;
137
- overflow: auto;
138
- padding: var(--viking-space-1);
139
- }
140
- .viking-command-group {
141
- margin: var(--viking-space-1) var(--viking-space-1) 3px;
142
- font-size: var(--viking-font-size);
143
- font-weight: 600;
144
- text-transform: uppercase;
145
- letter-spacing: 0.06em;
146
- color: var(--viking-text-muted);
147
- }
148
- .viking-command-item {
149
- display: flex;
150
- align-items: center;
151
- gap: var(--viking-space-1);
152
- width: 100%;
153
- min-height: var(--viking-control-height-sm);
154
- border: none;
155
- background: transparent;
156
- color: var(--viking-text);
157
- font-family: var(--viking-font-family);
158
- font-size: var(--viking-font-size);
159
- padding: var(--viking-space-1) var(--viking-space-1-5);
160
- border-radius: var(--viking-radius-sm);
161
- cursor: pointer;
162
- text-align: left;
163
- transition: var(--viking-transition-interactive);
164
- }
165
- .viking-command-item:hover:not(.viking-active),
166
- .viking-command-item.viking-active {
167
- background: var(--viking-accent-soft);
168
- }
169
- .viking-command-item:focus-visible {
170
- outline: var(--viking-ring-width) solid var(--viking-ring);
171
- outline-offset: var(--viking-ring-offset);
172
- }
173
- .viking-command-item:active {
174
- transform: scale(var(--viking-state-active-scale));
175
- }
176
- .viking-command-label {
177
- flex: 1;
178
- }
179
- .viking-command-empty {
180
- margin: 0;
181
- padding: var(--viking-space-2);
182
- color: var(--viking-text-muted);
183
- font-size: var(--viking-font-size);
184
- text-align: center;
185
- }
186
- `,
187
- ],
188
- })
189
- export class VikingCommand {
190
- readonly items = input.required<VikingCommandItem[]>();
191
- readonly open = model<boolean>(false);
192
- readonly placeholder = input<string>("Type a command or search…");
193
-
194
- readonly executed = output<VikingCommandItem>();
195
-
196
- private readonly queryInput =
197
- viewChild<ElementRef<HTMLInputElement>>("queryInput");
198
-
199
- protected readonly query = signal("");
200
- protected readonly activeId = signal<string>("");
201
-
202
- constructor() {
203
- effect(() => {
204
- if (this.open()) {
205
- this.query.set("");
206
- this.activeId.set(this.items()[0]?.id ?? "");
207
- queueMicrotask(() => this.queryInput()?.nativeElement.focus());
208
- }
209
- });
210
- }
211
-
212
- protected readonly filtered = computed(() => {
213
- const query = this.query().toLowerCase().trim();
214
- if (!query) {
215
- return this.items();
216
- }
217
- return this.items().filter((item) =>
218
- item.label.toLowerCase().includes(query),
219
- );
220
- });
221
-
222
- protected readonly groups = computed(() => {
223
- const map = new Map<string, VikingCommandItem[]>();
224
- for (const item of this.filtered()) {
225
- const group = item.group ?? "Commands";
226
- map.set(group, [...(map.get(group) ?? []), item]);
227
- }
228
- return [...map.entries()].map(([name, items]) => ({ name, items }));
229
- });
230
-
231
- protected onQuery = (event: Event): void => {
232
- this.query.set((event.target as HTMLInputElement).value);
233
- this.activeId.set(this.filtered()[0]?.id ?? "");
234
- };
235
-
236
- protected run = (item: VikingCommandItem): void => {
237
- this.executed.emit(item);
238
- this.open.set(false);
239
- this.query.set("");
240
- };
241
-
242
- protected onKeydown = (event: KeyboardEvent): void => {
243
- const items = this.filtered();
244
- const index = items.findIndex((item) => item.id === this.activeId());
245
- if (event.key === "ArrowDown") {
246
- event.preventDefault();
247
- this.activeId.set(items[Math.min(items.length - 1, index + 1)]?.id ?? "");
248
- } else if (event.key === "ArrowUp") {
249
- event.preventDefault();
250
- this.activeId.set(items[Math.max(0, index - 1)]?.id ?? "");
251
- } else if (event.key === "Enter") {
252
- const active =
253
- items.find((item) => item.id === this.activeId()) ?? items[0];
254
- if (active) {
255
- event.preventDefault();
256
- this.run(active);
257
- }
258
- }
259
- };
260
- }
@@ -1,180 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- input,
5
- model,
6
- output,
7
- } from "@angular/core";
8
- import { VikingIcon } from "../icon/icon";
9
-
10
- /**
11
- * viking-composer — message composer with attachments and send action
12
- *.
13
- */
14
- @Component({
15
- selector: "viking-composer",
16
- imports: [VikingIcon],
17
- changeDetection: ChangeDetectionStrategy.OnPush,
18
- template: `
19
- <div class="viking-composer">
20
- <textarea
21
- rows="1"
22
- [placeholder]="placeholder()"
23
- [value]="value()"
24
- [disabled]="disabled()"
25
- [attr.aria-label]="placeholder() || 'Message'"
26
- (input)="onInput($event)"
27
- (keydown)="onKeydown($event)"
28
- ></textarea>
29
- <div class="viking-composer-actions">
30
- <div class="viking-composer-tools">
31
- @if (allowAttachments()) {
32
- <button
33
- type="button"
34
- class="viking-composer-tool"
35
- aria-label="Attach file"
36
- (click)="attach.emit()"
37
- >
38
- <viking-icon name="paperclip" [size]="20" />
39
- </button>
40
- }
41
- <ng-content />
42
- </div>
43
- <button
44
- type="button"
45
- class="viking-composer-send"
46
- aria-label="Send message"
47
- [disabled]="disabled() || !value().trim()"
48
- (click)="send()"
49
- >
50
- <viking-icon name="send" [size]="18" />
51
- <span>Send</span>
52
- </button>
53
- </div>
54
- </div>
55
- `,
56
- styles: [
57
- `
58
- .viking-composer {
59
- display: flex;
60
- flex-direction: column;
61
- background: var(--viking-surface);
62
- border: 1px solid var(--viking-border-strong);
63
- border-radius: var(--viking-radius);
64
- box-shadow: var(--viking-shadow-sm);
65
- transition: var(--viking-transition);
66
- font-family: var(--viking-font-family);
67
- }
68
- .viking-composer:focus-within {
69
- outline: var(--viking-ring-width) solid var(--viking-ring);
70
- outline-offset: var(--viking-ring-offset);
71
- }
72
- textarea {
73
- border: none;
74
- outline: none;
75
- resize: none;
76
- background: transparent;
77
- color: var(--viking-text);
78
- font-family: var(--viking-font-family);
79
- font-size: var(--viking-font-size);
80
- line-height: 1.55;
81
- padding: var(--viking-space-2);
82
- min-height: var(--viking-space-5);
83
- }
84
- textarea::placeholder {
85
- color: var(--viking-text-muted);
86
- }
87
- .viking-composer-actions {
88
- display: flex;
89
- align-items: center;
90
- justify-content: space-between;
91
- gap: var(--viking-space-1);
92
- padding: var(--viking-space-1) var(--viking-space-2)
93
- var(--viking-space-1) var(--viking-space-1);
94
- border-top: 1px solid var(--viking-border);
95
- }
96
- .viking-composer-tools {
97
- display: flex;
98
- align-items: center;
99
- gap: calc(var(--viking-space-1) / 2);
100
- }
101
- .viking-composer-tool {
102
- display: inline-flex;
103
- border: none;
104
- background: transparent;
105
- color: var(--viking-text-muted);
106
- cursor: pointer;
107
- padding: var(--viking-space-1);
108
- border-radius: calc(var(--viking-radius) / 1.5);
109
- transition: var(--viking-transition);
110
- }
111
- .viking-composer-tool:hover {
112
- color: var(--viking-text);
113
- background: var(--viking-accent-soft);
114
- }
115
- .viking-composer-tool:focus-visible {
116
- outline: var(--viking-ring-width) solid var(--viking-ring);
117
- outline-offset: 1px;
118
- }
119
- .viking-composer-send {
120
- display: inline-flex;
121
- align-items: center;
122
- gap: calc(var(--viking-space-1) / 1.5);
123
- border: 1px solid var(--viking-accent);
124
- background: var(--viking-accent);
125
- color: var(--viking-accent-content);
126
- font-family: var(--viking-font-family);
127
- /* >= 18.67px bold qualifies as WCAG large text (3:1 on accent fill). */
128
- font-size: calc(var(--viking-font-size) * 1.05);
129
- font-weight: 700;
130
- padding: calc(var(--viking-space-1) / 1.5) var(--viking-space-2);
131
- border-radius: var(--viking-radius);
132
- cursor: pointer;
133
- transition: var(--viking-transition);
134
- }
135
- .viking-composer-send:hover:not(:disabled) {
136
- background: var(--viking-accent-strong);
137
- border-color: var(--viking-accent-strong);
138
- }
139
- .viking-composer-send:focus-visible {
140
- outline: var(--viking-ring-width) solid var(--viking-ring);
141
- outline-offset: var(--viking-ring-offset);
142
- }
143
- .viking-composer-send:disabled {
144
- opacity: var(--viking-state-disabled-opacity);
145
- cursor: not-allowed;
146
- }
147
- `,
148
- ],
149
- })
150
- export class VikingComposer {
151
- readonly value = model<string>("");
152
- readonly placeholder = input<string>("Write a message…");
153
- readonly disabled = input<boolean>(false);
154
- readonly allowAttachments = input<boolean>(true);
155
-
156
- readonly sent = output<string>();
157
- readonly attach = output<void>();
158
-
159
- protected onInput = (event: Event): void => {
160
- const el = event.target as HTMLTextAreaElement;
161
- this.value.set(el.value);
162
- el.style.height = "auto";
163
- el.style.height = `${el.scrollHeight}px`;
164
- };
165
-
166
- protected onKeydown = (event: KeyboardEvent): void => {
167
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
168
- event.preventDefault();
169
- this.send();
170
- }
171
- };
172
-
173
- protected send = (): void => {
174
- const message = this.value().trim();
175
- if (message) {
176
- this.sent.emit(message);
177
- this.value.set("");
178
- }
179
- };
180
- }
@@ -1,163 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- computed,
5
- signal,
6
- } from "@angular/core";
7
- import { FormsModule } from "@angular/forms";
8
- import { VikingButton } from "../button/button";
9
- import { VikingField } from "../field/field";
10
- import { VikingIcon } from "../icon/icon";
11
- import { VikingInput } from "../input/input";
12
- import { VikingModal } from "../modal/modal";
13
- import { VikingText } from "../typography/text";
14
- import type { VikingIconName } from "../../core/icons";
15
- import { VikingConfirmDialogData, VikingDialogService } from "./dialog.service";
16
-
17
- /**
18
- * viking-confirm-dialog — alert / confirm / prompt modal wired to VikingDialogService.
19
- */
20
- @Component({
21
- selector: "viking-confirm-dialog",
22
- imports: [
23
- FormsModule,
24
- VikingModal,
25
- VikingButton,
26
- VikingField,
27
- VikingInput,
28
- VikingText,
29
- VikingIcon,
30
- ],
31
- changeDetection: ChangeDetectionStrategy.OnPush,
32
- template: `
33
- @if (data(); as dialogData) {
34
- <viking-modal
35
- [open]="open()"
36
- [heading]="heading()"
37
- (openChange)="onOpenChange($event)"
38
- >
39
- <div class="viking-confirm-body">
40
- <div class="viking-confirm-title-row">
41
- <viking-icon [name]="iconName()" [size]="24" />
42
- <viking-text>{{ dialogData.message }}</viking-text>
43
- </div>
44
- @if (dialogData.type === "prompt" && dialogData.confirmText) {
45
- <viking-field
46
- label="Verification text"
47
- [description]="'Type ' + dialogData.confirmText + ' to proceed'"
48
- >
49
- <viking-input
50
- [ngModel]="inputValue()"
51
- (ngModelChange)="inputValue.set($event)"
52
- autocomplete="off"
53
- (keyup.enter)="onConfirm()"
54
- />
55
- </viking-field>
56
- }
57
- </div>
58
- <div vikingModalActions>
59
- @if (dialogData.type !== "alert") {
60
- <viking-button variant="outline" (pressed)="onCancel()"
61
- >Cancel</viking-button
62
- >
63
- }
64
- <viking-button
65
- [variant]="
66
- dialogData.confirmBtnColor === 'warn' ? 'danger' : 'primary'
67
- "
68
- [disabled]="!isValid()"
69
- [icon]="
70
- dialogData.type === 'alert'
71
- ? 'check-circle'
72
- : dialogData.confirmBtnColor === 'warn'
73
- ? 'trash'
74
- : 'check'
75
- "
76
- (pressed)="onConfirm()"
77
- >
78
- {{
79
- dialogData.confirmBtnText ||
80
- (dialogData.type === "alert" ? "OK" : "Confirm")
81
- }}
82
- </viking-button>
83
- </div>
84
- </viking-modal>
85
- }
86
- `,
87
- styles: [
88
- `
89
- .viking-confirm-body {
90
- display: flex;
91
- flex-direction: column;
92
- gap: var(--viking-space-2);
93
- }
94
- .viking-confirm-title-row {
95
- display: flex;
96
- align-items: center;
97
- gap: var(--viking-space-2);
98
- }
99
- `,
100
- ],
101
- })
102
- export class VikingConfirmDialog {
103
- constructor(private readonly vikingDialog: VikingDialogService) {}
104
-
105
- protected readonly inputValue = signal<string>("");
106
-
107
- protected readonly data = computed(() => {
108
- const active = this.vikingDialog.active();
109
- return active?.kind === "confirm"
110
- ? (active.data as VikingConfirmDialogData)
111
- : null;
112
- });
113
-
114
- protected readonly open = computed(() => this.data() !== null);
115
-
116
- protected readonly heading = computed(() => {
117
- const data = this.data();
118
- if (!data) return "";
119
- return (
120
- data.title ??
121
- (data.type === "alert"
122
- ? "Notice"
123
- : data.type === "prompt"
124
- ? "Verification Required"
125
- : "Confirm Action")
126
- );
127
- });
128
-
129
- protected readonly iconName = computed((): VikingIconName => {
130
- const data = this.data();
131
- if (!data) return "info";
132
- if (data.type === "alert") return "info";
133
- if (data.confirmBtnColor === "warn") return "alert-triangle";
134
- return "info";
135
- });
136
-
137
- protected readonly isValid = computed(() => {
138
- const data = this.data();
139
- if (!data || data.type !== "prompt" || !data.confirmText) {
140
- return true;
141
- }
142
- return this.inputValue() === data.confirmText;
143
- });
144
-
145
- protected onCancel = (): void => {
146
- this.inputValue.set("");
147
- this.vikingDialog.resolveConfirm(false);
148
- };
149
-
150
- protected onConfirm = (): void => {
151
- if (!this.isValid()) return;
152
- this.inputValue.set("");
153
- this.vikingDialog.resolveConfirm(true);
154
- };
155
-
156
- protected onOpenChange = (next: boolean): void => {
157
- if (!next) {
158
- this.onCancel();
159
- }
160
- };
161
- }
162
-
163
- export type { VikingConfirmDialogData };
@@ -1,79 +0,0 @@
1
- import { Injectable, signal } from "@angular/core";
2
-
3
- export type VikingDialogKind = "confirm" | "search" | "onboarding";
4
-
5
- export interface VikingConfirmDialogData {
6
- title?: string;
7
- message: string;
8
- type?: "alert" | "confirm" | "prompt";
9
- confirmText?: string;
10
- confirmBtnText?: string;
11
- confirmBtnColor?: "primary" | "warn" | "accent";
12
- }
13
-
14
- export interface VikingDialogState {
15
- kind: VikingDialogKind;
16
- data?: VikingConfirmDialogData & { force?: boolean };
17
- }
18
-
19
- /** Programmatic confirm / prompt / overlay orchestration for Viking-UI modals. */
20
- @Injectable({ providedIn: "root" })
21
- export class VikingDialogService {
22
- readonly active = signal<VikingDialogState | null>(null);
23
-
24
- private confirmResolver: ((value: boolean) => void) | null = null;
25
- private onboardingResolver: ((value: boolean | undefined) => void) | null =
26
- null;
27
-
28
- openConfirm(data: VikingConfirmDialogData): Promise<boolean> {
29
- this.closeActive(false);
30
- return new Promise<boolean>((resolve) => {
31
- this.confirmResolver = resolve;
32
- this.active.set({ kind: "confirm", data });
33
- });
34
- }
35
-
36
- resolveConfirm(result: boolean): void {
37
- this.confirmResolver?.(result);
38
- this.confirmResolver = null;
39
- this.active.set(null);
40
- }
41
-
42
- openSearch(): void {
43
- if (this.active()?.kind === "search") {
44
- return;
45
- }
46
- this.closeActive(false);
47
- this.active.set({ kind: "search" });
48
- }
49
-
50
- closeSearch(): void {
51
- if (this.active()?.kind === "search") {
52
- this.active.set(null);
53
- }
54
- }
55
-
56
- openOnboarding(force = false): Promise<boolean | undefined> {
57
- this.closeActive(false);
58
- return new Promise<boolean | undefined>((resolve) => {
59
- this.onboardingResolver = resolve;
60
- this.active.set({ kind: "onboarding", data: { message: "", force } });
61
- });
62
- }
63
-
64
- resolveOnboarding(result?: boolean): void {
65
- this.onboardingResolver?.(result);
66
- this.onboardingResolver = null;
67
- this.active.set(null);
68
- }
69
-
70
- closeActive(cancelPending = true): void {
71
- if (cancelPending) {
72
- this.confirmResolver?.(false);
73
- this.onboardingResolver?.(undefined);
74
- }
75
- this.confirmResolver = null;
76
- this.onboardingResolver = null;
77
- this.active.set(null);
78
- }
79
- }