@cfpb/cfpb-design-system 3.12.1 → 3.13.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/CHANGELOG.md +19 -1
- package/dist/base/index.css +1 -1
- package/dist/base/index.css.map +2 -2
- package/dist/base/index.js +1 -1
- package/dist/base/index.js.map +1 -1
- package/dist/components/cfpb-buttons/index.css +1 -1
- package/dist/components/cfpb-buttons/index.css.map +2 -2
- package/dist/components/cfpb-buttons/index.js +1 -1
- package/dist/components/cfpb-buttons/index.js.map +1 -1
- package/dist/components/cfpb-expandables/index.css +1 -2
- package/dist/components/cfpb-expandables/index.css.map +3 -3
- package/dist/components/cfpb-expandables/index.js +1 -1
- package/dist/components/cfpb-expandables/index.js.map +4 -4
- package/dist/components/cfpb-forms/index.css +1 -2
- package/dist/components/cfpb-forms/index.css.map +3 -3
- package/dist/components/cfpb-forms/index.js +1 -1
- package/dist/components/cfpb-forms/index.js.map +4 -4
- package/dist/components/cfpb-icons/index.css +1 -1
- package/dist/components/cfpb-icons/index.css.map +2 -2
- package/dist/components/cfpb-icons/index.js +1 -1
- package/dist/components/cfpb-icons/index.js.map +1 -1
- package/dist/components/cfpb-layout/index.css +1 -1
- package/dist/components/cfpb-layout/index.css.map +2 -2
- package/dist/components/cfpb-layout/index.js +1 -1
- package/dist/components/cfpb-layout/index.js.map +1 -1
- package/dist/components/cfpb-notifications/index.css +1 -1
- package/dist/components/cfpb-notifications/index.css.map +2 -2
- package/dist/components/cfpb-notifications/index.js +1 -1
- package/dist/components/cfpb-notifications/index.js.map +1 -1
- package/dist/components/cfpb-pagination/index.css +1 -1
- package/dist/components/cfpb-pagination/index.css.map +2 -2
- package/dist/components/cfpb-pagination/index.js +1 -1
- package/dist/components/cfpb-pagination/index.js.map +1 -1
- package/dist/components/cfpb-tables/index.css +1 -1
- package/dist/components/cfpb-tables/index.css.map +2 -2
- package/dist/components/cfpb-tables/index.js +1 -1
- package/dist/components/cfpb-tables/index.js.map +1 -1
- package/dist/components/cfpb-tooltips/index.css +1 -2
- package/dist/components/cfpb-tooltips/index.css.map +3 -3
- package/dist/components/cfpb-tooltips/index.js +1 -1
- package/dist/components/cfpb-tooltips/index.js.map +4 -4
- package/dist/components/cfpb-typography/index.css +1 -1
- package/dist/components/cfpb-typography/index.css.map +2 -2
- package/dist/components/cfpb-typography/index.js +1 -1
- package/dist/components/cfpb-typography/index.js.map +1 -1
- package/dist/elements/cfpb-button/index.js +30 -0
- package/dist/elements/cfpb-button/index.js.map +7 -0
- package/dist/elements/cfpb-file-upload/index.js +39 -0
- package/dist/elements/cfpb-file-upload/index.js.map +7 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +2 -2
- package/dist/index.js +39 -1
- package/dist/index.js.map +4 -4
- package/dist/utilities/index.css +1 -2
- package/dist/utilities/index.css.map +3 -3
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/index.js.map +4 -4
- package/package.json +1 -1
- package/src/components/cfpb-tooltips/index.js +1 -1
- package/src/elements/cfpb-button/cfpb-button.component.scss +8 -0
- package/src/elements/cfpb-button/index.js +53 -0
- package/src/elements/cfpb-file-upload/cfpb-file-upload.component.scss +14 -0
- package/src/elements/cfpb-file-upload/index.js +81 -0
- package/src/index.js +3 -0
- package/src/utilities/behavior/behavior.js +2 -1
- package/src/utilities/behavior/flyout-menu.js +4 -7
- package/src/utilities/transition/alpha-transition.js +2 -1
- package/src/utilities/transition/max-height-transition.js +2 -1
- package/src/utilities/transition/move-transition.js +2 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
========================================================================== */
|
|
4
4
|
|
|
5
5
|
import tippy from 'tippy.js';
|
|
6
|
-
import { instantiateAll } from '
|
|
6
|
+
import { instantiateAll } from '../../utilities/atomic-helpers.js';
|
|
7
7
|
|
|
8
8
|
import * as TooltipStyles from './tooltip.scss';
|
|
9
9
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { html, LitElement, css, unsafeCSS } from 'lit';
|
|
2
|
+
import styles from './cfpb-button.component.scss';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @element cfpb-button
|
|
7
|
+
* @slot - The main content for the button.
|
|
8
|
+
*/
|
|
9
|
+
export class CfpbButton extends LitElement {
|
|
10
|
+
static styles = css`
|
|
11
|
+
${unsafeCSS(styles)}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
static get properties() {
|
|
15
|
+
return {
|
|
16
|
+
isDisabled: { type: Boolean },
|
|
17
|
+
type: { type: String },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.isDisabled = false;
|
|
24
|
+
this.type = '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get _btnClass() {
|
|
28
|
+
let btnClass = 'a-btn';
|
|
29
|
+
switch (this.type) {
|
|
30
|
+
case 'secondary':
|
|
31
|
+
btnClass += ' a-btn--secondary';
|
|
32
|
+
break;
|
|
33
|
+
case 'warning':
|
|
34
|
+
btnClass += ' a-btn--warning';
|
|
35
|
+
break;
|
|
36
|
+
case 'disabled':
|
|
37
|
+
btnClass += ' a-btn--disabled';
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return btnClass;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
return html`
|
|
46
|
+
<button class="${this._btnClass}" ?disabled=${this.isDisabled}>
|
|
47
|
+
<slot></slot>
|
|
48
|
+
</button>
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
window.customElements.define('cfpb-button', CfpbButton);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use '@cfpb/cfpb-design-system/src/abstracts' as *;
|
|
2
|
+
@use '@cfpb/cfpb-design-system/src/components/cfpb-buttons/vars' as *;
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
// This prevents the child button from having an empty gap after the button.
|
|
6
|
+
display: flex;
|
|
7
|
+
width: fit-content;
|
|
8
|
+
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host::part(upload-details)[hidden='true'] {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { html, LitElement, css, unsafeCSS } from 'lit';
|
|
2
|
+
import { ref, createRef } from 'lit/directives/ref.js';
|
|
3
|
+
import styles from './cfpb-file-upload.component.scss';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @element cfpb-file-upload.
|
|
8
|
+
* @slot - The main content for the upload button.
|
|
9
|
+
*/
|
|
10
|
+
export class CfpbFileUpload extends LitElement {
|
|
11
|
+
static styles = css`
|
|
12
|
+
${unsafeCSS(styles)}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
isDetailHidden: { type: Boolean },
|
|
18
|
+
fileName: { type: String },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.isDetailHidden = true;
|
|
25
|
+
this.fileName = '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fileInput = createRef();
|
|
29
|
+
fileDetails = createRef();
|
|
30
|
+
|
|
31
|
+
#getUploadName(fileName) {
|
|
32
|
+
let uploadName = fileName;
|
|
33
|
+
if (uploadName.indexOf('\\') > -1) {
|
|
34
|
+
const uploadNameParts = uploadName.split('\\');
|
|
35
|
+
uploadName = uploadNameParts[uploadNameParts.length - 1];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return uploadName;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#showDetails() {
|
|
42
|
+
this.fileName = this.#getUploadName(this.fileInput.value.value);
|
|
43
|
+
this.isDetailHidden = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
return html`
|
|
48
|
+
<cfpb-button
|
|
49
|
+
type="secondary"
|
|
50
|
+
@click="${() => {
|
|
51
|
+
this.fileInput.value.click();
|
|
52
|
+
}}"
|
|
53
|
+
>
|
|
54
|
+
<slot></slot>
|
|
55
|
+
</cfpb-button>
|
|
56
|
+
<input
|
|
57
|
+
id="file-upload"
|
|
58
|
+
class="a-btn a-btn--secondary"
|
|
59
|
+
type="file"
|
|
60
|
+
hidden
|
|
61
|
+
@input="${() => this.#showDetails()}"
|
|
62
|
+
${ref(this.fileInput)}
|
|
63
|
+
/>
|
|
64
|
+
<div
|
|
65
|
+
part="upload-details"
|
|
66
|
+
?hidden=${this.isDetailHidden}
|
|
67
|
+
${ref(this.fileDetails)}
|
|
68
|
+
>
|
|
69
|
+
<h4>File added</h4>
|
|
70
|
+
<ul>
|
|
71
|
+
<li>${this.fileName} ${this.isDetailHidden}</li>
|
|
72
|
+
</ul>
|
|
73
|
+
<p>
|
|
74
|
+
To remove or replace your file, select a new file and upload again.
|
|
75
|
+
</p>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
window.customElements.define('cfpb-file-upload', CfpbFileUpload);
|
package/src/index.js
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
========================================================================== */
|
|
23
23
|
|
|
24
|
-
import { BEHAVIOR_PREFIX, JS_HOOK
|
|
24
|
+
import { BEHAVIOR_PREFIX, JS_HOOK } from '../standard-type.js';
|
|
25
|
+
import { contains } from '../data-hook.js';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @param {string} behaviorSelector - Behavior type used to find the element
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
EventObserver,
|
|
6
|
-
checkBehaviorDom,
|
|
7
|
-
} from '@cfpb/cfpb-design-system';
|
|
1
|
+
import { BaseTransition } from '../transition/base-transition.js';
|
|
2
|
+
import { EventObserver } from '../event-observer.js';
|
|
3
|
+
import { checkBehaviorDom } from '../behavior/behavior.js';
|
|
4
|
+
import { BEHAVIOR_PREFIX, JS_HOOK } from '../standard-type.js';
|
|
8
5
|
|
|
9
6
|
const BASE_CLASS = BEHAVIOR_PREFIX + 'flyout-menu';
|
|
10
7
|
const SEL_PREFIX = '[' + JS_HOOK + '=' + BASE_CLASS;
|