You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
30 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, inject, computed, ref, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, toDisplayString, createVNode, createCommentVNode } from 'vue';\nimport dayjs from 'dayjs';\nimport { union } from 'lodash-unified';\nimport { panelTimeRangeProps } from '../props/panel-time-range.mjs';\nimport { useTimePanel } from '../composables/use-time-panel.mjs';\nimport { useOldValue, buildAvailableTimeSlotGetter } from '../composables/use-time-picker.mjs';\nimport TimeSpinner from './basic-time-spinner.mjs';\nimport _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useLocale } from '../../../../hooks/use-locale/index.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { isArray } from '@vue/shared';\nimport { EVENT_CODE } from '../../../../constants/aria.mjs';\nconst _sfc_main = /* @__PURE__ */defineComponent({\n __name: \"panel-time-range\",\n props: panelTimeRangeProps,\n emits: [\"pick\", \"select-range\", \"set-picker-option\"],\n setup(__props, {\n emit\n }) {\n const props = __props;\n const makeSelectRange = (start, end) => {\n const result = [];\n for (let i = start; i <= end; i++) {\n result.push(i);\n }\n return result;\n };\n const {\n t,\n lang\n } = useLocale();\n const nsTime = useNamespace(\"time\");\n const nsPicker = useNamespace(\"picker\");\n const pickerBase = inject(\"EP_PICKER_BASE\");\n const {\n arrowControl,\n disabledHours,\n disabledMinutes,\n disabledSeconds,\n defaultValue\n } = pickerBase.props;\n const startContainerKls = computed(() => [nsTime.be(\"range-picker\", \"body\"), nsTime.be(\"panel\", \"content\"), nsTime.is(\"arrow\", arrowControl), showSeconds.value ? \"has-seconds\" : \"\"]);\n const endContainerKls = computed(() => [nsTime.be(\"range-picker\", \"body\"), nsTime.be(\"panel\", \"content\"), nsTime.is(\"arrow\", arrowControl), showSeconds.value ? \"has-seconds\" : \"\"]);\n const startTime = computed(() => props.parsedValue[0]);\n const endTime = computed(() => props.parsedValue[1]);\n const oldValue = useOldValue(props);\n const handleCancel = () => {\n emit(\"pick\", oldValue.value, false);\n };\n const showSeconds = computed(() => {\n return props.format.includes(\"ss\");\n });\n const amPmMode = computed(() => {\n if (props.format.includes(\"A\")) return \"A\";\n if (props.format.includes(\"a\")) return \"a\";\n return \"\";\n });\n const handleConfirm = (visible = false) => {\n emit(\"pick\", [startTime.value, endTime.value], visible);\n };\n const handleMinChange = date => {\n handleChange(date.millisecond(0), endTime.value);\n };\n const handleMaxChange = date => {\n handleChange(startTime.value, date.millisecond(0));\n };\n const isValidValue = _date => {\n const parsedDate = _date.map(_ => dayjs(_).locale(lang.value));\n const result = getRangeAvailableTime(parsedDate);\n return parsedDate[0].isSame(result[0]) && parsedDate[1].isSame(result[1]);\n };\n const handleChange = (start, end) => {\n if (!props.visible) {\n return;\n }\n emit(\"pick\", [start, end], true);\n };\n const btnConfirmDisabled = computed(() => {\n return startTime.value > endTime.value;\n });\n const selectionRange = ref([0, 2]);\n const setMinSelectionRange = (start, end) => {\n emit(\"select-range\", start, end, \"min\");\n selectionRange.value = [start, end];\n };\n const offset = computed(() => showSeconds.value ? 11 : 8);\n const setMaxSelectionRange = (start, end) => {\n emit(\"select-range\", start, end, \"max\");\n const _offset = unref(offset);\n selectionRange.value = [start + _offset, end + _offset];\n };\n const changeSelectionRange = step => {\n const list = showSeconds.value ? [0, 3, 6, 11, 14, 17] : [0, 3, 8, 11];\n const mapping = [\"hours\", \"minutes\"].concat(showSe