@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,105 @@
|
|
|
1
|
+
import { attachShadowStyles } from "../core/base";
|
|
2
|
+
import {
|
|
3
|
+
defineCustomElement,
|
|
4
|
+
defineCustomElementAlias,
|
|
5
|
+
escapeHtml,
|
|
6
|
+
HTMLElementBase,
|
|
7
|
+
} from "../core/dom";
|
|
8
|
+
import { renderInlineIcon, TONE_ICON_NAMES } from "../core/icons-inline";
|
|
9
|
+
import { VIKING_CALLOUT_STYLES } from "../core/styles";
|
|
10
|
+
import type { VikingWcTone } from "../core/types";
|
|
11
|
+
|
|
12
|
+
const TONES = new Set<VikingWcTone>([
|
|
13
|
+
"accent",
|
|
14
|
+
"secondary",
|
|
15
|
+
"success",
|
|
16
|
+
"warning",
|
|
17
|
+
"danger",
|
|
18
|
+
"info",
|
|
19
|
+
"muted",
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Framework-agnostic Viking callout Web Component.
|
|
24
|
+
* Tag: `viking-callout` (legacy alias: `viking-callout-wc`)
|
|
25
|
+
*
|
|
26
|
+
* @attr tone - Semantic tone (default: info)
|
|
27
|
+
* @attr heading - Bold callout title
|
|
28
|
+
* @attr icon - Override leading icon from the Viking registry
|
|
29
|
+
* @attr dismissible - Shows dismiss control; dispatches `viking-close`
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <viking-callout-wc tone="warning" heading="Degraded worker">Lag exceeds 3s.</viking-callout-wc>
|
|
33
|
+
*/
|
|
34
|
+
export class VikingCalloutWc extends HTMLElementBase {
|
|
35
|
+
static readonly tag = "viking-callout";
|
|
36
|
+
static readonly legacyTag = "viking-callout-wc";
|
|
37
|
+
|
|
38
|
+
static get observedAttributes(): string[] {
|
|
39
|
+
return ["tone", "heading", "icon", "dismissible", "hidden"];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private readonly shadow: ShadowRoot;
|
|
43
|
+
|
|
44
|
+
constructor() {
|
|
45
|
+
super();
|
|
46
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
47
|
+
attachShadowStyles(this.shadow, VIKING_CALLOUT_STYLES);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
connectedCallback(): void {
|
|
51
|
+
this.render();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
attributeChangedCallback(): void {
|
|
55
|
+
if (this.isConnected) {
|
|
56
|
+
this.render();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private get tone(): VikingWcTone {
|
|
61
|
+
const value = (this.getAttribute("tone") ?? "info") as VikingWcTone;
|
|
62
|
+
return TONES.has(value) ? value : "info";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private get dismissible(): boolean {
|
|
66
|
+
return (
|
|
67
|
+
this.hasAttribute("dismissible") &&
|
|
68
|
+
this.getAttribute("dismissible") !== "false"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private readonly onDismiss = (): void => {
|
|
73
|
+
this.setAttribute("hidden", "");
|
|
74
|
+
this.dispatchEvent(
|
|
75
|
+
new CustomEvent("viking-close", { bubbles: true, composed: true }),
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
private render(): void {
|
|
80
|
+
const heading = this.getAttribute("heading") ?? "";
|
|
81
|
+
const iconName =
|
|
82
|
+
this.getAttribute("icon") ?? TONE_ICON_NAMES[this.tone] ?? "info";
|
|
83
|
+
const iconMarkup = renderInlineIcon(iconName, 22, "viking-callout-icon");
|
|
84
|
+
|
|
85
|
+
this.shadow.innerHTML = `
|
|
86
|
+
<div class="viking-callout viking-callout-${this.tone}" role="note" part="surface">
|
|
87
|
+
<span part="icon">${iconMarkup}</span>
|
|
88
|
+
<div class="viking-callout-body" part="body">
|
|
89
|
+
${heading ? `<p class="viking-callout-heading" part="heading">${escapeHtml(heading)}</p>` : ""}
|
|
90
|
+
<div class="viking-callout-text" part="text"><slot></slot></div>
|
|
91
|
+
</div>
|
|
92
|
+
${this.dismissible ? `<button type="button" class="viking-callout-close" part="close" aria-label="Dismiss">${renderInlineIcon("x", 18)}</button>` : ""}
|
|
93
|
+
</div>
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
this.shadow
|
|
97
|
+
.querySelector(".viking-callout-close")
|
|
98
|
+
?.addEventListener("click", this.onDismiss);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const registerVikingCalloutWc = (): void => {
|
|
103
|
+
defineCustomElement(VikingCalloutWc.tag, VikingCalloutWc);
|
|
104
|
+
defineCustomElementAlias(VikingCalloutWc.legacyTag, VikingCalloutWc);
|
|
105
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineCustomElement,
|
|
3
|
+
defineCustomElementAlias,
|
|
4
|
+
HTMLElementBase,
|
|
5
|
+
} from "../core/dom";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Framework-agnostic Viking card Web Component (light DOM — inherits global viking-card CSS).
|
|
9
|
+
* Tag: `viking-card` (legacy alias: `viking-card-wc`)
|
|
10
|
+
*
|
|
11
|
+
* Uses light DOM so slotted content inherits `viking-card`, `viking-card-header`, and related
|
|
12
|
+
* classes from the synced static CSS bundle.
|
|
13
|
+
*
|
|
14
|
+
* @attr compact - Applies `viking-card-compact` padding
|
|
15
|
+
* @attr interactive - Hover lift for clickable cards
|
|
16
|
+
* @attr title - Accessible name when the card is a landmark region
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <viking-card-wc compact title="Event throughput">
|
|
20
|
+
* <div class="viking-card-header">
|
|
21
|
+
* <h3 class="viking-heading viking-heading-sm">Event throughput</h3>
|
|
22
|
+
* </div>
|
|
23
|
+
* <p class="viking-text-muted">8.2K events/sec</p>
|
|
24
|
+
* </viking-card-wc>
|
|
25
|
+
*/
|
|
26
|
+
export class VikingCardWc extends HTMLElementBase {
|
|
27
|
+
static readonly tag = "viking-card";
|
|
28
|
+
static readonly legacyTag = "viking-card-wc";
|
|
29
|
+
|
|
30
|
+
static get observedAttributes(): string[] {
|
|
31
|
+
return ["compact", "interactive", "title"];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
connectedCallback(): void {
|
|
35
|
+
this.syncClasses();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
attributeChangedCallback(): void {
|
|
39
|
+
if (this.isConnected) {
|
|
40
|
+
this.syncClasses();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private syncClasses(): void {
|
|
45
|
+
this.classList.add("viking-card");
|
|
46
|
+
this.classList.toggle("viking-card-compact", this.hasAttribute("compact"));
|
|
47
|
+
this.classList.toggle(
|
|
48
|
+
"viking-card-interactive",
|
|
49
|
+
this.hasAttribute("interactive"),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const title = this.getAttribute("title");
|
|
53
|
+
if (title) {
|
|
54
|
+
this.setAttribute("role", "region");
|
|
55
|
+
this.setAttribute("aria-label", title);
|
|
56
|
+
} else {
|
|
57
|
+
this.removeAttribute("role");
|
|
58
|
+
this.removeAttribute("aria-label");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const registerVikingCardWc = (): void => {
|
|
64
|
+
defineCustomElement(VikingCardWc.tag, VikingCardWc);
|
|
65
|
+
defineCustomElementAlias(VikingCardWc.legacyTag, VikingCardWc);
|
|
66
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Attaches constructable stylesheet to a shadow root (with fallback). */
|
|
2
|
+
export const attachShadowStyles = (shadow: ShadowRoot, css: string): void => {
|
|
3
|
+
if (
|
|
4
|
+
"adoptedStyleSheets" in Document.prototype &&
|
|
5
|
+
"replaceSync" in CSSStyleSheet.prototype
|
|
6
|
+
) {
|
|
7
|
+
const sheet = new CSSStyleSheet();
|
|
8
|
+
sheet.replaceSync(css);
|
|
9
|
+
shadow.adoptedStyleSheets = [sheet];
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const style = document.createElement("style");
|
|
14
|
+
style.textContent = css;
|
|
15
|
+
shadow.append(style);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Reads a boolean attribute presence/value. */
|
|
19
|
+
export const readBoolAttr = (el: HTMLElement, name: string): boolean =>
|
|
20
|
+
el.hasAttribute(name) && el.getAttribute(name) !== "false";
|
|
21
|
+
|
|
22
|
+
/** Safely sets form value when ElementInternals is fully supported (e.g. not in jsdom). */
|
|
23
|
+
export const setFormValue = (
|
|
24
|
+
internals: ElementInternals | null,
|
|
25
|
+
value: string,
|
|
26
|
+
): void => {
|
|
27
|
+
if (internals && typeof internals.setFormValue === "function") {
|
|
28
|
+
internals.setFormValue(value);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Attaches ElementInternals where available without breaking older WebKit or test DOMs. */
|
|
33
|
+
export const attachElementInternals = (
|
|
34
|
+
el: HTMLElement,
|
|
35
|
+
): ElementInternals | null => {
|
|
36
|
+
const attachInternals = (
|
|
37
|
+
el as HTMLElement & { attachInternals?: () => ElementInternals }
|
|
38
|
+
).attachInternals;
|
|
39
|
+
return typeof attachInternals === "function"
|
|
40
|
+
? attachInternals.call(el)
|
|
41
|
+
: null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Opens a native dialog when showModal is available. */
|
|
45
|
+
export const showModalDialog = (dialog: HTMLDialogElement | null): void => {
|
|
46
|
+
if (dialog && typeof dialog.showModal === "function" && !dialog.open) {
|
|
47
|
+
dialog.showModal();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Closes a native dialog when close is available. */
|
|
52
|
+
export const closeModalDialog = (dialog: HTMLDialogElement | null): void => {
|
|
53
|
+
if (dialog && typeof dialog.close === "function" && dialog.open) {
|
|
54
|
+
dialog.close();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const HTMLElementBase: typeof HTMLElement =
|
|
2
|
+
typeof HTMLElement === "undefined"
|
|
3
|
+
? (class {} as unknown as typeof HTMLElement)
|
|
4
|
+
: HTMLElement;
|
|
5
|
+
|
|
6
|
+
/** Stable unique id for associating labels and controls. */
|
|
7
|
+
export const vikingWcUid = (prefix: string): string =>
|
|
8
|
+
`${prefix}-${Math.random().toString(36).slice(2, 9)}`;
|
|
9
|
+
|
|
10
|
+
/** Escape text for safe innerHTML insertion. */
|
|
11
|
+
export const escapeHtml = (value: string): string => {
|
|
12
|
+
const entities: Record<string, string> = {
|
|
13
|
+
"&": "&",
|
|
14
|
+
"<": "<",
|
|
15
|
+
">": ">",
|
|
16
|
+
'"': """,
|
|
17
|
+
"'": "'",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return value.replace(
|
|
21
|
+
/[&<>"']/g,
|
|
22
|
+
(character) => entities[character] ?? character,
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Platform modifier label for keyboard shortcut hints. */
|
|
27
|
+
export const modKeyLabel = (): string =>
|
|
28
|
+
typeof navigator !== "undefined" &&
|
|
29
|
+
/Mac|iPhone|iPad/i.test(navigator.platform)
|
|
30
|
+
? "⌘"
|
|
31
|
+
: "Ctrl";
|
|
32
|
+
|
|
33
|
+
/** Register a custom element when the runtime supports it (skip during SSR/prerender). */
|
|
34
|
+
export const defineCustomElement = (
|
|
35
|
+
tag: string,
|
|
36
|
+
ctor: CustomElementConstructor,
|
|
37
|
+
): void => {
|
|
38
|
+
if (typeof customElements === "undefined" || customElements.get(tag)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
customElements.define(tag, ctor);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Register an alias tag with a fresh subclass; customElements disallows reusing constructors. */
|
|
45
|
+
export const defineCustomElementAlias = <T extends CustomElementConstructor>(
|
|
46
|
+
tag: string,
|
|
47
|
+
ctor: T,
|
|
48
|
+
): void => {
|
|
49
|
+
if (typeof customElements === "undefined" || customElements.get(tag)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
customElements.define(tag, class extends ctor {});
|
|
53
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveVikingIcon,
|
|
3
|
+
VIKING_FILLED_ICON_NAMES,
|
|
4
|
+
VIKING_ICON_FILLED_PATHS,
|
|
5
|
+
VIKING_ICON_PATHS,
|
|
6
|
+
type VikingIconName,
|
|
7
|
+
} from "../../lib/core/icons";
|
|
8
|
+
|
|
9
|
+
const FILLED_ICON_SET = new Set<string>(VIKING_FILLED_ICON_NAMES);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Renders a zero-dependency inline SVG icon for Web Components.
|
|
13
|
+
* Uses the same registry as `viking-icon` in Angular.
|
|
14
|
+
*/
|
|
15
|
+
export const renderInlineIcon = (
|
|
16
|
+
name: string,
|
|
17
|
+
size = 16,
|
|
18
|
+
className = "viking-wc-icon",
|
|
19
|
+
): string => {
|
|
20
|
+
const resolved = resolveVikingIcon(name);
|
|
21
|
+
const filled = FILLED_ICON_SET.has(resolved);
|
|
22
|
+
const paths = filled
|
|
23
|
+
? (VIKING_ICON_FILLED_PATHS[resolved as VikingIconName] ??
|
|
24
|
+
VIKING_ICON_PATHS[resolved])
|
|
25
|
+
: VIKING_ICON_PATHS[resolved];
|
|
26
|
+
|
|
27
|
+
if (filled) {
|
|
28
|
+
return `<svg class="${className}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="currentColor" fill-rule="evenodd" aria-hidden="true">${paths}</svg>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return `<svg class="${className}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Default tone → icon mapping shared by callout and badge surfaces. */
|
|
35
|
+
export const TONE_ICON_NAMES: Record<string, string> = {
|
|
36
|
+
accent: "info",
|
|
37
|
+
secondary: "info",
|
|
38
|
+
success: "check-circle",
|
|
39
|
+
warning: "alert-triangle",
|
|
40
|
+
danger: "alert-circle",
|
|
41
|
+
info: "info",
|
|
42
|
+
muted: "info",
|
|
43
|
+
subtle: "info",
|
|
44
|
+
};
|