0a792ebca687c1fce58404cf9cd08b1c93456de1ef3eb29ab7e1bf53ff3226269be449bccc122f6a108f2b9cbc75cc3264c3ee1961d7b7f19e3dcdd063a01b 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { useAttrs, useSlots, computed } from 'vue';
  2. import { useNamespace } from '../../../../hooks/use-namespace/index.mjs';
  3. function useInputTagDom({
  4. props,
  5. isFocused,
  6. hovering,
  7. disabled,
  8. inputValue,
  9. size,
  10. validateState,
  11. validateIcon,
  12. needStatusIcon
  13. }) {
  14. const attrs = useAttrs();
  15. const slots = useSlots();
  16. const ns = useNamespace("input-tag");
  17. const nsInput = useNamespace("input");
  18. const containerKls = computed(() => [
  19. ns.b(),
  20. ns.is("focused", isFocused.value),
  21. ns.is("hovering", hovering.value),
  22. ns.is("disabled", disabled.value),
  23. ns.m(size.value),
  24. ns.e("wrapper"),
  25. attrs.class
  26. ]);
  27. const containerStyle = computed(() => [attrs.style]);
  28. const innerKls = computed(() => {
  29. var _a, _b;
  30. return [
  31. ns.e("inner"),
  32. ns.is("draggable", props.draggable),
  33. ns.is("left-space", !((_a = props.modelValue) == null ? void 0 : _a.length) && !slots.prefix),
  34. ns.is("right-space", !((_b = props.modelValue) == null ? void 0 : _b.length) && !showSuffix.value)
  35. ];
  36. });
  37. const showClear = computed(() => {
  38. var _a;
  39. return props.clearable && !disabled.value && !props.readonly && (((_a = props.modelValue) == null ? void 0 : _a.length) || inputValue.value) && (isFocused.value || hovering.value);
  40. });
  41. const showSuffix = computed(() => {
  42. return slots.suffix || showClear.value || validateState.value && validateIcon.value && needStatusIcon.value;
  43. });
  44. return {
  45. ns,
  46. nsInput,
  47. containerKls,
  48. containerStyle,
  49. innerKls,
  50. showClear,
  51. showSuffix
  52. };
  53. }
  54. export { useInputTagDom };
  55. //# sourceMappingURL=use-input-tag-dom.mjs.map