mention.mjs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { filterOption } from './helper.mjs';
  2. import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
  3. import { inputProps } from '../../input/src/input2.mjs';
  4. import { isString, isFunction, isObject } from '@vue/shared';
  5. import { useTooltipContentProps } from '../../tooltip/src/content.mjs';
  6. import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
  7. const mentionProps = buildProps({
  8. ...inputProps,
  9. options: {
  10. type: definePropType(Array),
  11. default: () => []
  12. },
  13. prefix: {
  14. type: definePropType([String, Array]),
  15. default: "@",
  16. validator: (val) => {
  17. if (isString(val))
  18. return val.length === 1;
  19. return val.every((v) => isString(v) && v.length === 1);
  20. }
  21. },
  22. split: {
  23. type: String,
  24. default: " ",
  25. validator: (val) => val.length === 1
  26. },
  27. filterOption: {
  28. type: definePropType([Boolean, Function]),
  29. default: () => filterOption,
  30. validator: (val) => {
  31. if (val === false)
  32. return true;
  33. return isFunction(val);
  34. }
  35. },
  36. placement: {
  37. type: definePropType(String),
  38. default: "bottom"
  39. },
  40. showArrow: Boolean,
  41. offset: {
  42. type: Number,
  43. default: 0
  44. },
  45. whole: Boolean,
  46. checkIsWhole: {
  47. type: definePropType(
  48. Function
  49. )
  50. },
  51. modelValue: String,
  52. loading: Boolean,
  53. popperClass: useTooltipContentProps.popperClass,
  54. popperStyle: useTooltipContentProps.popperStyle,
  55. popperOptions: {
  56. type: definePropType(Object),
  57. default: () => ({})
  58. },
  59. props: {
  60. type: definePropType(Object),
  61. default: () => mentionDefaultProps
  62. }
  63. });
  64. const mentionEmits = {
  65. [UPDATE_MODEL_EVENT]: (value) => isString(value),
  66. "whole-remove": (pattern, prefix) => isString(pattern) && isString(prefix),
  67. input: (value) => isString(value),
  68. search: (pattern, prefix) => isString(pattern) && isString(prefix),
  69. select: (option, prefix) => isObject(option) && isString(prefix),
  70. focus: (evt) => evt instanceof FocusEvent,
  71. blur: (evt) => evt instanceof FocusEvent
  72. };
  73. const mentionDefaultProps = {
  74. value: "value",
  75. label: "label",
  76. disabled: "disabled"
  77. };
  78. export { mentionDefaultProps, mentionEmits, mentionProps };
  79. //# sourceMappingURL=mention.mjs.map