fix(@omiu/input): tirgger native event of props

This commit is contained in:
dntzhang 2021-08-06 14:38:13 +08:00
parent 1fbf5dd470
commit b4f1275f1e
16 changed files with 119 additions and 57 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@omiu/input",
"version": "0.0.11",
"version": "0.0.12",
"description": "Generally used to input information and submit it to the server.",
"docsExtend": {
"cnName": "输入框",

View File

@ -42,8 +42,8 @@ export default class Input extends WeElement<Props> {
_onSetValue: (value: any) => void;
_tempTagName: string;
valueLength: number;
handleBlur: () => void;
handleFocus: () => void;
handleBlur: (evt: any) => void;
handleFocus: (evt: any) => void;
handleChange: (evt: any) => void;
handleInput: (evt: any) => void;
focus(): void;

View File

@ -1,5 +1,5 @@
/**
* @omiu/input v0.0.11 http://omijs.org
* @omiu/input v0.0.12 http://omijs.org
* Front End Cross-Frameworks Framework.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -27,11 +27,13 @@ PERFORMANCE OF THIS SOFTWARE.
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@ -488,22 +490,42 @@ var Input = /** @class */ (function (_super) {
_this.setAttribute('value', value);
};
_this.valueLength = 0;
_this.handleBlur = function () {
_this.fire('blur', _this.props.value);
_this.handleBlur = function (evt) {
if (_this.props.onBlur) {
_this.props.onBlur(evt);
}
else {
_this.fire('blur', _this.props.value);
}
};
_this.handleFocus = function () {
_this.fire('focus', _this.props.value);
_this.handleFocus = function (evt) {
if (_this.props.onFocus) {
_this.props.onFocus(evt);
}
else {
_this.fire('focus', _this.props.value);
}
};
_this.handleChange = function (evt) {
_this.__$value = evt.target.value;
_this.props.value = evt.target.value;
_this.fire('change', _this.props.value);
if (_this.props.onChange) {
_this.props.onChange(evt);
}
else {
_this.fire('change', _this.props.value);
}
};
_this.handleInput = function (evt) {
evt.stopPropagation();
_this.__$value = evt.target.value;
_this.props.value = evt.target.value;
_this.fire('input', _this.props.value);
if (_this.props.onInput) {
_this.props.onInput(evt);
}
else {
_this.fire('input', _this.props.value);
}
if (_this.props.maxLength) {
_this.valueLength = evt.target.value.length;
_this.update();

File diff suppressed because one or more lines are too long

View File

@ -96,14 +96,14 @@ return /******/ (function(modules) { // webpackBootstrap
/************************************************************************/
/******/ ({
/***/ "./node_modules/_css-loader@1.0.1@css-loader/index.js!./node_modules/_resolve-url-loader@3.1.4@resolve-url-loader/index.js!./node_modules/_sass-loader@7.3.1@sass-loader/dist/cjs.js?!./src/index.scss":
/*!****************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/_css-loader@1.0.1@css-loader!./node_modules/_resolve-url-loader@3.1.4@resolve-url-loader!./node_modules/_sass-loader@7.3.1@sass-loader/dist/cjs.js??ref--4-3!./src/index.scss ***!
\****************************************************************************************************************************************************************************************************/
/***/ "./node_modules/css-loader/index.js!./node_modules/resolve-url-loader/index.js!./node_modules/sass-loader/dist/cjs.js?!./src/index.scss":
/*!*************************************************************************************************************************************!*\
!*** ./node_modules/css-loader!./node_modules/resolve-url-loader!./node_modules/sass-loader/dist/cjs.js??ref--4-3!./src/index.scss ***!
\*************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(/*! ../node_modules/_css-loader@1.0.1@css-loader/lib/css-base.js */ "./node_modules/_css-loader@1.0.1@css-loader/lib/css-base.js")(false);
exports = module.exports = __webpack_require__(/*! ../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
// imports
@ -115,10 +115,10 @@ exports.push([module.i, ":host {\n display: inline-block; }\n\n:host([block]) {
/***/ }),
/***/ "./node_modules/_css-loader@1.0.1@css-loader/lib/css-base.js":
/*!*******************************************************************!*\
!*** ./node_modules/_css-loader@1.0.1@css-loader/lib/css-base.js ***!
\*******************************************************************/
/***/ "./node_modules/css-loader/lib/css-base.js":
/*!*************************************************!*\
!*** ./node_modules/css-loader/lib/css-base.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
@ -210,7 +210,7 @@ function toComment(sourceMap) {
/***/ (function(module, exports, __webpack_require__) {
var result = __webpack_require__(/*! !../node_modules/_css-loader@1.0.1@css-loader!../node_modules/_resolve-url-loader@3.1.4@resolve-url-loader!../node_modules/_sass-loader@7.3.1@sass-loader/dist/cjs.js??ref--4-3!./index.scss */ "./node_modules/_css-loader@1.0.1@css-loader/index.js!./node_modules/_resolve-url-loader@3.1.4@resolve-url-loader/index.js!./node_modules/_sass-loader@7.3.1@sass-loader/dist/cjs.js?!./src/index.scss");
var result = __webpack_require__(/*! !../node_modules/css-loader!../node_modules/resolve-url-loader!../node_modules/sass-loader/dist/cjs.js??ref--4-3!./index.scss */ "./node_modules/css-loader/index.js!./node_modules/resolve-url-loader/index.js!./node_modules/sass-loader/dist/cjs.js?!./src/index.scss");
if (typeof result === "string") {
module.exports = result;
@ -287,22 +287,42 @@ var Input = /** @class */ (function (_super) {
_this.setAttribute('value', value);
};
_this.valueLength = 0;
_this.handleBlur = function () {
_this.fire('blur', _this.props.value);
_this.handleBlur = function (evt) {
if (_this.props.onBlur) {
_this.props.onBlur(evt);
}
else {
_this.fire('blur', _this.props.value);
}
};
_this.handleFocus = function () {
_this.fire('focus', _this.props.value);
_this.handleFocus = function (evt) {
if (_this.props.onFocus) {
_this.props.onFocus(evt);
}
else {
_this.fire('focus', _this.props.value);
}
};
_this.handleChange = function (evt) {
_this.__$value = evt.target.value;
_this.props.value = evt.target.value;
_this.fire('change', _this.props.value);
if (_this.props.onChange) {
_this.props.onChange(evt);
}
else {
_this.fire('change', _this.props.value);
}
};
_this.handleInput = function (evt) {
evt.stopPropagation();
_this.__$value = evt.target.value;
_this.props.value = evt.target.value;
_this.fire('input', _this.props.value);
if (_this.props.onInput) {
_this.props.onInput(evt);
}
else {
_this.fire('input', _this.props.value);
}
if (_this.props.maxLength) {
_this.valueLength = evt.target.value.length;
_this.update();

File diff suppressed because one or more lines are too long

View File

@ -70,25 +70,45 @@ export default class Input extends WeElement<Props>{
valueLength = 0
handleBlur = () => {
this.fire('blur', this.props.value)
handleBlur = (evt) => {
if (this.props.onBlur) {
this.props.onBlur(evt)
} else {
this.fire('blur', this.props.value)
}
}
handleFocus = () => {
this.fire('focus', this.props.value)
handleFocus = (evt) => {
if (this.props.onFocus) {
this.props.onFocus(evt)
} else {
this.fire('focus', this.props.value)
}
}
handleChange = (evt) => {
this.__$value = evt.target.value
this.props.value = evt.target.value
this.fire('change', this.props.value)
if (this.props.onChange) {
this.props.onChange(evt)
} else {
this.fire('change', this.props.value)
}
}
handleInput = (evt) => {
evt.stopPropagation()
this.__$value = evt.target.value
this.props.value = evt.target.value
this.fire('input', this.props.value)
if (this.props.onInput) {
this.props.onInput(evt)
} else {
this.fire('input', this.props.value)
}
if (this.props.maxLength) {
this.valueLength = evt.target.value.length
this.update()

View File

@ -1,4 +1,4 @@
var e=Object.defineProperty,n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,i=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;import{h as r,e as a,b as l,W as s,j as c,d as p,t as d,s as u}from"./vendor.97211ee9.js";import"./index.esm.2a7f07e8.js";
var e=Object.defineProperty,n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,i=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;import{h as r,e as a,b as l,W as s,j as c,d as p,t as d,s as u}from"./vendor.97211ee9.js";import"./index.esm.6be211d5.js";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
import{_ as e}from"./index.d90d7f3d.js";import{W as t,h as i,t as a,s as n,b as s}from"./vendor.97211ee9.js";import"./index.esm.3739927d.js";import"./index.esm.cb491051.js";import"./index.esm.0be7bcf8.js";var d=Object.defineProperty,r=Object.getOwnPropertyDescriptor;let o=class extends t{constructor(){super(...arguments),this.dataSource=[{id:1,name:"xwang",age:18,address:"Tencent"},{id:2,name:"dntzhang",age:12,address:"Tencent",$config:{bgColor:"rgb(247 176 176 / 32%)"}},{id:3,name:"lucy",age:12,address:"Tencent"},{id:4,name:"john",age:12,address:"Tencent",$config:{bgColor:"rgb(230 162 60 / 34%)"}},{id:5,name:"tim",age:12,address:"Tencent"},{id:6,name:"tim",age:12,address:"Tencent"},{id:7,name:"tim",age:12,address:"Tencent"},{id:8,name:"tim",age:12,address:"Tencent"},{id:9,name:"xwang",age:18,address:"Tencent"},{id:10,name:"dntzhang",age:12,address:"Tencent",$config:{bgColor:"rgb(247 176 176 / 32%)"}},{id:11,name:"lucy",age:12,address:"Tencent"},{id:12,name:"john",age:12,address:"Tencent",$config:{bgColor:"rgb(230 162 60 / 34%)"}},{id:13,name:"tim",age:12,address:"Tencent"},{id:14,name:"tim",age:12,address:"Tencent"},{id:15,name:"tim",age:12,address:"Tencent"},{id:16,name:"tim",age:12,address:"Tencent"}],this.columns=[{title:"ID",render:e=>i("strong",null,e.id)},{title:"Name",width:120,key:"name",editable:!0},{title:"Age",width:90,key:"age",editable:!0},{title:"Address",width:290,key:"address",editable:!0},{title:"操作",align:"right",render:e=>i("o-tooltip",{content:"删除"+e.name},i("o-icon-delete",{"data-item-id":e.id,_onclick:this.onClick,style:"cursor:pointer;font-size:20px;"}))}],this.paging=!0,this.pageSize=5,this.pageIndex=0,this.filterData=[],this.change=e=>{this.pageIndex=e.detail,this.renderTable()},this.onClick=e=>{this.table.deleteRowById(e.currentTarget.dataset.itemId)},this.exportExcel=()=>{e((()=>import("./export-excel.b093e625.js")),["assets/export-excel.b093e625.js","assets/vendor.97211ee9.js","assets/___vite-browser-external_commonjs-proxy.80177ef5.js"]).then((e=>{e.exportTableToExcel(this.table.rootNode.querySelector("table"))}))}}renderTable(){this.filterData=this.dataSource.slice(this.pageIndex*this.pageSize,this.pageIndex*this.pageSize+this.pageSize),this.update()}installed(){this.renderTable()}deleteItemById(e){const t=this.dataSource.indexOf(this.dataSource.find((t=>t.id===e)));-1!==t&&this.dataSource.splice(t,1),this.update()}render(){return i("div",{class:a`pl-0.5`},i("div",{class:a`relative h-10 text-right`},i("o-button",{class:a`relative top-2 right-2`,size:"mini",onClick:this.exportExcel},"导出Excel")),i("div",{class:a`px-2`},i("o-table",{ref:e=>this.table=e,checkbox:!1,stripe:!1,border:!1,compact:!1,columns:this.columns,dataSource:this.filterData}),i("div",{class:a`mt-3 text-right`},i("o-pagination",{total:this.dataSource.length,"current-page":this.pageIndex,"page-size":this.pageSize,onchange:this.change}))))}};o.css=n.target,o=((e,t,i,a)=>{for(var n,s=a>1?void 0:a?r(t,i):t,o=e.length-1;o>=0;o--)(n=e[o])&&(s=(a?n(t,i,s):n(s))||s);return a&&s&&d(t,i,s),s})([s("inline-editing")],o);export{o as default};
import{_ as e}from"./index.fa8c5b16.js";import{W as t,h as a,t as i,s as n,b as s}from"./vendor.97211ee9.js";import"./index.esm.3739927d.js";import"./index.esm.cb491051.js";import"./index.esm.0be7bcf8.js";var d=Object.defineProperty,r=Object.getOwnPropertyDescriptor;let o=class extends t{constructor(){super(...arguments),this.dataSource=[{id:1,name:"xwang",age:18,address:"Tencent"},{id:2,name:"dntzhang",age:12,address:"Tencent",$config:{bgColor:"rgb(247 176 176 / 32%)"}},{id:3,name:"lucy",age:12,address:"Tencent"},{id:4,name:"john",age:12,address:"Tencent",$config:{bgColor:"rgb(230 162 60 / 34%)"}},{id:5,name:"tim",age:12,address:"Tencent"},{id:6,name:"tim",age:12,address:"Tencent"},{id:7,name:"tim",age:12,address:"Tencent"},{id:8,name:"tim",age:12,address:"Tencent"},{id:9,name:"xwang",age:18,address:"Tencent"},{id:10,name:"dntzhang",age:12,address:"Tencent",$config:{bgColor:"rgb(247 176 176 / 32%)"}},{id:11,name:"lucy",age:12,address:"Tencent"},{id:12,name:"john",age:12,address:"Tencent",$config:{bgColor:"rgb(230 162 60 / 34%)"}},{id:13,name:"tim",age:12,address:"Tencent"},{id:14,name:"tim",age:12,address:"Tencent"},{id:15,name:"tim",age:12,address:"Tencent"},{id:16,name:"tim",age:12,address:"Tencent"}],this.columns=[{title:"ID",render:e=>a("strong",null,e.id)},{title:"Name",width:120,key:"name",editable:!0},{title:"Age",width:90,key:"age",editable:!0},{title:"Address",width:290,key:"address",editable:!0},{title:"操作",align:"right",render:e=>a("o-tooltip",{content:"删除"+e.name},a("o-icon-delete",{"data-item-id":e.id,_onclick:this.onClick,style:"cursor:pointer;font-size:20px;"}))}],this.paging=!0,this.pageSize=5,this.pageIndex=0,this.filterData=[],this.change=e=>{this.pageIndex=e.detail,this.renderTable()},this.onClick=e=>{this.table.deleteRowById(e.currentTarget.dataset.itemId)},this.exportExcel=()=>{e((()=>import("./export-excel.b093e625.js")),["assets/export-excel.b093e625.js","assets/vendor.97211ee9.js","assets/___vite-browser-external_commonjs-proxy.80177ef5.js"]).then((e=>{e.exportTableToExcel(this.table.rootNode.querySelector("table"))}))}}renderTable(){this.filterData=this.dataSource.slice(this.pageIndex*this.pageSize,this.pageIndex*this.pageSize+this.pageSize),this.update()}installed(){this.renderTable()}deleteItemById(e){const t=this.dataSource.indexOf(this.dataSource.find((t=>t.id===e)));-1!==t&&this.dataSource.splice(t,1),this.update()}render(){return a("div",{class:i`pl-0.5`},a("div",{class:i`relative h-10 text-right`},a("o-button",{class:i`relative top-2 right-2`,size:"mini",onClick:this.exportExcel},"导出Excel")),a("div",{class:i`px-2`},a("o-table",{ref:e=>this.table=e,checkbox:!1,stripe:!1,border:!1,compact:!1,columns:this.columns,dataSource:this.filterData}),a("div",{class:i`mt-3 text-right`},a("o-pagination",{total:this.dataSource.length,"current-page":this.pageIndex,"page-size":this.pageSize,onchange:this.change}))))}};o.css=n.target,o=((e,t,a,i)=>{for(var n,s=i>1?void 0:i?r(t,a):t,o=e.length-1;o>=0;o--)(n=e[o])&&(s=(i?n(t,a,s):n(s))||s);return i&&s&&d(t,a,s),s})([s("inline-editing")],o);export{o as default};

View File

@ -1,4 +1,4 @@
import{e as n,h as e,b as o,W as r,t as i,s as t}from"./vendor.97211ee9.js";import"./index.esm.2a7f07e8.js";import"./admin-docs.e07f425e.js";import"./container.e56529f6.js";import"./___vite-browser-external_commonjs-proxy.80177ef5.js";
import{e as n,h as e,b as o,W as r,t as i,s as t}from"./vendor.97211ee9.js";import"./index.esm.6be211d5.js";import"./admin-docs.e07f425e.js";import"./container.e56529f6.js";import"./___vite-browser-external_commonjs-proxy.80177ef5.js";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OMI ADMIN</title>
<script type="module" crossorigin src="./assets/index.d90d7f3d.js"></script>
<script type="module" crossorigin src="./assets/index.fa8c5b16.js"></script>
<link rel="modulepreload" href="./assets/vendor.97211ee9.js">
<link rel="stylesheet" href="./assets/index.e4c38a11.css">
</head>

View File

@ -28,7 +28,7 @@
"@omiu/hamburger-menu": "^0.0.5",
"@omiu/icon": "^0.0.3",
"@omiu/image": "^0.0.2",
"@omiu/input": "^0.0.8",
"@omiu/input": "^0.0.12",
"@omiu/link": "^0.0.4",
"@omiu/loading": "0.0.2",
"@omiu/pagination": "^0.0.5",