diff --git a/build.dev.js b/build.dev.js index d88ce45..b90a39f 100644 --- a/build.dev.js +++ b/build.dev.js @@ -37,15 +37,19 @@ $cd: #62778d #526273 #425064; ::after{box-sizing:border-box;} ` +function fixImport(str) { + return str + .replace(/import '([\w-/_.]*)'/g, 'import "$1.js"') + .replace( + /import ([\w\s,{}]*) from '([a-z0-9\/\.\-_]*)'/g, + 'import $1 from "$2.js"' + ) +} + function compileJs(entry, output) { log('编译JS: %s', chalk.green(entry)) let buf = fs.cat(entry).toString() - let code = buf - .replace(/import '([a-z0-9\/\.\-_]*)'/g, 'import "$1.js"') - .replace( - /import ([\w]*) from '([a-z0-9\/\.\-_]*)'/g, - 'import $1 from "$2.js"' - ) + let code = fixImport(buf) fs.echo(code, output) } @@ -81,16 +85,11 @@ function mkWCFile({ style, html, js }) { ` }) - js = js + js = fixImport(js) .replace(/class ([\w]+)/, function(s, m) { name = m return `${s} extends HTMLElement ` }) - .replace(/import '([a-z0-9\/\.\-_]*)'/g, 'import "$1.js"') - .replace( - /import ([\w]*) from '([a-z0-9\/\.\-_]*)'/g, - 'import $1 from "$2.js"' - ) .replace(/constructor\([^)]?\)\s+\{/, 'constructor() {\n super();') .replace( '/* render */', diff --git a/build.prod.js b/build.prod.js index 2d3060f..224c6cb 100644 --- a/build.prod.js +++ b/build.prod.js @@ -37,16 +37,21 @@ $cd: #62778d #526273 #425064; ::after{box-sizing:border-box;} ` +function fixImport(str) { + return str + .replace(/import '([\w-/_.]*)'/g, 'import "$1.js"') + .replace( + /import ([\w\s,{}]*) from '([a-z0-9\/\.\-_]*)'/g, + 'import $1 from "$2.js"' + ) +} + const compileJs = (entry, output) => { let t1 = Date.now() let buf = fs.cat(entry).toString() let { code } = uglify.minify(buf) - code = code - .replace(/import"([a-z0-9\/\.\-_]*)"/g, 'import "$1.js"') - .replace( - /import ([\w]*) from"([a-z0-9\/\.\-_]*)"/g, - 'import $1 from "$2.js"' - ) + code = fixImport(code) + log( '编译JS: %s, 耗时 %s ms', chalk.green(entry), @@ -87,16 +92,11 @@ function mkWCFile({ style, html, js }) { ` }) - js = js + js = fixImport(js) .replace(/class ([\w]+)/, function(s, m) { name = m return `${s} extends HTMLElement ` }) - .replace(/import '([a-z0-9\/\.\-_]*)'/g, 'import "$1.js"') - .replace( - /import ([\w]*) from '([a-z0-9\/\.\-_]*)'/g, - 'import $1 from "$2.js"' - ) .replace(/constructor\([^)]?\)\s+\{/, 'constructor() {\n super();') .replace( '/* render */', diff --git a/src/form/input.wc b/src/form/input.wc index 6c3a412..2a3cbc7 100644 --- a/src/form/input.wc +++ b/src/form/input.wc @@ -6,7 +6,9 @@
- + + +
@@ -17,6 +19,7 @@ li { list-style: none; } :host { + overflow: hidden; display: inline-block; user-select: none; -moz-user-select: none; @@ -25,7 +28,6 @@ li { } .label { - position: relative; display: flex; justify-content: center; align-items: center; @@ -94,11 +96,11 @@ li { .suggestion { display: none; - position: absolute; + position: fixed; z-index: 10240; left: 0; - top: 50px; - width: 100%; + top: 0; + width: 200px; height: auto; max-height: 200px; min-height: 46px; @@ -108,8 +110,6 @@ li { box-shadow: 0 0 3px rgba(0, 0, 0, 0.2); .list { - overflow: hidden; - overflow-y: auto; width: 100%; } @@ -219,7 +219,9 @@ li {