@jack-henry/jh-elements 2.0.0-beta.10
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/NOTICE +26 -0
- package/README.md +13 -0
- package/components/badge/badge.js +73 -0
- package/components/button/button.js +953 -0
- package/components/card/card.js +343 -0
- package/components/checkbox/checkbox.js +601 -0
- package/components/checkbox-group/checkbox-group.js +241 -0
- package/components/divider/divider.js +91 -0
- package/components/icon/icon.js +96 -0
- package/components/input/input.js +1247 -0
- package/components/input-email/input-email.js +18 -0
- package/components/input-password/input-password.js +153 -0
- package/components/input-search/input-search.js +41 -0
- package/components/input-telephone/input-telephone.js +18 -0
- package/components/input-textarea/input-textarea.js +379 -0
- package/components/input-url/input-url.js +31 -0
- package/components/list-group/list-group.js +103 -0
- package/components/list-item/list-item.js +350 -0
- package/components/menu/menu.js +60 -0
- package/components/notification/notification.js +327 -0
- package/components/progress/progress.js +417 -0
- package/components/radio/radio.js +422 -0
- package/components/radio-group/radio-group.js +400 -0
- package/components/switch/switch.js +315 -0
- package/components/table/table.js +367 -0
- package/components/table-data-cell/table-data-cell.js +107 -0
- package/components/table-header-cell/table-header-cell.js +321 -0
- package/components/table-row/table-row.js +52 -0
- package/components/tag/tag.js +422 -0
- package/components/tag-group/tag-group.js +57 -0
- package/components/toast/toast.js +172 -0
- package/components/toast-controller/toast-controller.js +122 -0
- package/components/tooltip/tooltip.js +498 -0
- package/custom-elements.json +6892 -0
- package/index.d.ts +69 -0
- package/jsconfig.json +9 -0
- package/package.json +52 -0
- package/utils/themeProvider.js +32 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 Jack Henry
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import { LitElement, css, html } from 'lit';
|
|
6
|
+
import '../button/button.js';
|
|
7
|
+
import '@jack-henry/jh-icons/icons-wc/icon-xmark.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @cssprop --jh-notification-border-radius-alert - The notification border-radius when `type="alert"`. Defaults to `--jh-border-radius-100`.
|
|
11
|
+
* @cssprop --jh-notification-border-radius-banner - The notification border-radius when `type="banner"`. Defaults to `--jh-border-radius-0`.
|
|
12
|
+
* @cssprop --jh-notification-color-background-neutral - The notification background color when `appearance="neutral"`. Defaults to `--jh-color-content-primary-enabled`.
|
|
13
|
+
* @cssprop --jh-notification-color-background-positive - The notification background color when `appearance="positive"`. Defaults to `--jh-color-content-positive-enabled`.
|
|
14
|
+
* @cssprop --jh-notification-color-background-negative - The notification background color when `appearance="negative"`. Defaults to `--jh-color-content-negative-enabled`.
|
|
15
|
+
* @cssprop --jh-notification-color-text-neutral - The notification text color when `appearance="neutral"`. Defaults to `--jh-color-content-on-primary-enabled`.
|
|
16
|
+
* @cssprop --jh-notification-color-text-positive - The notification text color when `appearance="positive"`. Defaults to `--jh-color-content-on-positive-enabled`.
|
|
17
|
+
* @cssprop --jh-notification-color-text-negative - The notification text color when `appearance="negative"`. Defaults to `--jh-color-content-on-negative-enabled`.
|
|
18
|
+
* @cssprop --jh-notification-icon-color-fill-neutral - The icon fill color when `appearance="neutral"`. Defaults to `--jh-color-content-on-primary-enabled`.
|
|
19
|
+
* @cssprop --jh-notification-icon-color-fill-positive - The icon fill color when `appearance="positive"`. Defaults to `--jh-color-content-on-positive-enabled`.
|
|
20
|
+
* @cssprop --jh-notification-icon-color-fill-negative - The icon fill color when `appearance="negative"`. Defaults to `--jh-color-content-on-negative-enabled`.
|
|
21
|
+
* @cssprop --jh-notification-dismiss-icon-color-enabled - The dismiss button icon fill color. Defaults to `--jh-color-content-inverse-enabled`.
|
|
22
|
+
* @cssprop --jh-notification-dismiss-color-background-enabled - The dismiss button background color. Defaults to transparent.
|
|
23
|
+
* @cssprop --jh-notification-dismiss-color-border-enabled - The dismiss button border color. Defaults to transparent.
|
|
24
|
+
* @cssprop --jh-notification-dismiss-color-focus - The dismiss button outline when it receives keyboard focus. Defaults to `--jh-color-content-inverse-enabled`.
|
|
25
|
+
* @cssprop --jh-notification-dismiss-icon-color-focus - The dismiss button icon fill color when focused. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
26
|
+
* @cssprop --jh-notification-dismiss-color-background-focus - The dismiss button background color when focused. Defaults to `--jh-color-content-inverse-hover`.
|
|
27
|
+
* @cssprop --jh-notification-dismiss-color-border-focus - The dismiss button border color when focused. Defaults to transparent.
|
|
28
|
+
* @cssprop --jh-notification-dismiss-icon-color-hover - The dismiss button icon fill color when hovered. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
29
|
+
* @cssprop --jh-notification-dismiss-color-background-hover - The dismiss button background color when hovered. Defaults to `--jh-color-content-inverse-hover`.
|
|
30
|
+
* @cssprop --jh-notification-dismiss-color-border-hover - The dismiss button border color when hovered. Defaults to transparent.
|
|
31
|
+
* @cssprop --jh-notification-dismiss-icon-color-active - The dismiss button icon fill color when activated. Defaults to `--jh-color-content-on-inverse-active`.
|
|
32
|
+
* @cssprop --jh-notification-dismiss-color-background-active - The dismiss button background color when activated. Defaults to `--jh-color-content-inverse-active`.
|
|
33
|
+
* @cssprop --jh-notification-dismiss-color-border-active - The dismiss button border color when activated. Defaults to transparent.
|
|
34
|
+
* @cssprop --jh-notification-action-label-color-text-enabled - The action button(s) text color. Defaults to `--jh-color-content-inverse-enabled`.
|
|
35
|
+
* @cssprop --jh-notification-action-color-background-enabled - The action button(s) background color. Defaults to transparent.
|
|
36
|
+
* @cssprop --jh-notification-action-color-border-enabled - The action button(s) border color. Defaults to transparent.
|
|
37
|
+
* @cssprop --jh-notification-action-color-focus - The action button(s) outline when they receive keyboard focus. Defaults to `--jh-color-content-inverse-enabled`.
|
|
38
|
+
* @cssprop --jh-notification-action-label-color-text-focus - The action button(s) text color when focused. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
39
|
+
* @cssprop --jh-notification-action-color-background-focus - The action button(s) background color when focused. Defaults to `--jh-color-content-inverse-hover`.
|
|
40
|
+
* @cssprop --jh-notification-action-color-border-focus - The action button(s) border color when focused. Defaults to transparent.
|
|
41
|
+
* @cssprop --jh-notification-action-label-color-text-hover - The action button(s) text color when hovered. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
42
|
+
* @cssprop --jh-notification-action-color-background-hover - The action button(s) background color when hovered. Defaults to `--jh-color-content-inverse-hover`.
|
|
43
|
+
* @cssprop --jh-notification-action-color-border-hover - The action button(s) border color when hovered. Defaults to transparent.
|
|
44
|
+
* @cssprop --jh-notification-action-label-color-text-active - The action button(s) text color when active. Defaults to `--jh-color-content-on-inverse-active`.
|
|
45
|
+
* @cssprop --jh-notification-action-color-background-active - The action button(s) background color when active. Defaults to `--jh-color-content-inverse-active`.
|
|
46
|
+
* @cssprop --jh-notification-action-color-border-active - The action button(s) border color when active. Defaults to transparent.
|
|
47
|
+
* @cssprop --jh-notification-action-color-background-pending - The action button(s) background color when pending. Defaults to transparent.
|
|
48
|
+
* @cssprop --jh-notification-action-color-border-pending - The action button(s) border color when pending. Defaults to transparent.
|
|
49
|
+
* @cssprop --jh-notification-action-icon-color-fill-enabled - The action button(s) icon fill color. Defaults to `--jh-color-content-inverse-enabled`.
|
|
50
|
+
* @cssprop --jh-notification-action-icon-color-fill-focus - The action button(s) icon fill color when focused. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
51
|
+
* @cssprop --jh-notification-action-icon-color-fill-hover - The action button(s) icon fill color when hovered. Defaults to `--jh-color-content-on-inverse-hover`.
|
|
52
|
+
* @cssprop --jh-notification-action-icon-color-fill-active - The action button(s) icon fill color when active. Defaults to `--jh-color-content-on-inverse-active`.
|
|
53
|
+
* @cssprop --jh-notification-action-progress-color-border-pending - The action button(s) progress indicator color when pending. Defaults to `--jh-color-content-inverse-enabled`.
|
|
54
|
+
* @slot default - Use to insert contextual information.
|
|
55
|
+
* @slot jh-notification-icon - Use to insert a button or icon to the left of the default slot.
|
|
56
|
+
* @slot jh-notification-dismiss-icon - Use to insert icon within the dismiss button.
|
|
57
|
+
* @slot jh-notification-action - Use to insert action button(s). Placed to the right of the default slot. Set `stacked` property to place slot below default slot.
|
|
58
|
+
* @event jh-dismiss - Dispatched when the notification is dismissed.
|
|
59
|
+
*
|
|
60
|
+
* @customElement jh-notification
|
|
61
|
+
*/
|
|
62
|
+
export class JhNotification extends LitElement {
|
|
63
|
+
static get styles() {
|
|
64
|
+
return css`
|
|
65
|
+
:host {
|
|
66
|
+
font-family: var(--jh-font-body-regular-1-font-family);
|
|
67
|
+
font-weight: var(--jh-font-body-regular-1-font-weight);
|
|
68
|
+
font-size: var(--jh-font-body-regular-1-font-size);
|
|
69
|
+
line-height: var(--jh-font-body-regular-1-line-height);
|
|
70
|
+
padding: var(--jh-dimension-300) var(--jh-dimension-400);
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
:host([type='alert']) {
|
|
74
|
+
border-radius: var(
|
|
75
|
+
--jh-notification-border-radius-alert,
|
|
76
|
+
var(--jh-border-radius-100)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
:host([type='banner']) {
|
|
80
|
+
border-radius: var(
|
|
81
|
+
--jh-notification-border-radius-banner,
|
|
82
|
+
var(--jh-border-radius-0)
|
|
83
|
+
);
|
|
84
|
+
position: absolute;
|
|
85
|
+
top: 0;
|
|
86
|
+
left: 0;
|
|
87
|
+
width: 100%;
|
|
88
|
+
box-sizing: border-box;
|
|
89
|
+
}
|
|
90
|
+
/* Appearances */
|
|
91
|
+
:host([appearance='neutral']) {
|
|
92
|
+
background-color: var(
|
|
93
|
+
--jh-notification-color-background-neutral,
|
|
94
|
+
var(--jh-color-content-primary-enabled)
|
|
95
|
+
);
|
|
96
|
+
color: var(
|
|
97
|
+
--jh-notification-color-text-neutral,
|
|
98
|
+
var(--jh-color-content-on-primary-enabled)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
:host([appearance='positive']) {
|
|
102
|
+
background-color: var(
|
|
103
|
+
--jh-notification-color-background-positive,
|
|
104
|
+
var(--jh-color-content-positive-enabled)
|
|
105
|
+
);
|
|
106
|
+
color: var(
|
|
107
|
+
--jh-notification-color-text-positive,
|
|
108
|
+
var(--jh-color-content-on-positive-enabled)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
:host([appearance='negative']) {
|
|
112
|
+
background-color: var(
|
|
113
|
+
--jh-notification-color-background-negative,
|
|
114
|
+
var(--jh-color-content-negative-enabled)
|
|
115
|
+
);
|
|
116
|
+
color: var(
|
|
117
|
+
--jh-notification-color-text-negative,
|
|
118
|
+
var(--jh-color-content-on-negative-enabled)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
jh-button {
|
|
122
|
+
--jh-button-icon-color-fill-secondary-enabled: var(--jh-notification-dismiss-icon-color-enabled, var(--jh-color-content-inverse-enabled));
|
|
123
|
+
--jh-button-color-background-secondary-enabled: var(--jh-notification-dismiss-color-background-enabled, transparent);
|
|
124
|
+
--jh-button-color-border-secondary-enabled: var(--jh-notification-dismiss-color-border-enabled, transparent);
|
|
125
|
+
--jh-button-icon-color-fill-secondary-active: var(--jh-notification-dismiss-icon-color-active, var(--jh-color-content-on-inverse-active));
|
|
126
|
+
--jh-button-color-background-secondary-active: var(--jh-notification-dismiss-color-background-active, var(--jh-color-content-inverse-active));
|
|
127
|
+
--jh-button-color-border-secondary-active: var(--jh-notification-dismiss-color-border-active, transparent);
|
|
128
|
+
--jh-button-icon-color-fill-secondary-focus: var(--jh-notification-dismiss-icon-color-focus, var(--jh-color-content-on-inverse-hover));
|
|
129
|
+
--jh-button-color-background-secondary-focus: var(--jh-notification-dismiss-color-background-focus, var(--jh-color-content-inverse-hover));
|
|
130
|
+
--jh-button-color-border-secondary-focus: var(--jh-notification-dismiss-color-border-focus, transparent);
|
|
131
|
+
--jh-button-icon-color-fill-secondary-hover: var(--jh-notification-dismiss-icon-color-hover, var(--jh-color-content-on-inverse-hover));
|
|
132
|
+
--jh-button-color-background-secondary-hover: var(--jh-notification-dismiss-color-background-hover, var(--jh-color-content-inverse-hover));
|
|
133
|
+
--jh-button-color-border-secondary-hover: var(--jh-notification-dismiss-color-border-hover, transparent);
|
|
134
|
+
--jh-button-color-focus: var(--jh-notification-dismiss-color-focus, var(--jh-color-content-inverse-enabled));
|
|
135
|
+
margin-left: var(--jh-dimension-400);
|
|
136
|
+
}
|
|
137
|
+
/* Default slot styling */
|
|
138
|
+
.display-default-slot {
|
|
139
|
+
padding: var(--jh-dimension-200) 0;
|
|
140
|
+
margin: var(--jh-dimension-50) 0;
|
|
141
|
+
font: var(--jh-font-body-regular-1);
|
|
142
|
+
display: flex;
|
|
143
|
+
flex: 1;
|
|
144
|
+
word-break: break-all;
|
|
145
|
+
}
|
|
146
|
+
/* Icon slot styling */
|
|
147
|
+
slot[name="jh-notification-icon"] {
|
|
148
|
+
display: block;
|
|
149
|
+
}
|
|
150
|
+
slot[name="jh-notification-icon"]::slotted(*) {
|
|
151
|
+
margin-right: var(--jh-dimension-400);
|
|
152
|
+
padding: var(--jh-dimension-200) 0;
|
|
153
|
+
}
|
|
154
|
+
:host([appearance='neutral']) slot[name="jh-notification-icon"] {
|
|
155
|
+
--jh-icon-color-fill: var(--jh-notification-icon-color-fill-neutral, var(--jh-color-content-on-primary-enabled));
|
|
156
|
+
}
|
|
157
|
+
:host([appearance='positive']) slot[name="jh-notification-icon"] {
|
|
158
|
+
--jh-icon-color-fill: var(--jh-notification-icon-color-fill-positive, var(--jh-color-content-on-positive-enabled));
|
|
159
|
+
}
|
|
160
|
+
:host([appearance='negative']) slot[name="jh-notification-icon"] {
|
|
161
|
+
--jh-icon-color-fill: var(--jh-notification-icon-color-fill-negative, var(--jh-color-content-on-negative-enabled));
|
|
162
|
+
}
|
|
163
|
+
/* action slot styling*/
|
|
164
|
+
slot[name="jh-notification-action"]::slotted(*) {
|
|
165
|
+
--jh-button-label-color-text-secondary-enabled: var(--jh-notification-action-label-color-text-enabled, var(--jh-color-content-inverse-enabled));
|
|
166
|
+
--jh-button-color-background-secondary-enabled: var(--jh-notification-action-color-background-enabled, transparent);
|
|
167
|
+
--jh-button-color-border-secondary-enabled: var(--jh-notification-action-color-border-enabled, transparent);
|
|
168
|
+
--jh-button-label-color-text-secondary-focus: var(--jh-notification-action-label-color-text-focus, var(--jh-color-content-on-inverse-hover));
|
|
169
|
+
--jh-button-color-background-secondary-focus: var(--jh-notification-action-color-background-focus, var(--jh-color-content-inverse-hover));
|
|
170
|
+
--jh-button-color-border-secondary-focus: var(--jh-notification-action-color-border-focus, transparent);
|
|
171
|
+
--jh-button-label-color-text-secondary-hover: var(--jh-notification-action-label-color-text-hover, var(--jh-color-content-on-inverse-hover));
|
|
172
|
+
--jh-button-color-background-secondary-hover: var(--jh-notification-action-color-background-hover, var(--jh-color-content-inverse-hover));
|
|
173
|
+
--jh-button-color-border-secondary-hover: var(--jh-notification-action-color-border-hover, transparent);
|
|
174
|
+
--jh-button-label-color-text-secondary-active: var(--jh-notification-action-label-color-text-active, var(--jh-color-content-on-inverse-active));
|
|
175
|
+
--jh-button-color-background-secondary-active: var(--jh-notification-action-color-background-active, var(--jh-color-content-inverse-active));
|
|
176
|
+
--jh-button-color-border-secondary-active: var(--jh-notification-action-color-border-active, transparent);
|
|
177
|
+
--jh-button-color-background-secondary-pending: var(--jh-notification-action-color-background-pending, transparent);
|
|
178
|
+
--jh-button-color-border-secondary-pending: var(--jh-notification-action-color-border-pending, transparent);
|
|
179
|
+
--jh-button-icon-color-fill-secondary-enabled: var(--jh-notification-action-icon-color-fill-enabled, var(--jh-color-content-inverse-enabled));
|
|
180
|
+
--jh-button-icon-color-fill-secondary-focus: var(--jh-notification-action-icon-color-fill-focus, var(--jh-color-content-on-inverse-hover));
|
|
181
|
+
--jh-button-icon-color-fill-secondary-hover: var(--jh-notification-action-icon-color-fill-hover, var(--jh-color-content-on-inverse-hover));
|
|
182
|
+
--jh-button-icon-color-fill-secondary-active: var(--jh-notification-action-icon-color-fill-active, var(--jh-color-content-on-inverse-active));
|
|
183
|
+
--jh-button-progress-color-border-secondary-pending: var(--jh-notification-action-progress-color-border-pending, var(--jh-color-content-inverse-enabled));
|
|
184
|
+
--jh-button-color-focus: var(--jh-notification-action-color-focus, var(--jh-color-content-inverse-enabled));
|
|
185
|
+
}
|
|
186
|
+
slot[name="jh-notification-action"]::slotted(:first-of-type) {
|
|
187
|
+
margin-left: var(--jh-dimension-400);
|
|
188
|
+
}
|
|
189
|
+
slot[name="jh-notification-action"]::slotted(:not(:first-of-type)) {
|
|
190
|
+
margin-left: var(--jh-dimension-200);
|
|
191
|
+
}
|
|
192
|
+
:host([stacked]) {
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
}
|
|
196
|
+
:host([stacked]) slot[name="jh-notification-action"]::slotted(:first-of-type) {
|
|
197
|
+
margin-left: 0;
|
|
198
|
+
}
|
|
199
|
+
.stacked-action-btn {
|
|
200
|
+
margin-top: var(--jh-dimension-400);
|
|
201
|
+
display: flex;
|
|
202
|
+
justify-content: flex-end;
|
|
203
|
+
}
|
|
204
|
+
.stacked-container,
|
|
205
|
+
.inline-container {
|
|
206
|
+
display: flex;
|
|
207
|
+
align-items: flex-start;
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
static get properties() {
|
|
213
|
+
return {
|
|
214
|
+
/**
|
|
215
|
+
* Sets background color of container to convey message connotation.
|
|
216
|
+
*/
|
|
217
|
+
appearance: { type: String, reflect: true },
|
|
218
|
+
/**
|
|
219
|
+
* Adds an aria-label to the dismiss button to assist screen readers.
|
|
220
|
+
*/
|
|
221
|
+
dismissButtonAccessibleLabel: {
|
|
222
|
+
type: String,
|
|
223
|
+
attribute: 'dismiss-button-accessible-label',
|
|
224
|
+
},
|
|
225
|
+
/**
|
|
226
|
+
* Removes dismiss button from notification.
|
|
227
|
+
*/
|
|
228
|
+
hideDismissButton: { type: Boolean, attribute: 'hide-dismiss-button' },
|
|
229
|
+
/**
|
|
230
|
+
* Places action button(s) on new line, below default slot.
|
|
231
|
+
*/
|
|
232
|
+
stacked: { type: Boolean, reflect: true },
|
|
233
|
+
/**
|
|
234
|
+
* Determines where in viewport notification is displayed. Alerts will follow typical content flow, while banners will break out of standard flow and go edge-to-edge within a container.
|
|
235
|
+
*/
|
|
236
|
+
type: { type: String, reflect: true },
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
constructor() {
|
|
241
|
+
super();
|
|
242
|
+
/** @type {'positive'|'neutral'|'negative'} */
|
|
243
|
+
this.appearance = 'neutral';
|
|
244
|
+
/** @type {string} */
|
|
245
|
+
this.dismissButtonAccessibleLabel = null;
|
|
246
|
+
/** @type {boolean} */
|
|
247
|
+
this.hideDismissButton = false;
|
|
248
|
+
/** @type {boolean} */
|
|
249
|
+
this.stacked = false;
|
|
250
|
+
/** @type {'alert'|'banner'} */
|
|
251
|
+
this.type = 'alert';
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
#handleDismissal() {
|
|
255
|
+
this.#dispatch('jh-dismiss');
|
|
256
|
+
// if notification is wrapped by jh-toast component, do not remove notification from DOM
|
|
257
|
+
if (this.parentNode.host?.nodeName === 'JH-TOAST') {
|
|
258
|
+
return;
|
|
259
|
+
} else {
|
|
260
|
+
this.remove();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#dispatch(name) {
|
|
265
|
+
this.dispatchEvent(
|
|
266
|
+
new CustomEvent(name, {
|
|
267
|
+
bubbles: true,
|
|
268
|
+
cancelable: true,
|
|
269
|
+
composed: true,
|
|
270
|
+
})
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#getActionButtons() {
|
|
275
|
+
let className = this.stacked ? 'stacked-action-btn' : 'inline-action-btn';
|
|
276
|
+
return html`
|
|
277
|
+
<slot name="jh-notification-action" class=${className} @slotchange=${this.#handleActionSlotChange}></slot>
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
#handleActionSlotChange() {
|
|
282
|
+
let actionBtns = this.querySelectorAll('jh-button');
|
|
283
|
+
|
|
284
|
+
for (const btn of actionBtns) {
|
|
285
|
+
if (btn.getAttribute('size') !== 'small') {
|
|
286
|
+
btn.setAttribute('size', 'small');
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#handleSlotChange(e) {
|
|
292
|
+
if (e) {
|
|
293
|
+
let defaultSlot = this.shadowRoot.querySelector('slot:not([name])');
|
|
294
|
+
defaultSlot.classList.add("display-default-slot");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
render() {
|
|
299
|
+
let dismissBtn;
|
|
300
|
+
|
|
301
|
+
if (!this.hideDismissButton) {
|
|
302
|
+
dismissBtn = html`
|
|
303
|
+
<jh-button
|
|
304
|
+
size="small"
|
|
305
|
+
appearance="secondary"
|
|
306
|
+
accessible-label=${this.dismissButtonAccessibleLabel}
|
|
307
|
+
@click=${this.#handleDismissal}
|
|
308
|
+
><slot name="jh-notification-dismiss-icon" slot="jh-button-icon">
|
|
309
|
+
<jh-icon-xmark slot="jh-button-icon"></jh-icon-xmark>
|
|
310
|
+
</slot>
|
|
311
|
+
</jh-button>
|
|
312
|
+
`;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return html`
|
|
316
|
+
<div class=${this.stacked ? 'stacked-container' : 'inline-container'}>
|
|
317
|
+
<slot aria-hidden="true" name="jh-notification-icon"></slot>
|
|
318
|
+
<slot @slotchange=${this.#handleSlotChange}></slot>
|
|
319
|
+
${this.stacked ? null : this.#getActionButtons()}
|
|
320
|
+
${dismissBtn}
|
|
321
|
+
</div>
|
|
322
|
+
${this.stacked ? this.#getActionButtons() : null}
|
|
323
|
+
`;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
customElements.define('jh-notification', JhNotification);
|