hongluan-ui
Version:
Hongluan Component Library for Vue 3
149 lines (142 loc) • 5.88 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var dayjs = require('dayjs');
var customParseFormat = require('dayjs/plugin/customParseFormat.js');
require('../../../hooks/index.js');
var index = require('../../select/index.js');
var index$1 = require('../../option/index.js');
var index$2 = require('../../icon/index.js');
require('../../system-icon/index.js');
var timeSelect = require('./time-select.js');
var utils = require('./utils.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var clock = require('../../system-icon/src/clock.js');
var index$3 = require('../../../hooks/use-locale/index.js');
var index$4 = require('../../../hooks/use-consistent-prop/index.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
var customParseFormat__default = /*#__PURE__*/_interopDefaultLegacy(customParseFormat);
dayjs__default["default"].extend(customParseFormat__default["default"]);
const _sfc_main = vue.defineComponent({
name: "TimeSelect",
components: { HlSelect: index.HlSelect, HlOption: index$1.HlOption, HlIcon: index$2.HlIcon, SystemClock: clock["default"] },
props: timeSelect.timeSelectProps,
emits: ["change", "blur", "focus", "clear", "update:modelValue"],
setup(props) {
const { lang } = index$3.useLocale();
const select = vue.ref();
const value = vue.computed(() => props.modelValue);
const start = vue.computed(() => {
const time = utils.parseTime(props.start);
return time ? utils.formatTime(time) : null;
});
const end = vue.computed(() => {
const time = utils.parseTime(props.end);
return time ? utils.formatTime(time) : null;
});
const step = vue.computed(() => {
const time = utils.parseTime(props.step);
return time ? utils.formatTime(time) : null;
});
const minTime = vue.computed(() => {
const time = utils.parseTime(props.minTime || "");
return time ? utils.formatTime(time) : null;
});
const maxTime = vue.computed(() => {
const time = utils.parseTime(props.maxTime || "");
return time ? utils.formatTime(time) : null;
});
const items = vue.computed(() => {
const result = [];
if (props.start && props.end && props.step) {
let current = start.value;
let currentTime;
while (current && end.value && utils.compareTime(current, end.value) <= 0) {
currentTime = dayjs__default["default"](current, "HH:mm").locale(lang.value).format(props.format);
result.push({
value: currentTime,
disabled: utils.compareTime(current, minTime.value || "-1:-1") <= 0 || utils.compareTime(current, maxTime.value || "100:100") >= 0
});
current = utils.nextTime(current, step.value);
}
}
return result;
});
const popperPaneRef = vue.computed(() => {
var _a;
return (_a = select.value) == null ? void 0 : _a.popperPaneRef;
});
const blur = () => {
var _a, _b;
(_b = (_a = select.value) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
};
const focus = () => {
var _a, _b;
(_b = (_a = select.value) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
};
const { size: timeSize, disabled: timeDisabled, fill: timeFill } = index$4.useConsistentProp();
return {
select,
popperPaneRef,
value,
items,
blur,
focus,
timeSize,
timeDisabled,
timeFill
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_hl_option = vue.resolveComponent("hl-option");
const _component_system_clock = vue.resolveComponent("system-clock");
const _component_hl_icon = vue.resolveComponent("hl-icon");
const _component_hl_select = vue.resolveComponent("hl-select");
return vue.openBlock(), vue.createBlock(_component_hl_select, {
ref: "select",
"model-value": _ctx.value,
disabled: _ctx.timeDisabled,
clearable: _ctx.clearable,
size: _ctx.timeSize,
effect: _ctx.effect,
fill: _ctx.timeFill,
placeholder: _ctx.placeholder,
"default-first-option": "",
filterable: _ctx.editable,
teleported: _ctx.teleported,
"empty-values": _ctx.emptyValues,
"value-on-clear": _ctx.valueOnClear,
"onUpdate:modelValue": (event) => _ctx.$emit("update:modelValue", event),
onChange: (event) => _ctx.$emit("change", event),
onBlur: (event) => _ctx.$emit("blur", event),
onFocus: (event) => _ctx.$emit("focus", event),
onClear: () => _ctx.$emit("clear")
}, {
prefix: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "prefix", {}, () => [
vue.createVNode(_component_hl_icon, null, {
default: vue.withCtx(() => [
vue.createVNode(_component_system_clock)
]),
_: 1
})
])
]),
default: vue.withCtx(() => [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
return vue.openBlock(), vue.createBlock(_component_hl_option, {
key: item.value,
label: item.value,
value: item.value,
disabled: item.disabled
}, null, 8, ["label", "value", "disabled"]);
}), 128))
]),
_: 3
}, 8, ["model-value", "disabled", "clearable", "size", "effect", "fill", "placeholder", "filterable", "teleported", "empty-values", "value-on-clear", "onUpdate:modelValue", "onChange", "onBlur", "onFocus", "onClear"]);
}
var TimeSelect = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
exports["default"] = TimeSelect;
//# sourceMappingURL=time-select2.js.map