You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.0 KiB
128 lines
3.0 KiB
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _utils = require("../utils");
|
|
|
|
var _functional = require("../utils/functional");
|
|
|
|
var _event = require("../utils/dom/event");
|
|
|
|
var _field = _interopRequireDefault(require("../field"));
|
|
|
|
// Utils
|
|
// Components
|
|
var _createNamespace = (0, _utils.createNamespace)('search'),
|
|
createComponent = _createNamespace[0],
|
|
bem = _createNamespace[1],
|
|
t = _createNamespace[2];
|
|
|
|
function Search(h, props, slots, ctx) {
|
|
function Label() {
|
|
if (slots.label || props.label) {
|
|
return h("div", {
|
|
"class": bem('label')
|
|
}, [slots.label ? slots.label() : props.label]);
|
|
}
|
|
}
|
|
|
|
function Action() {
|
|
if (!props.showAction) {
|
|
return;
|
|
}
|
|
|
|
function onCancel() {
|
|
if (slots.action) {
|
|
return;
|
|
}
|
|
|
|
(0, _functional.emit)(ctx, 'input', '');
|
|
(0, _functional.emit)(ctx, 'cancel');
|
|
}
|
|
|
|
return h("div", {
|
|
"class": bem('action'),
|
|
"attrs": {
|
|
"role": "button",
|
|
"tabindex": "0"
|
|
},
|
|
"on": {
|
|
"click": onCancel
|
|
}
|
|
}, [slots.action ? slots.action() : props.actionText || t('cancel')]);
|
|
}
|
|
|
|
var fieldData = {
|
|
attrs: ctx.data.attrs,
|
|
on: (0, _extends2.default)({}, ctx.listeners, {
|
|
keypress: function keypress(event) {
|
|
// press enter
|
|
if (event.keyCode === 13) {
|
|
(0, _event.preventDefault)(event);
|
|
(0, _functional.emit)(ctx, 'search', props.value);
|
|
}
|
|
|
|
(0, _functional.emit)(ctx, 'keypress', event);
|
|
}
|
|
})
|
|
};
|
|
var inheritData = (0, _functional.inherit)(ctx);
|
|
inheritData.attrs = undefined;
|
|
return h("div", (0, _babelHelperVueJsxMergeProps.default)([{
|
|
"class": bem({
|
|
'show-action': props.showAction
|
|
}),
|
|
"style": {
|
|
background: props.background
|
|
}
|
|
}, inheritData]), [slots.left == null ? void 0 : slots.left(), h("div", {
|
|
"class": bem('content', props.shape)
|
|
}, [Label(), h(_field.default, (0, _babelHelperVueJsxMergeProps.default)([{
|
|
"attrs": {
|
|
"type": "search",
|
|
"border": false,
|
|
"value": props.value,
|
|
"leftIcon": props.leftIcon,
|
|
"rightIcon": props.rightIcon,
|
|
"clearable": props.clearable,
|
|
"clearTrigger": props.clearTrigger
|
|
},
|
|
"scopedSlots": {
|
|
'left-icon': slots['left-icon'],
|
|
'right-icon': slots['right-icon']
|
|
}
|
|
}, fieldData]))]), Action()]);
|
|
}
|
|
|
|
Search.props = {
|
|
value: String,
|
|
label: String,
|
|
rightIcon: String,
|
|
actionText: String,
|
|
background: String,
|
|
showAction: Boolean,
|
|
clearTrigger: String,
|
|
shape: {
|
|
type: String,
|
|
default: 'square'
|
|
},
|
|
clearable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
leftIcon: {
|
|
type: String,
|
|
default: 'search'
|
|
}
|
|
};
|
|
|
|
var _default = createComponent(Search);
|
|
|
|
exports.default = _default; |