import { css, html } from 'lit' import { property, query, state } from 'lit/decorators.js' import { classMap } from 'lit/directives/class-map.js' import { when } from 'lit/directives/when.js' import { unsafeHTML } from 'lit/directives/unsafe-html.js' import type { Placement } from '@floating-ui/dom' import { customElementIfNotExist } from '../../utils/customElementIfNotExist' import { dispatchCustomEvent } from '../../utils/dispatchCustomEvent' import { UsBaseElement } from '../base/UsBaseElement' import { getDataByLocale, localizeManager, localized } from '../../dependencies' import UsInsightButton_css from './insightButton.pcss' import vars_css from './vars.pcss' import type { IInsgihtOpenEventData, IInsightAction, IInsightButtonProps, IInsightCTAEventData } from './model/IInsightButtonProps' import { IInsightActionName, IInsightActionType, IInsightNotificationCounterVariant } from './model/IInsightButtonProps' import '../button/UsButton' import '../notification/UsNotification' import '../tooltip/UsTooltip' import '../badge/UsBadge' import '../alert/UsAlert' declare global { interface HTMLElementTagNameMap { 'us-insight-button': UsInsightButton } } @customElementIfNotExist('us-insight-button') @localized() export class UsInsightButton extends UsBaseElement implements IInsightButtonProps { static override styles = [ UsBaseElement.styles, css([vars_css] as TemplateStringsArray | any), css([UsInsightButton_css] as TemplateStringsArray | any), ] @property({ type: Boolean, attribute: 'item' }) isItem!: boolean @property({ type: Boolean, attribute: 'alert' }) isAlert!: boolean @property({ type: Boolean, attribute: 'read' }) isRead!: boolean @property({ type: Boolean }) demo = false @property({ type: Boolean }) disableApps = false @property({ type: Boolean }) showAction = false @property({ type: String }) insightId!: string @property({ type: String }) placementId!: string @property({ type: Number }) flipPadding!: number @property({ type: Number }) notificationCounter = 0 @property({ type: String }) tooltip = '' @property({ type: String }) tooltipCorner: Placement = 'bottom' @property({ type: String }) tooltipStrategy: 'absolute' | 'fixed' = 'absolute' @property({ type: String }) locale = '' @property({ type: String }) widgetView = '' @property({ type: Object }) actionData = {} as IInsightAction @property({ type: String }) notificationVariant: IInsightNotificationCounterVariant = IInsightNotificationCounterVariant.COUNTER @property({ type: String, attribute: 'data-testid', reflect: true }) dataTestId = 'button_insight' @state() inFocus = false @query('#item-button') itemButtonEl!: HTMLButtonElement | null render() { return html`
` } renderCurrentView() { switch (true) { case this.isItem: return this.renderItemBtn() case this.isAlert: return this.renderAlert() default: return this.renderListBtn() } } renderListBtn() { return html` ` } renderItemBtn() { return html`