@cfpb/cfpb-design-system 5.3.0 → 5.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfpb/cfpb-design-system",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "CFPB's UI framework",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -1,4 +1,5 @@
1
1
  import { html, LitElement, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { classMap } from 'lit/directives/class-map.js';
3
4
  import { ref, createRef } from 'lit/directives/ref.js';
4
5
  import styles from './styles.component.scss?inline';
@@ -175,8 +176,6 @@ export class CfpbButton extends LitElement {
175
176
 
176
177
  static init() {
177
178
  CfpbIconText.init();
178
-
179
- window.customElements.get('cfpb-button') ||
180
- window.customElements.define('cfpb-button', CfpbButton);
179
+ defineComponent('cfpb-button', CfpbButton);
181
180
  }
182
181
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
 
4
5
  // The validation states are error, warning, or success.
@@ -98,7 +99,6 @@ export class CfpbCheckboxIcon extends LitElement {
98
99
  }
99
100
 
100
101
  static init() {
101
- window.customElements.get('cfpb-checkbox-icon') ||
102
- window.customElements.define('cfpb-checkbox-icon', CfpbCheckboxIcon);
102
+ defineComponent('cfpb-checkbox-icon', CfpbCheckboxIcon);
103
103
  }
104
104
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { CfpbIcon } from '../cfpb-icon';
4
5
  import { MaxHeightTransition } from '../../utilities/transition/max-height-transition';
@@ -6,8 +7,9 @@ import { FlyoutMenu } from '../../utilities/behavior/flyout-menu';
6
7
 
7
8
  /**
8
9
  *
9
- * @element cfpb-button
10
- * @slot - The main content for the button.
10
+ * @element cfpb-expandable
11
+ * @slot header - The header content for the expandable.
12
+ * @slot content - The content within the expandable.
11
13
  */
12
14
  export class CfpbExpandable extends LitElement {
13
15
  static styles = css`
@@ -120,8 +122,6 @@ export class CfpbExpandable extends LitElement {
120
122
 
121
123
  static init() {
122
124
  CfpbIcon.init();
123
-
124
- window.customElements.get('cfpb-expandable') ||
125
- window.customElements.define('cfpb-expandable', CfpbExpandable);
125
+ defineComponent('cfpb-expandable', CfpbExpandable);
126
126
  }
127
127
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { ref, createRef } from 'lit/directives/ref.js';
3
4
  import styles from './styles.component.css?inline';
4
5
  import { CfpbButton } from '../cfpb-button';
@@ -101,11 +102,7 @@ export class CfpbFileUpload extends LitElement {
101
102
  }
102
103
 
103
104
  static init() {
104
- // Initialize internal button.
105
105
  CfpbButton.init();
106
-
107
- // Initialize parent file upload.
108
- window.customElements.get('cfpb-file-upload') ||
109
- window.customElements.define('cfpb-file-upload', CfpbFileUpload);
106
+ defineComponent('cfpb-file-upload', CfpbFileUpload);
110
107
  }
111
108
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.css?inline';
3
4
 
4
5
  /**
@@ -10,7 +11,6 @@ export class CfpbFlagUsa extends LitElement {
10
11
  `;
11
12
 
12
13
  static init() {
13
- globalThis.customElements.get('cfpb-flag-usa') ??
14
- globalThis.customElements.define('cfpb-flag-usa', CfpbFlagUsa);
14
+ defineComponent('cfpb-flag-usa', CfpbFlagUsa);
15
15
  }
16
16
  }
@@ -1,10 +1,11 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { CfpbIcon } from '../cfpb-icon';
4
5
 
5
6
  /**
6
- * @element cfpb-form-search
7
- * @slot - The label for the form input.
7
+ * @element cfpb-form-alert
8
+ * @slot - The text for the form alert.
8
9
  */
9
10
  export class CfpbFormAlert extends LitElement {
10
11
  static styles = css`
@@ -60,8 +61,6 @@ export class CfpbFormAlert extends LitElement {
60
61
 
61
62
  static init() {
62
63
  CfpbIcon.init();
63
-
64
- window.customElements.get('cfpb-form-alert') ||
65
- window.customElements.define('cfpb-form-alert', CfpbFormAlert);
64
+ defineComponent('cfpb-form-alert', CfpbFormAlert);
66
65
  }
67
66
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { classMap } from 'lit/directives/class-map.js';
3
4
  import { ref, createRef } from 'lit/directives/ref.js';
4
5
  import styles from './styles.component.scss?inline';
@@ -169,8 +170,6 @@ export class CfpbFormChoice extends LitElement {
169
170
 
170
171
  static init() {
171
172
  CfpbCheckboxIcon.init();
172
-
173
- window.customElements.get('cfpb-form-choice') ||
174
- window.customElements.define('cfpb-form-choice', CfpbFormChoice);
173
+ defineComponent('cfpb-form-choice', CfpbFormChoice);
175
174
  }
176
175
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { ref, createRef } from 'lit/directives/ref.js';
4
5
  import { CfpbFormSearchInput } from '../cfpb-form-search-input';
@@ -8,6 +9,7 @@ import { CfpbFormAlert } from '../cfpb-form-alert';
8
9
 
9
10
  /**
10
11
  * @element cfpb-form-search
12
+ * @slot - Slot for list of autocomplete items.
11
13
  */
12
14
  export class CfpbFormSearch extends LitElement {
13
15
  static styles = css`
@@ -190,8 +192,6 @@ export class CfpbFormSearch extends LitElement {
190
192
  CfpbFormSearchInput.init();
191
193
  CfpbListbox.init();
192
194
  CfpbFormAlert.init();
193
-
194
- window.customElements.get('cfpb-form-search') ||
195
- window.customElements.define('cfpb-form-search', CfpbFormSearch);
195
+ defineComponent('cfpb-form-search', CfpbFormSearch);
196
196
  }
197
197
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { ref, createRef } from 'lit/directives/ref.js';
3
4
  import styles from './styles.component.scss?inline';
4
5
  import { CfpbIcon } from '../cfpb-icon';
@@ -141,11 +142,6 @@ export class CfpbFormSearchInput extends LitElement {
141
142
 
142
143
  static init() {
143
144
  CfpbIcon.init();
144
-
145
- window.customElements.get('cfpb-form-search-input') ||
146
- window.customElements.define(
147
- 'cfpb-form-search-input',
148
- CfpbFormSearchInput,
149
- );
145
+ defineComponent('cfpb-form-search-input', CfpbFormSearchInput);
150
146
  }
151
147
  }
@@ -1,6 +1,9 @@
1
1
  import { html, LitElement, css, unsafeCSS } from 'lit';
2
+ import {
3
+ defineComponent,
4
+ getSharedConfig,
5
+ } from '../cfpb-utilities/shared-config';
2
6
  import styles from './styles.component.css?inline';
3
- import { getSharedConfig } from '../cfpb-utilities/shared-config';
4
7
 
5
8
  /**
6
9
  * @element cfpb-icon
@@ -37,7 +40,6 @@ export class CfpbIcon extends LitElement {
37
40
  }
38
41
 
39
42
  static init() {
40
- globalThis.customElements.get('cfpb-icon') ??
41
- globalThis.customElements.define('cfpb-icon', CfpbIcon);
43
+ defineComponent('cfpb-icon', CfpbIcon);
42
44
  }
43
45
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
 
4
5
  /**
@@ -72,7 +73,6 @@ export class CfpbIconText extends LitElement {
72
73
  }
73
74
 
74
75
  static init() {
75
- window.customElements.get('cfpb-icon-text') ||
76
- window.customElements.define('cfpb-icon-text', CfpbIconText);
76
+ defineComponent('cfpb-icon-text', CfpbIconText);
77
77
  }
78
78
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { ifDefined } from 'lit/directives/if-defined.js';
4
5
 
@@ -53,7 +54,6 @@ export class CfpbLabel extends LitElement {
53
54
  }
54
55
 
55
56
  static init() {
56
- window.customElements.get('cfpb-label') ||
57
- window.customElements.define('cfpb-label', CfpbLabel);
57
+ defineComponent('cfpb-label', CfpbLabel);
58
58
  }
59
59
  }
@@ -1,9 +1,14 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { ref, createRef } from 'lit/directives/ref.js';
3
4
  import styles from './styles.component.scss?inline';
4
5
  import { CfpbListboxItem } from '../cfpb-listbox-item';
5
6
  import { parseChildData } from '../cfpb-utilities/parse-child-data';
6
7
 
8
+ /**
9
+ * @element cfpb-listbox.
10
+ * @slot - Slot for the list of items in the list box.
11
+ */
7
12
  export class CfpbListbox extends LitElement {
8
13
  static styles = css`
9
14
  ${unsafeCSS(styles)}
@@ -373,9 +378,6 @@ export class CfpbListbox extends LitElement {
373
378
 
374
379
  static init() {
375
380
  CfpbListboxItem.init();
376
-
377
- if (!window.customElements.get('cfpb-listbox')) {
378
- window.customElements.define('cfpb-listbox', CfpbListbox);
379
- }
381
+ defineComponent('cfpb-listbox', CfpbListbox);
380
382
  }
381
383
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { ref, createRef } from 'lit/directives/ref.js';
4
5
  import { CfpbCheckboxIcon } from '../cfpb-checkbox-icon';
@@ -207,9 +208,6 @@ export class CfpbListboxItem extends LitElement {
207
208
 
208
209
  static init() {
209
210
  CfpbCheckboxIcon.init();
210
-
211
- if (!window.customElements.get('cfpb-listbox-item')) {
212
- window.customElements.define('cfpb-listbox-item', CfpbListboxItem);
213
- }
211
+ defineComponent('cfpb-listbox-item', CfpbListboxItem);
214
212
  }
215
213
  }
@@ -1,12 +1,13 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { CfpbIcon } from '../cfpb-icon';
4
5
  import { I18nService, MediaQueryService } from '../cfpb-utilities/';
5
6
 
6
7
  /**
7
8
  *
8
- * @element cfpb-button
9
- * @slot - The main content for the button.
9
+ * @element cfpb-pagination
10
+ * @slot - Slot for passing in i18n (internationalization) service strings via a <template>.
10
11
  */
11
12
  export class CfpbPagination extends LitElement {
12
13
  #mediaService;
@@ -202,8 +203,6 @@ export class CfpbPagination extends LitElement {
202
203
  static init() {
203
204
  CfpbIcon.init();
204
205
  I18nService.init();
205
-
206
- window.customElements.get('cfpb-pagination') ||
207
- window.customElements.define('cfpb-pagination', CfpbPagination);
206
+ defineComponent('cfpb-pagination', CfpbPagination);
208
207
  }
209
208
  }
@@ -1,6 +1,7 @@
1
1
  import { html, LitElement, css, unsafeCSS, nothing } from 'lit';
2
- import { ref, createRef } from 'lit/directives/ref.js';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
3
3
  import styles from './styles.component.scss?inline';
4
+ import { ref, createRef } from 'lit/directives/ref.js';
4
5
  import { CfpbIcon } from '../cfpb-icon';
5
6
  import { CfpbFormSearchInput } from '../cfpb-form-search-input';
6
7
  import { SearchService } from '../cfpb-utilities/search-service.js';
@@ -373,8 +374,6 @@ export class CfpbSelect extends LitElement {
373
374
  CfpbFormSearchInput.init();
374
375
  CfpbListbox.init();
375
376
  CfpbTagGroup.init();
376
-
377
- window.customElements.get('cfpb-select') ||
378
- window.customElements.define('cfpb-select', CfpbSelect);
377
+ defineComponent('cfpb-select', CfpbSelect);
379
378
  }
380
379
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { unsafeHTML } from 'lit/directives/unsafe-html.js';
3
4
  import styles from './styles.component.scss?inline';
4
5
  import { errorIcon as icon } from '../../components/cfpb-icons/icons-lib';
@@ -64,8 +65,6 @@ export class CfpbTagFilter extends LitElement {
64
65
  }
65
66
 
66
67
  static init() {
67
- // Initialize parent file upload.
68
- window.customElements.get('cfpb-tag-filter') ||
69
- window.customElements.define('cfpb-tag-filter', CfpbTagFilter);
68
+ defineComponent('cfpb-tag-filter', CfpbTagFilter);
70
69
  }
71
70
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
  import { parseChildData } from '../cfpb-utilities/parse-child-data';
4
5
 
@@ -364,7 +365,6 @@ export class CfpbTagGroup extends LitElement {
364
365
  }
365
366
 
366
367
  static init() {
367
- window.customElements.get('cfpb-tag-group') ||
368
- window.customElements.define('cfpb-tag-group', CfpbTagGroup);
368
+ defineComponent('cfpb-tag-group', CfpbTagGroup);
369
369
  }
370
370
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import styles from './styles.component.scss?inline';
3
4
 
4
5
  /**
@@ -67,8 +68,6 @@ export class CfpbTagTopic extends LitElement {
67
68
  }
68
69
 
69
70
  static init() {
70
- // Initialize parent file upload.
71
- window.customElements.get('cfpb-tag-topic') ||
72
- window.customElements.define('cfpb-tag-topic', CfpbTagTopic);
71
+ defineComponent('cfpb-tag-topic', CfpbTagTopic);
73
72
  }
74
73
  }
@@ -1,9 +1,10 @@
1
1
  import { LitElement, html, css, unsafeCSS } from 'lit';
2
+ import { defineComponent } from '../cfpb-utilities/shared-config';
2
3
  import { CfpbFlagUsa } from '../cfpb-flag-usa';
3
4
  import styles from './styles.component.scss?inline';
4
5
 
5
6
  /**
6
- * @element cfpb-icon-text
7
+ * @element cfpb-tagline
7
8
  * @slot - The main content for the tagline.
8
9
  */
9
10
  export class CfpbTagline extends LitElement {
@@ -46,8 +47,6 @@ export class CfpbTagline extends LitElement {
46
47
 
47
48
  static init() {
48
49
  CfpbFlagUsa.init();
49
-
50
- globalThis.customElements.get('cfpb-tagline') ??
51
- globalThis.customElements.define('cfpb-tagline', CfpbTagline);
50
+ defineComponent('cfpb-tagline', CfpbTagline);
52
51
  }
53
52
  }
@@ -39,3 +39,14 @@ export function setSharedConfig(userConfig) {
39
39
  export function getSharedConfig() {
40
40
  return config;
41
41
  }
42
+
43
+ /**
44
+ * Check if a custom element is registered, and if not, define it on the globalThis (window).
45
+ * @param {string} tag - A custom element's tag as it appears in markup.
46
+ * @param {HTMLElement} constructor - A custom element constructor.
47
+ */
48
+ export function defineComponent(tag, constructor) {
49
+ if (!globalThis.customElements.get(tag)) {
50
+ globalThis.customElements.define(tag, constructor);
51
+ }
52
+ }