xdesign-vue-next
Version:
XDesign Component for vue-next
192 lines (188 loc) • 8.58 kB
JavaScript
/**
* xdesign v1.0.6
* (c) 2023 xdesign
* @license MIT
*/
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, computed, createVNode, mergeProps } from 'vue';
import { Popup } from '../popup/index.js';
import props from './props.js';
import useSingle from './useSingle.js';
import useMultiple from './useMultiple.js';
import useOverlayInnerStyle from './useOverlayInnerStyle.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/slicedToArray';
import '@popperjs/core';
import 'lodash/isFunction';
import 'lodash/isObject';
import 'lodash/debounce';
import 'lodash/isString';
import '../hooks/useVModel.js';
import 'lodash/kebabCase';
import '../utils/dom.js';
import '../_chunks/dep-3a1cce9f.js';
import 'lodash/isArray';
import '../utils/easing.js';
import '../_common/js/utils/set-style.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../popup/props.js';
import '../hooks/useResizeObserver.js';
import '../utils/withInstall.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/en_US.js';
import 'lodash/camelCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/pick';
import '../input/index.js';
import '../input/input.js';
import '../_chunks/dep-fb0628ce.js';
import '../_chunks/dep-eade0dcf.js';
import '../input/props.js';
import '../form/hooks.js';
import '../input/useInput.js';
import '../form/const.js';
import '../input/useLengthLimit.js';
import '../_common/js/log/log.js';
import '../_common/js/utils/helper.js';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import '../input/useInputEventHandler.js';
import '../input/useInputWidth.js';
import '../input/input-group.js';
import '../input/input-group-props.js';
import '../loading/index.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../loading/props.js';
import '../hooks/useTeleport.js';
import '../hooks/useDefaultValue.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../_chunks/dep-ae5efda0.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '@babel/runtime/helpers/typeof';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var useComponentClassName = function useComponentClassName() {
return {
NAME_CLASS: usePrefixClass("select-input"),
BASE_CLASS_BORDERLESS: usePrefixClass("select-input--borderless"),
BASE_CLASS_MULTIPLE: usePrefixClass("select-input--multiple"),
BASE_CLASS_POPUP_VISIBLE: usePrefixClass("select-input--popup-visible"),
BASE_CLASS_EMPTY: usePrefixClass("select-input--empty")
};
};
var _SelectInput = defineComponent({
name: "XSelectInput",
props: _objectSpread({}, props),
setup: function setup(props2, context) {
var _useComponentClassNam = useComponentClassName(),
NAME_CLASS = _useComponentClassNam.NAME_CLASS,
BASE_CLASS_BORDERLESS = _useComponentClassNam.BASE_CLASS_BORDERLESS,
BASE_CLASS_MULTIPLE = _useComponentClassNam.BASE_CLASS_MULTIPLE,
BASE_CLASS_POPUP_VISIBLE = _useComponentClassNam.BASE_CLASS_POPUP_VISIBLE,
BASE_CLASS_EMPTY = _useComponentClassNam.BASE_CLASS_EMPTY;
var classPrefix = usePrefixClass();
var renderTNodeJSX = useTNodeJSX();
var selectInputRef = ref();
var popupRef = ref();
var _toRefs = toRefs(props2),
multiple = _toRefs.multiple,
value = _toRefs.value,
popupVisible = _toRefs.popupVisible,
borderless = _toRefs.borderless;
var _useSingle = useSingle(props2, context),
commonInputProps = _useSingle.commonInputProps,
onInnerClear = _useSingle.onInnerClear,
renderSelectSingle = _useSingle.renderSelectSingle;
var _useMultiple = useMultiple(props2, context),
renderSelectMultiple = _useMultiple.renderSelectMultiple;
var _useOverlayInnerStyle = useOverlayInnerStyle(props2),
tOverlayInnerStyle = _useOverlayInnerStyle.tOverlayInnerStyle,
innerPopupVisible = _useOverlayInnerStyle.innerPopupVisible,
onInnerPopupVisibleChange = _useOverlayInnerStyle.onInnerPopupVisibleChange;
var classes = computed(function () {
var _popupVisible$value, _ref;
return ["".concat(NAME_CLASS.value), (_ref = {}, _defineProperty(_ref, BASE_CLASS_MULTIPLE.value, multiple.value), _defineProperty(_ref, BASE_CLASS_BORDERLESS.value, borderless.value), _defineProperty(_ref, BASE_CLASS_POPUP_VISIBLE.value, (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty(_ref, BASE_CLASS_EMPTY.value, value.value instanceof Array ? !value.value.length : !value.value), _ref)];
});
return {
classPrefix: classPrefix,
NAME_CLASS: NAME_CLASS,
innerPopupVisible: innerPopupVisible,
commonInputProps: commonInputProps,
tOverlayInnerStyle: tOverlayInnerStyle,
selectInputRef: selectInputRef,
popupRef: popupRef,
classes: classes,
onInnerClear: onInnerClear,
renderTNodeJSX: renderTNodeJSX,
renderSelectSingle: renderSelectSingle,
renderSelectMultiple: renderSelectMultiple,
onInnerPopupVisibleChange: onInnerPopupVisibleChange
};
},
render: function render() {
var _this$popupVisible,
_this$popupProps,
_this = this;
var visibleProps = {
visible: (_this$popupVisible = this.popupVisible) !== null && _this$popupVisible !== void 0 ? _this$popupVisible : this.innerPopupVisible
};
var mainContent = createVNode(Popup, mergeProps({
"ref": "popupRef",
"trigger": ((_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.trigger) || "click",
"placement": "bottom-left"
}, visibleProps, {
"content": this.panel,
"hideEmptyPopup": true
}, _objectSpread(_objectSpread({
onVisibleChange: this.onInnerPopupVisibleChange
}, this.popupProps), {}, {
overlayInnerStyle: this.tOverlayInnerStyle
})), _objectSpread({
"default": function _default() {
return [_this.multiple ? _this.renderSelectMultiple({
commonInputProps: _this.commonInputProps,
onInnerClear: _this.onInnerClear,
popupVisible: visibleProps.visible,
allowInput: _this.allowInput
}) : _this.renderSelectSingle(visibleProps.visible)];
}
}, _objectSpread(_objectSpread({}, this.$slots), {}, {
content: this.$slots.panel
})));
var tipsNode = this.renderTNodeJSX("tips");
var tipsClasses = ["".concat(this.classPrefix, "-input__tips"), "".concat(this.classPrefix, "-tips"), "".concat(this.classPrefix, "-is-").concat(this.status)];
return createVNode("div", {
"ref": "selectInputRef",
"class": this.classes
}, [mainContent, tipsNode && createVNode("div", {
"class": tipsClasses
}, [tipsNode])]);
}
});
export { _SelectInput as default };
//# sourceMappingURL=select-input.js.map