@digipair/skill-web-inputs 0.91.0-0 → 0.92.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/index.cjs.d.ts +1 -0
- package/index.cjs.js +3944 -0
- package/index.esm.js +3934 -0
- package/libs/skill-web-inputs/src/lib/input-dom-attribute.element.d.ts +11 -0
- package/libs/skill-web-inputs/src/lib/input-element.element.d.ts +17 -0
- package/libs/skill-web-inputs/src/lib/input-fetch.element.d.ts +11 -0
- package/libs/skill-web-inputs/src/lib/input-file.element.d.ts +15 -0
- package/libs/skill-web-inputs/src/lib/input-hidden.element.d.ts +6 -0
- package/libs/skill-web-inputs/src/lib/input-json.element.d.ts +15 -0
- package/libs/skill-web-inputs/src/lib/input-text.element.d.ts +15 -0
- package/libs/skill-web-inputs/src/lib/tools/css-selector.d.ts +1 -0
- package/package.json +5 -21
- package/.swcrc +0 -28
- package/README.md +0 -7
- package/eslint.config.mjs +0 -22
- package/rollup.config.cjs +0 -28
- package/src/lib/input-dom-attribute.element.ts +0 -45
- package/src/lib/input-element.element.ts +0 -189
- package/src/lib/input-fetch.element.ts +0 -38
- package/src/lib/input-file.element.ts +0 -101
- package/src/lib/input-hidden.element.ts +0 -15
- package/src/lib/input-json.element.ts +0 -101
- package/src/lib/input-text.element.ts +0 -101
- package/src/lib/skill-web-inputs.spec.ts +0 -7
- package/src/lib/tools/css-selector.ts +0 -12
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- /package/{src/index.d.ts → index.d.ts} +0 -0
- /package/{src/index.ts → libs/skill-web-inputs/src/index.d.ts} +0 -0
- /package/{src/lib/skill-web-inputs.ts → libs/skill-web-inputs/src/lib/skill-web-inputs.d.ts} +0 -0
- /package/{src/schema.fr.json → schema.fr.json} +0 -0
- /package/{src/schema.json → schema.json} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class DomAttributeElement extends LitElement {
|
|
3
|
+
selector: string;
|
|
4
|
+
attribute: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
private _value;
|
|
7
|
+
get value(): any;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
private initialize;
|
|
10
|
+
render(): TemplateResult;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class ElementElement extends LitElement {
|
|
3
|
+
label: string;
|
|
4
|
+
selector: string;
|
|
5
|
+
filter: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
private state;
|
|
8
|
+
private _content;
|
|
9
|
+
get content(): string;
|
|
10
|
+
private _value;
|
|
11
|
+
get value(): string;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
private loadElement;
|
|
14
|
+
private addSelectingStyle;
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
render(): TemplateResult;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class FetchElement extends LitElement {
|
|
3
|
+
url: string;
|
|
4
|
+
type: 'json' | 'text';
|
|
5
|
+
required: boolean;
|
|
6
|
+
private _value;
|
|
7
|
+
get value(): any;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
private initialize;
|
|
10
|
+
render(): TemplateResult;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class InputFileElement extends LitElement {
|
|
3
|
+
label: string;
|
|
4
|
+
accept: string;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
required: boolean;
|
|
7
|
+
private state;
|
|
8
|
+
private _content;
|
|
9
|
+
get content(): string;
|
|
10
|
+
private _value;
|
|
11
|
+
get value(): string | ArrayBuffer | null;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
private loadFile;
|
|
14
|
+
render(): TemplateResult;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class InputJsonElement extends LitElement {
|
|
3
|
+
label: string;
|
|
4
|
+
accept: string;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
required: boolean;
|
|
7
|
+
private state;
|
|
8
|
+
private _content;
|
|
9
|
+
get content(): string;
|
|
10
|
+
private _value;
|
|
11
|
+
get value(): string | ArrayBuffer | null;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
private loadFile;
|
|
14
|
+
render(): TemplateResult;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class InputTextElement extends LitElement {
|
|
3
|
+
label: string;
|
|
4
|
+
accept: string;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
required: boolean;
|
|
7
|
+
private state;
|
|
8
|
+
private _content;
|
|
9
|
+
get content(): string;
|
|
10
|
+
private _value;
|
|
11
|
+
get value(): any;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
private loadFile;
|
|
14
|
+
render(): TemplateResult;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCssSelector(element: any, options?: any): any;
|
package/package.json
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digipair/skill-web-inputs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/libs/skill-web-inputs/index.cjs.js",
|
|
6
|
-
"module": "dist/libs/skill-web-inputs/index.esm.js",
|
|
7
|
-
"types": "dist/libs/skill-web-inputs/index.esm.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./libs/skill-web-inputs/package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"development": "./dist/libs/skill-web-inputs/src/index.ts",
|
|
12
|
-
"types": "./dist/libs/skill-web-inputs/index.esm.d.ts",
|
|
13
|
-
"import": "./dist/libs/skill-web-inputs/index.esm.js",
|
|
14
|
-
"default": "./dist/libs/skill-web-inputs/index.cjs.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
3
|
+
"version": "0.92.0",
|
|
17
4
|
"keywords": [
|
|
18
5
|
"digipair",
|
|
19
6
|
"web",
|
|
20
7
|
"util"
|
|
21
8
|
],
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"@digipair/engine": "0.91.0-0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
9
|
+
"dependencies": {},
|
|
10
|
+
"main": "./index.cjs.js",
|
|
11
|
+
"module": "./index.esm.js"
|
|
12
|
+
}
|
package/.swcrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"jsc": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"parser": {
|
|
5
|
-
"syntax": "typescript",
|
|
6
|
-
"decorators": true,
|
|
7
|
-
"dynamicImport": true
|
|
8
|
-
},
|
|
9
|
-
"transform": {
|
|
10
|
-
"decoratorMetadata": true,
|
|
11
|
-
"legacyDecorator": true
|
|
12
|
-
},
|
|
13
|
-
"keepClassNames": true,
|
|
14
|
-
"externalHelpers": true,
|
|
15
|
-
"loose": true
|
|
16
|
-
},
|
|
17
|
-
"module": {
|
|
18
|
-
"type": "es6"
|
|
19
|
-
},
|
|
20
|
-
"sourceMaps": true,
|
|
21
|
-
"exclude": [
|
|
22
|
-
"jest.config.ts",
|
|
23
|
-
".*\\.spec.tsx?$",
|
|
24
|
-
".*\\.test.tsx?$",
|
|
25
|
-
"./src/jest-setup.ts$",
|
|
26
|
-
"./**/jest-setup.ts$"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/README.md
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser: await import('jsonc-eslint-parser'),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/rollup.config.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
-
|
|
3
|
-
module.exports = withNx(
|
|
4
|
-
{
|
|
5
|
-
main: 'libs/skill-web-inputs/src/index.ts',
|
|
6
|
-
outputPath: 'dist/libs/skill-web-inputs',
|
|
7
|
-
tsConfig: 'libs/skill-web-inputs/tsconfig.lib.json',
|
|
8
|
-
compiler: 'swc',
|
|
9
|
-
format: ['esm', "cjs"],
|
|
10
|
-
assets: [
|
|
11
|
-
{
|
|
12
|
-
input: 'libs/skill-web-inputs/',
|
|
13
|
-
glob: 'package.json',
|
|
14
|
-
output: '.'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
input: 'libs/skill-web-inputs/src/',
|
|
18
|
-
glob: '*.json',
|
|
19
|
-
output: '.'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
25
|
-
// e.g.
|
|
26
|
-
// output: { sourcemap: true },
|
|
27
|
-
}
|
|
28
|
-
);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, html } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
@customElement('digipair-input-dom-attribute')
|
|
5
|
-
export class DomAttributeElement extends LitElement {
|
|
6
|
-
@property()
|
|
7
|
-
selector = '';
|
|
8
|
-
|
|
9
|
-
@property()
|
|
10
|
-
attribute = '';
|
|
11
|
-
|
|
12
|
-
@property()
|
|
13
|
-
required = true;
|
|
14
|
-
|
|
15
|
-
private _value: any;
|
|
16
|
-
get value(): any {
|
|
17
|
-
return this._value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
override connectedCallback(): void {
|
|
21
|
-
super.connectedCallback();
|
|
22
|
-
this.initialize();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private async initialize(): Promise<void> {
|
|
26
|
-
const element = document.querySelector(this.selector) as any;
|
|
27
|
-
const value = element[this.attribute] ?? element.getAttribute(this.attribute);
|
|
28
|
-
|
|
29
|
-
if (!(value instanceof Promise)) {
|
|
30
|
-
this._value = value;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
this._value = await value;
|
|
36
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
37
|
-
} catch (error) {
|
|
38
|
-
this._value = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
override render(): TemplateResult {
|
|
43
|
-
return html``;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, css, html, nothing } from 'lit';
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
|
-
import getCssSelector from './tools/css-selector';
|
|
4
|
-
|
|
5
|
-
@customElement('digipair-input-element')
|
|
6
|
-
export class ElementElement extends LitElement {
|
|
7
|
-
@property()
|
|
8
|
-
label = 'Element';
|
|
9
|
-
|
|
10
|
-
@property()
|
|
11
|
-
selector = '';
|
|
12
|
-
|
|
13
|
-
@property()
|
|
14
|
-
filter = '*';
|
|
15
|
-
|
|
16
|
-
@property()
|
|
17
|
-
required = true;
|
|
18
|
-
|
|
19
|
-
@state()
|
|
20
|
-
private state = 'unloaded';
|
|
21
|
-
|
|
22
|
-
@state()
|
|
23
|
-
private _content = 'aucun element selectionne';
|
|
24
|
-
get content() {
|
|
25
|
-
return this._content;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private _value = '';
|
|
29
|
-
get value(): string {
|
|
30
|
-
return this._value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static override styles = css`
|
|
34
|
-
.digipair-input {
|
|
35
|
-
padding: 10px 15px;
|
|
36
|
-
margin-bottom: 10px;
|
|
37
|
-
line-height: 1.4;
|
|
38
|
-
border: 1px solid var(--digipair-color-primary, #52dfdb);
|
|
39
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
40
|
-
align-self: flex-start;
|
|
41
|
-
margin-right: auto;
|
|
42
|
-
text-align: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.digipair-input ui5-icon {
|
|
46
|
-
color: var(--digipair-color-secondary, #52dfdb);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.digipair-input.unloaded ui5-icon {
|
|
50
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.digipair-input p {
|
|
54
|
-
text-align: center;
|
|
55
|
-
font-size: 12px;
|
|
56
|
-
margin: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.digipair-input.unloaded {
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.digipair-input.loaded ui5-icon {
|
|
64
|
-
float: left;
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
private loadElement() {
|
|
69
|
-
const digipairEl = document.querySelector('digipair-chatbot') as any;
|
|
70
|
-
|
|
71
|
-
this.state = 'selecting';
|
|
72
|
-
digipairEl.closeResult();
|
|
73
|
-
|
|
74
|
-
const unsetCurrentElement = () => {
|
|
75
|
-
document
|
|
76
|
-
.querySelectorAll('.digipair-input-element-selecting')
|
|
77
|
-
.forEach(el => el.classList.remove('digipair-input-element-selecting'));
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const keydown = (event: any) => {
|
|
81
|
-
if (event.key === 'Escape' || event.keyCode === 27) {
|
|
82
|
-
document.removeEventListener('keydown', keydown);
|
|
83
|
-
document.removeEventListener('click', click);
|
|
84
|
-
document.removeEventListener('mouseout', mouseout);
|
|
85
|
-
unsetCurrentElement();
|
|
86
|
-
this.state = this._value ? 'loaded' : 'unloaded';
|
|
87
|
-
digipairEl.openResult();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const click = (event: any) => {
|
|
92
|
-
if (event.target.closest('digipair-chatbot')) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
document.removeEventListener('keydown', keydown);
|
|
97
|
-
document.removeEventListener('click', click);
|
|
98
|
-
document.removeEventListener('mouseout', mouseout);
|
|
99
|
-
|
|
100
|
-
const selector = document.querySelector('.digipair-input-element-selecting');
|
|
101
|
-
|
|
102
|
-
if (!selector) {
|
|
103
|
-
this.state = this._value ? 'loaded' : 'unloaded';
|
|
104
|
-
digipairEl.openResult();
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
this._value = getCssSelector(selector, { blacklist: ['.digipair-input-element-selecting'] });
|
|
109
|
-
this._content = `> $(${this._value})`;
|
|
110
|
-
this.state = 'loaded';
|
|
111
|
-
unsetCurrentElement();
|
|
112
|
-
|
|
113
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
114
|
-
|
|
115
|
-
setTimeout(() => {
|
|
116
|
-
digipairEl.openResult();
|
|
117
|
-
}, 1);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const mouseout = (event: any) => {
|
|
121
|
-
if (event.target.closest('digipair-chatbot')) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
unsetCurrentElement();
|
|
126
|
-
event.target.closest(this.filter)?.classList.add('digipair-input-element-selecting');
|
|
127
|
-
this.requestUpdate();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
document.addEventListener('keydown', keydown);
|
|
131
|
-
document.addEventListener('click', click);
|
|
132
|
-
document.addEventListener('mouseout', mouseout);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private addSelectingStyle() {
|
|
136
|
-
if (document.querySelector('#digipair-input-element-style')) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const style = document.createElement('style');
|
|
141
|
-
style.setAttribute('id', 'digipair-input-element-style');
|
|
142
|
-
style.innerHTML = `
|
|
143
|
-
.digipair-input-element-selecting {
|
|
144
|
-
border: 1px dashed rgb(153, 153, 153) !important;
|
|
145
|
-
}
|
|
146
|
-
`;
|
|
147
|
-
document.body.append(style);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
override connectedCallback(): void {
|
|
151
|
-
super.connectedCallback();
|
|
152
|
-
|
|
153
|
-
this.addSelectingStyle();
|
|
154
|
-
|
|
155
|
-
if (this.selector) {
|
|
156
|
-
this._value = this.selector;
|
|
157
|
-
this._content = `> $(${this.selector})`;
|
|
158
|
-
this.state = 'loaded';
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
override render(): TemplateResult {
|
|
163
|
-
return html`
|
|
164
|
-
<section
|
|
165
|
-
class="digipair-input ${this.state}"
|
|
166
|
-
@click=${() =>
|
|
167
|
-
['unloaded', 'loaded'].indexOf(this.state) >= 0 ? this.loadElement() : void 0}
|
|
168
|
-
>
|
|
169
|
-
${this.state === 'loaded'
|
|
170
|
-
? html`
|
|
171
|
-
<ui5-icon name="attachment"></ui5-icon>
|
|
172
|
-
<p>${this.label}<br />${this._content}</p>
|
|
173
|
-
`
|
|
174
|
-
: this.state === 'selecting'
|
|
175
|
-
? html` <ui5-icon name="locate-me"></ui5-icon>
|
|
176
|
-
<p>
|
|
177
|
-
${this.label}${document.querySelector('.digipair-input-element-selecting')
|
|
178
|
-
? html`<br />$(${getCssSelector(
|
|
179
|
-
document.querySelector('.digipair-input-element-selecting'),
|
|
180
|
-
{ blacklist: ['.digipair-input-element-selecting'] },
|
|
181
|
-
)})`
|
|
182
|
-
: nothing}
|
|
183
|
-
</p>`
|
|
184
|
-
: html` <ui5-icon name="add-document"></ui5-icon>
|
|
185
|
-
<p>${this.label}</p>`}
|
|
186
|
-
</section>
|
|
187
|
-
`;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, html } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
@customElement('digipair-input-fetch')
|
|
5
|
-
export class FetchElement extends LitElement {
|
|
6
|
-
@property()
|
|
7
|
-
url!: string;
|
|
8
|
-
|
|
9
|
-
@property()
|
|
10
|
-
type: 'json' | 'text' = 'json';
|
|
11
|
-
|
|
12
|
-
@property()
|
|
13
|
-
required = true;
|
|
14
|
-
|
|
15
|
-
private _value: any;
|
|
16
|
-
get value(): any {
|
|
17
|
-
return this._value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
override connectedCallback(): void {
|
|
21
|
-
super.connectedCallback();
|
|
22
|
-
this.initialize();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private async initialize() {
|
|
26
|
-
const response = await fetch(this.url);
|
|
27
|
-
if (this.type === 'text') {
|
|
28
|
-
this._value = await response.text();
|
|
29
|
-
} else if (this.type === 'json') {
|
|
30
|
-
this._value = await response.json();
|
|
31
|
-
}
|
|
32
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override render(): TemplateResult {
|
|
36
|
-
return html``;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, css, html } from 'lit';
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
@customElement('digipair-input-file')
|
|
5
|
-
export class InputFileElement extends LitElement {
|
|
6
|
-
@property()
|
|
7
|
-
label = 'Upload';
|
|
8
|
-
|
|
9
|
-
@property()
|
|
10
|
-
accept = '*';
|
|
11
|
-
|
|
12
|
-
@property()
|
|
13
|
-
multiple = false;
|
|
14
|
-
|
|
15
|
-
@property()
|
|
16
|
-
required = true;
|
|
17
|
-
|
|
18
|
-
@state()
|
|
19
|
-
private state = 'unloaded';
|
|
20
|
-
|
|
21
|
-
@state()
|
|
22
|
-
private _content = 'no file selected';
|
|
23
|
-
get content() {
|
|
24
|
-
return this._content;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private _value: string | ArrayBuffer | null = '';
|
|
28
|
-
get value(): string | ArrayBuffer | null {
|
|
29
|
-
return this._value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static override styles = css`
|
|
33
|
-
.download {
|
|
34
|
-
padding: 10px 15px;
|
|
35
|
-
margin-bottom: 10px;
|
|
36
|
-
line-height: 1.4;
|
|
37
|
-
border: 1px solid var(--digipair-color-primary, #52dfdb);
|
|
38
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
39
|
-
align-self: flex-start;
|
|
40
|
-
margin-right: auto;
|
|
41
|
-
text-align: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.download ui5-icon {
|
|
45
|
-
color: var(--digipair-color-secondary, #52dfdb);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.download.unloaded ui5-icon {
|
|
49
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.download p {
|
|
53
|
-
text-align: center;
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
margin: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.download.unloaded {
|
|
59
|
-
cursor: pointer;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.download.loaded ui5-icon {
|
|
63
|
-
float: left;
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
private loadFile() {
|
|
68
|
-
const input = document.createElement('input');
|
|
69
|
-
input.type = 'file';
|
|
70
|
-
input.multiple = this.multiple;
|
|
71
|
-
input.accept = this.accept;
|
|
72
|
-
input.onchange = (event: any) => {
|
|
73
|
-
const files = event.target.files;
|
|
74
|
-
const file = files[0];
|
|
75
|
-
const reader = new FileReader();
|
|
76
|
-
reader.readAsDataURL(file);
|
|
77
|
-
reader.onload = () => {
|
|
78
|
-
this._value = reader.result;
|
|
79
|
-
this._content = `> ${file.name}`;
|
|
80
|
-
this.state = 'loaded';
|
|
81
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
input.click();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
override render(): TemplateResult {
|
|
88
|
-
return html`
|
|
89
|
-
<section
|
|
90
|
-
class="download ${this.state}"
|
|
91
|
-
@click=${() => (['unloaded', 'loaded'].indexOf(this.state) >= 0 ? this.loadFile() : void 0)}
|
|
92
|
-
>
|
|
93
|
-
${this.state === 'loaded'
|
|
94
|
-
? html` <ui5-icon name="attachment"></ui5-icon>
|
|
95
|
-
<p>${this.label}<br />${this._content}</p>`
|
|
96
|
-
: html` <ui5-icon name="add-document"></ui5-icon>
|
|
97
|
-
<p>${this.label}</p>`}
|
|
98
|
-
</section>
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, html } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
@customElement('digipair-input-hidden')
|
|
5
|
-
export class HiddenElement extends LitElement {
|
|
6
|
-
@property()
|
|
7
|
-
value = '';
|
|
8
|
-
|
|
9
|
-
@property()
|
|
10
|
-
required = true;
|
|
11
|
-
|
|
12
|
-
override render(): TemplateResult {
|
|
13
|
-
return html``;
|
|
14
|
-
}
|
|
15
|
-
}
|