-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.js
98 lines (86 loc) · 2.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import AXAIcon from '@axa-ch-webhub-cloud/icon';
import { html } from 'lit';
import { classMap } from 'lit/directives/class-map.js';
import {
defineVersioned,
versionedHtml,
} from '../../../utils/component-versioning';
import createRefId from '../../../utils/create-ref-id';
import NoShadowDOM from '../../../utils/no-shadow';
import applyDefaults from '../../../utils/apply-defaults';
import styles from './index.scss';
const TYPE = 'file';
class AXAInputFile extends NoShadowDOM {
static get tagName() {
return 'axa-input-file';
}
static get styles() {
return styles;
}
static get properties() {
return {
text: { type: String },
variant: { type: String },
icon: { type: String },
refId: { type: String, defaultValue: `input-file-${createRefId()}` },
large: { type: Boolean },
motionOff: { type: Boolean },
disabled: { type: Boolean, reflect: true },
accept: {
type: String,
defaultValue: 'image/jpg, image/jpeg, application/pdf, image/png',
},
capture: { type: Boolean },
multiple: { type: Boolean },
onChange: { type: Function, attribute: false },
};
}
constructor() {
super();
applyDefaults(this);
defineVersioned([AXAIcon], __VERSION_INFO__, this);
}
render() {
const {
text = '',
large,
motionOff,
disabled,
variant = '',
icon = '',
accept,
capture,
multiple,
} = this;
const classes = {
'a-input-file--secondary': variant === 'secondary',
'a-input-file--red': variant === 'red',
'a-input-file--inverted': variant === 'inverted',
'a-input-file--large': large,
'a-input-file--motion': !motionOff,
'a-input-file--disabled': disabled,
};
return html`
<label class="a-input-file ${classMap(classes)}" for="${this.refId}">
<span class="a-input-file__flex-wrapper">
${icon &&
versionedHtml(this)`
<axa-icon class="a-input-file__icon js-input-file__icon" icon="${icon}"></axa-icon>
`}
${text}
</span>
</label>
<input
type="${TYPE}"
accept="${accept}"
?multiple="${multiple}"
?capture="${capture}"
@change="${this.onChange}"
class="a-input-file__input js-input-file__input"
id="${this.refId}"
/>
`;
}
}
defineVersioned([AXAInputFile], __VERSION_INFO__);
export default AXAInputFile;