mention.mjs 2.2 KB

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