UNPKG

tdesign-vue

Version:
259 lines (251 loc) 10.7 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var VueCompositionAPI = require('@vue/composition-api'); var dayjs = require('dayjs'); var customParseFormat = require('../../_chunks/dep-fb824cb8.js'); var _common_js_timePicker_const = require('../../_common/js/time-picker/const.js'); var timePicker_panel_props = require('./props.js'); var timePicker_panel_singlePanel = require('./single-panel.js'); var button_button = require('../../button/button.js'); var hooks_useConfig = require('../../hooks/useConfig.js'); var _common_js_log_log = require('../../_common/js/log/log.js'); var configProvider_useConfig = require('../../config-provider/useConfig.js'); require('../../_chunks/dep-c13dcbfd.js'); require('../props.js'); require('../../_common/js/time-picker/utils.js'); require('../../_chunks/dep-ded1e6bc.js'); require('../../_chunks/dep-ee4e645f.js'); require('../../_chunks/dep-2bc87cc8.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-3b2292ce.js'); require('../../_chunks/dep-0ea9f257.js'); require('../../_chunks/dep-803744d9.js'); require('../../_chunks/dep-ba7f5924.js'); require('../../_chunks/dep-d4d8c513.js'); require('../../_chunks/dep-d844c9ed.js'); require('../../_chunks/dep-010db548.js'); require('../../_chunks/dep-8d206316.js'); require('../../_chunks/dep-9dae8101.js'); require('../../_chunks/dep-3c03af0f.js'); require('../../_chunks/dep-689d381f.js'); require('../../_chunks/dep-10fcb46d.js'); require('../../_chunks/dep-84027b7f.js'); require('../../_chunks/dep-49400b00.js'); require('../../_chunks/dep-edb55477.js'); require('../../loading/index.js'); require('../../loading/directive.js'); require('../../loading/plugin.js'); require('vue'); require('../../loading/loading.js'); require('../../loading/icon/gradient.js'); require('../../_common/js/loading/circle-adapter.js'); require('../../_common/js/utils/setStyle.js'); require('../../_common/js/utils/helper.js'); require('@babel/runtime/helpers/toConsumableArray'); require('@babel/runtime/helpers/objectWithoutProperties'); require('@babel/runtime/helpers/slicedToArray'); require('../../_chunks/dep-721fcdf6.js'); require('../../_chunks/dep-591b87f1.js'); require('../../_chunks/dep-a2217d56.js'); require('../../_chunks/dep-268c68b1.js'); require('../../config-provider/config-receiver.js'); require('../../_chunks/dep-8eddb350.js'); require('../../_common/js/global-config/default-config.js'); require('../../_common/js/global-config/locale/zh_CN.js'); require('../../_chunks/dep-0c37520c.js'); require('../../_chunks/dep-6f4e680e.js'); require('../../_chunks/dep-bb0ececf.js'); require('../../_chunks/dep-6eba4d23.js'); require('../../_chunks/dep-f77d6ad5.js'); require('../../_chunks/dep-7c84d9a0.js'); require('../../_chunks/dep-733a2279.js'); require('../../_chunks/dep-c05a9033.js'); require('../../_chunks/dep-efe55b82.js'); require('../../_chunks/dep-7da70ee1.js'); require('../../_chunks/dep-124386d4.js'); require('../../_chunks/dep-f5b14344.js'); require('../../_chunks/dep-36c2788b.js'); require('../../_chunks/dep-fa353fbb.js'); require('../../_chunks/dep-d66ab3a4.js'); require('../../_common/js/global-config/t.js'); require('../../utils/mixins.js'); require('../../utils/dom.js'); require('raf'); require('../../utils/easing.js'); require('../../utils/render-tnode.js'); require('@babel/runtime/helpers/readOnlyError'); require('../../_chunks/dep-9c5b91d3.js'); require('../../_chunks/dep-9a74c2be.js'); require('../../_chunks/dep-f1081d8e.js'); require('../../_chunks/dep-2c592e99.js'); require('../../utils/transfer-dom.js'); require('../../loading/props.js'); require('../../config.js'); require('../../_chunks/dep-97fef2be.js'); require('../../_chunks/dep-0b47afa3.js'); require('../../_chunks/dep-d7516e38.js'); require('../../_chunks/dep-74be1050.js'); require('../../_chunks/dep-7fbd94e9.js'); require('../../_chunks/dep-56f568d3.js'); require('../../_chunks/dep-82ce56ef.js'); require('../../_chunks/dep-4e96e31a.js'); require('../../_chunks/dep-17ce3e74.js'); require('../../_chunks/dep-a7198720.js'); require('../../_chunks/dep-1e173c2b.js'); require('../../_chunks/dep-c9ce9427.js'); require('../../utils/withInstall.js'); require('../../button/props.js'); require('../../utils/ripple.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs); 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__default["default"](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__default["default"].extend(customParseFormat.customParseFormat); var _TimePickerPanel = VueCompositionAPI.defineComponent({ name: "TTimePickerPanel", props: _objectSpread(_objectSpread({}, timePicker_panel_props.panelProps()), {}, { handleConfirmClick: Function, onChange: Function, onPick: Function, disableTime: Function }), setup: function setup(props, ctx) { var panelClassName = hooks_useConfig.usePrefixClass("time-picker__panel"); var triggerScroll = VueCompositionAPI.ref(false); var _useConfig = configProvider_useConfig.useConfig("timePicker"), global = _useConfig.global; var showNowTimeBtn = VueCompositionAPI.computed(function () { return !!props.steps.filter(function (v) { return v > 1; }).length; }); var defaultValue = VueCompositionAPI.computed(function () { var isStepsSet = showNowTimeBtn.value; var formattedValue = dayjs__default["default"](props.value, props.format); if (props.value && formattedValue.isValid()) { return formattedValue; } if (isStepsSet) { return dayjs__default["default"]().hour(0).minute(0).second(0); } return dayjs__default["default"]().hour(0).minute(0).second(0).format(props.format); }); var panelColUpdate = function panelColUpdate() { VueCompositionAPI.nextTick(function () { triggerScroll.value = true; }); }; var resetTriggerScroll = function resetTriggerScroll() { triggerScroll.value = false; }; var handleChange = function handleChange(v, e) { var _props$onPick, _props$onChange; (_props$onPick = props.onPick) === null || _props$onPick === void 0 || _props$onPick.call(props, v, e); ctx.emit("pick", v, e); (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, v); ctx.emit("change", v); }; var handlePresetClick = function handlePresetClick(presetValue) { var presetVal = typeof presetValue === "function" ? presetValue() : presetValue; if (typeof props.activeIndex === "number") { if (Array.isArray(presetVal)) { props.onChange(presetVal[props.activeIndex]); } else { _common_js_log_log["default"].error("TimePicker", "preset: ".concat(props.presets, " \u9884\u8BBE\u503C\u5FC5\u987B\u662F\u6570\u7EC4!")); } } else { props.onChange(presetVal); } }; VueCompositionAPI.onMounted(function () { panelColUpdate(); }); VueCompositionAPI.watch(function () { return props.isShowPanel; }, function () { panelColUpdate(); }); return { showNowTimeBtn: showNowTimeBtn, panelClassName: panelClassName, triggerScroll: triggerScroll, resetTriggerScroll: resetTriggerScroll, defaultValue: defaultValue, global: global, handleChange: handleChange, handlePresetClick: handlePresetClick }; }, render: function render() { var _this = this; var h = arguments[0]; return h("div", { "class": this.panelClassName }, [h("div", { "class": "".concat(this.panelClassName, "-section-body") }, [h(timePicker_panel_singlePanel["default"], { "props": _objectSpread({}, { value: dayjs__default["default"](this.value, this.format).isValid() ? this.value : this.defaultValue, onChange: this.handleChange, onPick: this.onPick, format: this.format || _common_js_timePicker_const.DEFAULT_FORMAT, steps: this.steps || _common_js_timePicker_const.DEFAULT_STEPS, triggerScroll: this.triggerScroll, disableTime: this.disableTime, position: this.position, resetTriggerScroll: this.resetTriggerScroll, isShowPanel: this.isShowPanel, hideDisabledTime: this.hideDisabledTime }) })]), this.isFooterDisplay ? h("div", { "class": "".concat(this.panelClassName, "-section-footer") }, [h(button_button["default"], { "attrs": { "theme": "primary", "variant": "base", "disabled": !this.value, "size": "small" }, "on": { "click": function click() { return _this.handleConfirmClick(_this.defaultValue); } } }, [this.global.confirm]), h("div", [!this.showNowTimeBtn ? h(button_button["default"], { "attrs": { "theme": "primary", "variant": "text", "size": "small" }, "on": { "click": function click() { return _this.onChange(dayjs__default["default"]().format(_this.format)); } } }, [this.global.now]) : null, this.presets && Object.keys(this.presets).map(function (key) { return h(button_button["default"], { "key": key, "attrs": { "theme": "primary", "size": "small", "variant": "text" }, "on": { "click": function click() { var _this$handlePresetCli; return (_this$handlePresetCli = _this.handlePresetClick) === null || _this$handlePresetCli === void 0 ? void 0 : _this$handlePresetCli.call(_this, _this.presets[key]); } } }, [key]); })])]) : null]); } }); exports["default"] = _TimePickerPanel; //# sourceMappingURL=time-picker-panel.js.map