UNPKG

tdesign-vue

Version:
281 lines (277 loc) 11 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, ref, computed, toRefs, watch } from '@vue/composition-api'; import dayjs from 'dayjs'; import { c as customParseFormat } from '../_chunks/dep-655d809c.js'; import { TimeIcon } from 'tdesign-icons-vue'; 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 { useVModel } from '../hooks/useVModel.js'; import { usePrefixClass } from '../hooks/useConfig.js'; import { useGlobalIcon } from '../hooks/useGlobalIcon.js'; import { useFormDisabled } from '../hooks/useFormDisabled.js'; import props from './props.js'; import { useConfig } from '../config-provider/useConfig.js'; import '../_chunks/dep-fdb1b253.js'; import '../_common/js/time-picker/const.js'; import './panel/props.js'; import './panel/single-panel.js'; import 'lodash-es'; import '../button/button.js'; import '../loading/index.js'; import '../loading/directive.js'; import '../loading/plugin.js'; import 'vue'; import '../loading/loading.js'; import '../loading/icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/setStyle.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../config-provider/config-receiver.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-ba613a02.js'; import '@babel/runtime/helpers/typeof'; import '../_common/js/global-config/t.js'; import '../utils/mixins.js'; import '../utils/dom.js'; import 'raf'; import '../utils/easing.js'; import '../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '../utils/transfer-dom.js'; import '../loading/props.js'; import '../config.js'; import '../utils/withInstall.js'; import '../button/props.js'; import '../utils/ripple.js'; import '../_common/js/log/log.js'; import '../select-input/select-input.js'; import '../_chunks/dep-6a4dc7bb.js'; import '../popup/index.js'; import '../popup/popup.js'; import '@popperjs/core'; import '../utils/helper.js'; import '../popup/props.js'; import '../popup/container.js'; import '../utils/event.js'; import '../popup/utils.js'; import '../utils/map-props.js'; import '../popup/plugin.js'; import '../select-input/props.js'; import '../select-input/useSingle.js'; import '../input/index.js'; import '../input/input.js'; import '../input/props.js'; import '../input/input-group.js'; import '../hooks/tnode.js'; import '../hooks/render-tnode.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 'tinycolor2'; import '../tag/props.js'; import '../tag/check-tag.js'; import '../tag/check-tag-props.js'; import '../_common/js/common.js'; import '../tag/check-tag-group.js'; import '../tag/check-tag-group-props.js'; import '../tag-input/hooks/useHover.js'; import '../tag-input/hooks/useDragSorter.js'; import '../select-input/useOverlayInnerStyle.js'; import '../_chunks/dep-84c94da7.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } dayjs.extend(customParseFormat); var _TimePicker = defineComponent({ name: "TTimePicker", props: _objectSpread({}, props), setup: function setup(props2, ctx) { var _useConfig = useConfig("classPrefix"), classPrefix = _useConfig.classPrefix; var componentName = usePrefixClass("time-picker"); var _useGlobalIcon = useGlobalIcon({ TimeIcon: TimeIcon }), TimeIcon$1 = _useGlobalIcon.TimeIcon; var _useFormDisabled = useFormDisabled(), formDisabled = _useFormDisabled.formDisabled; var currentValue = ref(""); var isShowPanel = ref(false); var _useConfig2 = useConfig("timePicker"), global = _useConfig2.global; var isDisabled = computed(function () { return formDisabled.value || props2.disabled; }); var _toRefs = toRefs(props2), value = _toRefs.value; var _useVModel = useVModel(value, props2.defaultValue, props2.onChange, "change"), _useVModel2 = _slicedToArray(_useVModel, 2), innerValue = _useVModel2[0], setInnerValue = _useVModel2[1]; var inputClasses = computed(function () { return ["".concat(componentName.value, "__group"), _defineProperty({}, "".concat(classPrefix.value, "-is-focused"), isShowPanel.value)]; }); var handleShowPopup = function handleShowPopup(visible, context) { isShowPanel.value = visible; if (visible) { var _props2$onOpen; (_props2$onOpen = props2.onOpen) === null || _props2$onOpen === void 0 || _props2$onOpen.call(props2, context); ctx.emit("open", context); } else { var _props2$onClose; (_props2$onClose = props2.onClose) === null || _props2$onClose === void 0 || _props2$onClose.call(props2, context); ctx.emit("close", 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 (props2.allowInput) { var isValidTime = validateInputValue(currentValue.value, props2.format); if (isValidTime) { setInnerValue(formatInputValue(currentValue.value, props2.format)); } } (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 || _props2$onBlur.call(props2, { value: value2, e: e }); ctx.emit("blur", { value: value2, e: e }); }; var handleClickConfirm = function handleClickConfirm() { var isValidTime = validateInputValue(currentValue.value, props2.format); if (isValidTime) setInnerValue(currentValue.value); isShowPanel.value = false; }; var handlePanelChange = function handlePanelChange(v) { currentValue.value = v; }; var handleOnFocus = function handleOnFocus(context) { var _props2$onFocus; (_props2$onFocus = props2.onFocus) === null || _props2$onFocus === void 0 || _props2$onFocus.call(props2, context); ctx.emit("focus", context); }; var handleOnPick = function handleOnPick(v, e) { var _props2$onPick; (_props2$onPick = props2.onPick) === null || _props2$onPick === void 0 || _props2$onPick.call(props2, v, { e: e }); ctx.emit("pick", 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 { handleClickConfirm: handleClickConfirm, handlePanelChange: handlePanelChange, handleInputBlur: handleInputBlur, handleInputChange: handleInputChange, handleClear: handleClear, handleShowPopup: handleShowPopup, handleOnFocus: handleOnFocus, handleOnPick: handleOnPick, inputClasses: inputClasses, componentName: componentName, innerValue: innerValue, isShowPanel: isShowPanel, global: global, currentValue: currentValue, TimeIcon: TimeIcon$1, isDisabled: isDisabled }; }, render: function render() { var _this$innerValue, _this$innerValue2, _this = this; var h = arguments[0]; var TimeIcon = this.TimeIcon; return h("div", { "class": this.componentName }, [h(SelectInput, { "props": _objectSpread({}, { onFocus: this.handleOnFocus, onClear: this.handleClear, onBlur: this.handleInputBlur, onInputChange: this.handleInputChange, borderless: this.borderless, disabled: this.isDisabled, readonly: this.readonly, clearable: this.clearable, allowInput: this.allowInput, "class": this.inputClasses, suffixIcon: function suffixIcon() { return h(TimeIcon); }, popupVisible: this.isShowPanel, placeholder: !this.innerValue ? this.placeholder || this.global.placeholder : void 0, value: this.isShowPanel ? this.currentValue : (_this$innerValue = this.innerValue) !== null && _this$innerValue !== void 0 ? _this$innerValue : void 0, inputValue: this.isShowPanel ? this.currentValue : (_this$innerValue2 = this.innerValue) !== null && _this$innerValue2 !== void 0 ? _this$innerValue2 : void 0, inputProps: _objectSpread(_objectSpread({}, this.inputProps), {}, { size: this.size }), status: this.status, tips: this.tips, panel: function panel() { return h(_TimePickerPanel, { "props": _objectSpread({}, { steps: _this.steps, format: _this.format, value: _this.currentValue, isFooterDisplay: true, isShowPanel: _this.isShowPanel, disableTime: _this.disableTime, onChange: _this.handlePanelChange, onPick: _this.handleOnPick, hideDisabledTime: _this.hideDisabledTime, handleConfirmClick: _this.handleClickConfirm, presets: _this.presets }) }); }, popupProps: _objectSpread({ overlayInnerStyle: { width: "auto", padding: 0 }, onVisibleChange: this.handleShowPopup }, this.popupProps) }) })]); } }); export { _TimePicker as default }; //# sourceMappingURL=time-picker.js.map