@aplus-frontend/ui
Version:
121 lines (120 loc) • 3.42 kB
JavaScript
import { defineComponent as v, computed as n, createElementBlock as d, openBlock as r, Fragment as i, createTextVNode as l, createBlock as b, toDisplayString as p, resolveDynamicComponent as h } from "vue";
import { isNil as g } from "lodash-unified";
import { useDateTimezone as w } from "../hooks/use-date-timezone.mjs";
import { getTimeFormatToZone as m } from "@aplus-frontend/utils";
import c from "dayjs";
import { ApFieldDatePresetFormats as C, PRESET_FORMAT_MAP as S } from "../date/constant.mjs";
const M = /* @__PURE__ */ v({
name: "ApFieldDateRangeRead",
__name: "read",
props: {
mode: {},
class: {},
style: {},
id: {},
defaultPickerValue: {},
placeholder: {},
disabled: { type: [Boolean, Array] },
disabledTime: {},
ranges: {},
separator: { type: [Object, String, Number, Boolean, null, Array] },
allowEmpty: {},
onCalendarChange: {},
onFocus: {},
onBlur: {},
onMousedown: {},
onMouseup: {},
onMouseenter: {},
onMouseleave: {},
onClick: {},
direction: {},
autocomplete: {},
activePickerIndex: {},
dateRender: {},
panelRender: {},
dropdownClassName: {},
dropdownAlign: {},
popupStyle: {},
transitionName: {},
allowClear: { type: Boolean },
autofocus: { type: Boolean },
tabindex: {},
open: { type: Boolean },
defaultOpen: { type: Boolean },
inputReadOnly: { type: Boolean },
suffixIcon: { type: [Object, String, Number, Boolean, null, Array] },
clearIcon: { type: [Object, String, Number, Boolean, null, Array] },
getPopupContainer: {},
inputRender: {},
onOpenChange: {},
onContextmenu: {},
onKeydown: {},
role: {},
name: {},
picker: {},
prefixCls: {},
disabledDate: {},
showWeek: { type: Boolean },
monthCellRender: {},
locale: {},
size: {},
bordered: { type: Boolean },
variant: {},
showTime: { type: [Boolean, Object] },
showNow: { type: Boolean },
order: { type: Boolean },
defaultOpenValue: {},
showHour: { type: Boolean },
showMinute: { type: Boolean },
showSecond: { type: Boolean },
use12Hours: { type: Boolean },
hourStep: {},
minuteStep: {},
secondStep: {},
hideDisabledOptions: { type: Boolean },
disabledHours: {},
disabledMinutes: {},
disabledSeconds: {},
valueFormat: {},
emptyText: { default: "--" },
value: {},
defaultValue: {},
"onUpdate:value": {},
onChange: {},
onOk: {},
format: { default: "Y-D" },
shownFormat: {},
timezone: {},
readModeSeparator: {},
presets: { type: [Array, Boolean] }
},
setup(y) {
const e = y, { currentTimezone: a } = w(e), t = n(() => {
const o = e.value;
if (g(o) || !o?.length)
return o;
const s = a.value ? m(
e.value[0],
a.value
) : e.value?.[0], B = e.timezone ? m(
e.value[1],
a.value
) : e.value?.[1];
return [c(s), c(B)];
}), f = n(
() => C.indexOf(e.format) > -1
), u = n(
() => f.value ? S[e.format] : e.format
);
return (o, s) => t.value ? (r(), d(i, { key: 0 }, [
l(p(t.value[0]?.format(u.value)) + " ", 1),
(r(), b(h(o.readModeSeparator))),
l(" " + p(t.value[1]?.format(u.value)), 1)
], 64)) : (r(), d(i, { key: 1 }, [
l(p(o.emptyText), 1)
], 64));
}
});
export {
M as default
};