@dataengineeringformachinelearning/viking-ui 1.0.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 +217 -38
- 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/deml-components.css +1122 -0
- package/dist/design-tokens.css +688 -0
- package/dist/elements/button/viking-button.d.ts +14 -0
- package/dist/elements/card/viking-card.d.ts +8 -0
- package/dist/elements/core/dom.d.ts +4 -0
- package/dist/elements/core/styles.d.ts +2 -0
- package/dist/elements/modal/viking-modal.d.ts +15 -0
- package/dist/fonts/inter/InterVariable-Italic.woff2 +0 -0
- package/dist/fonts/inter/InterVariable.woff2 +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4051 -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/brand-icons.d.ts +29 -0
- package/dist/lib/core/cva.d.ts +15 -0
- package/dist/lib/core/icons.d.ts +132 -0
- package/dist/lib/core/integration-brand-icons.d.ts +18 -0
- package/dist/lib/core/lucide-paths.generated.d.ts +90 -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-drakkar.config.d.ts +50 -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/site-drakkar/suite-search-items.d.ts +17 -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/dist/viking-components.css +1837 -0
- package/dist/viking-tokens.json +318 -0
- package/dist/viking-ui-elements.js +1750 -0
- package/dist/viking-ui.css +1 -0
- package/dist/web/badge/viking-badge-wc.d.ts +28 -0
- package/dist/web/button/viking-button-wc.d.ts +28 -0
- package/dist/web/callout/viking-callout-wc.d.ts +27 -0
- package/dist/web/card/viking-card-wc.d.ts +29 -0
- package/dist/web/core/base.d.ts +12 -0
- package/dist/web/core/dom.d.ts +11 -0
- package/dist/web/core/icons-inline.d.ts +7 -0
- package/dist/web/core/styles.d.ts +12 -0
- package/dist/web/core/types.d.ts +10 -0
- package/dist/web/field/viking-field-wc.d.ts +32 -0
- package/dist/web/index.d.ts +15 -0
- package/dist/web/input/viking-input-wc.d.ts +32 -0
- package/dist/web/modal/viking-modal-wc.d.ts +50 -0
- package/dist/web/search-palette/viking-search-palette-wc.d.ts +64 -0
- package/dist/web/select/viking-select-wc.d.ts +48 -0
- package/dist/web/suite-header/viking-suite-header-wc.d.ts +36 -0
- package/dist/web/suite-search-palette/viking-suite-search-palette-wc.d.ts +39 -0
- package/dist/web/theme-toggle/viking-theme-toggle-wc.d.ts +19 -0
- package/dist/web/types.d.ts +40 -0
- package/dist/web-components/index.d.ts +1 -0
- package/dist/web-components.js +1750 -0
- package/dist/widget.js +1182 -0
- package/package.json +89 -30
- package/src/assets/drakkar-favicon.svg +17 -0
- package/src/assets/fonts/inter/InterVariable-Italic.woff2 +0 -0
- package/src/assets/fonts/inter/InterVariable.woff2 +0 -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/elements/button/viking-button.ts +201 -0
- package/src/elements/card/viking-card.ts +60 -0
- package/src/elements/core/dom.ts +33 -0
- package/src/elements/core/styles.ts +28 -0
- package/src/elements/modal/viking-modal.ts +154 -0
- package/src/index.ts +1 -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/brand-icons.ts +62 -0
- package/src/lib/core/cva.ts +33 -0
- package/src/lib/core/icons.ts +206 -0
- package/src/lib/core/integration-brand-icons.ts +77 -0
- package/src/lib/core/lucide-paths.generated.ts +130 -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-drakkar.config.ts +295 -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/site-drakkar/suite-search-items.ts +246 -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/styles/_buttons.scss +301 -0
- package/src/styles/_component-primitives.scss +183 -0
- package/src/styles/_drakkar-buttons.scss +85 -0
- package/src/styles/_fonts.scss +22 -0
- package/src/styles/_forms.scss +66 -0
- package/src/styles/_input.scss +106 -0
- package/src/styles/_layout-enforcement.scss +166 -0
- package/src/styles/_layout-rhythm.scss +158 -0
- package/src/styles/_legacy-aliases.scss +212 -0
- package/src/styles/_series-colors.scss +24 -0
- package/src/styles/_static-primitives.scss +857 -0
- package/src/styles/_typography.scss +87 -0
- package/src/styles/_variables.scss +527 -0
- package/src/styles/components/a11y.scss +90 -0
- package/src/styles/components/badges.scss +102 -0
- package/src/styles/components/extracted-utilities.scss +459 -0
- package/src/styles/components/footer.scss +155 -0
- package/src/styles/components/icon-heading.scss +47 -0
- package/src/styles/components/icon-inline.scss +78 -0
- package/src/styles/components/layout.scss +59 -0
- package/src/styles/components/utilities.scss +131 -0
- package/src/styles/components/viking-inspired.scss +204 -0
- package/src/styles/components/whitepaper-cta.scss +130 -0
- package/src/styles/components-bundle.scss +9 -0
- package/src/styles/components.scss +175 -0
- package/src/styles/deml-components.scss +10 -0
- package/src/styles/index.scss +8 -0
- package/src/styles/layout-shell.scss +39 -11
- package/src/styles/page-shell.scss +663 -33
- package/src/styles/static-navbar.scss +862 -146
- package/src/styles/surfaces/backend.scss +142 -0
- package/src/styles/surfaces/docs-global.scss +73 -0
- package/src/styles/surfaces/docs-shell.scss +412 -0
- package/src/styles/surfaces/docs-showcase.scss +1051 -0
- package/src/styles/surfaces/marketing-cta.scss +62 -0
- package/src/styles/surfaces/marketing-docs-bento.scss +67 -0
- package/src/styles/surfaces/marketing-global.scss +748 -0
- package/src/styles/surfaces/marketing-landing.scss +1260 -0
- package/src/styles/surfaces/marketing-publication.scss +535 -0
- package/src/styles/surfaces/marketing-theme.scss +14 -0
- package/src/styles/surfaces/swagger-ui.scss +921 -0
- package/src/styles/tokens-export.scss +18 -0
- package/src/styles/tokens.scss +5 -0
- package/src/styles/viking-ui-bundle.scss +20 -2
- package/src/styles/viking-ui.scss +213 -51
- package/src/tokens/series-presets.ts +15 -0
- package/src/tokens/tailwind.preset.js +209 -0
- package/src/tokens/viking-tokens.json +318 -0
- package/src/viking-ui.spec.ts +416 -0
- package/src/web/badge/viking-badge-wc.ts +116 -0
- package/src/web/button/viking-button-wc.ts +165 -0
- package/src/web/callout/viking-callout-wc.ts +105 -0
- package/src/web/card/viking-card-wc.ts +66 -0
- package/src/web/core/base.ts +56 -0
- package/src/web/core/dom.ts +53 -0
- package/src/web/core/icons-inline.ts +44 -0
- package/src/web/core/styles.ts +1138 -0
- package/src/web/core/types.ts +19 -0
- package/src/web/field/viking-field-wc.ts +154 -0
- package/src/web/index.ts +73 -0
- package/src/web/input/viking-input-wc.ts +211 -0
- package/src/web/modal/viking-modal-wc.ts +187 -0
- package/src/web/search-palette/viking-search-palette-wc.ts +494 -0
- package/src/web/select/viking-select-wc.ts +218 -0
- package/src/web/suite-header/viking-suite-header-wc.ts +714 -0
- package/src/web/suite-search-palette/viking-suite-search-palette-wc.ts +234 -0
- package/src/web/theme-toggle/viking-theme-toggle-wc.ts +139 -0
- package/src/web/types.ts +37 -0
- package/src/web/web-components.spec.ts +297 -0
- package/src/web-components/index.ts +1 -0
- package/fesm2022/dataengineeringformachinelearning-viking-ui.mjs +0 -6114
- package/fesm2022/dataengineeringformachinelearning-viking-ui.mjs.map +0 -1
- package/types/dataengineeringformachinelearning-viking-ui.d.ts +0 -1397
- package/viking.manifest.json +0 -238
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 };
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
}
|