@govtechsg/sgds-web-component 3.6.0-rc.2 → 3.6.0
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/base/button.js +1 -1
- package/components/Alert/index.umd.min.js +17 -17
- package/components/Alert/index.umd.min.js.map +1 -1
- package/components/Alert/sgds-alert.d.ts +1 -1
- package/components/Alert/sgds-alert.js +2 -2
- package/components/Alert/sgds-alert.js.map +1 -1
- package/components/Badge/index.umd.min.js +16 -16
- package/components/Badge/index.umd.min.js.map +1 -1
- package/components/Badge/sgds-badge.d.ts +1 -1
- package/components/Badge/sgds-badge.js +2 -2
- package/components/Badge/sgds-badge.js.map +1 -1
- package/components/Breadcrumb/index.umd.min.js +17 -17
- package/components/Breadcrumb/index.umd.min.js.map +1 -1
- package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +1 -0
- package/components/Breadcrumb/sgds-breadcrumb-item.js +5 -2
- package/components/Breadcrumb/sgds-breadcrumb-item.js.map +1 -1
- package/components/Button/index.umd.min.js +1 -1
- package/components/Card/index.umd.min.js.map +1 -1
- package/components/Card/sgds-card.js.map +1 -1
- package/components/CloseButton/close-button.js +6 -0
- package/components/CloseButton/index.js +5 -0
- package/components/CloseButton/index.js.map +1 -0
- package/components/CloseButton/index.umd.min.js +50 -0
- package/components/CloseButton/index.umd.min.js.map +1 -0
- package/{internals → components}/CloseButton/sgds-close-button.d.ts +2 -4
- package/{internals → components}/CloseButton/sgds-close-button.js +4 -10
- package/components/CloseButton/sgds-close-button.js.map +1 -0
- package/components/ComboBox/index.umd.min.js +18 -18
- package/components/ComboBox/index.umd.min.js.map +1 -1
- package/components/Datepicker/index.umd.min.js +1 -1
- package/components/Datepicker/index.umd.min.js.map +1 -1
- package/components/Drawer/index.umd.min.js +6 -11
- package/components/Drawer/index.umd.min.js.map +1 -1
- package/components/Drawer/sgds-drawer.d.ts +1 -1
- package/components/Drawer/sgds-drawer.js +1 -1
- package/components/Drawer/sgds-drawer.js.map +1 -1
- package/components/FileUpload/index.umd.min.js +26 -26
- package/components/FileUpload/index.umd.min.js.map +1 -1
- package/components/FileUpload/sgds-file-upload.d.ts +1 -1
- package/components/FileUpload/sgds-file-upload.js +1 -1
- package/components/FileUpload/sgds-file-upload.js.map +1 -1
- package/components/Footer/footer-item.js +1 -1
- package/components/Footer/footer.js +1 -1
- package/components/Footer/index.umd.min.js +17 -17
- package/components/Footer/index.umd.min.js.map +1 -1
- package/components/Footer/sgds-footer-item.d.ts +1 -0
- package/components/Footer/sgds-footer-item.js +11 -1
- package/components/Footer/sgds-footer-item.js.map +1 -1
- package/components/Footer/sgds-footer.js +7 -7
- package/components/Footer/sgds-footer.js.map +1 -1
- package/components/IconButton/index.umd.min.js +1 -1
- package/components/IconCard/index.umd.min.js.map +1 -1
- package/components/IconCard/sgds-icon-card.js.map +1 -1
- package/components/ImageCard/index.umd.min.js.map +1 -1
- package/components/ImageCard/sgds-image-card.js.map +1 -1
- package/components/Input/index.umd.min.js.map +1 -1
- package/components/Input/sgds-input.js.map +1 -1
- package/components/Link/index.umd.min.js +9 -9
- package/components/Link/index.umd.min.js.map +1 -1
- package/components/Link/link.js +1 -1
- package/components/Link/sgds-link.d.ts +7 -1
- package/components/Link/sgds-link.js +28 -2
- package/components/Link/sgds-link.js.map +1 -1
- package/components/Mainnav/index.umd.min.js +1 -1
- package/components/Modal/index.umd.min.js +4 -4
- package/components/Modal/index.umd.min.js.map +1 -1
- package/components/Modal/sgds-modal.d.ts +1 -1
- package/components/Modal/sgds-modal.js +2 -2
- package/components/Modal/sgds-modal.js.map +1 -1
- package/components/Pagination/index.umd.min.js +1 -1
- package/components/QuantityToggle/index.umd.min.js +1 -1
- package/components/QuantityToggle/index.umd.min.js.map +1 -1
- package/components/Subnav/index.umd.min.js +11 -9
- package/components/Subnav/index.umd.min.js.map +1 -1
- package/components/Subnav/sgds-subnav.d.ts +4 -0
- package/components/Subnav/sgds-subnav.js +18 -2
- package/components/Subnav/sgds-subnav.js.map +1 -1
- package/components/Subnav/subnav.js +1 -1
- package/components/SystemBanner/index.d.ts +6 -0
- package/components/SystemBanner/index.js +6 -0
- package/components/SystemBanner/index.js.map +1 -0
- package/components/SystemBanner/index.umd.min.js +2101 -0
- package/components/SystemBanner/index.umd.min.js.map +1 -0
- package/components/SystemBanner/sgds-system-banner-item.d.ts +24 -0
- package/components/SystemBanner/sgds-system-banner-item.js +93 -0
- package/components/SystemBanner/sgds-system-banner-item.js.map +1 -0
- package/components/SystemBanner/sgds-system-banner.d.ts +51 -0
- package/components/SystemBanner/sgds-system-banner.js +224 -0
- package/components/SystemBanner/sgds-system-banner.js.map +1 -0
- package/components/SystemBanner/system-banner-context.d.ts +3 -0
- package/components/SystemBanner/system-banner-context.js +6 -0
- package/components/SystemBanner/system-banner-context.js.map +1 -0
- package/components/SystemBanner/system-banner-item.js +6 -0
- package/components/SystemBanner/system-banner-item.js.map +1 -0
- package/components/SystemBanner/system-banner.js +6 -0
- package/components/SystemBanner/system-banner.js.map +1 -0
- package/components/Toast/index.umd.min.js +12 -12
- package/components/Toast/index.umd.min.js.map +1 -1
- package/components/Toast/sgds-toast.d.ts +1 -1
- package/components/Toast/sgds-toast.js +2 -2
- package/components/Toast/sgds-toast.js.map +1 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -1
- package/components/index.umd.min.js +168 -136
- package/components/index.umd.min.js.map +1 -1
- package/css/fouc.css +3 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.umd.min.js +212 -161
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/base/button.cjs.js +1 -1
- package/react/base/button.js +1 -1
- package/react/close-button/index.cjs.js +40 -0
- package/react/close-button/index.cjs.js.map +1 -0
- package/react/close-button/index.d.ts +2 -0
- package/react/close-button/index.js +16 -0
- package/react/close-button/index.js.map +1 -0
- package/react/components/Alert/sgds-alert.cjs.js +2 -2
- package/react/components/Alert/sgds-alert.cjs.js.map +1 -1
- package/react/components/Alert/sgds-alert.js +2 -2
- package/react/components/Alert/sgds-alert.js.map +1 -1
- package/react/components/Badge/sgds-badge.cjs.js +2 -2
- package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
- package/react/components/Badge/sgds-badge.js +2 -2
- package/react/components/Badge/sgds-badge.js.map +1 -1
- package/react/components/Breadcrumb/sgds-breadcrumb-item.cjs.js +5 -2
- package/react/components/Breadcrumb/sgds-breadcrumb-item.cjs.js.map +1 -1
- package/react/components/Breadcrumb/sgds-breadcrumb-item.js +5 -2
- package/react/components/Breadcrumb/sgds-breadcrumb-item.js.map +1 -1
- package/react/components/Card/sgds-card.cjs.js.map +1 -1
- package/react/components/Card/sgds-card.js.map +1 -1
- package/react/components/CloseButton/close-button.cjs.js +11 -0
- package/react/components/CloseButton/close-button.js +7 -0
- package/react/{internals → components}/CloseButton/sgds-close-button.cjs.js +4 -10
- package/react/components/CloseButton/sgds-close-button.cjs.js.map +1 -0
- package/react/{internals → components}/CloseButton/sgds-close-button.js +4 -10
- package/react/components/CloseButton/sgds-close-button.js.map +1 -0
- package/react/components/Drawer/sgds-drawer.cjs.js +1 -1
- package/react/components/Drawer/sgds-drawer.cjs.js.map +1 -1
- package/react/components/Drawer/sgds-drawer.js +1 -1
- package/react/components/Drawer/sgds-drawer.js.map +1 -1
- package/react/components/FileUpload/sgds-file-upload.cjs.js +1 -1
- package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
- package/react/components/FileUpload/sgds-file-upload.js +1 -1
- package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
- package/react/components/Footer/footer-item.cjs.js +1 -1
- package/react/components/Footer/footer-item.js +1 -1
- package/react/components/Footer/footer.cjs.js +1 -1
- package/react/components/Footer/footer.js +1 -1
- package/react/components/Footer/sgds-footer-item.cjs.js +11 -1
- package/react/components/Footer/sgds-footer-item.cjs.js.map +1 -1
- package/react/components/Footer/sgds-footer-item.js +11 -1
- package/react/components/Footer/sgds-footer-item.js.map +1 -1
- package/react/components/Footer/sgds-footer.cjs.js +7 -7
- package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
- package/react/components/Footer/sgds-footer.js +7 -7
- package/react/components/Footer/sgds-footer.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.js.map +1 -1
- package/react/components/Input/sgds-input.cjs.js.map +1 -1
- package/react/components/Input/sgds-input.js.map +1 -1
- package/react/components/Link/link.cjs.js +1 -1
- package/react/components/Link/link.js +1 -1
- package/react/components/Link/sgds-link.cjs.js +28 -2
- package/react/components/Link/sgds-link.cjs.js.map +1 -1
- package/react/components/Link/sgds-link.js +28 -2
- package/react/components/Link/sgds-link.js.map +1 -1
- package/react/components/Modal/sgds-modal.cjs.js +2 -2
- package/react/components/Modal/sgds-modal.cjs.js.map +1 -1
- package/react/components/Modal/sgds-modal.js +2 -2
- package/react/components/Modal/sgds-modal.js.map +1 -1
- package/react/components/Subnav/sgds-subnav.cjs.js +17 -1
- package/react/components/Subnav/sgds-subnav.cjs.js.map +1 -1
- package/react/components/Subnav/sgds-subnav.js +18 -2
- package/react/components/Subnav/sgds-subnav.js.map +1 -1
- package/react/components/Subnav/subnav.cjs.js +1 -1
- package/react/components/Subnav/subnav.js +1 -1
- package/react/components/SystemBanner/sgds-system-banner-item.cjs.js +99 -0
- package/react/components/SystemBanner/sgds-system-banner-item.cjs.js.map +1 -0
- package/react/components/SystemBanner/sgds-system-banner-item.js +94 -0
- package/react/components/SystemBanner/sgds-system-banner-item.js.map +1 -0
- package/react/components/SystemBanner/sgds-system-banner.cjs.js +230 -0
- package/react/components/SystemBanner/sgds-system-banner.cjs.js.map +1 -0
- package/react/components/SystemBanner/sgds-system-banner.js +225 -0
- package/react/components/SystemBanner/sgds-system-banner.js.map +1 -0
- package/react/components/SystemBanner/system-banner-context.cjs.js +11 -0
- package/react/components/SystemBanner/system-banner-context.cjs.js.map +1 -0
- package/react/components/SystemBanner/system-banner-context.js +7 -0
- package/react/components/SystemBanner/system-banner-context.js.map +1 -0
- package/react/components/SystemBanner/system-banner-item.cjs.js +11 -0
- package/react/components/SystemBanner/system-banner-item.cjs.js.map +1 -0
- package/react/components/SystemBanner/system-banner-item.js +7 -0
- package/react/components/SystemBanner/system-banner-item.js.map +1 -0
- package/react/components/SystemBanner/system-banner.cjs.js +11 -0
- package/react/components/SystemBanner/system-banner.cjs.js.map +1 -0
- package/react/components/SystemBanner/system-banner.js +7 -0
- package/react/components/SystemBanner/system-banner.js.map +1 -0
- package/react/components/Toast/sgds-toast.cjs.js +2 -2
- package/react/components/Toast/sgds-toast.cjs.js.map +1 -1
- package/react/components/Toast/sgds-toast.js +2 -2
- package/react/components/Toast/sgds-toast.js.map +1 -1
- package/react/index.cjs.js +114 -108
- package/react/index.cjs.js.map +1 -1
- package/react/index.d.ts +3 -0
- package/react/index.js +3 -0
- package/react/index.js.map +1 -1
- package/react/system-banner/index.cjs.js +43 -0
- package/react/system-banner/index.cjs.js.map +1 -0
- package/react/system-banner/index.d.ts +2 -0
- package/react/system-banner/index.js +19 -0
- package/react/system-banner/index.js.map +1 -0
- package/react/system-banner-item/index.cjs.js +42 -0
- package/react/system-banner-item/index.cjs.js.map +1 -0
- package/react/system-banner-item/index.d.ts +2 -0
- package/react/system-banner-item/index.js +18 -0
- package/react/system-banner-item/index.js.map +1 -0
- package/themes/root.css +14 -2
- package/internals/CloseButton/close-button.js +0 -6
- package/internals/CloseButton/sgds-close-button.js.map +0 -1
- package/react/internals/CloseButton/close-button.cjs.js +0 -11
- package/react/internals/CloseButton/close-button.js +0 -7
- package/react/internals/CloseButton/sgds-close-button.cjs.js.map +0 -1
- package/react/internals/CloseButton/sgds-close-button.js.map +0 -1
- package/utils/test.d.ts +0 -28
- /package/{internals → components}/CloseButton/close-button.js.map +0 -0
- /package/{internals → components}/CloseButton/index.d.ts +0 -0
- /package/react/{internals → components}/CloseButton/close-button.cjs.js.map +0 -0
- /package/react/{internals → components}/CloseButton/close-button.js.map +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import SgdsElement from "../../base/sgds-element";
|
|
2
|
+
/**
|
|
3
|
+
* @slot icon - The slot to pass in an icon element.
|
|
4
|
+
* @slot action - The slot to pass in an action element such as a button or link
|
|
5
|
+
* @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view
|
|
6
|
+
*
|
|
7
|
+
* @event sgds-show-more - The event emitted when user clicks on "show more" in the banner text message
|
|
8
|
+
*/
|
|
9
|
+
export declare class SgdsSystemBannerItem extends SgdsElement {
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
/** Used only for SSR to indicate the presence of the `action` slot. */
|
|
12
|
+
hasActionSlot: boolean;
|
|
13
|
+
private clamped;
|
|
14
|
+
private siblingsCount;
|
|
15
|
+
private readonly hasSlotController;
|
|
16
|
+
private _resizeObserver;
|
|
17
|
+
firstUpdated(_changedProperties: any): Promise<void>;
|
|
18
|
+
disconnectedCallback(): void;
|
|
19
|
+
updated(): void;
|
|
20
|
+
private _clampCheck;
|
|
21
|
+
private _handleShowMoreClick;
|
|
22
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
23
|
+
}
|
|
24
|
+
export default SgdsSystemBannerItem;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { property, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import SgdsElement from '../../base/sgds-element.js';
|
|
6
|
+
import css_248z from './system-banner-item.js';
|
|
7
|
+
import { HasSlotController } from '../../utils/slot.js';
|
|
8
|
+
import { SystemBannerChildCountContext } from './system-banner-context.js';
|
|
9
|
+
import { consume } from '@lit/context';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @slot icon - The slot to pass in an icon element.
|
|
13
|
+
* @slot action - The slot to pass in an action element such as a button or link
|
|
14
|
+
* @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view
|
|
15
|
+
*
|
|
16
|
+
* @event sgds-show-more - The event emitted when user clicks on "show more" in the banner text message
|
|
17
|
+
*/
|
|
18
|
+
class SgdsSystemBannerItem extends SgdsElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
/** Used only for SSR to indicate the presence of the `action` slot. */
|
|
22
|
+
this.hasActionSlot = false;
|
|
23
|
+
this.clamped = false;
|
|
24
|
+
this.siblingsCount = 0;
|
|
25
|
+
this.hasSlotController = new HasSlotController(this, "action");
|
|
26
|
+
}
|
|
27
|
+
async firstUpdated(_changedProperties) {
|
|
28
|
+
super.firstUpdated(_changedProperties);
|
|
29
|
+
await this.updateComplete;
|
|
30
|
+
this._clampCheck();
|
|
31
|
+
// Watch resizing for dynamic layout changes
|
|
32
|
+
this._resizeObserver = new ResizeObserver(() => this._clampCheck());
|
|
33
|
+
this._resizeObserver.observe(this.shadowRoot.querySelector(".message"));
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
super.disconnectedCallback();
|
|
37
|
+
if (this._resizeObserver)
|
|
38
|
+
this._resizeObserver.disconnect();
|
|
39
|
+
}
|
|
40
|
+
updated() {
|
|
41
|
+
if (!this.hasActionSlot)
|
|
42
|
+
this.hasActionSlot = this.hasSlotController.test("action");
|
|
43
|
+
}
|
|
44
|
+
_clampCheck() {
|
|
45
|
+
const textEl = this.shadowRoot.querySelector(".message");
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
this.clamped = textEl.scrollHeight > textEl.clientHeight;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
_handleShowMoreClick() {
|
|
51
|
+
this.emit("sgds-show-more");
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
return html `
|
|
55
|
+
<div class="banner-item">
|
|
56
|
+
<slot name="icon"></slot>
|
|
57
|
+
<div class="banner-item__message_and__action">
|
|
58
|
+
<div class="clamped-container">
|
|
59
|
+
<div class=${classMap({ message: true, truncated: this.clamped })}>
|
|
60
|
+
<slot></slot>
|
|
61
|
+
</div>
|
|
62
|
+
${this.clamped
|
|
63
|
+
? html `<span class="show-more"
|
|
64
|
+
>...<a class="show-more__link" @click="${this._handleShowMoreClick}">show more</a></span
|
|
65
|
+
>`
|
|
66
|
+
: nothing}
|
|
67
|
+
</div>
|
|
68
|
+
${this.hasActionSlot || this.siblingsCount > 1
|
|
69
|
+
? html `
|
|
70
|
+
<div class="action">
|
|
71
|
+
<slot name="action"></slot>
|
|
72
|
+
</div>
|
|
73
|
+
`
|
|
74
|
+
: nothing}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
SgdsSystemBannerItem.styles = [...SgdsElement.styles, css_248z];
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: Boolean })
|
|
83
|
+
], SgdsSystemBannerItem.prototype, "hasActionSlot", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
state()
|
|
86
|
+
], SgdsSystemBannerItem.prototype, "clamped", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
consume({ context: SystemBannerChildCountContext, subscribe: true }),
|
|
89
|
+
state()
|
|
90
|
+
], SgdsSystemBannerItem.prototype, "siblingsCount", void 0);
|
|
91
|
+
|
|
92
|
+
export { SgdsSystemBannerItem, SgdsSystemBannerItem as default };
|
|
93
|
+
//# sourceMappingURL=sgds-system-banner-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sgds-system-banner-item.js","sources":["../../../src/components/SystemBanner/sgds-system-banner-item.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport alertBannerItemStyles from \"./system-banner-item.css\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { SystemBannerChildCountContext } from \"./system-banner-context\";\nimport { consume } from \"@lit/context\";\n\n/**\n * @slot icon - The slot to pass in an icon element.\n * @slot action - The slot to pass in an action element such as a button or link\n * @slot default - The slot to pass in the message content of the banner item. Text will be clamped at 2 lines in desktop view and 5 lines in mobile view\n *\n * @event sgds-show-more - The event emitted when user clicks on \"show more\" in the banner text message\n */\nexport class SgdsSystemBannerItem extends SgdsElement {\n static styles = [...SgdsElement.styles, alertBannerItemStyles];\n /** Used only for SSR to indicate the presence of the `action` slot. */\n @property({ type: Boolean }) hasActionSlot = false;\n\n @state() private clamped = false;\n\n @consume({ context: SystemBannerChildCountContext, subscribe: true })\n @state()\n private siblingsCount = 0;\n\n private readonly hasSlotController = new HasSlotController(this, \"action\");\n\n private _resizeObserver: ResizeObserver;\n async firstUpdated(_changedProperties) {\n super.firstUpdated(_changedProperties);\n await this.updateComplete;\n this._clampCheck();\n\n // Watch resizing for dynamic layout changes\n this._resizeObserver = new ResizeObserver(() => this._clampCheck());\n this._resizeObserver.observe(this.shadowRoot.querySelector(\".message\"));\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this._resizeObserver) this._resizeObserver.disconnect();\n }\n updated() {\n if (!this.hasActionSlot) this.hasActionSlot = this.hasSlotController.test(\"action\");\n }\n private _clampCheck() {\n const textEl = this.shadowRoot.querySelector(\".message\");\n requestAnimationFrame(() => {\n this.clamped = textEl.scrollHeight > textEl.clientHeight;\n });\n }\n\n private _handleShowMoreClick() {\n this.emit(\"sgds-show-more\");\n }\n render() {\n return html`\n <div class=\"banner-item\">\n <slot name=\"icon\"></slot>\n <div class=\"banner-item__message_and__action\">\n <div class=\"clamped-container\">\n <div class=${classMap({ message: true, truncated: this.clamped })}>\n <slot></slot>\n </div>\n ${this.clamped\n ? html`<span class=\"show-more\"\n >...<a class=\"show-more__link\" @click=\"${this._handleShowMoreClick}\">show more</a></span\n >`\n : nothing}\n </div>\n ${this.hasActionSlot || this.siblingsCount > 1\n ? html`\n <div class=\"action\">\n <slot name=\"action\"></slot>\n </div>\n `\n : nothing}\n </div>\n </div>\n `;\n }\n}\nexport default SgdsSystemBannerItem;\n"],"names":["alertBannerItemStyles"],"mappings":";;;;;;;;;;AASA;;;;;;AAMG;AACG,MAAO,oBAAqB,SAAQ,WAAW,CAAA;AAArD,IAAA,WAAA,GAAA;;;QAG+B,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;QAElC,IAAO,CAAA,OAAA,GAAG,KAAK,CAAC;QAIzB,IAAa,CAAA,aAAA,GAAG,CAAC,CAAC;QAET,IAAiB,CAAA,iBAAA,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAwD5E;IArDC,MAAM,YAAY,CAAC,kBAAkB,EAAA;AACnC,QAAA,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;;AAGnB,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACpE,QAAA,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;KACzE;IAED,oBAAoB,GAAA;QAClB,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,eAAe;AAAE,YAAA,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;KAC7D;IACD,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACrF;IACO,WAAW,GAAA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SAAS,EAAE,IAAI,EAAE,CAAC;AACpE,IAAA,KAAK,EAAE;AACkB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PropertyValueMap } from "lit";
|
|
2
|
+
import SgdsElement from "../../base/sgds-element";
|
|
3
|
+
import SgdsCloseButton from "../CloseButton/sgds-close-button";
|
|
4
|
+
import SgdsIcon from "../Icon/sgds-icon";
|
|
5
|
+
import SgdsIconButton from "../IconButton/sgds-icon-button";
|
|
6
|
+
/**
|
|
7
|
+
* @summary The system banner component for displaying important messages to users at the application level.
|
|
8
|
+
* Each banner can contain up to 5 banner items that cycle automatically every 5 seconds. Pagination appears when there are multiple items, allowing users to navigate between them. The banner can also be made dismissible with a close button.
|
|
9
|
+
* `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.
|
|
10
|
+
*
|
|
11
|
+
* @slot default - The slot to pass in `sgds-system-banner-item`
|
|
12
|
+
*
|
|
13
|
+
* @event sgds-show - Emitted when the banner has start to appear on screen
|
|
14
|
+
* @event sgds-hide - Emitted when the banner is disappearing from the screen
|
|
15
|
+
*/
|
|
16
|
+
export declare class SgdsSystemBanner extends SgdsElement {
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
/**@internal */
|
|
19
|
+
static dependencies: {
|
|
20
|
+
"sgds-close-button": typeof SgdsCloseButton;
|
|
21
|
+
"sgds-icon": typeof SgdsIcon;
|
|
22
|
+
"sgds-icon-button": typeof SgdsIconButton;
|
|
23
|
+
};
|
|
24
|
+
/** Controls the appearance of the alert */
|
|
25
|
+
show: boolean;
|
|
26
|
+
/** Enables a close button that allows the user to dismiss the alert. */
|
|
27
|
+
dismissible: boolean;
|
|
28
|
+
/** Closes the alert */
|
|
29
|
+
close(): void;
|
|
30
|
+
private bannerItem;
|
|
31
|
+
private banner;
|
|
32
|
+
private childCount;
|
|
33
|
+
private _intervalId;
|
|
34
|
+
private _intervalTime;
|
|
35
|
+
private _currentIndex;
|
|
36
|
+
protected firstUpdated(changedProperties: PropertyValueMap<this>): void;
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
/**@internal */
|
|
39
|
+
_handleShowChange(): Promise<void>;
|
|
40
|
+
private _updateActiveItem;
|
|
41
|
+
private _next;
|
|
42
|
+
private _prev;
|
|
43
|
+
private _animateItem;
|
|
44
|
+
private _startAutoCycle;
|
|
45
|
+
private _stopAutoCycle;
|
|
46
|
+
private _resetAutoCycle;
|
|
47
|
+
private _pauseAutoCycle;
|
|
48
|
+
private _resumeAutoCycle;
|
|
49
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
50
|
+
}
|
|
51
|
+
export default SgdsSystemBanner;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { property, queryAssignedElements, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import SgdsElement from '../../base/sgds-element.js';
|
|
6
|
+
import { SgdsCloseButton } from '../CloseButton/sgds-close-button.js';
|
|
7
|
+
import { animateTo } from '../../utils/animate.js';
|
|
8
|
+
import { setDefaultAnimation, getAnimation } from '../../utils/animation-registry.js';
|
|
9
|
+
import { watch } from '../../utils/watch.js';
|
|
10
|
+
import { SgdsIcon } from '../Icon/sgds-icon.js';
|
|
11
|
+
import { SgdsIconButton } from '../IconButton/sgds-icon-button.js';
|
|
12
|
+
import css_248z from './system-banner.js';
|
|
13
|
+
import { SystemBannerChildCountContext } from './system-banner-context.js';
|
|
14
|
+
import { provide } from '@lit/context';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @summary The system banner component for displaying important messages to users at the application level.
|
|
18
|
+
* Each banner can contain up to 5 banner items that cycle automatically every 5 seconds. Pagination appears when there are multiple items, allowing users to navigate between them. The banner can also be made dismissible with a close button.
|
|
19
|
+
* `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.
|
|
20
|
+
*
|
|
21
|
+
* @slot default - The slot to pass in `sgds-system-banner-item`
|
|
22
|
+
*
|
|
23
|
+
* @event sgds-show - Emitted when the banner has start to appear on screen
|
|
24
|
+
* @event sgds-hide - Emitted when the banner is disappearing from the screen
|
|
25
|
+
*/
|
|
26
|
+
class SgdsSystemBanner extends SgdsElement {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
/** Controls the appearance of the alert */
|
|
30
|
+
this.show = false;
|
|
31
|
+
/** Enables a close button that allows the user to dismiss the alert. */
|
|
32
|
+
this.dismissible = false;
|
|
33
|
+
this._intervalId = null;
|
|
34
|
+
this._intervalTime = 5000;
|
|
35
|
+
this._currentIndex = 0;
|
|
36
|
+
}
|
|
37
|
+
/** Closes the alert */
|
|
38
|
+
close() {
|
|
39
|
+
this.show = false;
|
|
40
|
+
}
|
|
41
|
+
firstUpdated(changedProperties) {
|
|
42
|
+
super.firstUpdated(changedProperties);
|
|
43
|
+
this.childCount = this.bannerItem.length;
|
|
44
|
+
if (!this.show) {
|
|
45
|
+
this.banner.classList.add("d-none");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.childCount > 1 && this._startAutoCycle();
|
|
49
|
+
this.addEventListener("mouseenter", this._pauseAutoCycle.bind(this));
|
|
50
|
+
this.addEventListener("mouseleave", this._resumeAutoCycle.bind(this));
|
|
51
|
+
this.addEventListener("focus", this._pauseAutoCycle.bind(this));
|
|
52
|
+
this.addEventListener("blur", this._resumeAutoCycle.bind(this));
|
|
53
|
+
}
|
|
54
|
+
this._updateActiveItem();
|
|
55
|
+
if (this.childCount > 5) {
|
|
56
|
+
console.warn("It is not recommended to have more than 5 <sgds-system-banner-item> elements.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
disconnectedCallback() {
|
|
60
|
+
super.disconnectedCallback();
|
|
61
|
+
this._stopAutoCycle();
|
|
62
|
+
}
|
|
63
|
+
/**@internal */
|
|
64
|
+
async _handleShowChange() {
|
|
65
|
+
if (this.show) {
|
|
66
|
+
this.childCount > 1 && this._startAutoCycle();
|
|
67
|
+
this.emit("sgds-show");
|
|
68
|
+
this.banner.classList.remove("d-none");
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this._stopAutoCycle();
|
|
72
|
+
this.emit("sgds-hide");
|
|
73
|
+
this.banner.classList.add("d-none");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_updateActiveItem() {
|
|
77
|
+
const items = this.bannerItem;
|
|
78
|
+
items.forEach((item, i) => {
|
|
79
|
+
if (i === this._currentIndex) {
|
|
80
|
+
item.setAttribute("active", "");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
item.removeAttribute("active");
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
_next() {
|
|
88
|
+
const items = this.bannerItem;
|
|
89
|
+
this._currentIndex = (this._currentIndex + 1) % items.length;
|
|
90
|
+
this._updateActiveItem();
|
|
91
|
+
this._animateItem(items[this._currentIndex], "next");
|
|
92
|
+
this._resetAutoCycle();
|
|
93
|
+
}
|
|
94
|
+
_prev() {
|
|
95
|
+
const items = this.bannerItem;
|
|
96
|
+
this._currentIndex = (this._currentIndex - 1 + items.length) % items.length;
|
|
97
|
+
this._updateActiveItem();
|
|
98
|
+
this._animateItem(items[this._currentIndex], "prev");
|
|
99
|
+
this._resetAutoCycle();
|
|
100
|
+
}
|
|
101
|
+
async _animateItem(item, direction) {
|
|
102
|
+
// Cancel any existing animations before starting a new one
|
|
103
|
+
item.getAnimations().forEach(a => a.cancel());
|
|
104
|
+
// Start the slide-down animation
|
|
105
|
+
const bannerLoopMessage = getAnimation(this, `banner.item.${direction}`);
|
|
106
|
+
await animateTo(item, bannerLoopMessage.keyframes, bannerLoopMessage.options);
|
|
107
|
+
}
|
|
108
|
+
_startAutoCycle() {
|
|
109
|
+
this._stopAutoCycle(); // avoid duplicates
|
|
110
|
+
this._intervalId = setInterval(() => this._next(), this._intervalTime);
|
|
111
|
+
}
|
|
112
|
+
_stopAutoCycle() {
|
|
113
|
+
if (this._intervalId) {
|
|
114
|
+
clearInterval(this._intervalId);
|
|
115
|
+
this._intervalId = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_resetAutoCycle() {
|
|
119
|
+
this._stopAutoCycle();
|
|
120
|
+
this._startAutoCycle();
|
|
121
|
+
}
|
|
122
|
+
_pauseAutoCycle() {
|
|
123
|
+
this._stopAutoCycle();
|
|
124
|
+
}
|
|
125
|
+
_resumeAutoCycle() {
|
|
126
|
+
if (this.show && this.childCount > 1) {
|
|
127
|
+
this._startAutoCycle();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
return html `
|
|
132
|
+
<div
|
|
133
|
+
class="${classMap({
|
|
134
|
+
banner: true
|
|
135
|
+
})}"
|
|
136
|
+
role="alert"
|
|
137
|
+
aria-hidden=${this.show ? "false" : "true"}
|
|
138
|
+
>
|
|
139
|
+
<div class="content">
|
|
140
|
+
<slot id="loop-slot"></slot>
|
|
141
|
+
</div>
|
|
142
|
+
${this.childCount > 1
|
|
143
|
+
? html ` <div class="pagination">
|
|
144
|
+
<sgds-icon-button
|
|
145
|
+
name="chevron-left"
|
|
146
|
+
tone="fixed-light"
|
|
147
|
+
variant="ghost"
|
|
148
|
+
size="xs"
|
|
149
|
+
@click=${this._prev}
|
|
150
|
+
></sgds-icon-button>
|
|
151
|
+
<span>${this._currentIndex + 1}/${this.childCount}</span>
|
|
152
|
+
<sgds-icon-button
|
|
153
|
+
name="chevron-right"
|
|
154
|
+
tone="fixed-light"
|
|
155
|
+
variant="ghost"
|
|
156
|
+
size="xs"
|
|
157
|
+
@click=${this._next}
|
|
158
|
+
></sgds-icon-button>
|
|
159
|
+
</div>`
|
|
160
|
+
: nothing}
|
|
161
|
+
${this.dismissible
|
|
162
|
+
? html `
|
|
163
|
+
<sgds-close-button aria-label="close the alert" @click=${this.close} tone="fixed-light"></sgds-close-button>
|
|
164
|
+
`
|
|
165
|
+
: nothing}
|
|
166
|
+
</div>
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
SgdsSystemBanner.styles = [...SgdsElement.styles, css_248z];
|
|
171
|
+
/**@internal */
|
|
172
|
+
SgdsSystemBanner.dependencies = {
|
|
173
|
+
"sgds-close-button": SgdsCloseButton,
|
|
174
|
+
"sgds-icon": SgdsIcon,
|
|
175
|
+
"sgds-icon-button": SgdsIconButton
|
|
176
|
+
};
|
|
177
|
+
__decorate([
|
|
178
|
+
property({ type: Boolean, reflect: true })
|
|
179
|
+
], SgdsSystemBanner.prototype, "show", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
property({ type: Boolean, reflect: true })
|
|
182
|
+
], SgdsSystemBanner.prototype, "dismissible", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
queryAssignedElements({ flatten: true })
|
|
185
|
+
], SgdsSystemBanner.prototype, "bannerItem", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
query(".banner")
|
|
188
|
+
], SgdsSystemBanner.prototype, "banner", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
provide({ context: SystemBannerChildCountContext }),
|
|
191
|
+
state()
|
|
192
|
+
], SgdsSystemBanner.prototype, "childCount", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
state()
|
|
195
|
+
], SgdsSystemBanner.prototype, "_intervalId", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
state()
|
|
198
|
+
], SgdsSystemBanner.prototype, "_currentIndex", void 0);
|
|
199
|
+
__decorate([
|
|
200
|
+
watch("show", { waitUntilFirstUpdate: true })
|
|
201
|
+
], SgdsSystemBanner.prototype, "_handleShowChange", null);
|
|
202
|
+
setDefaultAnimation("banner.item.next", {
|
|
203
|
+
keyframes: [
|
|
204
|
+
{ opacity: 0, transform: "translateY(-100%)" },
|
|
205
|
+
{ opacity: 1, transform: "translateY(0)" }
|
|
206
|
+
],
|
|
207
|
+
options: {
|
|
208
|
+
duration: 500,
|
|
209
|
+
easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
setDefaultAnimation("banner.item.prev", {
|
|
213
|
+
keyframes: [
|
|
214
|
+
{ opacity: 0, transform: "translateY(100%)" },
|
|
215
|
+
{ opacity: 1, transform: "translateY(0)" }
|
|
216
|
+
],
|
|
217
|
+
options: {
|
|
218
|
+
duration: 500,
|
|
219
|
+
easing: "cubic-bezier(0.45,0.05,0.55,0.95)"
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
export { SgdsSystemBanner, SgdsSystemBanner as default };
|
|
224
|
+
//# sourceMappingURL=sgds-system-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sgds-system-banner.js","sources":["../../../src/components/SystemBanner/sgds-system-banner.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\nimport { animateTo } from \"../../utils/animate\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry\";\nimport { watch } from \"../../utils/watch\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport SgdsIconButton from \"../IconButton/sgds-icon-button\";\nimport alertBannerStyles from \"./system-banner.css\";\nimport SgdsSystemBannerItem from \"./sgds-system-banner-item\";\nimport { SystemBannerChildCountContext } from \"./system-banner-context\";\nimport { provide } from \"@lit/context\";\n\n/**\n * @summary The system banner component for displaying important messages to users at the application level.\n * Each banner can contain up to 5 banner items that cycle automatically every 5 seconds. Pagination appears when there are multiple items, allowing users to navigate between them. The banner can also be made dismissible with a close button.\n * `sgds-system-banner-item` is the subcomponent for `sgds-system-banner`. Each banner item represents a message in the system banner.\n *\n * @slot default - The slot to pass in `sgds-system-banner-item`\n *\n * @event sgds-show - Emitted when the banner has start to appear on screen\n * @event sgds-hide - Emitted when the banner is disappearing from the screen\n */\nexport class SgdsSystemBanner extends SgdsElement {\n static styles = [...SgdsElement.styles, alertBannerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton,\n \"sgds-icon\": SgdsIcon,\n \"sgds-icon-button\": SgdsIconButton\n };\n /** Controls the appearance of the alert */\n @property({ type: Boolean, reflect: true }) show = false;\n\n /** Enables a close button that allows the user to dismiss the alert. */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /** Closes the alert */\n public close() {\n this.show = false;\n }\n @queryAssignedElements({ flatten: true })\n private bannerItem: SgdsSystemBannerItem[];\n\n @query(\".banner\")\n private banner: HTMLDivElement;\n\n @provide({ context: SystemBannerChildCountContext })\n @state()\n private childCount: number;\n\n @state() private _intervalId = null;\n\n private _intervalTime = 5000;\n\n @state() private _currentIndex = 0;\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>): void {\n super.firstUpdated(changedProperties);\n this.childCount = this.bannerItem.length;\n if (!this.show) {\n this.banner.classList.add(\"d-none\");\n } else {\n this.childCount > 1 && this._startAutoCycle();\n this.addEventListener(\"mouseenter\", this._pauseAutoCycle.bind(this));\n this.addEventListener(\"mouseleave\", this._resumeAutoCycle.bind(this));\n\n this.addEventListener(\"focus\", this._pauseAutoCycle.bind(this));\n this.addEventListener(\"blur\", this._resumeAutoCycle.bind(this));\n }\n this._updateActiveItem();\n\n if (this.childCount > 5) {\n console.warn(\"It is not recommended to have more than 5 <sgds-system-banner-item> elements.\");\n }\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._stopAutoCycle();\n }\n\n /**@internal */\n @watch(\"show\", { waitUntilFirstUpdate: true })\n async _handleShowChange() {\n if (this.show) {\n this.childCount > 1 && this._startAutoCycle();\n this.emit(\"sgds-show\");\n this.banner.classList.remove(\"d-none\");\n } else {\n this._stopAutoCycle();\n this.emit(\"sgds-hide\");\n this.banner.classList.add(\"d-none\");\n }\n }\n\n private _updateActiveItem() {\n const items = this.bannerItem;\n items.forEach((item, i) => {\n if (i === this._currentIndex) {\n item.setAttribute(\"active\", \"\");\n } else {\n item.removeAttribute(\"active\");\n }\n });\n }\n private _next() {\n const items = this.bannerItem;\n this._currentIndex = (this._currentIndex + 1) % items.length;\n this._updateActiveItem();\n this._animateItem(items[this._currentIndex], \"next\");\n this._resetAutoCycle();\n }\n\n private _prev() {\n const items = this.bannerItem;\n this._currentIndex = (this._currentIndex - 1 + items.length) % items.length;\n this._updateActiveItem();\n this._animateItem(items[this._currentIndex], \"prev\");\n this._resetAutoCycle();\n }\n private async _animateItem(item: SgdsSystemBannerItem, direction: \"next\" | \"prev\") {\n // Cancel any existing animations before starting a new one\n item.getAnimations().forEach(a => a.cancel());\n // Start the slide-down animation\n const bannerLoopMessage = getAnimation(this, `banner.item.${direction}`);\n await animateTo(item, bannerLoopMessage.keyframes, bannerLoopMessage.options);\n }\n private _startAutoCycle() {\n this._stopAutoCycle(); // avoid duplicates\n this._intervalId = setInterval(() => this._next(), this._intervalTime);\n }\n\n private _stopAutoCycle() {\n if (this._intervalId) {\n clearInterval(this._intervalId);\n this._intervalId = null;\n }\n }\n private _resetAutoCycle() {\n this._stopAutoCycle();\n this._startAutoCycle();\n }\n private _pauseAutoCycle(): void {\n this._stopAutoCycle();\n }\n\n private _resumeAutoCycle(): void {\n if (this.show && this.childCount > 1) {\n this._startAutoCycle();\n }\n }\n render() {\n return html`\n <div\n class=\"${classMap({\n banner: true\n })}\"\n role=\"alert\"\n aria-hidden=${this.show ? \"false\" : \"true\"}\n >\n <div class=\"content\">\n <slot id=\"loop-slot\"></slot>\n </div>\n ${this.childCount > 1\n ? html` <div class=\"pagination\">\n <sgds-icon-button\n name=\"chevron-left\"\n tone=\"fixed-light\"\n variant=\"ghost\"\n size=\"xs\"\n @click=${this._prev}\n ></sgds-icon-button>\n <span>${this._currentIndex + 1}/${this.childCount}</span>\n <sgds-icon-button\n name=\"chevron-right\"\n tone=\"fixed-light\"\n variant=\"ghost\"\n size=\"xs\"\n @click=${this._next}\n ></sgds-icon-button>\n </div>`\n : nothing}\n ${this.dismissible\n ? html`\n <sgds-close-button aria-label=\"close the alert\" @click=${this.close} tone=\"fixed-light\"></sgds-close-button>\n `\n : nothing}\n </div>\n `;\n }\n}\n\nexport default SgdsSystemBanner;\n\nsetDefaultAnimation(\"banner.item.next\", {\n keyframes: [\n { opacity: 0, transform: \"translateY(-100%)\" },\n { opacity: 1, transform: \"translateY(0)\" }\n ],\n options: {\n duration: 500,\n easing: \"cubic-bezier(0.45,0.05,0.55,0.95)\"\n }\n});\nsetDefaultAnimation(\"banner.item.prev\", {\n keyframes: [\n { opacity: 0, transform: \"translateY(100%)\" },\n { opacity: 1, transform: \"translateY(0)\" }\n ],\n options: {\n duration: 500,\n easing: \"cubic-bezier(0.45,0.05,0.55,0.95)\"\n }\n});\n"],"names":["alertBannerStyles"],"mappings":";;;;;;;;;;;;;;;AAeA;;;;;;;;;AASG;AACG,MAAO,gBAAiB,SAAQ,WAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAS8C,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;;QAGb,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;QAgB/C,IAAW,CAAA,WAAA,GAAG,IAAI,CAAC;QAE5B,IAAa,CAAA,aAAA,GAAG,IAAI,CAAC;QAEZ,IAAa,CAAA,aAAA,GAAG,CAAC,CAAC;KAuIpC;;IAxJQ,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;KACnB;AAiBS,IAAA,YAAY,CAAC,iBAAyC,EAAA;AAC9D,QAAA,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,U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AAE;AAC3C,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,MAAM,EAAE,mCAAmC;AAC5C,KAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-banner-context.js","sources":["../../../src/components/SystemBanner/system-banner-context.ts"],"sourcesContent":["import { createContext } from \"@lit/context\";\n\nexport const SystemBannerChildCountContext = createContext<boolean>(\"system-banner-children-count-context\");\n"],"names":[],"mappings":";;MAEa,6BAA6B,GAAG,aAAa,CAAU,sCAAsC;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
var css_248z = css`:host{display:block;font-size:var(--sgds-font-size-1,14px);font-style:normal;font-weight:var(--sgds-font-weight-regular,400);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-20,20px);width:inherit}.banner-item{color:var(--sgds-color-fixed-light);display:flex;gap:var(--sgds-gap-sm);padding:var(--sgds-padding-2-xs) 0}.message{line-clamp:5;-webkit-line-clamp:5;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*5);overflow:hidden;word-break:break-all}.message.truncated:after{background-color:var(--sgds-surface-fixed-dark);bottom:0;content:"";height:var(--sgds-line-height-20,20px);position:absolute;right:0;text-align:right;width:10ch}.clamped-container{display:inline-block;margin-right:var(--sgds-margin-md);max-width:var(--sgds-dimension-872);position:relative}.show-more{bottom:0;position:absolute;right:0;white-space:nowrap}.show-more__link{cursor:pointer;text-decoration:underline}.action{align-items:center;display:flex;gap:var(--sgds-gap-2-xs,4px);margin-top:6px;min-height:var(--sgds-line-height-20);white-space:nowrap}slot[name=action]::slotted(a){color:var(--sgds-color-fixed-light)!important;font-size:var(--sgds-font-size-1,14px)!important;text-decoration:none!important}.banner-item__message_and__action{display:flex;flex:1 0 0;flex-direction:column;gap:var(--sgds-gap-xs)}@media (min-width:512px){.banner-item__message_and__action{flex-direction:row;gap:var(--sgds-gap-sm)}.action{margin-left:auto;margin-top:0}.message{line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;max-height:calc(var(--sgds-line-height-20, 20px)*2);overflow:hidden;word-break:break-all}}`;
|
|
4
|
+
|
|
5
|
+
export { css_248z as default };
|
|
6
|
+
//# sourceMappingURL=system-banner-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-banner-item.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
var css_248z = css`.banner{align-items:center;background-color:var(--sgds-surface-fixed-dark);color:var(--sgds-color-fixed-light);display:flex;flex-direction:row;gap:var(--sgds-gap-xl);min-height:var(--sgds-dimension-64);padding:var(--sgds-padding-sm) var(--sgds-padding-2-xl);position:relative}.content{flex:1;overflow:hidden;width:100%}::slotted(sgds-system-banner-item){display:none;flex:0 0 100%;opacity:0}::slotted(sgds-system-banner-item[active]){display:block;opacity:1}.pagination{align-items:center;bottom:12px;display:flex;font-size:var(--sgds-font-size-0);font-weight:var(--sgds-font-weight-regular,400);gap:var(--sgds-gap-2-xs);letter-spacing:var(--sgds-letter-spacing-normal,0);line-height:var(--sgds-line-height-16,16px);position:absolute;right:20px}.d-none{display:none}sgds-close-button{position:absolute;right:20px;top:10px}@media (min-width:512px){.pagination,sgds-close-button{position:static}}`;
|
|
4
|
+
|
|
5
|
+
export { css_248z as default };
|
|
6
|
+
//# sourceMappingURL=system-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-banner.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|