@fluid-topics/ftds-file-button 2.1.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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ The design system file button component
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ftds-file-button
7
+ yarn add @fluid-topics/ftds-file-button
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ftds-file-button"
15
+
16
+ function render() {
17
+ return html` <ftds-file-button foo="bar"></ftds-file-button> `
18
+ }
19
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { customElements } from "@fluid-topics/ft-wc-utils";
2
+ import definitions from "./definitions";
3
+ customElements(definitions);
@@ -0,0 +1,5 @@
1
+ import { FtdsFileButton } from "./ftds-file-button";
2
+ declare const _default: {
3
+ "ftds-file-button": typeof FtdsFileButton;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { FtdsFileButton } from "./ftds-file-button";
2
+ export default {
3
+ "ftds-file-button": FtdsFileButton,
4
+ };
@@ -0,0 +1,26 @@
1
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtdsIcons, FtdsIconVariants } from "@fluid-topics/ftds-icon";
3
+ import { FtdsFileButtonProperties } from "./ftds-file-button.properties";
4
+ export declare class FileChangeEvent extends CustomEvent<{
5
+ file: File;
6
+ }> {
7
+ constructor(file: File);
8
+ }
9
+ declare const FtdsFileButton_base: import("@fluid-topics/ft-wc-utils").FtdsBaseType<typeof FtLitElement>;
10
+ export declare class FtdsFileButton extends FtdsFileButton_base implements FtdsFileButtonProperties {
11
+ static elementDefinitions: ElementDefinitionsMap;
12
+ static styles: import("lit").CSSResult;
13
+ disabled: boolean;
14
+ label: string;
15
+ icon?: FtdsIcons;
16
+ iconVariant?: FtdsIconVariants;
17
+ trailingIcon: boolean;
18
+ accept: string;
19
+ private input;
20
+ private button;
21
+ focus(): void;
22
+ clear(): void;
23
+ protected render(): import("lit-html").TemplateResult<1>;
24
+ private onFileChange;
25
+ }
26
+ export {};
@@ -0,0 +1,85 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { styles } from "./ftds-file-button.styles";
8
+ import { FtdsButton } from "@fluid-topics/ftds-button";
9
+ import { html } from "lit";
10
+ import { property, query, } from "lit/decorators.js";
11
+ import { FtLitElement, toFtdsBase, } from "@fluid-topics/ft-wc-utils";
12
+ export class FileChangeEvent extends CustomEvent {
13
+ constructor(file) {
14
+ super("change", { detail: { file } });
15
+ }
16
+ }
17
+ export class FtdsFileButton extends toFtdsBase(FtLitElement) {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.disabled = false;
21
+ this.label = "";
22
+ this.trailingIcon = false;
23
+ this.accept = "";
24
+ }
25
+ focus() {
26
+ this.button.focus();
27
+ }
28
+ clear() {
29
+ this.input.value = "";
30
+ }
31
+ render() {
32
+ return html `
33
+ <div class="ftds-file-button">
34
+ <ftds-button ?disabled=${this.disabled}
35
+ label="${this.label}"
36
+ family="${this.family}"
37
+ size="${this.size}"
38
+ icon="${this.icon}"
39
+ .iconVariant=${this.iconVariant}
40
+ ?trailingIcon=${this.trailingIcon}
41
+ @click=${() => this.input.click()}>
42
+ <slot></slot>
43
+ </ftds-button>
44
+ <input class="ftds-file-button--input"
45
+ type="file"
46
+ accept="${this.accept}"
47
+ @change=${this.onFileChange}
48
+ hidden/>
49
+ </div>
50
+ `;
51
+ }
52
+ onFileChange() {
53
+ if (this.input.files.length > 0) {
54
+ this.dispatchEvent(new FileChangeEvent(this.input.files.item(0)));
55
+ }
56
+ }
57
+ }
58
+ FtdsFileButton.elementDefinitions = {
59
+ "ftds-button": FtdsButton,
60
+ };
61
+ FtdsFileButton.styles = styles;
62
+ __decorate([
63
+ property({ type: Boolean })
64
+ ], FtdsFileButton.prototype, "disabled", void 0);
65
+ __decorate([
66
+ property()
67
+ ], FtdsFileButton.prototype, "label", void 0);
68
+ __decorate([
69
+ property()
70
+ ], FtdsFileButton.prototype, "icon", void 0);
71
+ __decorate([
72
+ property()
73
+ ], FtdsFileButton.prototype, "iconVariant", void 0);
74
+ __decorate([
75
+ property({ type: Boolean })
76
+ ], FtdsFileButton.prototype, "trailingIcon", void 0);
77
+ __decorate([
78
+ property()
79
+ ], FtdsFileButton.prototype, "accept", void 0);
80
+ __decorate([
81
+ query(".ftds-file-button--input")
82
+ ], FtdsFileButton.prototype, "input", void 0);
83
+ __decorate([
84
+ query("ftds-button")
85
+ ], FtdsFileButton.prototype, "button", void 0);