@operato/form 1.0.0-alpha.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/.editorconfig +29 -0
- package/.storybook/main.js +3 -0
- package/.storybook/server.mjs +8 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/demo/index.html +33 -0
- package/dist/src/components/ox-custom-input.d.ts +23 -0
- package/dist/src/components/ox-custom-input.js +114 -0
- package/dist/src/components/ox-custom-input.js.map +1 -0
- package/dist/src/components/ox-custom-select.d.ts +21 -0
- package/dist/src/components/ox-custom-select.js +100 -0
- package/dist/src/components/ox-custom-select.js.map +1 -0
- package/dist/src/components/ox-file-uploader.d.ts +13 -0
- package/dist/src/components/ox-file-uploader.js +166 -0
- package/dist/src/components/ox-file-uploader.js.map +1 -0
- package/dist/src/components/ox-form-master.d.ts +1 -0
- package/dist/src/components/ox-form-master.js +208 -0
- package/dist/src/components/ox-form-master.js.map +1 -0
- package/dist/src/components/ox-form-paginator.d.ts +9 -0
- package/dist/src/components/ox-form-paginator.js +70 -0
- package/dist/src/components/ox-form-paginator.js.map +1 -0
- package/dist/src/components/ox-search-form-paginator.d.ts +1 -0
- package/dist/src/components/ox-search-form-paginator.js +51 -0
- package/dist/src/components/ox-search-form-paginator.js.map +1 -0
- package/dist/src/components/ox-search-form.d.ts +56 -0
- package/dist/src/components/ox-search-form.js +284 -0
- package/dist/src/components/ox-search-form.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/styles/index.d.ts +3 -0
- package/dist/src/styles/index.js +4 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/styles/multi-column-form-styles.d.ts +1 -0
- package/dist/src/styles/multi-column-form-styles.js +192 -0
- package/dist/src/styles/multi-column-form-styles.js.map +1 -0
- package/dist/src/styles/search-form-styles.d.ts +1 -0
- package/dist/src/styles/search-form-styles.js +156 -0
- package/dist/src/styles/search-form-styles.js.map +1 -0
- package/dist/src/styles/single-column-form-styles.d.ts +1 -0
- package/dist/src/styles/single-column-form-styles.js +114 -0
- package/dist/src/styles/single-column-form-styles.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +77 -0
- package/src/components/ox-custom-input.ts +102 -0
- package/src/components/ox-custom-select.ts +90 -0
- package/src/components/ox-file-uploader.ts +163 -0
- package/src/components/ox-form-master.ts +241 -0
- package/src/components/ox-form-paginator.ts +60 -0
- package/src/components/ox-search-form-paginator.ts +46 -0
- package/src/components/ox-search-form.ts +317 -0
- package/src/index.ts +3 -0
- package/src/styles/index.ts +3 -0
- package/src/styles/multi-column-form-styles.ts +192 -0
- package/src/styles/search-form-styles.ts +156 -0
- package/src/styles/single-column-form-styles.ts +114 -0
- package/src/themes/form-theme.css +75 -0
- package/tsconfig.json +23 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
+
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
+
|
|
4
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
open: '/',
|
|
7
|
+
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
+
});
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [1.0.0-alpha.1](https://github.com/hatiolab/operato/compare/v0.4.3...v1.0.0-alpha.1) (2022-03-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* 1.0-alpha ([42f87cf](https://github.com/hatiolab/operato/commit/42f87cf6a3cef0381db91ecb1179e63c64c01370))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) hatiolab.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# \<mini-app>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i mini-app
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'mini-app/mini-app.js'
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<mini-app></mini-app>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Linting and formatting
|
|
22
|
+
|
|
23
|
+
To scan the project for linting and formatting errors, run
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To automatically fix linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Testing with Web Test Runner
|
|
36
|
+
|
|
37
|
+
To execute a single test run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To run the tests in interactive watch mode run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test:watch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Demoing with Storybook
|
|
50
|
+
|
|
51
|
+
To run a local instance of Storybook for your component, run
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm run storybook
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To build a production version of Storybook, run
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run storybook:build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Tooling configs
|
|
64
|
+
|
|
65
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
66
|
+
|
|
67
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
68
|
+
|
|
69
|
+
## Local Demo with `web-dev-server`
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm start
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa;
|
|
8
|
+
--ox-checkbox-size: 12px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#demo {
|
|
12
|
+
position: relative;
|
|
13
|
+
height: 300px;
|
|
14
|
+
background-color: lightgray;
|
|
15
|
+
vertical-align: middle;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
|
19
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<div id="demo"></div>
|
|
23
|
+
|
|
24
|
+
<script type="module">
|
|
25
|
+
import { html, render } from 'lit'
|
|
26
|
+
import '@material/mwc-icon'
|
|
27
|
+
|
|
28
|
+
const parent = document.querySelector('#demo')
|
|
29
|
+
|
|
30
|
+
render(html``, parent)
|
|
31
|
+
</script>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export declare class CustomInput extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
name?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
props: any;
|
|
8
|
+
attrs: any;
|
|
9
|
+
valueField?: string;
|
|
10
|
+
value: any;
|
|
11
|
+
autofocus: boolean;
|
|
12
|
+
input: HTMLInputElement;
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
get checked(): boolean;
|
|
15
|
+
set checked(checked: boolean);
|
|
16
|
+
firstUpdated(): void;
|
|
17
|
+
updated(changes: PropertyValues<this>): void;
|
|
18
|
+
_isObject(v: any): boolean;
|
|
19
|
+
focus(): void;
|
|
20
|
+
select(): void;
|
|
21
|
+
blur(): void;
|
|
22
|
+
checkValidity(): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, css, html } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
let CustomInput = class CustomInput extends LitElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.autofocus = false;
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
return html `
|
|
11
|
+
<input
|
|
12
|
+
name=${this.name}
|
|
13
|
+
placeholder=${this.placeholder}
|
|
14
|
+
type=${this.type || 'text'}
|
|
15
|
+
value=${this.value || ''}
|
|
16
|
+
@input=${(e) => (this.value = e.currentTarget.value)}
|
|
17
|
+
?autofocus=${this.autofocus}
|
|
18
|
+
/>
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
get checked() {
|
|
22
|
+
return this.input.checked;
|
|
23
|
+
}
|
|
24
|
+
set checked(checked) {
|
|
25
|
+
this.input.checked = checked;
|
|
26
|
+
}
|
|
27
|
+
firstUpdated() {
|
|
28
|
+
this.dispatchEvent(new CustomEvent('load'));
|
|
29
|
+
}
|
|
30
|
+
updated(changes) {
|
|
31
|
+
if (changes.has('props')) {
|
|
32
|
+
if (this._isObject(this.props)) {
|
|
33
|
+
for (let prop in this.props) {
|
|
34
|
+
if (this.props[prop]) {
|
|
35
|
+
this.input.setAttribute(prop, this.props[prop]);
|
|
36
|
+
this.setAttribute(prop, this.props[prop]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (changes.has('attrs')) {
|
|
42
|
+
if (this.attrs && Array.isArray(this.attrs)) {
|
|
43
|
+
this.attrs.forEach(attr => {
|
|
44
|
+
this.input.setAttribute(attr, '');
|
|
45
|
+
this.setAttribute(attr, '');
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (changes.has('value') && this._isObject(this.value)) {
|
|
50
|
+
let value = this.value;
|
|
51
|
+
this.value = (this.valueField && value[this.valueField]) || value[Object.keys(value)[0]];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_isObject(v) {
|
|
55
|
+
return v instanceof Object && !Array.isArray(v);
|
|
56
|
+
}
|
|
57
|
+
focus() {
|
|
58
|
+
this.input.focus();
|
|
59
|
+
}
|
|
60
|
+
select() {
|
|
61
|
+
this.input.select();
|
|
62
|
+
}
|
|
63
|
+
blur() {
|
|
64
|
+
this.input.blur();
|
|
65
|
+
}
|
|
66
|
+
checkValidity() {
|
|
67
|
+
return this.input.checkValidity();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
CustomInput.styles = css `
|
|
71
|
+
input {
|
|
72
|
+
margin: auto 0;
|
|
73
|
+
border-style: var(--form-input-border-style, solid);
|
|
74
|
+
border-width: var(--form-input-border-width, 1px);
|
|
75
|
+
border-color: var(--form-input-border-color, #c4c5c6);
|
|
76
|
+
padding: var(--form-input-padding, 5px);
|
|
77
|
+
min-width: var(--form-input-width, 300px);
|
|
78
|
+
max-width: var(--form-input-width, 300px);
|
|
79
|
+
outline: var(--form-input-outline, none);
|
|
80
|
+
background-color: var(--form-input-background-color, #fff);
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
__decorate([
|
|
84
|
+
property({ type: String })
|
|
85
|
+
], CustomInput.prototype, "name", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
property({ type: String })
|
|
88
|
+
], CustomInput.prototype, "placeholder", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property({ type: String })
|
|
91
|
+
], CustomInput.prototype, "type", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: Object })
|
|
94
|
+
], CustomInput.prototype, "props", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: Array })
|
|
97
|
+
], CustomInput.prototype, "attrs", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: String })
|
|
100
|
+
], CustomInput.prototype, "valueField", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: Object })
|
|
103
|
+
], CustomInput.prototype, "value", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Boolean })
|
|
106
|
+
], CustomInput.prototype, "autofocus", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
query('input')
|
|
109
|
+
], CustomInput.prototype, "input", void 0);
|
|
110
|
+
CustomInput = __decorate([
|
|
111
|
+
customElement('custom-input')
|
|
112
|
+
], CustomInput);
|
|
113
|
+
export { CustomInput };
|
|
114
|
+
//# sourceMappingURL=ox-custom-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-custom-input.js","sourceRoot":"","sources":["../../../src/components/ox-custom-input.ts"],"names":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C;CACF,CAAA;AAhGQ,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;GAYlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAW;AACX;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CAAW;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAW;AACT;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAA2B;AAEvC;IAAf,KAAK,CAAC,OAAO,CAAC;0CAAyB;AAxB7B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAiGvB;SAjGY,WAAW","sourcesContent":["import { LitElement, PropertyValues, css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\n@customElement('custom-input')\nexport class CustomInput extends LitElement {\n static styles = css`\n input {\n margin: auto 0;\n border-style: var(--form-input-border-style, solid);\n border-width: var(--form-input-border-width, 1px);\n border-color: var(--form-input-border-color, #c4c5c6);\n padding: var(--form-input-padding, 5px);\n min-width: var(--form-input-width, 300px);\n max-width: var(--form-input-width, 300px);\n outline: var(--form-input-outline, none);\n background-color: var(--form-input-background-color, #fff);\n }\n `\n\n @property({ type: String }) name?: string\n @property({ type: String }) placeholder?: string\n @property({ type: String }) type?: string\n @property({ type: Object }) props: any\n @property({ type: Array }) attrs: any\n @property({ type: String }) valueField?: string\n @property({ type: Object }) value: any\n @property({ type: Boolean }) autofocus: boolean = false\n\n @query('input') input!: HTMLInputElement\n\n render() {\n return html`\n <input\n name=${this.name}\n placeholder=${this.placeholder}\n type=${this.type || 'text'}\n value=${this.value || ''}\n @input=${(e: InputEvent) => (this.value = (e.currentTarget as HTMLInputElement).value)}\n ?autofocus=${this.autofocus}\n />\n `\n }\n\n get checked() {\n return this.input.checked\n }\n\n set checked(checked) {\n this.input.checked = checked\n }\n\n firstUpdated() {\n this.dispatchEvent(new CustomEvent('load'))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('props')) {\n if (this._isObject(this.props)) {\n for (let prop in this.props) {\n if (this.props[prop]) {\n this.input.setAttribute(prop, this.props[prop])\n this.setAttribute(prop, this.props[prop])\n }\n }\n }\n }\n\n if (changes.has('attrs')) {\n if (this.attrs && Array.isArray(this.attrs)) {\n this.attrs.forEach(attr => {\n this.input.setAttribute(attr, '')\n this.setAttribute(attr, '')\n })\n }\n }\n\n if (changes.has('value') && this._isObject(this.value)) {\n let value = this.value\n this.value = (this.valueField && value[this.valueField]) || value[Object.keys(value)[0]]\n }\n }\n\n _isObject(v: any) {\n return v instanceof Object && !Array.isArray(v)\n }\n\n focus() {\n this.input.focus()\n }\n\n select() {\n this.input.select()\n }\n\n blur() {\n this.input.blur()\n }\n\n checkValidity() {\n return this.input.checkValidity()\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export declare class CustomSelect extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
name?: string;
|
|
5
|
+
options?: {
|
|
6
|
+
name: string;
|
|
7
|
+
value: any;
|
|
8
|
+
}[];
|
|
9
|
+
props: any;
|
|
10
|
+
attrs: any;
|
|
11
|
+
value: any;
|
|
12
|
+
autofocus: boolean;
|
|
13
|
+
select: HTMLInputElement;
|
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
15
|
+
firstUpdated(): void;
|
|
16
|
+
updated(changes: PropertyValues<this>): void;
|
|
17
|
+
_isObject(v: any): boolean;
|
|
18
|
+
focus(): void;
|
|
19
|
+
blur(): void;
|
|
20
|
+
checkValidity(): boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, css, html } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
let CustomSelect = class CustomSelect extends LitElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.autofocus = false;
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
return html `
|
|
11
|
+
<select
|
|
12
|
+
name=${this.name}
|
|
13
|
+
?autofocus=${this.autofocus}
|
|
14
|
+
@change=${(e) => (this.value = e.currentTarget.value)}
|
|
15
|
+
>
|
|
16
|
+
${(this.options || []).map(option => html `
|
|
17
|
+
<option value=${option.value} ?selected=${this.value === option.value}>${option.name}</option>
|
|
18
|
+
`)}
|
|
19
|
+
</select>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
firstUpdated() {
|
|
23
|
+
this.dispatchEvent(new CustomEvent('load'));
|
|
24
|
+
}
|
|
25
|
+
updated(changes) {
|
|
26
|
+
if (changes.has('props') && this._isObject(this.props)) {
|
|
27
|
+
for (let prop in this.props) {
|
|
28
|
+
if (this.props[prop]) {
|
|
29
|
+
this.select.setAttribute(prop, this.props[prop]);
|
|
30
|
+
this.setAttribute(prop, this.props[prop]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (changes.has('attrs')) {
|
|
35
|
+
if (this.attrs && Array.isArray(this.attrs)) {
|
|
36
|
+
this.attrs.forEach(attr => {
|
|
37
|
+
this.select.setAttribute(attr, '');
|
|
38
|
+
this.setAttribute(attr, '');
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
_isObject(v) {
|
|
44
|
+
return v instanceof Object && !Array.isArray(v);
|
|
45
|
+
}
|
|
46
|
+
focus() {
|
|
47
|
+
this.select.focus();
|
|
48
|
+
}
|
|
49
|
+
blur() {
|
|
50
|
+
this.select.blur();
|
|
51
|
+
}
|
|
52
|
+
checkValidity() {
|
|
53
|
+
return this.select.checkValidity();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
CustomSelect.styles = css `
|
|
57
|
+
select {
|
|
58
|
+
margin: auto 0;
|
|
59
|
+
border-style: var(--form-input-border-style, solid);
|
|
60
|
+
border-width: var(--form-input-border-width, 1px);
|
|
61
|
+
border-color: var(--form-input-border-color, #c4c5c6);
|
|
62
|
+
padding: var(--form-input-padding, 5px);
|
|
63
|
+
outline: var(--form-input-outline, none);
|
|
64
|
+
background-color: var(--form-input-background-color, #fff);
|
|
65
|
+
min-width: calc(
|
|
66
|
+
var(--form-input-width, 300px) + 2 * var(--form-input-padding, 5px) + 2 * var(--form-input-border-width, 1px)
|
|
67
|
+
);
|
|
68
|
+
max-width: calc(
|
|
69
|
+
var(--form-input-width) + 2 * var(--form-input-padding, 5px) + 2 * var(--form-input-border-width, 1px)
|
|
70
|
+
);
|
|
71
|
+
-webkit-appearance: none;
|
|
72
|
+
-webkit-border-radius: 0px;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
__decorate([
|
|
76
|
+
property({ type: String })
|
|
77
|
+
], CustomSelect.prototype, "name", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
property({ type: Array })
|
|
80
|
+
], CustomSelect.prototype, "options", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: Object })
|
|
83
|
+
], CustomSelect.prototype, "props", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
property({ type: Array })
|
|
86
|
+
], CustomSelect.prototype, "attrs", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
property({ type: String })
|
|
89
|
+
], CustomSelect.prototype, "value", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: Boolean })
|
|
92
|
+
], CustomSelect.prototype, "autofocus", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
query('select')
|
|
95
|
+
], CustomSelect.prototype, "select", void 0);
|
|
96
|
+
CustomSelect = __decorate([
|
|
97
|
+
customElement('ox-custom-select')
|
|
98
|
+
], CustomSelect);
|
|
99
|
+
export { CustomSelect };
|
|
100
|
+
//# sourceMappingURL=ox-custom-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-custom-select.js","sourceRoot":"","sources":["../../../src/components/ox-custom-select.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlE,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QA0B+B,cAAS,GAAY,KAAK,CAAA;IA2DzD,CAAC;IAvDC,MAAM;QACJ,OAAO,IAAI,CAAA;;eAEA,IAAI,CAAC,IAAI;qBACH,IAAI,CAAC,SAAS;kBACjB,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAI,CAAC,CAAC,aAAmC,CAAC,KAAK,CAAC;;UAEjF,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CACxB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;4BACI,MAAM,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;WACrF,CACF;;KAEJ,CAAA;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,IAAI,OAAO,CAAC,GA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EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAc;AACd;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAAyC;AACvC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAW;AACX;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAW;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAW;AACT;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAA2B;AAEtC;IAAhB,KAAK,CAAC,QAAQ,CAAC;4CAA0B;AA5B/B,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CAqFxB;SArFY,YAAY","sourcesContent":["import { LitElement, PropertyValues, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\n@customElement('ox-custom-select')\nexport class CustomSelect extends LitElement {\n static styles = css`\n select {\n margin: auto 0;\n border-style: var(--form-input-border-style, solid);\n border-width: var(--form-input-border-width, 1px);\n border-color: var(--form-input-border-color, #c4c5c6);\n padding: var(--form-input-padding, 5px);\n outline: var(--form-input-outline, none);\n background-color: var(--form-input-background-color, #fff);\n min-width: calc(\n var(--form-input-width, 300px) + 2 * var(--form-input-padding, 5px) + 2 * var(--form-input-border-width, 1px)\n );\n max-width: calc(\n var(--form-input-width) + 2 * var(--form-input-padding, 5px) + 2 * var(--form-input-border-width, 1px)\n );\n -webkit-appearance: none;\n -webkit-border-radius: 0px;\n }\n `\n\n @property({ type: String }) name?: string\n @property({ type: Array }) options?: { name: string; value: any }[]\n @property({ type: Object }) props: any\n @property({ type: Array }) attrs: any\n @property({ type: String }) value: any\n @property({ type: Boolean }) autofocus: boolean = false\n\n @query('select') select!: HTMLInputElement\n\n render() {\n return html`\n <select\n name=${this.name}\n ?autofocus=${this.autofocus}\n @change=${(e: Event) => (this.value = (e.currentTarget as HTMLSelectElement).value)}\n >\n ${(this.options || []).map(\n option => html`\n <option value=${option.value} ?selected=${this.value === option.value}>${option.name}</option>\n `\n )}\n </select>\n `\n }\n\n firstUpdated() {\n this.dispatchEvent(new CustomEvent('load'))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('props') && this._isObject(this.props)) {\n for (let prop in this.props) {\n if (this.props[prop]) {\n this.select.setAttribute(prop, this.props[prop])\n this.setAttribute(prop, this.props[prop])\n }\n }\n }\n\n if (changes.has('attrs')) {\n if (this.attrs && Array.isArray(this.attrs)) {\n this.attrs.forEach(attr => {\n this.select.setAttribute(attr, '')\n this.setAttribute(attr, '')\n })\n }\n }\n }\n\n _isObject(v: any) {\n return v instanceof Object && !Array.isArray(v)\n }\n\n focus() {\n this.select.focus()\n }\n\n blur() {\n this.select.blur()\n }\n\n checkValidity() {\n return this.select.checkValidity()\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class FileUploader extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
multiple: boolean;
|
|
5
|
+
accept: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
_files: File[];
|
|
8
|
+
fileInput: HTMLInputElement;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
firstUpdated(): void;
|
|
11
|
+
get files(): File[];
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, css, html } from 'lit';
|
|
3
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
+
import { FileDropHelper } from '@operato/utils';
|
|
5
|
+
let FileUploader = class FileUploader extends LitElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.multiple = false;
|
|
9
|
+
this.accept = '*/*';
|
|
10
|
+
this._files = [];
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
var _a;
|
|
14
|
+
return html `
|
|
15
|
+
<mwc-icon>post_add</mwc-icon>
|
|
16
|
+
<span>add file or drop files here!</span>
|
|
17
|
+
<input
|
|
18
|
+
id="input-file"
|
|
19
|
+
type="file"
|
|
20
|
+
accept=${this.accept}
|
|
21
|
+
?multiple=${this.multiple}
|
|
22
|
+
hidden
|
|
23
|
+
@change=${(e) => {
|
|
24
|
+
const fileInput = e.currentTarget;
|
|
25
|
+
const files = fileInput.files;
|
|
26
|
+
//// Temporary Validation preventing file size more than 10mb to be uploaded
|
|
27
|
+
for (let index = 0; index < files.length; index++) {
|
|
28
|
+
if (files[index].size > 9999999) {
|
|
29
|
+
document.dispatchEvent(new CustomEvent('notify', {
|
|
30
|
+
detail: {
|
|
31
|
+
type: 'error',
|
|
32
|
+
message: 'File size must be less than 10 MB.'
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
throw new Error('File size must be less than 10 MB.');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this._files = [...this._files, ...Array.from(files)];
|
|
39
|
+
this.dispatchEvent(new CustomEvent('files-change', {
|
|
40
|
+
bubbles: true,
|
|
41
|
+
composed: true,
|
|
42
|
+
detail: {
|
|
43
|
+
files: files
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
fileInput.value = '';
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
<label for="input-file">${this.label || 'select file'}</label>
|
|
50
|
+
|
|
51
|
+
${((_a = this._files) === null || _a === void 0 ? void 0 : _a.length)
|
|
52
|
+
? html ` <ul>
|
|
53
|
+
${this._files.map(file => html `
|
|
54
|
+
<li>
|
|
55
|
+
- ${file.name}
|
|
56
|
+
<mwc-icon
|
|
57
|
+
@click=${(e) => {
|
|
58
|
+
this._files.splice(this._files.indexOf(file), 1);
|
|
59
|
+
this.requestUpdate();
|
|
60
|
+
}}
|
|
61
|
+
>delete_outline</mwc-icon
|
|
62
|
+
>
|
|
63
|
+
</li>
|
|
64
|
+
`)}
|
|
65
|
+
</ul>`
|
|
66
|
+
: ''}
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
firstUpdated() {
|
|
70
|
+
FileDropHelper.set(this);
|
|
71
|
+
this.addEventListener('file-drop', (e) => {
|
|
72
|
+
const de = e;
|
|
73
|
+
this._files = this.multiple ? de.detail : de.detail[0] ? [de.detail[0]] : [];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
get files() {
|
|
77
|
+
return this._files;
|
|
78
|
+
}
|
|
79
|
+
reset() {
|
|
80
|
+
this.fileInput.value = '';
|
|
81
|
+
this._files = [];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
FileUploader.styles = [
|
|
85
|
+
css `
|
|
86
|
+
:host {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
border-radius: var(--border-radius);
|
|
90
|
+
text-align: center;
|
|
91
|
+
padding-bottom: 5px !important;
|
|
92
|
+
text-transform: capitalize;
|
|
93
|
+
|
|
94
|
+
border: var(--file-uploader-border);
|
|
95
|
+
background-color: var(--main-section-background-color);
|
|
96
|
+
font: var(--file-uploader-font) !important;
|
|
97
|
+
color: var(--file-uploader-color);
|
|
98
|
+
}
|
|
99
|
+
:host > mwc-icon {
|
|
100
|
+
color: var(--file-uploader-icon-color);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host(.candrop) {
|
|
104
|
+
background-color: var(--file-uploader-candrop-background-color);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#input-file {
|
|
108
|
+
display: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
label {
|
|
112
|
+
position: relative;
|
|
113
|
+
width: auto;
|
|
114
|
+
border: none;
|
|
115
|
+
text-transform: capitalize;
|
|
116
|
+
|
|
117
|
+
padding: var(--file-uploader-label-padding);
|
|
118
|
+
border-radius: var(--file-uploader-label-border-radius);
|
|
119
|
+
background-color: var(--file-uploader-label-background-color);
|
|
120
|
+
color: var(--file-uploader-label-color);
|
|
121
|
+
font: var(--file-uploader-label-font) !important;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
ul {
|
|
125
|
+
max-width: 500px;
|
|
126
|
+
list-style: none;
|
|
127
|
+
padding: 0;
|
|
128
|
+
}
|
|
129
|
+
li {
|
|
130
|
+
text-align: left;
|
|
131
|
+
|
|
132
|
+
padding: var(--file-uploader-li-padding);
|
|
133
|
+
border-bottom: var(--file-uploader-li-border-bottom);
|
|
134
|
+
}
|
|
135
|
+
li mwc-icon {
|
|
136
|
+
float: right;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
font: var(--file-uploader-li-icon-font);
|
|
139
|
+
margin: var(--file-uploader-li-icon-margin);
|
|
140
|
+
}
|
|
141
|
+
li mwc-icon:hover,
|
|
142
|
+
li mwc-icon:active {
|
|
143
|
+
color: var(--file-uploader-li-icon-focus-color);
|
|
144
|
+
}
|
|
145
|
+
`
|
|
146
|
+
];
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ type: Boolean })
|
|
149
|
+
], FileUploader.prototype, "multiple", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: String })
|
|
152
|
+
], FileUploader.prototype, "accept", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: String })
|
|
155
|
+
], FileUploader.prototype, "label", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: Array })
|
|
158
|
+
], FileUploader.prototype, "_files", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
query('#input-file')
|
|
161
|
+
], FileUploader.prototype, "fileInput", void 0);
|
|
162
|
+
FileUploader = __decorate([
|
|
163
|
+
customElement('ox-file-uploader')
|
|
164
|
+
], FileUploader);
|
|
165
|
+
export { FileUploader };
|
|
166
|
+
//# sourceMappingURL=ox-file-uploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-file-uploader.js","source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QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;IAClB,CAAC;CACF,CAAA;AA3JQ,mBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4DF;CACF,CAAA;AAE4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAA0B;AAC1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAe;AAEf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CAAoB;AAExB;IAArB,KAAK,CAAC,aAAa,CAAC;+CAA6B;AAvEvC,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA4JxB;SA5JY,YAAY","sourcesContent":["import { LitElement, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { FileDropHelper } from '@operato/utils'\n\n@customElement('ox-file-uploader')\nexport class FileUploader extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--border-radius);\n text-align: center;\n padding-bottom: 5px !important;\n text-transform: capitalize;\n\n border: var(--file-uploader-border);\n background-color: var(--main-section-background-color);\n font: var(--file-uploader-font) !important;\n color: var(--file-uploader-color);\n }\n :host > mwc-icon {\n color: var(--file-uploader-icon-color);\n }\n\n :host(.candrop) {\n background-color: var(--file-uploader-candrop-background-color);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n background-color: var(--file-uploader-label-background-color);\n color: var(--file-uploader-label-color);\n font: var(--file-uploader-label-font) !important;\n }\n\n ul {\n max-width: 500px;\n list-style: none;\n padding: 0;\n }\n li {\n text-align: left;\n\n padding: var(--file-uploader-li-padding);\n border-bottom: var(--file-uploader-li-border-bottom);\n }\n li mwc-icon {\n float: right;\n cursor: pointer;\n font: var(--file-uploader-li-icon-font);\n margin: var(--file-uploader-li-icon-margin);\n }\n li mwc-icon:hover,\n li mwc-icon:active {\n color: var(--file-uploader-li-icon-focus-color);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple: boolean = false\n @property({ type: String }) accept: string = '*/*'\n @property({ type: String }) label?: string\n\n @property({ type: Array }) _files: File[] = []\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n render() {\n return html`\n <mwc-icon>post_add</mwc-icon>\n <span>add file or drop files here!</span>\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n @change=${(e: Event) => {\n const fileInput = e.currentTarget as HTMLInputElement\n const files = fileInput.files as FileList\n //// Temporary Validation preventing file size more than 10mb to be uploaded\n for (let index = 0; index < files.length; index++) {\n if (files[index].size > 9999999) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n type: 'error',\n message: 'File size must be less than 10 MB.'\n }\n })\n )\n throw new Error('File size must be less than 10 MB.')\n }\n }\n\n this._files = [...this._files, ...Array.from(files)]\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: files\n }\n })\n )\n\n fileInput.value = ''\n }}\n />\n <label for=\"input-file\">${this.label || 'select file'}</label>\n\n ${this._files?.length\n ? html` <ul>\n ${this._files.map(\n file => html`\n <li>\n - ${file.name}\n <mwc-icon\n @click=${(e: Event) => {\n this._files.splice(this._files.indexOf(file), 1)\n this.requestUpdate()\n }}\n >delete_outline</mwc-icon\n >\n </li>\n `\n )}\n </ul>`\n : ''}\n `\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n const de = e as any\n this._files = this.multiple ? de.detail : de.detail[0] ? [de.detail[0]] : []\n })\n }\n\n get files() {\n return this._files\n }\n\n reset() {\n this.fileInput.value = ''\n this._files = []\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|