UNPKG

tdesign-vue

Version:
256 lines (248 loc) 10.6 kB
/** * tdesign v1.11.2 * (c) 2025 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-9931ceef.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-27dd8cc6.js'); require('../props.js'); require('../../_common/js/time-picker/utils.js'); require('../../_chunks/dep-f3761329.js'); require('../../_chunks/dep-a4cecac4.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-a4308f57.js'); require('../../_chunks/dep-848a5a32.js'); require('../../_chunks/dep-d3015b4c.js'); require('../../_chunks/dep-e4278c54.js'); require('../../_chunks/dep-173eb46c.js'); require('../../_chunks/dep-ab142eaf.js'); require('../../_chunks/dep-5db8defc.js'); require('../../_chunks/dep-ecccff93.js'); require('../../_chunks/dep-234b7c02.js'); require('../../_chunks/dep-5284fe1d.js'); require('../../_chunks/dep-201f7798.js'); require('../../_chunks/dep-fcf0662d.js'); require('../../_chunks/dep-f8a85d6a.js'); require('../../_chunks/dep-5b117689.js'); require('../../_chunks/dep-f14aac54.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-62de1188.js'); require('../../_chunks/dep-867c284e.js'); require('../../_chunks/dep-738b4f21.js'); require('../../_chunks/dep-aa0a4aac.js'); require('../../config-provider/config-receiver.js'); require('../../_chunks/dep-07fb8c0e.js'); require('../../_common/js/global-config/default-config.js'); require('../../_common/js/global-config/locale/zh_CN.js'); require('../../_chunks/dep-a4a18104.js'); require('../../_chunks/dep-87c765cc.js'); require('../../_chunks/dep-75cd6d52.js'); require('../../_chunks/dep-b1a02818.js'); require('../../_chunks/dep-3d8ab37d.js'); require('../../_chunks/dep-6ad3de7c.js'); require('../../_chunks/dep-8b1e056e.js'); require('../../_chunks/dep-6e4c473c.js'); require('../../_chunks/dep-a4747856.js'); require('../../_chunks/dep-932dd69e.js'); require('../../_chunks/dep-9f4caea4.js'); require('../../_chunks/dep-dbd838d6.js'); require('../../_chunks/dep-b3120c1b.js'); require('../../_chunks/dep-68ba2357.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-7c854ec6.js'); require('../../_chunks/dep-eceed11d.js'); require('../../_chunks/dep-6478392e.js'); require('../../_chunks/dep-47bca35e.js'); require('../../utils/transfer-dom.js'); require('../../loading/props.js'); require('../../config.js'); require('../../_chunks/dep-013a3403.js'); require('../../_chunks/dep-8cb0d589.js'); require('../../_chunks/dep-d23147db.js'); require('../../_chunks/dep-de60f5aa.js'); require('../../_chunks/dep-63b02f7b.js'); require('../../_chunks/dep-bebcd284.js'); require('../../_chunks/dep-3eec664c.js'); require('../../_chunks/dep-eeb2e214.js'); require('../../_chunks/dep-315a67f0.js'); require('../../_chunks/dep-f84d1ea5.js'); require('../../_chunks/dep-362bc4d7.js'); require('../../_chunks/dep-2e32c1f2.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