123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- "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;
|