@hotosm/ui 0.6.0 → 0.7.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 +231 -139
- package/dist/chunks/{chunk.GEAU3JJH.js → chunk.252GL6HT.js} +11 -11
- package/dist/chunks/{chunk.BORCUX2M.js → chunk.2Y7OBKRQ.js} +1 -1
- package/dist/chunks/{chunk.AL4CJN73.js → chunk.5QY2VLMG.js} +1 -1
- package/dist/chunks/{chunk.ORZ5STBX.js → chunk.6BGQ256H.js} +2 -2
- package/dist/chunks/{chunk.SBUFNOMY.js → chunk.7JIKOYG6.js} +1 -1
- package/dist/chunks/{chunk.3LBUXCAP.js → chunk.APYFF2XE.js} +1 -1
- package/dist/chunks/{chunk.XEZQ5ZRE.js → chunk.BVHLTKMC.js} +1 -1
- package/dist/chunks/chunk.CNUZFRRF.js +105 -0
- package/dist/chunks/{chunk.LHZ7Q2M3.js → chunk.FDQFFQX3.js} +5 -5
- package/dist/chunks/chunk.FN6G7X23.js +251 -0
- package/dist/chunks/{chunk.OICCPCO3.js → chunk.IILWGAOM.js} +1 -1
- package/dist/chunks/{chunk.G6ZZSFVM.js → chunk.JYPMFVPO.js} +1 -1
- package/dist/chunks/chunk.LKMWWUYT.js +20 -0
- package/dist/chunks/{chunk.BD4Q32VT.js → chunk.LVCDAVRU.js} +4 -4
- package/dist/chunks/{chunk.ARF626EG.js → chunk.LXN3PNAP.js} +1 -1
- package/dist/chunks/chunk.P6GWPFCT.js +32 -0
- package/dist/chunks/{chunk.7BVHA4G6.js → chunk.X354U5TL.js} +3 -3
- package/dist/chunks/{chunk.7PROWJNJ.js → chunk.XU6UFL27.js} +4 -4
- package/dist/chunks/{chunk.MZOQNTPX.js → chunk.ZGC6XD6L.js} +37 -56
- package/dist/components/consent/consent.component.d.ts +0 -3
- package/dist/components/consent/consent.component.js +1 -1
- package/dist/components/consent/consent.js +1 -1
- package/dist/components/consent/consent.styles.js +1 -1
- package/dist/components/file-input-dropzone/file-input-dropzone.component.d.ts +0 -2
- package/dist/components/file-input-dropzone/file-input-dropzone.component.js +1 -1
- package/dist/components/file-input-dropzone/file-input-dropzone.js +1 -1
- package/dist/components/file-input-dropzone/file-input-dropzone.styles.js +1 -1
- package/dist/components/header/header.component.d.ts +0 -4
- package/dist/components/header/header.component.js +1 -1
- package/dist/components/header/header.js +1 -1
- package/dist/components/header/header.styles.js +1 -1
- package/dist/components/list-card/list-card.component.d.ts +0 -1
- package/dist/components/list-card/list-card.component.js +1 -1
- package/dist/components/list-card/list-card.js +1 -1
- package/dist/components/list-card/list-card.styles.js +1 -1
- package/dist/components/logo/logo.component.js +1 -1
- package/dist/components/logo/logo.js +1 -1
- package/dist/components/tool-menu/tool-menu.component.d.ts +0 -3
- package/dist/components/tool-menu/tool-menu.component.js +1 -1
- package/dist/components/tool-menu/tool-menu.js +1 -1
- package/dist/components/tool-menu/tool-menu.styles.js +1 -1
- package/dist/components/tracking/tracking.component.d.ts +0 -3
- package/dist/components/tracking/tracking.component.js +1 -1
- package/dist/components/tracking/tracking.js +1 -1
- package/dist/hotosm-ui.js +1 -1
- package/dist/style-core.css +1 -0
- package/dist/style.css +1 -14
- package/dist/themes/hot-wa.css +152 -115
- package/dist/themes/hot.css +1 -1
- package/package.json +5 -3
- package/dist/chunks/chunk.CQO3GWTI.js +0 -32
- package/dist/chunks/chunk.PLECT4NZ.js +0 -20
- package/dist/chunks/chunk.U4AAC5ID.js +0 -239
- package/dist/chunks/chunk.WTTPHBL3.js +0 -105
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import{a as c,b as r}from"./chunk.ZETV7TDG.js";import{a as b,d as l,f as u}from"./chunk.QABMDRWR.js";import{d as a,e as n,f as s,g as i}from"./chunk.N2W26RCT.js";import"@awesome.me/webawesome/dist/components/callout/callout.js";import"@awesome.me/webawesome/dist/components/icon/icon.js";import"@awesome.me/webawesome/dist/components/button/button.js";var w,m,f,x,v,t=class extends u{constructor(){super(...arguments);this.name="hot-tracking";s(this,w,"");s(this,m,"");s(this,f,"https://matomo.hotosm.org");s(this,x,!0);s(this,v,"We use cookies and similar technologies to help personalize content, tailor and measure ads, and provide a better experience. By clicking 'Accept', you consent to our use of cookies and tracking technologies.");this.consentGiven=!1;this.consentShown=!1;this.errorMessage="";this.showError=!1;this.successMessage="";this.showSuccess=!1;this.infoMessage="";this.showInfo=!1}get siteId(){return n(this,w)}set siteId(e){i(this,w,e)}get domain(){return n(this,m)}set domain(e){i(this,m,e)}get matomoURL(){return n(this,f)}set matomoURL(e){i(this,f,e)}get showConsent(){return n(this,x)}set showConsent(e){i(this,x,e)}get consentMessage(){return n(this,v)}set consentMessage(e){i(this,v,e)}agree(){this.consentGiven=!0,this.consentShown=!1;let e=window._paq=window._paq||[];e.length!==0&&(e.push(["rememberConsentGiven"]),e.push(["trackPageView"]),this.showSuccessCallout("Tracking consent granted. Thank you!"))}disagree(){this.consentGiven=!1,this.consentShown=!1;let e=window._paq=window._paq||[];e.length!==0&&(e.push(["forgetConsentGiven"]),this.showInfoCallout("Tracking disabled. You can change this preference later."))}showConsentBanner(){this.showConsent&&!this.consentGiven&&!this.consentShown&&(this.consentShown=!0)}showErrorCallout(e){this.errorMessage=e,this.showError=!0,setTimeout(()=>{this.showError=!1},1e4)}showSuccessCallout(e){this.successMessage=e,this.showSuccess=!0,setTimeout(()=>{this.showSuccess=!1},5e3)}showInfoCallout(e){this.infoMessage=e,this.showInfo=!0,setTimeout(()=>{this.showInfo=!1},5e3)}render(){return l`
|
|
2
|
-
${this.showError?l`
|
|
3
|
-
<div class="error-banner">
|
|
4
|
-
<wa-callout style="padding: 1rem;" variant="danger" appearance="outlined filled" size="large">
|
|
5
|
-
<wa-icon slot="icon" family="classic" variant="solid" name="circle-exclamation"></wa-icon>
|
|
6
|
-
<div style="padding: 0 1rem;">
|
|
7
|
-
<strong>Tracking Configuration Error</strong><br />
|
|
8
|
-
${this.errorMessage}
|
|
9
|
-
</div>
|
|
10
|
-
</wa-callout>
|
|
11
|
-
</div>
|
|
12
|
-
`:""}
|
|
13
|
-
|
|
14
|
-
${this.showSuccess?l`
|
|
15
|
-
<div class="toast-banner">
|
|
16
|
-
<wa-callout style="padding: 1rem;" variant="success" appearance="outlined accent" size="medium">
|
|
17
|
-
<wa-icon slot="icon" family="classic" variant="solid" name="circle-check"></wa-icon>
|
|
18
|
-
<div style="padding: 0 1rem;">
|
|
19
|
-
<strong>Success!</strong><br />
|
|
20
|
-
${this.successMessage}
|
|
21
|
-
</div>
|
|
22
|
-
</wa-callout>
|
|
23
|
-
</div>
|
|
24
|
-
`:""}
|
|
25
|
-
|
|
26
|
-
${this.showInfo?l`
|
|
27
|
-
<div class="toast-banner">
|
|
28
|
-
<wa-callout style="padding: 1rem;" variant="brand" appearance="outlined filled" size="medium">
|
|
29
|
-
<wa-icon slot="icon" family="classic" variant="solid" name="circle-info"></wa-icon>
|
|
30
|
-
<div style="padding: 0 1rem;">
|
|
31
|
-
<strong>Information</strong><br />
|
|
32
|
-
${this.infoMessage}
|
|
33
|
-
</div>
|
|
34
|
-
</wa-callout>
|
|
35
|
-
</div>
|
|
36
|
-
`:""}
|
|
37
|
-
|
|
38
|
-
${this.consentShown?l`
|
|
39
|
-
<div class="consent-banner">
|
|
40
|
-
<wa-callout variant="brand" appearance="outlined filled" size="large">
|
|
41
|
-
<wa-icon slot="icon" family="classic" variant="solid" name="shield-check"></wa-icon>
|
|
42
|
-
<div style="padding: 1rem;">
|
|
43
|
-
<strong>Privacy & Tracking</strong><br />
|
|
44
|
-
${this.consentMessage}
|
|
45
|
-
<div class="consent-actions">
|
|
46
|
-
<wa-button size="small" variant="neutral" @click=${e=>{e.preventDefault(),e.stopPropagation(),this.disagree()}}>
|
|
47
|
-
Decline
|
|
48
|
-
</wa-button>
|
|
49
|
-
<wa-button size="small" variant="brand" @click=${e=>{e.preventDefault(),e.stopPropagation(),this.agree()}}>
|
|
50
|
-
Accept
|
|
51
|
-
</wa-button>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</wa-callout>
|
|
55
|
-
</div>
|
|
56
|
-
`:""}
|
|
57
|
-
`}connectedCallback(){if(super.connectedCallback(),window.location.hostname!==this.domain){this.showErrorCallout(`Matomo tracking is not configured for this domain. Current domain: ${window.location.hostname}, Expected: ${this.domain}`);return}let e=this.siteId;if(e.length===0||this.domain.length===0){this.showErrorCallout("Matomo tracking is not properly configured. Please provide both site-id and domain attributes.");return}let o=window._paq=window._paq||[];o.push(["requireConsent"]),o.push(["setDomains",[this.domain]]),o.push(["enableLinkTracking"]),o.push(["trackVisibleContentImpressions"]),(function(h){o.push(["setTrackerUrl",`${h}/matomo.php`]),o.push(["setSiteId",e]);let g=document,p=g.createElement("script"),d=g.getElementsByTagName("script")[0];(d==null?void 0:d.parentNode)!=null?(p.async=!0,p.src=`${h}/matomo.js`,d.parentNode.insertBefore(p,d)):console.warn("Script insertion failed. Parent node is null.")})(this.matomoURL),setTimeout(()=>{this.showConsentBanner()},1e3)}};w=new WeakMap,m=new WeakMap,f=new WeakMap,x=new WeakMap,v=new WeakMap,t.styles=b`
|
|
58
|
-
:host {
|
|
59
|
-
display: block;
|
|
60
|
-
font-family: var(--wa-font-sans);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.consent-banner {
|
|
64
|
-
position: fixed;
|
|
65
|
-
bottom: 0;
|
|
66
|
-
left: 0;
|
|
67
|
-
right: 0;
|
|
68
|
-
z-index: 1000;
|
|
69
|
-
padding: 1rem;
|
|
70
|
-
background: rgba(255, 255, 255, 0.95);
|
|
71
|
-
backdrop-filter: blur(10px);
|
|
72
|
-
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.error-banner {
|
|
76
|
-
position: fixed;
|
|
77
|
-
top: 1rem;
|
|
78
|
-
left: 1rem;
|
|
79
|
-
right: 1rem;
|
|
80
|
-
z-index: 1001;
|
|
81
|
-
max-width: 600px;
|
|
82
|
-
margin: 0 auto;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.toast-banner {
|
|
86
|
-
position: fixed;
|
|
87
|
-
top: 1rem;
|
|
88
|
-
right: 1rem;
|
|
89
|
-
z-index: 1002;
|
|
90
|
-
max-width: 450px;
|
|
91
|
-
animation: slideIn 0.3s ease-out;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@keyframes slideIn {
|
|
95
|
-
from {
|
|
96
|
-
transform: translateX(100%);
|
|
97
|
-
opacity: 0;
|
|
98
|
-
}
|
|
99
|
-
to {
|
|
100
|
-
transform: translateX(0);
|
|
101
|
-
opacity: 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.consent-actions {
|
|
106
|
-
display: flex;
|
|
107
|
-
gap: 0.75rem;
|
|
108
|
-
margin-top: 1rem;
|
|
109
|
-
justify-content: flex-end;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
wa-callout {
|
|
113
|
-
--wa-callout-spacing: 1.5rem;
|
|
114
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
115
|
-
border-radius: 12px;
|
|
116
|
-
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
117
|
-
backdrop-filter: blur(8px);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
wa-button {
|
|
121
|
-
min-width: 80px;
|
|
122
|
-
font-weight: 500;
|
|
123
|
-
transition: all 0.2s ease;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
wa-button:hover {
|
|
127
|
-
transform: translateY(-1px);
|
|
128
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.error-banner wa-callout {
|
|
132
|
-
border-radius: 16px;
|
|
133
|
-
box-shadow: 0 16px 48px rgba(243, 77, 71, 0.2);
|
|
134
|
-
border: 1px solid rgba(243, 77, 71, 0.2);
|
|
135
|
-
background: linear-gradient(135deg, rgba(254, 236, 239, 0.95), rgba(253, 208, 214, 0.95));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.error-banner wa-callout::before {
|
|
139
|
-
content: '';
|
|
140
|
-
position: absolute;
|
|
141
|
-
top: 0;
|
|
142
|
-
left: 0;
|
|
143
|
-
right: 0;
|
|
144
|
-
height: 4px;
|
|
145
|
-
background: linear-gradient(90deg, var(--hot-color-red-500), var(--hot-color-red-600), var(--hot-color-red-700));
|
|
146
|
-
border-radius: 16px 16px 0 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.toast-banner wa-callout {
|
|
150
|
-
border-radius: 14px;
|
|
151
|
-
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
|
|
152
|
-
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
153
|
-
background: rgba(255, 255, 255, 0.98);
|
|
154
|
-
backdrop-filter: blur(12px);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.toast-banner wa-callout[variant="success"] {
|
|
158
|
-
box-shadow: 0 12px 40px rgba(34, 197, 94, 0.15);
|
|
159
|
-
border: 1px solid rgba(34, 197, 94, 0.2);
|
|
160
|
-
background: linear-gradient(135deg, rgba(240, 253, 244, 0.95), rgba(220, 252, 231, 0.95));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.toast-banner wa-callout[variant="success"]::before {
|
|
164
|
-
content: '';
|
|
165
|
-
position: absolute;
|
|
166
|
-
top: 0;
|
|
167
|
-
left: 0;
|
|
168
|
-
right: 0;
|
|
169
|
-
height: 3px;
|
|
170
|
-
background: linear-gradient(90deg, #22c55e, #16a34a);
|
|
171
|
-
border-radius: 14px 14px 0 0;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.toast-banner wa-callout[variant="brand"] {
|
|
175
|
-
box-shadow: 0 12px 40px rgba(243, 77, 71, 0.15);
|
|
176
|
-
border: 1px solid rgba(243, 77, 71, 0.2);
|
|
177
|
-
background: linear-gradient(135deg, rgba(254, 236, 239, 0.95), rgba(253, 208, 214, 0.95));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.toast-banner wa-callout[variant="brand"]::before {
|
|
181
|
-
content: '';
|
|
182
|
-
position: absolute;
|
|
183
|
-
top: 0;
|
|
184
|
-
left: 0;
|
|
185
|
-
right: 0;
|
|
186
|
-
height: 3px;
|
|
187
|
-
background: linear-gradient(90deg, var(--hot-color-red-500), var(--hot-color-red-600));
|
|
188
|
-
border-radius: 14px 14px 0 0;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.consent-banner wa-callout {
|
|
192
|
-
border-radius: 16px;
|
|
193
|
-
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
|
194
|
-
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
195
|
-
background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(249, 250, 251, 0.98));
|
|
196
|
-
backdrop-filter: blur(16px);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.consent-banner wa-callout::before {
|
|
200
|
-
content: '';
|
|
201
|
-
position: absolute;
|
|
202
|
-
top: 0;
|
|
203
|
-
left: 0;
|
|
204
|
-
right: 0;
|
|
205
|
-
height: 4px;
|
|
206
|
-
background: linear-gradient(90deg, var(--hot-color-red-500), var(--hot-color-red-600), var(--hot-color-red-700));
|
|
207
|
-
border-radius: 16px 16px 0 0;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
wa-icon {
|
|
211
|
-
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
@media (max-width: 768px) {
|
|
215
|
-
.consent-banner {
|
|
216
|
-
padding: 0.75rem;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.error-banner {
|
|
220
|
-
left: 0.5rem;
|
|
221
|
-
right: 0.5rem;
|
|
222
|
-
max-width: none;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.toast-banner {
|
|
226
|
-
right: 0.5rem;
|
|
227
|
-
max-width: calc(100vw - 1rem);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.consent-actions {
|
|
231
|
-
flex-direction: column;
|
|
232
|
-
gap: 0.5rem;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
wa-button {
|
|
236
|
-
width: 100%;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
`,a([c({type:String,attribute:"site-id"})],t.prototype,"siteId",1),a([c({type:String})],t.prototype,"domain",1),a([c({type:String})],t.prototype,"matomoURL",1),a([c({type:Boolean,attribute:"show-consent"})],t.prototype,"showConsent",1),a([c({type:String,attribute:"consent-message"})],t.prototype,"consentMessage",1),a([r()],t.prototype,"consentGiven",2),a([r()],t.prototype,"consentShown",2),a([r()],t.prototype,"errorMessage",2),a([r()],t.prototype,"showError",2),a([r()],t.prototype,"successMessage",2),a([r()],t.prototype,"showSuccess",2),a([r()],t.prototype,"infoMessage",2),a([r()],t.prototype,"showInfo",2);var q=t;export{t as a,q as b};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import{a as f,b as m,c as z}from"./chunk.ZETV7TDG.js";import{a as M}from"./chunk.GEAU3JJH.js";import{d as h,e as x,f as F}from"./chunk.QABMDRWR.js";import{d as n,e as o,f as d,g as c}from"./chunk.N2W26RCT.js";var E={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},y=l=>(...a)=>({_$litDirective$:l,values:a}),$=class{constructor(a){}get _$AU(){return this._$AM._$AU}_$AT(a,e,i){this._$Ct=a,this._$AM=e,this._$Ci=i}_$AS(a,e){return this.update(a,e)}update(a,e){return this.render(...e)}};var _=y(class extends ${constructor(l){var a;if(super(l),l.type!==E.ATTRIBUTE||l.name!=="class"||((a=l.strings)==null?void 0:a.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(l){return" "+Object.keys(l).filter(a=>l[a]).join(" ")+" "}update(l,[a]){var i,s;if(this.st===void 0){this.st=new Set,l.strings!==void 0&&(this.nt=new Set(l.strings.join(" ").split(/\s/).filter(t=>t!=="")));for(let t in a)a[t]&&!((i=this.nt)!=null&&i.has(t))&&this.st.add(t);return this.render(a)}let e=l.element.classList;for(let t of this.st)t in a||(e.remove(t),this.st.delete(t));for(let t in a){let p=!!a[t];p===this.st.has(t)||(s=this.nt)!=null&&s.has(t)||(p?(e.add(t),this.st.add(t)):(e.remove(t),this.st.delete(t)))}return x}});import"@awesome.me/webawesome/dist/components/icon/icon.js";import"@awesome.me/webawesome/dist/components/divider/divider.js";var S,T,C,D,A,B,L,P,k,W,I,O,r=class extends F{constructor(){super(...arguments);this.name="hot-file-input-dropzone";d(this,S,!1);d(this,T,"");d(this,C,0);d(this,D,!0);d(this,A,!1);d(this,B,"");d(this,L,"traditional");d(this,P,!1);d(this,k,[]);d(this,W,"");d(this,I,"");d(this,O)}get multiple(){return o(this,S)}set multiple(e){c(this,S,e)}get accept(){return o(this,T)}set accept(e){c(this,T,e)}get maxSize(){return o(this,C)}set maxSize(e){c(this,C,e)}get showPreview(){return o(this,D)}set showPreview(e){c(this,D,e)}get disabled(){return o(this,A)}set disabled(e){c(this,A,e)}get label(){return o(this,B)}set label(e){c(this,B,e)}get variant(){return o(this,L)}set variant(e){c(this,L,e)}get isDragging(){return o(this,P)}set isDragging(e){c(this,P,e)}get selectedFiles(){return o(this,k)}set selectedFiles(e){c(this,k,e)}get errorMessage(){return o(this,W)}set errorMessage(e){c(this,W,e)}get statusMessage(){return o(this,I)}set statusMessage(e){c(this,I,e)}get fileInput(){return o(this,O)}set fileInput(e){c(this,O,e)}_generateId(){return`file-${Date.now()}-${Math.random().toString(36).substring(2,11)}`}_handleDragOver(e){e.preventDefault(),e.stopPropagation(),this.disabled||(this.isDragging=!0)}_handleDragLeave(e){e.preventDefault(),e.stopPropagation(),this.isDragging=!1}_handleDrop(e){var s;if(e.preventDefault(),e.stopPropagation(),this.isDragging=!1,this.disabled)return;let i=Array.from(((s=e.dataTransfer)==null?void 0:s.files)||[]);this._processFiles(i)}_handleClick(){this.disabled||this.fileInput.click()}_handleKeyDown(e){!this.disabled&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.fileInput.click())}_handleFileInputChange(e){let i=e.target,s=Array.from(i.files||[]);this._processFiles(s)}_processFiles(e){if(this.errorMessage="",!this.multiple&&e.length>1){this.errorMessage="Only one file can be selected";return}if(this.accept){let t=this.accept.split(",").map(u=>u.trim().toLowerCase()),p=e.filter(u=>{let b=u.name.toLowerCase(),g=u.type.toLowerCase();return!t.some(v=>{if(v.startsWith("."))return b.endsWith(v);if(v.endsWith("/*")){let w=v.split("/")[0];if(g)return g.startsWith(w+"/");let j=b.substring(b.lastIndexOf("."));return this._getFileIcon(j).includes(w)}return g?g===v:!1})});if(p.length>0){this.errorMessage=`Invalid file type(s): ${p.map(u=>u.name).join(", ")}`;return}}if(this.maxSize>0){let t=e.filter(p=>p.size>this.maxSize);if(t.length>0){this.errorMessage=`File(s) exceed maximum size of ${this._formatFileSize(this.maxSize)}: ${t.map(p=>p.name).join(", ")}`;return}}let i=e.map(t=>({file:t,id:this._generateId()}));this.multiple?this.selectedFiles=[...i,...this.selectedFiles]:this.selectedFiles=i,this.dispatchEvent(new CustomEvent("hot-file-change",{detail:{files:this.selectedFiles.map(t=>t.file)},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("hot-files-selected",{detail:{files:i.map(t=>t.file),allFiles:this.selectedFiles.map(t=>t.file)},bubbles:!0,composed:!0}));let s=i.length;this.statusMessage=`${s} ${s===1?"file":"files"} selected: ${i.map(t=>t.file.name).join(", ")}`}_removeFile(e){let i=this.selectedFiles.find(s=>s.id===e);this.selectedFiles=this.selectedFiles.filter(s=>s.id!==e),this.fileInput&&(this.fileInput.value=""),this.dispatchEvent(new CustomEvent("hot-file-change",{detail:{files:this.selectedFiles.map(s=>s.file)},bubbles:!0,composed:!0})),i&&(this.statusMessage=`File removed: ${i.file.name}. ${this.selectedFiles.length} ${this.selectedFiles.length===1?"file":"files"} remaining.`)}_formatFileSize(e){if(e===0)return"0 Bytes";let i=1e3,s=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(i)),p=e/Math.pow(i,t);return`${Math.round(p*10)/10} ${s[t]}`}_getFileIcon(e){return e.startsWith("image/")?"file-image":e.startsWith("video/")?"file-video":e.startsWith("audio/")?"file-audio":e==="application/pdf"?"file-pdf":e.includes("word")?"file-word":e.includes("sheet")||e.includes("excel")?"file-excel":e.includes("zip")||e.includes("rar")||e.includes("7z")?"file-archive":e.includes("text")?"file-text":"file"}clearFiles(){this.selectedFiles=[],this.errorMessage="",this.fileInput&&(this.fileInput.value="")}getFiles(){return this.selectedFiles.map(e=>e.file)}render(){let e={dropzone:!0,"dropzone--dragging":this.isDragging,"dropzone--disabled":this.disabled,"dropzone--has-files":this.selectedFiles.length>0,"dropzone--compact":this.variant==="compact"},i=this.variant==="compact";return h`
|
|
2
|
-
<div class="file-input-dropzone">
|
|
3
|
-
${this.label&&this.variant==="traditional"?h`<label class="label" id="dropzone-label">${this.label}</label>`:""}
|
|
4
|
-
${this.variant==="traditional"?h`<wa-divider></wa-divider>`:""}
|
|
5
|
-
|
|
6
|
-
<div
|
|
7
|
-
class=${_(e)}
|
|
8
|
-
role="button"
|
|
9
|
-
tabindex=${this.disabled?"-1":"0"}
|
|
10
|
-
aria-disabled=${this.disabled}
|
|
11
|
-
aria-label=${this.label||"File upload"}
|
|
12
|
-
aria-describedby="dropzone-description${this.accept||this.maxSize?" dropzone-hints":""}"
|
|
13
|
-
@dragover=${this._handleDragOver}
|
|
14
|
-
@dragleave=${this._handleDragLeave}
|
|
15
|
-
@drop=${this._handleDrop}
|
|
16
|
-
@click=${this._handleClick}
|
|
17
|
-
@keydown=${this._handleKeyDown}
|
|
18
|
-
>
|
|
19
|
-
<input
|
|
20
|
-
type="file"
|
|
21
|
-
class="file-uploader"
|
|
22
|
-
?multiple=${this.multiple}
|
|
23
|
-
accept=${this.accept}
|
|
24
|
-
?disabled=${this.disabled}
|
|
25
|
-
@change=${this._handleFileInputChange}
|
|
26
|
-
aria-hidden="true"
|
|
27
|
-
tabindex="-1"
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
<div class="dropzone-content">
|
|
31
|
-
<wa-icon
|
|
32
|
-
name="${i?"arrow-up-from-bracket":"cloud-arrow-up"}"
|
|
33
|
-
class="dropzone-icon"
|
|
34
|
-
aria-hidden="true"
|
|
35
|
-
></wa-icon>
|
|
36
|
-
<div class="dropzone-text">
|
|
37
|
-
${i?h`<div class="compact-text" id="dropzone-description">
|
|
38
|
-
${this.label}
|
|
39
|
-
</div>`:this.isDragging?h`<div id="dropzone-description">
|
|
40
|
-
Drop ${this.multiple?"files":"file"} here
|
|
41
|
-
</div>`:h`
|
|
42
|
-
<div class="dropzone-cta" id="dropzone-description">
|
|
43
|
-
<div>
|
|
44
|
-
Drop ${this.multiple?"files":"file"} here or
|
|
45
|
-
</div>
|
|
46
|
-
<div class="browse">browse</div>
|
|
47
|
-
</div>
|
|
48
|
-
${this.accept||this.maxSize?h`<div id="dropzone-hints">
|
|
49
|
-
${this.accept?h`<div class="dropzone-accept">
|
|
50
|
-
${this.accept.split(",").join(", ")} only
|
|
51
|
-
</div>`:""}
|
|
52
|
-
${this.maxSize?h`<div class="dropzone-maxsize">
|
|
53
|
-
Max size: ${this._formatFileSize(this.maxSize)}
|
|
54
|
-
</div>`:""}
|
|
55
|
-
</div>`:""}
|
|
56
|
-
`}
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
${this.errorMessage?h`
|
|
61
|
-
<div class="error-message" role="alert">
|
|
62
|
-
<wa-icon name="exclamation-circle"></wa-icon>
|
|
63
|
-
${this.errorMessage}
|
|
64
|
-
</div>
|
|
65
|
-
`:""}
|
|
66
|
-
${this.showPreview&&this.selectedFiles.length>0?h`
|
|
67
|
-
<div class="file-preview-list">
|
|
68
|
-
${this.selectedFiles.map(({file:s,id:t})=>h`
|
|
69
|
-
<hot-list-card
|
|
70
|
-
title=${s.name}
|
|
71
|
-
subtitle=${this._formatFileSize(s.size)}
|
|
72
|
-
icon=${this._getFileIcon(s.type)}
|
|
73
|
-
itemId=${t}
|
|
74
|
-
@hot-remove=${()=>this._removeFile(t)}
|
|
75
|
-
></hot-list-card>
|
|
76
|
-
`)}
|
|
77
|
-
</div>
|
|
78
|
-
`:""}
|
|
79
|
-
|
|
80
|
-
<div
|
|
81
|
-
class="sr-only"
|
|
82
|
-
role="status"
|
|
83
|
-
aria-live="polite"
|
|
84
|
-
aria-atomic="true"
|
|
85
|
-
>
|
|
86
|
-
${this.statusMessage}
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
`}};S=new WeakMap,T=new WeakMap,C=new WeakMap,D=new WeakMap,A=new WeakMap,B=new WeakMap,L=new WeakMap,P=new WeakMap,k=new WeakMap,W=new WeakMap,I=new WeakMap,O=new WeakMap,r.styles=[M],n([f({type:Boolean})],r.prototype,"multiple",1),n([f({type:String})],r.prototype,"accept",1),n([f({type:Number})],r.prototype,"maxSize",1),n([f({type:Boolean})],r.prototype,"showPreview",1),n([f({type:Boolean})],r.prototype,"disabled",1),n([f({type:String})],r.prototype,"label",1),n([f({type:String})],r.prototype,"variant",1),n([m()],r.prototype,"isDragging",1),n([m()],r.prototype,"selectedFiles",1),n([m()],r.prototype,"errorMessage",1),n([m()],r.prototype,"statusMessage",1),n([z('input[type="file"]')],r.prototype,"fileInput",1);var te=r;export{r as a,te as b};
|
|
90
|
-
/*! Bundled license information:
|
|
91
|
-
|
|
92
|
-
lit-html/directive.js:
|
|
93
|
-
(**
|
|
94
|
-
* @license
|
|
95
|
-
* Copyright 2017 Google LLC
|
|
96
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
97
|
-
*)
|
|
98
|
-
|
|
99
|
-
lit-html/directives/class-map.js:
|
|
100
|
-
(**
|
|
101
|
-
* @license
|
|
102
|
-
* Copyright 2018 Google LLC
|
|
103
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
104
|
-
*)
|
|
105
|
-
*/
|