From b936200b457fb5cc325613880f3a6ba80a22fe96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 8 Aug 2019 16:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=A8=A1=E5=9D=97;=E4=BC=98=E5=8C=96scroll;=E5=AE=8C?= =?UTF-8?q?=E6=88=90datepicker;=E4=BC=98=E5=8C=96input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.dev.js | 23 ++- build.prod.js | 24 ++-- src/form/input.wc | 133 +++++++++--------- src/picker/date.wc | 334 +++++++++++++++++++++++++++++--------------- src/scroll/index.wc | 2 + src/utils.js | 87 ++++++++++++ 6 files changed, 397 insertions(+), 206 deletions(-) create mode 100644 src/utils.js 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 {