UNPKG

xdesign-vue-next

Version:

XDesign Component for vue-next

235 lines (231 loc) 9.93 kB
/** * xdesign v1.0.6 * (c) 2023 xdesign * @license MIT */ import { _ as __unplugin_components_0 } from '../_chunks/dep-095b410b.js'; import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, ref, toRefs, computed, watch, createVNode } from 'vue'; import dayjs from 'dayjs'; import { c as customParseFormat } from '../_chunks/dep-78e63d0d.js'; import _TimePickerPanel from './panel/time-picker-panel.js'; import { SelectInput } from '../select-input/index.js'; import { validateInputValue, formatInputValue } from '../_common/js/time-picker/utils.js'; import props from './props.js'; import useVModel from '../hooks/useVModel.js'; import { useFormDisabled } from '../form/hooks.js'; import { usePrefixClass } from '../hooks/useConfig.js'; import { useConfig } from '../config-provider/useConfig.js'; import '../_chunks/dep-3a1cce9f.js'; import '../_common/js/time-picker/const.js'; import './panel/props.js'; import 'lodash/isBoolean'; import './panel/single-panel.js'; import 'lodash/debounce'; import 'lodash/range'; import 'lodash/padStart'; import '../button/button.js'; import '@babel/runtime/helpers/toConsumableArray'; 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 '../_common/js/utils/set-style.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import 'lodash/isString'; import 'lodash/isNull'; import 'lodash/isUndefined'; import 'lodash/isNumber'; import 'lodash/isArray'; import '../utils/dom.js'; import 'lodash/isFunction'; import '../utils/easing.js'; import '../utils/render-tnode.js'; import 'lodash/isEmpty'; import 'lodash/isObject'; import 'lodash/camelCase'; import 'lodash/kebabCase'; import '../loading/props.js'; import '../hooks/useTeleport.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 '../utils/withInstall.js'; import '../button/props.js'; import '../hooks/useRipple.js'; import '../hooks/useKeepAnimation.js'; import '../utils/set-style.js'; import '../hooks/tnode.js'; import '../hooks/useDisabled.js'; import '../select-input/select-input.js'; import '../popup/index.js'; import '../popup/popup.js'; import '@popperjs/core'; import '../popup/container.js'; import '../popup/props.js'; import '../hooks/useResizeObserver.js'; import '../select-input/props.js'; import '../select-input/useSingle.js'; 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 '../input/useInput.js'; import '../form/const.js'; import '../input/useLengthLimit.js'; import '../_common/js/log/log.js'; import '../input/useInputEventHandler.js'; import '../input/useInputWidth.js'; import '../input/input-group.js'; import '../input/input-group-props.js'; import '../hooks/useDefaultValue.js'; import '../select-input/useMultiple.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 '../select-input/useOverlayInnerStyle.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; } dayjs.extend(customParseFormat); var _TimePicker = defineComponent({ name: "XTimePicker", props: _objectSpread({}, props), setup: function setup(props2) { var currentValue = ref(""); var isShowPanel = ref(false); var _useConfig = useConfig("timePicker"), globalConfig = _useConfig.globalConfig; var _toRefs = toRefs(props2), value = _toRefs.value, modelValue = _toRefs.modelValue; var _useVModel = useVModel(value, modelValue, props2.defaultValue, props2.onChange), _useVModel2 = _slicedToArray(_useVModel, 2), innerValue = _useVModel2[0], setInnerValue = _useVModel2[1]; var disabled = useFormDisabled(); var _toRefs2 = toRefs(props2), allowInput = _toRefs2.allowInput, format = _toRefs2.format; var _useConfig2 = useConfig("classPrefix"), classPrefix = _useConfig2.classPrefix; var componentName = usePrefixClass("time-picker"); var inputClasses = computed(function () { return ["".concat(componentName.value, "__group"), _defineProperty({}, "".concat(classPrefix.value, "-is-focused"), isShowPanel.value)]; }); var handleShowPopup = function handleShowPopup(visible, context) { var _props2$onOpen, _props2$onClose; isShowPanel.value = visible; visible ? (_props2$onOpen = props2.onOpen) === null || _props2$onOpen === void 0 ? void 0 : _props2$onOpen.call(props2, context) : (_props2$onClose = props2.onClose) === null || _props2$onClose === void 0 ? void 0 : _props2$onClose.call(props2, context); }; var handleClear = function handleClear(context) { var e = context.e; e.stopPropagation(); currentValue.value = null; setInnerValue(null); }; var handleInputChange = function handleInputChange(value2) { currentValue.value = value2; }; var handleInputBlur = function handleInputBlur(value2, _ref2) { var _props2$onBlur; var e = _ref2.e; if (allowInput.value) { var isValidTime = validateInputValue(currentValue.value, format.value); if (isValidTime) { setInnerValue(formatInputValue(currentValue.value, format.value)); } } (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 ? void 0 : _props2$onBlur.call(props2, { value: String(value2), e: e }); }; var handleClickConfirm = function handleClickConfirm() { var isValidTime = validateInputValue(currentValue.value, format.value); if (isValidTime) setInnerValue(currentValue.value); isShowPanel.value = false; }; var handlePanelChange = function handlePanelChange(v, e) { var _props2$onPick; currentValue.value = v; (_props2$onPick = props2.onPick) === null || _props2$onPick === void 0 ? void 0 : _props2$onPick.call(props2, v, { e: e }); }; watch(function () { return isShowPanel.value; }, function () { var _innerValue$value; currentValue.value = isShowPanel.value ? (_innerValue$value = innerValue.value) !== null && _innerValue$value !== void 0 ? _innerValue$value : "" : ""; }); return function () { var _innerValue$value2, _innerValue$value3; return createVNode("div", { "class": componentName.value }, [createVNode(SelectInput, { "onFocus": props2.onFocus, "onClear": handleClear, "disabled": disabled.value, "clearable": props2.clearable, "allowInput": allowInput.value, "className": inputClasses.value, "suffixIcon": function suffixIcon() { return createVNode(__unplugin_components_0, null, null); }, "popupVisible": isShowPanel.value, "onInputChange": handleInputChange, "onBlur": handleInputBlur, "onPopupVisibleChange": handleShowPopup, "placeholder": !innerValue.value ? props2.placeholder || globalConfig.value.placeholder : void 0, "value": isShowPanel.value ? currentValue.value : (_innerValue$value2 = innerValue.value) !== null && _innerValue$value2 !== void 0 ? _innerValue$value2 : void 0, "inputValue": isShowPanel.value ? currentValue.value : (_innerValue$value3 = innerValue.value) !== null && _innerValue$value3 !== void 0 ? _innerValue$value3 : void 0, "inputProps": _objectSpread(_objectSpread({}, props2.inputProps), {}, { size: props2.size }), "popupProps": _objectSpread({ overlayInnerStyle: { width: "auto", padding: 0 } }, props2.popupProps), "status": props2.status, "tips": props2.tips, "panel": function panel() { return createVNode(_TimePickerPanel, { "steps": props2.steps, "format": format.value, "value": currentValue.value, "isFooterDisplay": true, "isShowPanel": isShowPanel.value, "disableTime": props2.disableTime, "onChange": handlePanelChange, "hideDisabledTime": props2.hideDisabledTime, "handleConfirmClick": handleClickConfirm }, null); } }, null)]); }; } }); export { _TimePicker as default }; //# sourceMappingURL=time-picker.js.map