VOverflowBtn.mjs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // @ts-nocheck
  2. /* eslint-disable */
  3. // Styles
  4. import "./VOverflowBtn.css";
  5. // Extensions
  6. import VSelect from "../VSelect/VSelect.mjs";
  7. import VAutocomplete from "../VAutocomplete/index.mjs";
  8. import VTextField from "../VTextField/VTextField.mjs"; // Components
  9. import VBtn from "../VBtn/index.mjs"; // Utilities
  10. import { consoleWarn } from "../../util/console.mjs";
  11. /* @vue/component */
  12. export default VAutocomplete.extend({
  13. name: 'v-overflow-btn',
  14. props: {
  15. editable: Boolean,
  16. segmented: Boolean
  17. },
  18. computed: {
  19. classes() {
  20. return {
  21. ...VAutocomplete.options.computed.classes.call(this),
  22. 'v-overflow-btn': true,
  23. 'v-overflow-btn--segmented': this.segmented,
  24. 'v-overflow-btn--editable': this.editable
  25. };
  26. },
  27. isAnyValueAllowed() {
  28. return this.editable || VAutocomplete.options.computed.isAnyValueAllowed.call(this);
  29. },
  30. isSingle() {
  31. return true;
  32. },
  33. computedItems() {
  34. return this.segmented ? this.allItems : this.filteredItems;
  35. },
  36. labelValue() {
  37. return this.isFocused && !this.persistentPlaceholder || this.isLabelActive;
  38. }
  39. },
  40. methods: {
  41. genSelections() {
  42. return this.editable ? VAutocomplete.options.methods.genSelections.call(this) : VSelect.options.methods.genSelections.call(this); // Override v-autocomplete's override
  43. },
  44. genCommaSelection(item, index, last) {
  45. return this.segmented ? this.genSegmentedBtn(item) : VSelect.options.methods.genCommaSelection.call(this, item, index, last);
  46. },
  47. genInput() {
  48. const input = VTextField.options.methods.genInput.call(this);
  49. input.data = input.data || {};
  50. input.data.domProps.value = this.editable ? this.internalSearch : '';
  51. input.data.attrs.readonly = !this.isAnyValueAllowed;
  52. return input;
  53. },
  54. genLabel() {
  55. if (this.editable && this.isFocused) return null;
  56. const label = VTextField.options.methods.genLabel.call(this);
  57. if (!label) return label;
  58. label.data = label.data || {};
  59. // Reset previously set styles from parent
  60. label.data.style = {};
  61. return label;
  62. },
  63. genSegmentedBtn(item) {
  64. const itemValue = this.getValue(item);
  65. const itemObj = this.computedItems.find(i => this.getValue(i) === itemValue) || item;
  66. if (!itemObj.text || !itemObj.callback) {
  67. consoleWarn('When using "segmented" prop without a selection slot, items must contain both a text and callback property', this);
  68. return null;
  69. }
  70. return this.$createElement(VBtn, {
  71. props: {
  72. text: true
  73. },
  74. on: {
  75. click(e) {
  76. e.stopPropagation();
  77. itemObj.callback(e);
  78. }
  79. }
  80. }, [itemObj.text]);
  81. },
  82. updateValue(val) {
  83. if (val) {
  84. this.initialValue = this.lazyValue;
  85. } else if (this.initialValue !== this.lazyValue) {
  86. this.$emit('change', this.lazyValue);
  87. }
  88. }
  89. }
  90. });
  91. //# sourceMappingURL=VOverflowBtn.mjs.map