UNPKG

@vnmfify/core

Version:

```shell npm i @vnmfify/core -S ```

114 lines (102 loc) 5.23 kB
import _isBoolean from "lodash/isBoolean"; var _excluded = ["className", "value", "icon", "rightIcon", "label", "shape", "maxlength", "autoFocus", "focus", "disabled", "readonly", "placeholder", "placeholderClassName", "clearable", "clearIcon", "clearTrigger", "inputAlign", "inputColor", "feedback", "action", "onClear", "onCancel", "onSearch", "onChange", "onFocus", "onBlur"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import { Search as SearchIcon } from "@vnmfify/icons"; import { View } from "@vnxjs/components"; import classNames from "classnames"; import * as React from "react"; import Field from "../field"; import Input from "../input"; import { prefixClassname } from "../styles"; import { preventDefault } from "../utils/dom/event"; import { getLogger } from "../utils/logger"; var { deprecated } = getLogger("Search"); function Search(props) { var { className, value, icon = /*#__PURE__*/React.createElement(SearchIcon, null), rightIcon, label, shape, maxlength, autoFocus, focus, disabled, readonly, placeholder, placeholderClassName, clearable = true, clearIcon, clearTrigger, inputAlign, inputColor, feedback, action, onClear, onCancel, onSearch, onChange, onFocus, onBlur } = props, restProps = _objectWithoutProperties(props, _excluded); if (shape === "round") { deprecated('Use the shape="rounded" prop instead of the shape="round" prop'); } function handleSearch(event) { preventDefault(event); onSearch === null || onSearch === void 0 ? void 0 : onSearch(event); } return /*#__PURE__*/React.createElement(View, _objectSpread({ className: classNames(prefixClassname("search"), { [prefixClassname("search--action")]: action }, className) }, restProps), /*#__PURE__*/React.createElement(View, { className: classNames(prefixClassname("search__content"), { [prefixClassname("search__content--square")]: shape === "square", [prefixClassname("search__content--rounded")]: shape === "rounded" || shape === "round" }) }, label && /*#__PURE__*/React.createElement(View, { className: prefixClassname("search__label"), children: label }), /*#__PURE__*/React.createElement(Field, { className: prefixClassname("search__field"), icon: icon, rightIcon: rightIcon, feedback: feedback }, /*#__PURE__*/React.createElement(Input, { className: prefixClassname("search__input"), placeholderClassName: placeholderClassName, value: value, maxlength: maxlength, placeholder: placeholder, clearable: clearable, clearIcon: clearIcon, clearTrigger: clearTrigger, align: inputAlign, color: inputColor, autoFocus: autoFocus, focus: focus, disabled: disabled, readonly: readonly, confirmType: "search", onConfirm: handleSearch, onClear: onClear, onChange: onChange, onFocus: onFocus, onBlur: onBlur }))), action && /*#__PURE__*/React.createElement(View, { className: prefixClassname("search__action"), children: _isBoolean(action) ? "Cancel" : action, onClick: _isBoolean(action) ? onCancel : undefined })); } export default Search; //# sourceMappingURL=search.js.map