项目原始demo,不改动
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
Це архівний репозитарій. Ви можете переглядати і клонувати файли, але не можете робити пуш або відкривати питання/запити.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. require("../../../src/components/VBadge/VBadge.sass");
  7. var _VIcon = _interopRequireDefault(require("../VIcon/VIcon"));
  8. var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
  9. var _themeable = _interopRequireDefault(require("../../mixins/themeable"));
  10. var _toggleable = _interopRequireDefault(require("../../mixins/toggleable"));
  11. var _transitionable = _interopRequireDefault(require("../../mixins/transitionable"));
  12. var _positionable = require("../../mixins/positionable");
  13. var _mixins = _interopRequireDefault(require("../../util/mixins"));
  14. var _helpers = require("../../util/helpers");
  15. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16. function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  17. function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  18. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  19. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  20. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  21. var _default = (0, _mixins.default)(_colorable.default, (0, _positionable.factory)(['left', 'bottom']), _themeable.default, _toggleable.default, _transitionable.default).extend({
  22. name: 'v-badge',
  23. props: {
  24. avatar: Boolean,
  25. bordered: Boolean,
  26. color: {
  27. type: String,
  28. default: 'primary'
  29. },
  30. content: {
  31. required: false
  32. },
  33. dot: Boolean,
  34. label: {
  35. type: String,
  36. default: '$vuetify.badge'
  37. },
  38. icon: String,
  39. inline: Boolean,
  40. offsetX: [Number, String],
  41. offsetY: [Number, String],
  42. overlap: Boolean,
  43. tile: Boolean,
  44. transition: {
  45. type: String,
  46. default: 'scale-rotate-transition'
  47. },
  48. value: {
  49. default: true
  50. }
  51. },
  52. computed: {
  53. classes: function classes() {
  54. return _objectSpread({
  55. 'v-badge--avatar': this.avatar,
  56. 'v-badge--bordered': this.bordered,
  57. 'v-badge--bottom': this.bottom,
  58. 'v-badge--dot': this.dot,
  59. 'v-badge--icon': this.icon != null,
  60. 'v-badge--inline': this.inline,
  61. 'v-badge--left': this.left,
  62. 'v-badge--overlap': this.overlap,
  63. 'v-badge--tile': this.tile
  64. }, this.themeClasses);
  65. },
  66. computedBottom: function computedBottom() {
  67. return this.bottom ? 'auto' : this.computedYOffset;
  68. },
  69. computedLeft: function computedLeft() {
  70. if (this.isRtl) {
  71. return this.left ? this.computedXOffset : 'auto';
  72. }
  73. return this.left ? 'auto' : this.computedXOffset;
  74. },
  75. computedRight: function computedRight() {
  76. if (this.isRtl) {
  77. return this.left ? 'auto' : this.computedXOffset;
  78. }
  79. return !this.left ? 'auto' : this.computedXOffset;
  80. },
  81. computedTop: function computedTop() {
  82. return this.bottom ? this.computedYOffset : 'auto';
  83. },
  84. computedXOffset: function computedXOffset() {
  85. return this.calcPosition(this.offsetX);
  86. },
  87. computedYOffset: function computedYOffset() {
  88. return this.calcPosition(this.offsetY);
  89. },
  90. isRtl: function isRtl() {
  91. return this.$vuetify.rtl;
  92. },
  93. // Default fallback if offsetX
  94. // or offsetY are undefined.
  95. offset: function offset() {
  96. if (this.overlap) return this.dot ? 8 : 12;
  97. return this.dot ? 2 : 4;
  98. },
  99. styles: function styles() {
  100. if (this.inline) return {};
  101. return {
  102. bottom: this.computedBottom,
  103. left: this.computedLeft,
  104. right: this.computedRight,
  105. top: this.computedTop
  106. };
  107. }
  108. },
  109. methods: {
  110. calcPosition: function calcPosition(offset) {
  111. return "calc(100% - ".concat((0, _helpers.convertToUnit)(offset || this.offset), ")");
  112. },
  113. genBadge: function genBadge() {
  114. var lang = this.$vuetify.lang;
  115. var label = this.$attrs['aria-label'] || lang.t(this.label);
  116. var data = this.setBackgroundColor(this.color, {
  117. staticClass: 'v-badge__badge',
  118. style: this.styles,
  119. attrs: {
  120. 'aria-atomic': this.$attrs['aria-atomic'] || 'true',
  121. 'aria-label': label,
  122. 'aria-live': this.$attrs['aria-live'] || 'polite',
  123. title: this.$attrs.title,
  124. role: this.$attrs.role || 'status'
  125. },
  126. directives: [{
  127. name: 'show',
  128. value: this.isActive
  129. }]
  130. });
  131. var badge = this.$createElement('span', data, [this.genBadgeContent()]);
  132. if (!this.transition) return badge;
  133. return this.$createElement('transition', {
  134. props: {
  135. name: this.transition,
  136. origin: this.origin,
  137. mode: this.mode
  138. }
  139. }, [badge]);
  140. },
  141. genBadgeContent: function genBadgeContent() {
  142. // Dot prop shows no content
  143. if (this.dot) return undefined;
  144. var slot = (0, _helpers.getSlot)(this, 'badge');
  145. if (slot) return slot;
  146. if (this.content) return String(this.content);
  147. if (this.icon) return this.$createElement(_VIcon.default, this.icon);
  148. return undefined;
  149. },
  150. genBadgeWrapper: function genBadgeWrapper() {
  151. return this.$createElement('span', {
  152. staticClass: 'v-badge__wrapper'
  153. }, [this.genBadge()]);
  154. }
  155. },
  156. render: function render(h) {
  157. var badge = [this.genBadgeWrapper()];
  158. var children = [(0, _helpers.getSlot)(this)];
  159. var _this$$attrs = this.$attrs,
  160. _x = _this$$attrs['aria-atomic'],
  161. _y = _this$$attrs['aria-label'],
  162. _z = _this$$attrs['aria-live'],
  163. role = _this$$attrs.role,
  164. title = _this$$attrs.title,
  165. attrs = _objectWithoutProperties(_this$$attrs, ["aria-atomic", "aria-label", "aria-live", "role", "title"]);
  166. if (this.inline && this.left) children.unshift(badge);else children.push(badge);
  167. return h('span', {
  168. staticClass: 'v-badge',
  169. attrs: attrs,
  170. class: this.classes
  171. }, children);
  172. }
  173. });
  174. exports.default = _default;
  175. //# sourceMappingURL=VBadge.js.map