1ac3baec82b21c7c97301ffd3ee5040a71a0defc6ed24c94d05aaaaec8ea9f824467210ab6934e348c74c20276395db4a3758861898526bed671bb2d25a1da 2.0 KB

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