@websy/websy-designs 1.1.0 → 1.1.3
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/dist/websy-designs-es6.debug.js +21 -11
- package/dist/websy-designs-es6.js +19 -8
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +205 -11
- package/dist/websy-designs.js +391 -193
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/index.js +8 -8
- package/package.json +2 -2
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
APIService
|
|
23
23
|
ButtonGroup
|
|
24
24
|
WebsyUtils
|
|
25
|
+
WebsyCarousel
|
|
25
26
|
Pager
|
|
26
27
|
*/
|
|
27
28
|
|
|
@@ -197,6 +198,189 @@ class ButtonGroup {
|
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
/* global */
|
|
202
|
+
|
|
203
|
+
class WebsyCarousel {
|
|
204
|
+
constructor (elementId, options) {
|
|
205
|
+
const DEFAULTS = {
|
|
206
|
+
currentFrame: 0,
|
|
207
|
+
frameDuration: 4000,
|
|
208
|
+
showFrameSelector: true,
|
|
209
|
+
showPrevNext: true
|
|
210
|
+
}
|
|
211
|
+
this.playTimeoutFn = null
|
|
212
|
+
this.options = Object.assign({}, DEFAULTS, options)
|
|
213
|
+
if (!elementId) {
|
|
214
|
+
console.log('No element Id provided')
|
|
215
|
+
}
|
|
216
|
+
const el = document.getElementById(elementId)
|
|
217
|
+
if (el) {
|
|
218
|
+
this.elementId = elementId
|
|
219
|
+
el.addEventListener('click', this.handleClick.bind(this))
|
|
220
|
+
this.render()
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
handleClick (event) {
|
|
224
|
+
if (event.target.classList.contains('websy-next-arrow')) {
|
|
225
|
+
this.next()
|
|
226
|
+
}
|
|
227
|
+
if (event.target.classList.contains('websy-prev-arrow')) {
|
|
228
|
+
this.prev()
|
|
229
|
+
}
|
|
230
|
+
if (event.target.classList.contains('websy-progress-btn' || 'websy-progress-btn-active')) {
|
|
231
|
+
const index = +event.target.getAttribute('data-index')
|
|
232
|
+
let prevFrameIndex = this.options.currentFrame
|
|
233
|
+
this.options.currentFrame = index
|
|
234
|
+
this.showFrame(prevFrameIndex, index)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
next () {
|
|
238
|
+
this.pause()
|
|
239
|
+
let prevFrameIndex = this.options.currentFrame
|
|
240
|
+
if (this.options.currentFrame === this.options.frames.length - 1) {
|
|
241
|
+
this.options.currentFrame = 0
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this.options.currentFrame++
|
|
245
|
+
}
|
|
246
|
+
this.showFrame(prevFrameIndex, this.options.currentFrame)
|
|
247
|
+
// this.play()
|
|
248
|
+
// document.getElementById(`${this.elementId}_frame_${this.options.currentFrame}`)
|
|
249
|
+
// .style.transform = `translateX(-100%)`
|
|
250
|
+
// if (`${this.options.currentFrame === this.options.frames.length - 1}`) {
|
|
251
|
+
// document.getElementById`${this.elementId}_frame_${this.options.currentFrame}`.style.transform = `translateX('-100%')`
|
|
252
|
+
// }
|
|
253
|
+
}
|
|
254
|
+
pause () {
|
|
255
|
+
if (this.playTimeoutFn) {
|
|
256
|
+
clearTimeout(this.playTimeoutFn)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
play () {
|
|
260
|
+
this.playTimeoutFn = setTimeout(() => {
|
|
261
|
+
let prevFrameIndex = this.options.currentFrame
|
|
262
|
+
if (this.options.currentFrame === this.options.frames.length - 1) {
|
|
263
|
+
this.options.currentFrame = 0
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.options.currentFrame++
|
|
267
|
+
}
|
|
268
|
+
this.showFrame(prevFrameIndex, this.options.currentFrame)
|
|
269
|
+
this.play()
|
|
270
|
+
}, this.options.frameDuration)
|
|
271
|
+
}
|
|
272
|
+
prev () {
|
|
273
|
+
this.pause()
|
|
274
|
+
let prevFrameIndex = this.options.currentFrame
|
|
275
|
+
if (this.options.currentFrame === 0) {
|
|
276
|
+
this.options.currentFrame = this.options.frames.length - 1
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.options.currentFrame--
|
|
280
|
+
}
|
|
281
|
+
this.showFrame(prevFrameIndex, this.options.currentFrame)
|
|
282
|
+
// this.play()
|
|
283
|
+
// document.getElementById(`${this.elementId}_frame_${this.options.currentFrame}`)
|
|
284
|
+
// .style.transform = `translateX(100%)`
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
render (options) {
|
|
288
|
+
this.options = Object.assign({}, this.options, options)
|
|
289
|
+
this.resize()
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
resize () {
|
|
293
|
+
const el = document.getElementById(this.elementId)
|
|
294
|
+
if (el) {
|
|
295
|
+
let html = `
|
|
296
|
+
<div class="websy-carousel">
|
|
297
|
+
`
|
|
298
|
+
this.options.frames.forEach((frame, frameIndex) => {
|
|
299
|
+
html += `
|
|
300
|
+
<div id="${this.elementId}_frame_${frameIndex}" class="websy-frame-container animate" style="transform: translateX(${frameIndex === 0 ? '0' : '100%'})">
|
|
301
|
+
`
|
|
302
|
+
frame.images.forEach(image => {
|
|
303
|
+
html += `
|
|
304
|
+
<div style="${image.style || 'position: absolute; width: 100%; height: 100%; top: 0; left: 0;'} background-image: url('${image.url}')" class="${image.classes || ''} websy-carousel-image">
|
|
305
|
+
</div>
|
|
306
|
+
`
|
|
307
|
+
})
|
|
308
|
+
frame.text && frame.text.forEach(text => {
|
|
309
|
+
html += `
|
|
310
|
+
<div style="${text.style || 'position: absolute; width: 100%; height: 100%; top: 0; left: 0;'}" class="${text.classes || ''} websy-carousel-image">
|
|
311
|
+
${text.html}
|
|
312
|
+
</div>
|
|
313
|
+
`
|
|
314
|
+
})
|
|
315
|
+
html += `</div>`
|
|
316
|
+
})
|
|
317
|
+
if (this.options.showFrameSelector === true) {
|
|
318
|
+
html += `<div class="websy-btn-parent">`
|
|
319
|
+
this.options.frames.forEach((frame, frameIndex) => {
|
|
320
|
+
html += `
|
|
321
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-index="${frameIndex}" id="${this.elementId}_selector_${frameIndex}"
|
|
322
|
+
class="websy-progress-btn ${this.options.currentFrame === frameIndex ? 'websy-progress-btn-active' : ''}">
|
|
323
|
+
<title>Ellipse</title><circle cx="256" cy="256" r="192" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
|
|
324
|
+
</svg>
|
|
325
|
+
`
|
|
326
|
+
})
|
|
327
|
+
html += `</div>`
|
|
328
|
+
}
|
|
329
|
+
if (this.options.showPrevNext === true) {
|
|
330
|
+
html += `
|
|
331
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="websy-prev-arrow"
|
|
332
|
+
viewBox="0 0 512 512">
|
|
333
|
+
<title>Caret Back</title>
|
|
334
|
+
<path d="M321.94 98L158.82 237.78a24 24 0 000 36.44L321.94 414c15.57 13.34 39.62 2.28 39.62-18.22v-279.6c0-20.5-24.05-31.56-39.62-18.18z"/>
|
|
335
|
+
</svg>
|
|
336
|
+
</div>
|
|
337
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="websy-next-arrow">
|
|
338
|
+
<title>Caret Forward</title>
|
|
339
|
+
<path d="M190.06 414l163.12-139.78a24 24 0 000-36.44L190.06 98c-15.57-13.34-39.62-2.28-39.62 18.22v279.6c0 20.5 24.05 31.56 39.62 18.18z"/>
|
|
340
|
+
</svg>
|
|
341
|
+
`
|
|
342
|
+
}
|
|
343
|
+
html += `
|
|
344
|
+
</div>
|
|
345
|
+
`
|
|
346
|
+
el.innerHTML = html
|
|
347
|
+
}
|
|
348
|
+
// this.play()
|
|
349
|
+
// this.showFrameSelector()
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
showFrame (prevFrameIndex, currFrameIndex) {
|
|
353
|
+
let prevTranslateX = prevFrameIndex > currFrameIndex ? '100%' : '-100%'
|
|
354
|
+
let nextTranslateX = prevFrameIndex < currFrameIndex ? '100%' : '-100%'
|
|
355
|
+
if (currFrameIndex === 0 && prevFrameIndex === this.options.frames.length - 1) {
|
|
356
|
+
prevTranslateX = '-100%'
|
|
357
|
+
nextTranslateX = '100%'
|
|
358
|
+
}
|
|
359
|
+
else if (prevFrameIndex === 0 && currFrameIndex === this.options.frames.length - 1) {
|
|
360
|
+
prevTranslateX = '100%'
|
|
361
|
+
nextTranslateX = '-100%'
|
|
362
|
+
}
|
|
363
|
+
const prevF = document.getElementById(
|
|
364
|
+
`${this.elementId}_frame_${prevFrameIndex}`)
|
|
365
|
+
prevF.style.transform = `translateX(${prevTranslateX})`
|
|
366
|
+
const btnInactive = document.getElementById(`${this.elementId}_selector_${prevFrameIndex}`)
|
|
367
|
+
btnInactive.classList.remove('websy-progress-btn-active')
|
|
368
|
+
const newF = document.getElementById(`${this.elementId}_frame_${currFrameIndex}`)
|
|
369
|
+
newF.classList.remove('animate')
|
|
370
|
+
newF.style.transform = `translateX(${nextTranslateX})`
|
|
371
|
+
setTimeout(() => {
|
|
372
|
+
newF.classList.add('animate')
|
|
373
|
+
newF.style.transform = 'translateX(0%)'
|
|
374
|
+
}, 100)
|
|
375
|
+
|
|
376
|
+
const btnActive = document.getElementById(`${this.elementId}_selector_${currFrameIndex}`)
|
|
377
|
+
btnActive.classList.add('websy-progress-btn-active')
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// showFrameSelector () {
|
|
381
|
+
// }
|
|
382
|
+
}
|
|
383
|
+
|
|
200
384
|
class WebsyDatePicker {
|
|
201
385
|
constructor (elementId, options) {
|
|
202
386
|
this.oneDay = 1000 * 60 * 60 * 24
|
|
@@ -828,12 +1012,13 @@ class WebsyDropdown {
|
|
|
828
1012
|
const headerLabel = this.selectedItems.map(s => this.options.items[s].label || this.options.items[s].value).join(this.options.multiValueDelimiter)
|
|
829
1013
|
const headerValue = this.selectedItems.map(s => this.options.items[s].value || this.options.items[s].label).join(this.options.multiValueDelimiter)
|
|
830
1014
|
let html = `
|
|
831
|
-
<div class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''}'>
|
|
1015
|
+
<div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style}'>
|
|
832
1016
|
<div id='${this.elementId}_header' class='websy-dropdown-header ${this.selectedItems.length === 1 ? 'one-selected' : ''} ${this.options.allowClear === true ? 'allow-clear' : ''}'>
|
|
1017
|
+
<svg class='search' width="20" height="20" viewBox="0 0 512 512"><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>
|
|
833
1018
|
<span id='${this.elementId}_headerLabel' class='websy-dropdown-header-label'>${this.options.label}</span>
|
|
834
1019
|
<span data-info='${headerLabel}' class='websy-dropdown-header-value' id='${this.elementId}_selectedItems'>${headerLabel}</span>
|
|
835
1020
|
<input class='dropdown-input' id='${this.elementId}_input' name='${this.options.field || this.options.label}' value='${headerValue}'>
|
|
836
|
-
<svg class='arrow' xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z"/></svg>
|
|
1021
|
+
<svg class='arrow' xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z"/></svg>
|
|
837
1022
|
`
|
|
838
1023
|
if (this.options.allowClear === true) {
|
|
839
1024
|
html += `
|
|
@@ -928,6 +1113,10 @@ class WebsyDropdown {
|
|
|
928
1113
|
else if (event.target.classList.contains('clear')) {
|
|
929
1114
|
this.clearSelected()
|
|
930
1115
|
}
|
|
1116
|
+
else if (event.target.classList.contains('search')) {
|
|
1117
|
+
const el = document.getElementById(`${this.elementId}_container`)
|
|
1118
|
+
el.classList.toggle('search-open')
|
|
1119
|
+
}
|
|
931
1120
|
}
|
|
932
1121
|
handleKeyUp (event) {
|
|
933
1122
|
if (event.target.classList.contains('websy-dropdown-search')) {
|
|
@@ -3616,6 +3805,9 @@ class WebsyTable2 {
|
|
|
3616
3805
|
}
|
|
3617
3806
|
if (c.backgroundColor) {
|
|
3618
3807
|
style += `background-color: ${c.backgroundColor}; `
|
|
3808
|
+
if (!c.color) {
|
|
3809
|
+
style += `color: ${WebsyDesigns.Utils.getLightDark(c.backgroundColor)}; `
|
|
3810
|
+
}
|
|
3619
3811
|
}
|
|
3620
3812
|
if (c.color) {
|
|
3621
3813
|
style += `color: ${c.color}; `
|
|
@@ -3910,16 +4102,18 @@ class WebsyTable2 {
|
|
|
3910
4102
|
}).join('') + '</tr>'
|
|
3911
4103
|
const headEl = document.getElementById(`${this.elementId}_head`)
|
|
3912
4104
|
headEl.innerHTML = headHTML
|
|
3913
|
-
let dropdownHTML = ``
|
|
3914
|
-
this.options.columns.forEach((c, i) => {
|
|
3915
|
-
if (c.searchable && c.searchField) {
|
|
3916
|
-
dropdownHTML += `
|
|
3917
|
-
<div id="${this.elementId}_columnSearch_${i}" class="websy-modal-dropdown"></div>
|
|
3918
|
-
`
|
|
3919
|
-
}
|
|
3920
|
-
})
|
|
3921
4105
|
const dropdownEl = document.getElementById(`${this.elementId}_dropdownContainer`)
|
|
3922
|
-
dropdownEl.innerHTML
|
|
4106
|
+
if (dropdownEl.innerHTML === '') {
|
|
4107
|
+
let dropdownHTML = ``
|
|
4108
|
+
this.options.columns.forEach((c, i) => {
|
|
4109
|
+
if (c.searchable && c.searchField) {
|
|
4110
|
+
dropdownHTML += `
|
|
4111
|
+
<div id="${this.elementId}_columnSearch_${i}" class="websy-modal-dropdown"></div>
|
|
4112
|
+
`
|
|
4113
|
+
}
|
|
4114
|
+
})
|
|
4115
|
+
dropdownEl.innerHTML = dropdownHTML
|
|
4116
|
+
}
|
|
3923
4117
|
// const colGroupEl = document.getElementById(`${this.elementId}_cols`)
|
|
3924
4118
|
// colGroupEl.innerHTML = colGroupHTML
|
|
3925
4119
|
// let footHTML = '<tr>' + this.options.columns.map((c, i) => {
|