@jack-henry/jh-elements 2.0.0-beta.14 → 2.0.0-beta.15

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.
Files changed (36) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +2 -2
  3. package/components/badge/badge.js +4 -4
  4. package/components/button/button.js +8 -13
  5. package/components/card/card.js +4 -4
  6. package/components/checkbox/checkbox.js +19 -31
  7. package/components/checkbox-group/checkbox-group.js +12 -20
  8. package/components/divider/divider.js +5 -5
  9. package/components/element/element.js +94 -0
  10. package/components/icon/icon.js +14 -12
  11. package/components/input/input.js +63 -64
  12. package/components/input-email/input-email.js +1 -1
  13. package/components/input-password/input-password.js +3 -12
  14. package/components/input-search/input-search.js +1 -1
  15. package/components/input-telephone/input-telephone.js +1 -1
  16. package/components/input-textarea/input-textarea.js +4 -13
  17. package/components/input-url/input-url.js +1 -1
  18. package/components/list-group/list-group.js +6 -13
  19. package/components/list-item/list-item.js +131 -143
  20. package/components/menu/menu.js +5 -8
  21. package/components/notification/notification.js +5 -15
  22. package/components/progress/progress.js +62 -56
  23. package/components/radio/radio.js +8 -21
  24. package/components/radio-group/radio-group.js +16 -31
  25. package/components/select/select.js +51 -30
  26. package/components/switch/switch.js +9 -22
  27. package/components/table/table.js +7 -14
  28. package/components/table-data-cell/table-data-cell.js +5 -8
  29. package/components/table-header-cell/table-header-cell.js +14 -24
  30. package/components/table-row/table-row.js +5 -8
  31. package/components/tag/tag.js +5 -10
  32. package/components/tag-group/tag-group.js +5 -7
  33. package/components/toast/toast.js +5 -14
  34. package/components/tooltip/tooltip.js +8 -9
  35. package/custom-elements.json +338 -226
  36. package/package.json +3 -3
@@ -2,10 +2,9 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
6
  import { ifDefined } from 'lit/directives/if-defined.js';
7
-
8
- let id = 0;
7
+ import { JhElement } from '../element/element.js';
9
8
 
10
9
  /**
11
10
  * @cssprop --jh-switch-opacity-disabled - The switch opacity when disabled. Defaults to `--jh-opacity-disabled`.
@@ -28,9 +27,7 @@ let id = 0;
28
27
  *
29
28
  * @customElement jh-switch
30
29
  */
