@cainiaofe/cn-ui-m
Version:
36 lines (35 loc) • 1.58 kB
JavaScript
import { __spreadArray } from "tslib";
import * as React from 'react';
import { CnDemoPage, CnInputTextArea, CnDemoBlock } from "../../..";
var _evts = [];
export var 事件回调 = function () {
var _a = React.useState([]), evts = _a[0], setEvts = _a[1];
var addEvt = function (type, value) {
if (value === void 0) { value = ''; }
_evts.push({ type: type, value: value });
// @ts-ignore
setEvts(__spreadArray([], _evts, true));
};
return (React.createElement(CnDemoPage, { title: "\u4E8B\u4EF6\u56DE\u8C03" },
React.createElement(CnDemoBlock, { title: "\u4E8B\u4EF6\u56DE\u8C03" },
React.createElement(CnInputTextArea, { placeholder: "\u8BF7\u8F93\u5165", onFocus: function () {
addEvt('focus');
}, onBlur: function () {
addEvt('blur');
}, onConfirm: function (val) {
addEvt('confirm', val);
}, onClear: function () {
addEvt('clear');
}, onChange: function (val) {
addEvt('change', val);
} })),
React.createElement(CnDemoBlock, { title: "\u4E8B\u4EF6\u8BB0\u5F55" },
React.createElement("div", null, evts.map(function (item, index) {
return (React.createElement("div", { key: "evt-".concat(index) },
"[",
item.type,
"]",
item.value || ''));
})))));
};
export default { title: 'demo/CnInputTextarea' };