@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
123 lines (116 loc) • 4.8 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var dayjs = require('dayjs');
var customParseFormat = require('dayjs/plugin/customParseFormat.js');
var index = require('../../select/index.js');
require('../../../constants/index.js');
var utils = require('./utils.js');
var timeSelect = require('./time-select.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var event = require('../../../constants/event.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);
const __default__ = vue.defineComponent({
name: "VsTimeSelect"
});
const _sfc_main = vue.defineComponent({
...__default__,
props: timeSelect.timeSelectProps,
emits: ["change", "blur", "focus", event.UPDATE_MODEL_EVENT],
setup(__props, { expose: __expose }) {
const props = __props;
dayjs__default["default"].extend(customParseFormat__default["default"]);
const selectInstance = vue.ref();
const value = vue.computed(
() => dayjs__default["default"](props.modelValue || start.value, "HH:mm").format(props.format)
);
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").format(props.format);
result.push({
value: currentTime,
disabled: props.disabledItems.includes(current) || 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 focus = () => {
var _a;
(_a = selectInstance.value) == null ? void 0 : _a.focus();
};
const blur = () => {
var _a;
(_a = selectInstance.value) == null ? void 0 : _a.blur();
};
__expose({
focus,
blur
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(index.VsSelect), {
ref_key: "selectInstance",
ref: selectInstance,
"model-value": value.value,
disabled: _ctx.disabled,
clearable: _ctx.clearable,
"clear-icon": _ctx.clearIcon,
effect: _ctx.effect,
placeholder: _ctx.placeholder,
"default-first-option": "",
filter: _ctx.editable,
"onUpdate:modelValue": _cache[0] || (_cache[0] = (event) => _ctx.$emit("update:modelValue", event)),
onChange: _cache[1] || (_cache[1] = (event) => _ctx.$emit("change", event)),
onBlur: _cache[2] || (_cache[2] = (event) => _ctx.$emit("blur", event)),
onFocus: _cache[3] || (_cache[3] = (event) => _ctx.$emit("focus", event))
}, {
default: vue.withCtx(() => [
(vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
null,
vue.renderList(items.value, (item) => {
return vue.openBlock(), vue.createBlock(vue.unref(index.VsOption), {
key: item.value,
label: item.value,
value: item.value,
disabled: item.disabled
}, null, 8, ["label", "value", "disabled"]);
}),
128
))
]),
_: 1
}, 8, ["model-value", "disabled", "clearable", "clear-icon", "effect", "placeholder", "filter"]);
};
}
});
var TimeSelect = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/time-select/src/time-select.vue"]]);
exports["default"] = TimeSelect;
//# sourceMappingURL=time-select2.js.map