UNPKG

@aplus-frontend/ui

Version:

106 lines (105 loc) 2.84 kB
import { defineComponent as u, computed as t, toDisplayString as i, unref as d } from "vue"; import n from "dayjs"; import { isNil as m } from "lodash-unified"; import { getTimeFormatToZone as c } from "@aplus-frontend/utils"; import { useDateTimezone as f } from "../hooks/use-date-timezone.mjs"; import { ApFieldDatePresetFormats as y, PRESET_FORMAT_MAP as B } from "./constant.mjs"; const S = /* @__PURE__ */ u({ name: "ApFieldDateRead", __name: "read", props: { mode: {}, class: {}, style: {}, dropdownClassName: {}, dropdownAlign: {}, popupStyle: {}, transitionName: {}, placeholder: {}, allowClear: { type: Boolean }, autofocus: { type: Boolean }, disabled: { type: Boolean }, tabindex: {}, open: { type: Boolean }, defaultOpen: { type: Boolean }, inputReadOnly: { type: Boolean }, id: {}, presets: {}, suffixIcon: { type: [Object, String, Number, Boolean, null, Array] }, clearIcon: { type: [Object, String, Number, Boolean, null, Array] }, getPopupContainer: {}, panelRender: {}, inputRender: {}, onOpenChange: {}, onPanelChange: {}, onFocus: {}, onBlur: {}, onMousedown: {}, onMouseup: {}, onMouseenter: {}, onMouseleave: {}, onClick: {}, onContextmenu: {}, onKeydown: {}, role: {}, name: {}, autocomplete: {}, direction: {}, showToday: { type: Boolean }, showTime: { type: [Boolean, Object] }, picker: {}, prefixCls: {}, defaultPickerValue: {}, disabledDate: {}, showWeek: { type: Boolean }, dateRender: {}, monthCellRender: {}, renderExtraFooter: {}, onSelect: {}, locale: {}, size: {}, bordered: { type: Boolean }, variant: {}, showNow: { type: Boolean }, disabledTime: {}, 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: {}, formatBegins: { type: Boolean }, timezone: {} }, setup(l) { const e = l, { currentTimezone: r } = f(e), p = t( () => y.indexOf(e.format) > -1 ), s = t( () => p.value ? B[e.format] : e.format ), a = t(() => { if (m(e.value)) return; let o = n(e.value); return e.timezone && (o = n(c(e.value, r.value))), o; }); return (o, h) => i(a.value ? d(n)(a.value).format(s.value) : o.emptyText); } }); export { S as default };