@ampify/aquery
Advanced tools
Comparing version 1.5.0 to 1.5.3
{ | ||
"name": "@ampify/aquery", | ||
"version": "1.5.0", | ||
"version": "1.5.3", | ||
"main": "./dist/aquery.js", | ||
@@ -10,3 +10,3 @@ "module": "./src", | ||
"build-dev": "webpack -d", | ||
"build": "webpack -p", | ||
"build": "webpack --mode production", | ||
"test": "jest", | ||
@@ -27,4 +27,4 @@ "prepublish": "yarn build" | ||
"trash-cli": "^3.0.0", | ||
"webpack": "^4.41.2", | ||
"webpack-cli": "^3.3.10" | ||
"webpack": "^5.32.0", | ||
"webpack-cli": "^4.6.0" | ||
}, | ||
@@ -39,3 +39,3 @@ "jest": { | ||
}, | ||
"gitHead": "4d1a31ccf18a0c0812f103c5bb36676f8f4f08bb" | ||
"gitHead": "d1c6fc01907863033990b37ddb7e1deb3c21fe25" | ||
} |
@@ -6,51 +6,49 @@ import randomId from '../randomId'; | ||
const addDatePicker = (date, $) => { | ||
if (date) { | ||
date.mode = date.mode ? date.mode : 'lightbox'; | ||
const mode = mode_pre; | ||
const input = date.input; | ||
if (!input.getAttribute('name')) { | ||
input.setAttribute('name', randomId()); | ||
} | ||
const datePicker = document.createElement('amp-date-picker'); | ||
datePicker.setAttribute( | ||
'input-selector', | ||
`[name=${input.getAttribute('name')}]` | ||
); | ||
const format = resolveFormat(date.format); | ||
datePicker.setAttribute('format', format); | ||
if (date) { | ||
const mode = date.mode ? date.mode : 'lightbox'; | ||
const input = date.input; | ||
if (!input.getAttribute('name')) { | ||
input.setAttribute('name', randomId()); | ||
} | ||
const datePicker = document.createElement('amp-date-picker'); | ||
datePicker.setAttribute( | ||
'input-selector', | ||
`[name=${input.getAttribute('name')}]`, | ||
); | ||
const format = resolveFormat(date.format); | ||
datePicker.setAttribute('format', format); | ||
if (date.required) { | ||
input.removeAttribute('readonly'); | ||
input.setAttribute('required', ''); | ||
datePicker.setAttribute('required', ''); | ||
console.log('addDatePicker', datePicker); | ||
} | ||
if (date.mode && date.mode === 'static') {} else if (mode === "overlay") { | ||
datePicker.setAttribute('mode', 'overlay'); | ||
datePicker.setAttribute('layout', 'container'); | ||
const parent = input.parentNode; | ||
parent.appendChild(datePicker); | ||
datePicker.appendChild(input); | ||
} else { | ||
const lightboxID = `lb${input.getAttribute('name')}`; | ||
datePicker.setAttribute('mode', 'static'); | ||
datePicker.setAttribute('layout', 'fixed-height'); | ||
datePicker.setAttribute('height', '360'); | ||
datePicker.setAttribute('on', `select:${lightboxID}.close`); | ||
input.setAttribute('on', `tap:${lightboxID}.open`); | ||
input.setAttribute('tabindex', '0'); | ||
input.setAttribute('role', 'textbox'); | ||
const lightbox = document.createElement('amp-lightbox'); | ||
lightbox.setAttribute('id', `${lightboxID}`); | ||
lightbox.setAttribute('layout', 'nodisplay'); | ||
lightbox.innerHTML = ` | ||
if (date.required) { | ||
input.removeAttribute('readonly'); | ||
input.setAttribute('required', ''); | ||
datePicker.setAttribute('required', ''); | ||
console.log('addDatePicker', datePicker); | ||
} | ||
if (mode === 'overlay') { | ||
datePicker.setAttribute('mode', 'overlay'); | ||
datePicker.setAttribute('layout', 'container'); | ||
const parent = input.parentNode; | ||
parent.appendChild(datePicker); | ||
datePicker.appendChild(input); | ||
} else { | ||
const lightboxID = `lb${input.getAttribute('name')}`; | ||
datePicker.setAttribute('mode', 'static'); | ||
datePicker.setAttribute('layout', 'fixed-height'); | ||
datePicker.setAttribute('height', '360'); | ||
datePicker.setAttribute('on', `select:${lightboxID}.close`); | ||
input.setAttribute('on', `tap:${lightboxID}.open`); | ||
input.setAttribute('tabindex', '0'); | ||
input.setAttribute('role', 'textbox'); | ||
const lightbox = document.createElement('amp-lightbox'); | ||
lightbox.setAttribute('id', `${lightboxID}`); | ||
lightbox.setAttribute('layout', 'nodisplay'); | ||
lightbox.innerHTML = ` | ||
<button on="tap:${lightboxID}.close" tabindex="0" class="lb_close"></button> | ||
<div class="align-content-center"> | ||
${datePicker.outerHTML} | ||
</div>` | ||
</div>`; | ||
document.querySelector('body').append(lightbox); | ||
document.querySelector('body').append(lightbox); | ||
$.injectCss(` | ||
$.injectCss(` | ||
amp-lightbox {background-color: rgba(0 0 0 / 50%);} | ||
@@ -61,14 +59,14 @@ amp-lightbox > div {padding-top:35%;} | ||
amp-lightbox button.lb_close:before {font-size:35px;font-family: 'Helvetica', 'Arial', sans-serif; content: 'X';} | ||
`) | ||
$.cssIgnore(`#${lightboxID}`) | ||
} | ||
`); | ||
$.cssIgnore(`#${lightboxID}`); | ||
} | ||
} | ||
}; | ||
const resolveFormat = (format) => { | ||
if (format && format.toLowerCase().startsWith('mm')) { | ||
return FORMATS.FORMAT_US; | ||
} | ||
return FORMATS.FORMAT_WORLD; | ||
if (format && format.toLowerCase().startsWith('mm')) { | ||
return FORMATS.FORMAT_US; | ||
} | ||
return FORMATS.FORMAT_WORLD; | ||
}; | ||
export default addDatePicker; | ||
export default addDatePicker; |
@@ -7,2 +7,7 @@ const { name } = require('./package'); | ||
module.exports = { | ||
resolve: { | ||
fallback: { | ||
crypto: false, | ||
}, | ||
}, | ||
entry: { | ||
@@ -9,0 +14,0 @@ [packageName]: './src', |
1549
48964