@carbon/ibm-products-web-components
Version:
Carbon for IBM Products Web Components
116 lines (114 loc) • 3.75 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import "../../globals/settings.js";
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.127.0/helpers/decorate.js";
import notification_footer_default$1 from "./notification-footer.scss.js";
import { LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import HostListenerMixin from "@carbon/web-components/es/globals/mixins/host-listener.js";
import { selectorTabbable } from "@carbon/web-components/es/globals/settings.js";
import { carbonElement } from "@carbon/web-components/es/globals/decorators/carbon-element.js";
import { iconLoader } from "@carbon/web-components/es/globals/internal/icon-loader.js";
import Settings16 from "@carbon/icons/es/settings/16";
//#region src/components/notification-panel/notification-footer.ts
/**
* @license
*
* Copyright IBM Corp. 2023, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const blockClass = `c4p--notifications-panel`;
/**
* Notification Footer.
*
* @element c4p-notification-footer
* @csspart dialog The dialog.
* @fires c4p-notification-view-all
* The custom event is fired when a user clicks on View All button.
* @fires c4p-notification-settings - The custom event is fired when User clicks on settings button.
*/
let CDSNotificationFooter = class CDSNotificationFooter extends HostListenerMixin(LitElement) {
constructor(..._args) {
super(..._args);
this.viewAllLabel = "View All";
}
render() {
const { viewAllLabel, _viewAllNotification: viewAllNotification, _onClickSettings: onClickSettings } = this;
return html`
<cds-custom-button
kind="ghost"
class="${blockClass}__view-all-button"
@click=${viewAllNotification}
>
${viewAllLabel}
</cds-custom-button>
<cds-custom-button
kind="ghost"
size="sm"
class="${blockClass}__settings-button"
@click=${onClickSettings}
>
${iconLoader(Settings16, { slot: "icon" })}
</cds-custom-button>
`;
}
_viewAllNotification(event) {
const triggeredBy = event.target;
event.stopPropagation();
const init = {
bubbles: true,
cancelable: true,
composed: true,
detail: { triggeredBy }
};
this.dispatchEvent(new CustomEvent(this.constructor.notificationViewAll, init));
}
_onClickSettings(event) {
const triggeredBy = event.target;
event.stopPropagation();
const init = {
bubbles: true,
cancelable: true,
composed: true,
detail: { triggeredBy }
};
this.dispatchEvent(new CustomEvent(this.constructor.notificationSettings, init));
}
/**
* A selector selecting tabbable nodes.
*/
static get selectorTabbable() {
return selectorTabbable;
}
/**
* The custom event is fired when a notification is clicked or when the Enter key is pressed on it.
*/
static get notificationViewAll() {
return `c4p-notification-view-all`;
}
/**
* The custom event is fired when the notification is closed by a user gesture.
*/
static get notificationSettings() {
return `c4p-notification-settings`;
}
static {
this.styles = notification_footer_default$1;
}
};
__decorate([property({
reflect: true,
type: String,
attribute: "view-all-label"
})], CDSNotificationFooter.prototype, "viewAllLabel", void 0);
CDSNotificationFooter = __decorate([carbonElement(`c4p-notification-footer`)], CDSNotificationFooter);
var notification_footer_default = CDSNotificationFooter;
//#endregion
export { notification_footer_default as default };
//# sourceMappingURL=notification-footer.js.map