e28440f81b9cfd512bceb83a35704195e1b866ee47e5455c1ce5f753e7e413da19d923956e71273153b586296f34162d395f112a80ff154cc369b4f5821fe6 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { defineComponent, reactive, computed, ref, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, renderSlot, createElementVNode, mergeProps } from 'vue';
  2. import { timePickerRangeTriggerProps } from './props.mjs';
  3. import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
  4. import { useFormItem, useFormItemInputId } from '../../../form/src/hooks/use-form-item.mjs';
  5. import { useAttrs } from '../../../../hooks/use-attrs/index.mjs';
  6. import { useNamespace } from '../../../../hooks/use-namespace/index.mjs';
  7. import { useFocusController } from '../../../../hooks/use-focus-controller/index.mjs';
  8. const __default__ = defineComponent({
  9. name: "PickerRangeTrigger",
  10. inheritAttrs: false
  11. });
  12. const _sfc_main = /* @__PURE__ */ defineComponent({
  13. ...__default__,
  14. props: timePickerRangeTriggerProps,
  15. emits: [
  16. "mouseenter",
  17. "mouseleave",
  18. "click",
  19. "touchstart",
  20. "focus",
  21. "blur",
  22. "startInput",
  23. "endInput",
  24. "startChange",
  25. "endChange"
  26. ],
  27. setup(__props, { expose, emit }) {
  28. const props = __props;
  29. const { formItem } = useFormItem();
  30. const { inputId } = useFormItemInputId(reactive({ id: computed(() => {
  31. var _a;
  32. return (_a = props.id) == null ? void 0 : _a[0];
  33. }) }), {
  34. formItemContext: formItem
  35. });
  36. const attrs = useAttrs();
  37. const nsDate = useNamespace("date");
  38. const nsRange = useNamespace("range");
  39. const inputRef = ref();
  40. const endInputRef = ref();
  41. const { wrapperRef, isFocused } = useFocusController(inputRef, {
  42. disabled: computed(() => props.disabled)
  43. });
  44. const handleClick = (evt) => {
  45. emit("click", evt);
  46. };
  47. const handleMouseEnter = (evt) => {
  48. emit("mouseenter", evt);
  49. };
  50. const handleMouseLeave = (evt) => {
  51. emit("mouseleave", evt);
  52. };
  53. const handleTouchStart = (evt) => {
  54. emit("touchstart", evt);
  55. };
  56. const handleStartInput = (evt) => {
  57. emit("startInput", evt);
  58. };
  59. const handleEndInput = (evt) => {
  60. emit("endInput", evt);
  61. };
  62. const handleStartChange = (evt) => {
  63. emit("startChange", evt);
  64. };
  65. const handleEndChange = (evt) => {
  66. emit("endChange", evt);
  67. };
  68. const focus = () => {
  69. var _a;
  70. (_a = inputRef.value) == null ? void 0 : _a.focus();
  71. };
  72. const blur = () => {
  73. var _a, _b;
  74. (_a = inputRef.value) == null ? void 0 : _a.blur();
  75. (_b = endInputRef.value) == null ? void 0 : _b.blur();
  76. };
  77. expose({
  78. focus,
  79. blur
  80. });
  81. return (_ctx, _cache) => {
  82. return openBlock(), createElementBlock("div", {
  83. ref_key: "wrapperRef",
  84. ref: wrapperRef,
  85. class: normalizeClass([unref(nsDate).is("active", unref(isFocused)), _ctx.$attrs.class]),
  86. style: normalizeStyle(_ctx.$attrs.style),
  87. onClick: handleClick,
  88. onMouseenter: handleMouseEnter,
  89. onMouseleave: handleMouseLeave,
  90. onTouchstartPassive: handleTouchStart
  91. }, [
  92. renderSlot(_ctx.$slots, "prefix"),
  93. createElementVNode("input", mergeProps(unref(attrs), {
  94. id: unref(inputId),
  95. ref_key: "inputRef",
  96. ref: inputRef,
  97. name: _ctx.name && _ctx.name[0],
  98. placeholder: _ctx.startPlaceholder,
  99. value: _ctx.modelValue && _ctx.modelValue[0],
  100. class: unref(nsRange).b("input"),
  101. disabled: _ctx.disabled,
  102. onInput: handleStartInput,
  103. onChange: handleStartChange
  104. }), null, 16, ["id", "name", "placeholder", "value", "disabled"]),
  105. renderSlot(_ctx.$slots, "range-separator"),
  106. createElementVNode("input", mergeProps(unref(attrs), {
  107. id: _ctx.id && _ctx.id[1],
  108. ref_key: "endInputRef",
  109. ref: endInputRef,
  110. name: _ctx.name && _ctx.name[1],
  111. placeholder: _ctx.endPlaceholder,
  112. value: _ctx.modelValue && _ctx.modelValue[1],
  113. class: unref(nsRange).b("input"),
  114. disabled: _ctx.disabled,
  115. onInput: handleEndInput,
  116. onChange: handleEndChange
  117. }), null, 16, ["id", "name", "placeholder", "value", "disabled"]),
  118. renderSlot(_ctx.$slots, "suffix")
  119. ], 38);
  120. };
  121. }
  122. });
  123. var PickerRangeTrigger = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "picker-range-trigger.vue"]]);
  124. export { PickerRangeTrigger as default };
  125. //# sourceMappingURL=picker-range-trigger.mjs.map