@fluid-topics/ft-file-button 0.1.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/README.md +19 -0
- package/build/ft-file-button.d.ts +27 -0
- package/build/ft-file-button.js +84 -0
- package/build/ft-file-button.light.js +587 -0
- package/build/ft-file-button.min.js +674 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
File
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-file-button
|
|
7
|
+
yarn add @fluid-topics/ft-file-button
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ft-file-button"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-file-button accept="*.pdf">Upload a file</ft-file-button> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
export interface FtFileButtonProperties {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
trailingIcon: boolean;
|
|
7
|
+
accept: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const FtFileButtonCssVariables: {};
|
|
10
|
+
export declare class FileChangeEvent extends CustomEvent<{
|
|
11
|
+
file: File;
|
|
12
|
+
}> {
|
|
13
|
+
constructor(file: File);
|
|
14
|
+
}
|
|
15
|
+
export declare class FtFileButton extends FtLitElement implements FtFileButtonProperties {
|
|
16
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
17
|
+
protected getStyles(): import("lit").CSSResult;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
label: string;
|
|
20
|
+
icon?: string;
|
|
21
|
+
trailingIcon: boolean;
|
|
22
|
+
accept: string;
|
|
23
|
+
private input;
|
|
24
|
+
protected getTemplate(): import("lit-html").TemplateResult<1>;
|
|
25
|
+
private onFileChange;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ft-file-button.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { css, html } from "lit";
|
|
8
|
+
import { property, query } from "lit/decorators.js";
|
|
9
|
+
import { customElement, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { FtButton } from "@fluid-topics/ft-button";
|
|
11
|
+
export const FtFileButtonCssVariables = {};
|
|
12
|
+
export class FileChangeEvent extends CustomEvent {
|
|
13
|
+
constructor(file) {
|
|
14
|
+
super("change", { detail: { file } });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let FtFileButton = class FtFileButton extends FtLitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.disabled = false;
|
|
21
|
+
this.label = "";
|
|
22
|
+
this.icon = undefined;
|
|
23
|
+
this.trailingIcon = false;
|
|
24
|
+
this.accept = "";
|
|
25
|
+
}
|
|
26
|
+
getStyles() {
|
|
27
|
+
// language=CSS
|
|
28
|
+
return css `
|
|
29
|
+
.ft-file-button {
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
getTemplate() {
|
|
34
|
+
return html `
|
|
35
|
+
<div class="ft-file-button">
|
|
36
|
+
<ft-button primary
|
|
37
|
+
?disabled=${this.disabled}
|
|
38
|
+
label="${this.label}"
|
|
39
|
+
icon="${this.icon}"
|
|
40
|
+
?trailingIcon=${this.trailingIcon}
|
|
41
|
+
@click=${() => this.input.click()}>
|
|
42
|
+
<slot></slot>
|
|
43
|
+
</ft-button>
|
|
44
|
+
<input class="ft-file-button--input"
|
|
45
|
+
type="file"
|
|
46
|
+
accept="${this.accept}"
|
|
47
|
+
@change=${this.onFileChange}
|
|
48
|
+
hidden/>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
onFileChange() {
|
|
53
|
+
var _a;
|
|
54
|
+
if (((_a = this.input.files) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
55
|
+
this.dispatchEvent(new FileChangeEvent(this.input.files.item(0)));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
FtFileButton.elementDefinitions = {
|
|
60
|
+
"ft-button": FtButton,
|
|
61
|
+
};
|
|
62
|
+
__decorate([
|
|
63
|
+
property({ type: Boolean })
|
|
64
|
+
], FtFileButton.prototype, "disabled", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
property({ type: String })
|
|
67
|
+
], FtFileButton.prototype, "label", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
property({ type: String })
|
|
70
|
+
], FtFileButton.prototype, "icon", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
property({ type: Boolean })
|
|
73
|
+
], FtFileButton.prototype, "trailingIcon", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
property({ type: String })
|
|
76
|
+
], FtFileButton.prototype, "accept", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
query(".ft-file-button--input")
|
|
79
|
+
], FtFileButton.prototype, "input", void 0);
|
|
80
|
+
FtFileButton = __decorate([
|
|
81
|
+
customElement("ft-file-button")
|
|
82
|
+
], FtFileButton);
|
|
83
|
+
export { FtFileButton };
|
|
84
|
+
//# sourceMappingURL=ft-file-button.js.map
|