31
- export class JhSwitch extends LitElement {
32
- /** @type {?Number} */
33
- #id;
30
+ export class JhSwitch extends JhElement {
34
31
 
35
32
  static get styles() {
36
33
  return css`
@@ -253,20 +250,10 @@ export class JhSwitch extends LitElement {
253
250
  this.label = null;
254
251
  }
255
252
 
256
- connectedCallback() {
257
- super.connectedCallback();
258
- this.#id = id++;
259
- }
260
-
261
253
  #handleClick() {
262
254
  if (!this.disabled && this.accessibleDisabled !== 'true') {
263
255
  this.checked = !this.checked;
264
- const options = {
265
- bubbles: true,
266
- composed: true,
267
- cancelable: true,
268
- };
269
- this.dispatchEvent(new CustomEvent('jh-change', options));
256
+ this.dispatchCustomEvent('jh-change');
270
257
  }
271
258
  }
272
259
 
@@ -276,7 +263,7 @@ export class JhSwitch extends LitElement {
276
263
 
277
264
  if (this.helperText) {
278
265
  helperText = html`
279
- <p class="helper-text" id="switch-helper-text-${this.#id}">
266
+ <p class="helper-text" id="switch-helper-text-${this.uniqueId}">
280
267
  ${this.helperText}
281
268
  </p>
282
269
  `;
@@ -285,7 +272,7 @@ export class JhSwitch extends LitElement {
285
272
  if (this.label) {
286
273
  label = html`
287
274
  <div class="label-container">
288
- <label class="label-text" for="switch-label-${this.#id}">
275
+ <label class="label-text" for="switch-label-${this.uniqueId}">
289
276
  ${this.label}
290
277
  </label>
291
278
  ${helperText}
@@ -300,11 +287,11 @@ export class JhSwitch extends LitElement {
300
287
  aria-label="${ifDefined(this.accessibleLabel)}"
301
288
  aria-disabled="${ifDefined(this.accessibleDisabled)}"
302
289
  type="button"
303
- aria-describedby=${this.helperText ? `switch-helper-text-${this.#id}` : null}
290
+ aria-describedby=${this.helperText ? `switch-helper-text-${this.uniqueId}` : null}
304
291
  ?checked=${this.checked}
305
292
  ?disabled=${this.disabled}
306
293
  aria-pressed="${this.checked}"
307
- id="switch-label-${this.#id}"
294
+ id="switch-label-${this.uniqueId}"
308
295
  ></button>
309
296
  <span aria-hidden="true"></span>
310
297
  ${label}
@@ -312,4 +299,4 @@ export class JhSwitch extends LitElement {
312
299
  }
313
300
  }
314
301
 
315
- customElements.define('jh-switch', JhSwitch);
302
+ JhSwitch.register('jh-switch', JhSwitch);
@@ -2,14 +2,13 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
  import { ifDefined } from 'lit/directives/if-defined.js';
7
8
  import '../table-header-cell/table-header-cell.js';
8
9
  import '../table-data-cell/table-data-cell.js';
9
10
  import '../table-row/table-row.js';
10
11
 
11
- let id = 0;
12
-
13
12
  /**
14
13
  * Table
15
14
  * @cssprop --jh-table-color-text-striped-enabled - The striped row text color. Defaults to `--jh-color-content-primary-enabled`.
@@ -29,9 +28,7 @@ let id = 0;
29
28
  * @slot jh-table-toolbar - Use to insert toolbar.
30
29
  * @customElement jh-table
31
30
  */
32
- export class JhTable extends LitElement {
33
- /** @type {?Number} */
34
- #id;
31
+ export class JhTable extends JhElement {
35
32
 
36
33
  static get styles() {
37
34
  return css`
@@ -190,6 +187,7 @@ export class JhTable extends LitElement {
190
187
  :host([scrollable]) .table {
191
188
  width: auto;
192
189
  position: relative;
190
+ min-width: 100%;
193
191
  }
194
192
  .table-wrapper:has(.table-container:focus-visible) {
195
193
  outline-color: var(
@@ -289,11 +287,6 @@ export class JhTable extends LitElement {
289
287
  this.addEventListener('jh-sort', this.#handleSort);
290
288
  }
291
289
 
292
- connectedCallback() {
293
- super.connectedCallback();
294
- this.#id = id++;
295
- }
296
-
297
290
  disconnectedCallback() {
298
291
  super.disconnectedCallback();
299
292
  if (this.observer) {
@@ -349,12 +342,12 @@ export class JhTable extends LitElement {
349
342
 
350
343
  render() {
351
344
  return html`
352
- <slot name="jh-table-caption" id="table-caption-${this.#id}" @slotchange=${this.#handleSlot}></slot>
345
+ <slot name="jh-table-caption" id="table-caption-${this.uniqueId}" @slotchange=${this.#handleSlot}></slot>
353
346
  <slot name="jh-table-toolbar" @slotchange=${this.#handleSlot}></slot>
354
347
  <div class="table-wrapper">
355
348
  <div class="table-container" tabindex="${ifDefined(this.scrollable ? '0' : null)}">
356
349
  <div class="table" role="table"
357
- aria-labelledby="table-caption-${this.#id}" aria-label=${ifDefined(this.accessibleLabel === '' ? null : this.accessibleLabel)}>
350
+ aria-labelledby="table-caption-${this.uniqueId}" aria-label=${ifDefined(this.accessibleLabel === '' ? null : this.accessibleLabel)}>
358
351
  <slot name="jh-table-header" class="header" role="rowgroup"></slot>
359
352
  <slot class="body" role="rowgroup"></slot>
360
353
  <slot name="jh-table-footer" class="footer" role="rowgroup"></slot>
@@ -366,4 +359,4 @@ export class JhTable extends LitElement {
366
359
  }
367
360
  }
368
361
 
369
- customElements.define('jh-table', JhTable);
362
+ JhTable.register('jh-table', JhTable);
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
 
7
8
  /**
8
9
  * Table Cell
@@ -30,10 +31,7 @@ import { LitElement, css, html } from 'lit';
30
31
  *
31
32
  * @customElement jh-table-cell
32
33
  */
33
- export class JhTableDataCell extends LitElement {
34
-
35
- /** @type {ElementInternals} */
36
- #internals;
34
+ export class JhTableDataCell extends JhElement {
37
35
 
38
36
  static get styles() {
39
37
  return css`
@@ -89,8 +87,7 @@ export class JhTableDataCell extends LitElement {
89
87
 
90
88
  constructor() {
91
89
  super();
92
- this.#internals = this.attachInternals();
93
- this.#internals.role = 'cell';
90
+ this.internals.role = 'cell';
94
91
  /**
95
92
  * Sets the horizontal alignment of the content.
96
93
  * @attr horizontal-align
@@ -105,4 +102,4 @@ export class JhTableDataCell extends LitElement {
105
102
  }
106
103
  }
107
104
 
108
- customElements.define('jh-table-data-cell', JhTableDataCell);
105
+ JhTableDataCell.register('jh-table-data-cell', JhTableDataCell);
@@ -2,13 +2,12 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
  import '@jack-henry/jh-icons/icons-wc/icon-arrow-up-arrow-down.js';
7
8
  import '@jack-henry/jh-icons/icons-wc/icon-arrow-up-small.js';
8
9
  import '@jack-henry/jh-icons/icons-wc/icon-arrow-down-small.js';
9
10
 
10
- let id = 0;
11
-
12
11
  /**
13
12
  * Table Header Cell
14
13
  *
@@ -66,13 +65,10 @@ let id = 0;
66
65
  * @slot jh-table-sorted-none - Use to insert a custom icon for no sort.
67
66
  * @slot default - Use to insert table header text.
68
67
  *
69
- * @event jh-sort - Dispatched when a sortable header cell is activated. Event payload includes the column, sorted state, and id of the header cell and can be accessed via `e.detail.column`, `e.detail.sorted`, and ` e.detail.id`.
68
+ * @event jh-sort - Dispatched when a sortable header cell is activated. Event payload includes the column, sorted state, and id of the header cell and can be accessed via `e.detail.reference.column`, `e.detail.reference.sorted`, and `e.detail.reference.id`.
70
69
  * @customElement jh-table-header-cell
71
70
  */
72
- export class JhTableHeaderCell extends LitElement {
73
-
74
- /** @type {ElementInternals} */
75
- #internals;
71
+ export class JhTableHeaderCell extends JhElement {
76
72
 
77
73
  static get styles() {
78
74
  return css`
@@ -208,8 +204,7 @@ export class JhTableHeaderCell extends LitElement {
208
204
 
209
205
  constructor() {
210
206
  super();
211
- this.#internals = this.attachInternals();
212
- this.#internals.role = 'columnheader';
207
+ this.internals.role = 'columnheader';
213
208
  /**
214
209
  * Sets the horizontal alignment of the content.
215
210
  * @attr horizontal-align
@@ -233,7 +228,7 @@ export class JhTableHeaderCell extends LitElement {
233
228
  connectedCallback() {
234
229
  super.connectedCallback();
235
230
  /** @ignore */
236
- this.id = `table-header-${id++}`;
231
+ this.id = `table-header-${this.uniqueId}`;
237
232
  if (this.sortable) {
238
233
  this.setAttribute('tabindex', '0');
239
234
  this.setAttribute('aria-sort', this.sorted);
@@ -261,18 +256,13 @@ export class JhTableHeaderCell extends LitElement {
261
256
 
262
257
  this.setAttribute('aria-sort', this.sorted);
263
258
 
264
- this.dispatchEvent(
265
- new CustomEvent('jh-sort', {
266
- bubbles: true,
267
- cancelable: true,
268
- composed: true,
269
- detail: {
270
- column: this,
271
- sorted: this.sorted,
272
- id: this.id,
273
- },
274
- })
275
- );
259
+ this.dispatchCustomEvent('jh-sort', {
260
+ reference: {
261
+ sorted: this.sorted,
262
+ column: this,
263
+ id: this.id,
264
+ },
265
+ });
276
266
  }
277
267
 
278
268
  #getSortingIcon() {
@@ -318,4 +308,4 @@ export class JhTableHeaderCell extends LitElement {
318
308
  }
319
309
  }
320
310
 
321
- customElements.define('jh-table-header-cell', JhTableHeaderCell);
311
+ JhTableHeaderCell.register('jh-table-header-cell', JhTableHeaderCell);
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
 
7
8
  /**
8
9
  * Table Row
@@ -17,10 +18,7 @@ import { LitElement, css, html } from 'lit';
17
18
  * @slot default - Use to insert `<jh-table-data-cell>`s or `<jh-table-header-cell>`s.
18
19
  * @customElement jh-table-row
19
20
  */
20
- export class JhTableRow extends LitElement {
21
-
22
- /** @type {ElementInternals} */
23
- #internals;
21
+ export class JhTableRow extends JhElement {
24
22
 
25
23
  static get styles() {
26
24
  return css`
@@ -40,8 +38,7 @@ export class JhTableRow extends LitElement {
40
38
 
41
39
  constructor() {
42
40
  super();
43
- this.#internals = this.attachInternals();
44
- this.#internals.role = 'row';
41
+ this.internals.role = 'row';
45
42
  }
46
43
 
47
44
  render() {
@@ -49,4 +46,4 @@ export class JhTableRow extends LitElement {
49
46
  }
50
47
  }
51
48
 
52
- customElements.define('jh-table-row', JhTableRow);
49
+ JhTableRow.register('jh-table-row', JhTableRow);
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
  import '@jack-henry/jh-icons/icons-wc/icon-xmark.js';
7
8
  import '../button/button.js';
8
9
  import '../tooltip/tooltip.js';
@@ -42,7 +43,7 @@ import '../tooltip/tooltip.js';
42
43
  * @event jh-dismiss - Dispatched when the tag is dismissed.
43
44
  * @customElement jh-tag
44
45
  */
45
- export class JhTag extends LitElement {
46
+ export class JhTag extends JhElement {
46
47
 
47
48
  static get styles() {
48
49
  return css`
@@ -357,13 +358,7 @@ export class JhTag extends LitElement {
357
358
 
358
359
  #handleDismissal(e) {
359
360
  e.stopPropagation();
360
- this.dispatchEvent(
361
- new CustomEvent('jh-dismiss', {
362
- bubbles: true,
363
- cancelable: true,
364
- composed: true,
365
- })
366
- );
361
+ this.dispatchCustomEvent('jh-dismiss');
367
362
 
368
363
  if (this.removeOnDismiss) {
369
364
  this.remove();
@@ -422,4 +417,4 @@ export class JhTag extends LitElement {
422
417
  }
423
418
  }
424
419
 
425
- customElements.define('jh-tag', JhTag);
420
+ JhTag.register('jh-tag', JhTag);
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
 
7
8
  /**
8
9
  * Tag Group
@@ -10,9 +11,7 @@ import { LitElement, css, html } from 'lit';
10
11
  * @slot default - Use to insert `<jh-tag>` component(s).
11
12
  * @customElement jh-tag-group
12
13
  */
13
- export class JhTagGroup extends LitElement {
14
- /** @type {ElementInternals} */
15
- #internals;
14
+ export class JhTagGroup extends JhElement {
16
15
 
17
16
  static get styles() {
18
17
  return css`
@@ -43,8 +42,7 @@ export class JhTagGroup extends LitElement {
43
42
 
44
43
  constructor() {
45
44
  super();
46
- this.#internals = this.attachInternals();
47
- this.#internals.role = 'group';
45
+ this.internals.role = 'group';
48
46
  /** @type {'start'| 'end'} */
49
47
  this.alignment = 'start';
50
48
  }
@@ -54,4 +52,4 @@ export class JhTagGroup extends LitElement {
54
52
  }
55
53
  }
56
54
 
57
- customElements.define('jh-tag-group', JhTagGroup);
55
+ JhTagGroup.register('jh-tag-group', JhTagGroup);
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
+ import { JhElement } from '../element/element.js';
6
7
  import '../notification/notification.js';
7
8
 
8
9
  /**
@@ -15,7 +16,7 @@ import '../notification/notification.js';
15
16
  * @event jh-dismiss - Dispatched when the toast is dismissed.
16
17
  * @customElement jh-toast
17
18
  */
18
- export class JhToast extends LitElement {
19
+ export class JhToast extends JhElement {
19
20
  static get styles() {
20
21
  return css`
21
22
  @keyframes fadeInUp {
@@ -114,17 +115,7 @@ export class JhToast extends LitElement {
114
115
  }
115
116
 
116
117
  #removeToast() {
117
- this.#dispatch('jh-dismiss');
118
- }
119
-
120
- #dispatch(name) {
121
- this.dispatchEvent(
122
- new CustomEvent(name, {
123
- bubbles: true,
124
- cancelable: true,
125
- composed: true,
126
- })
127
- );
118
+ this.dispatchCustomEvent('jh-dismiss');
128
119
  }
129
120
 
130
121
  #handleDismiss() {
@@ -165,4 +156,4 @@ export class JhToast extends LitElement {
165
156
  }
166
157
  }
167
158
 
168
- customElements.define('jh-toast', JhToast);
159
+ JhToast.register('jh-toast', JhToast);
@@ -2,8 +2,9 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import { LitElement, css, html } from 'lit';
5
+ import { css, html } from 'lit';
6
6
  import { ifDefined } from 'lit/directives/if-defined.js';
7
+ import { JhElement } from '../element/element.js';
7
8
 
8
9
  let id = 0;
9
10
  const openAttr = 'open';
@@ -11,15 +12,14 @@ const openAttr = 'open';
11
12
  /**
12
13
  * @cssprop --jh-tooltip-color-background - The tooltip and arrow background-color. Defaults to `--jh-color-content-primary-enabled`.
13
14
  * @cssprop --jh-tooltip-color-text - The tooltip text color. Defaults to `--jh-color-content-on-primary-enabled`.
15
+ * @cssprop --jh-tooltip-size-max-width - The maximum width of the tooltip. Defaults to `160px`.
14
16
  *
15
17
  * @slot default - Use to insert the element that triggers the tooltip.
16
18
  * @slot jh-tooltip-content - Use to insert the content of the tooltip.
17
19
  *
18
20
  * @customElement jh-tooltip
19
21
  */
20
- export class JhTooltip extends LitElement {
21
- /** @type {ElementInternals} */
22
- #internals;
22
+ export class JhTooltip extends JhElement {
23
23
 
24
24
  static get styles() {
25
25
  return css`
@@ -36,13 +36,13 @@ export class JhTooltip extends LitElement {
36
36
  --jh-tooltip-color-text,
37
37
  var(--jh-color-content-on-primary-enabled)
38
38
  );
39
+ max-width: var(--jh-tooltip-size-max-width, 160px);
39
40
  border-radius: var(--jh-border-radius-100);
40
41
  padding: var(--jh-dimension-200);
41
42
  font-family: var(--jh-font-helper-bold-font-family);
42
43
  font-weight: var(--jh-font-helper-bold-font-weight);
43
44
  font-size: var(--jh-font-helper-bold-font-size);
44
45
  line-height: var(--jh-font-helper-bold-line-height);
45
- max-width: 160px;
46
46
  width: max-content;
47
47
  position: absolute;
48
48
  box-sizing: border-box;
@@ -224,7 +224,6 @@ export class JhTooltip extends LitElement {
224
224
 
225
225
  constructor() {
226
226
  super();
227
- this.#internals = this.attachInternals();
228
227
  /**@type {?Boolean} */
229
228
  this.flipDisabled = false;
230
229
  /**@type {?Boolean} */
@@ -253,14 +252,14 @@ export class JhTooltip extends LitElement {
253
252
  const hasContent = slot.assignedNodes().length > 0;
254
253
 
255
254
  if (hasContent) {
256
- this.#internals.role = 'tooltip';
255
+ this.internals.role = 'tooltip';
257
256
  this.addEventListener('focus', this.#handleOpenTooltip, true);
258
257
  this.addEventListener('mouseenter', this.#handleOpenTooltip);
259
258
  this.addEventListener('blur', this.#handleCloseTooltip, true);
260
259
  this.addEventListener('mouseleave', this.#handleCloseTooltip);
261
260
  this.addEventListener('keydown', this.#handleKeyDown);
262
261
  } else {
263
- this.#internals.role = '';
262
+ this.internals.role = '';
264
263
  this.#handleCloseTooltip();
265
264
  this.removeEventListener('focus', this.#handleOpenTooltip);
266
265
  this.removeEventListener('mouseenter', this.#handleOpenTooltip);
@@ -476,4 +475,4 @@ export class JhTooltip extends LitElement {
476
475
  }
477
476
  }
478
477
 
479
- customElements.define('jh-tooltip', JhTooltip);
478
+ JhTooltip.register('jh-tooltip', JhTooltip);