项目原始demo,不改动
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.
 
 
 
 

196 líneas
6.5 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. require("../../../src/components/VList/VListGroup.sass");
  7. var _VIcon = _interopRequireDefault(require("../VIcon"));
  8. var _VListItem = _interopRequireDefault(require("./VListItem"));
  9. var _VListItemIcon = _interopRequireDefault(require("./VListItemIcon"));
  10. var _bindsAttrs = _interopRequireDefault(require("../../mixins/binds-attrs"));
  11. var _bootable = _interopRequireDefault(require("../../mixins/bootable"));
  12. var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
  13. var _toggleable = _interopRequireDefault(require("../../mixins/toggleable"));
  14. var _registrable = require("../../mixins/registrable");
  15. var _ripple = _interopRequireDefault(require("../../directives/ripple"));
  16. var _transitions = require("../transitions");
  17. var _mixins = _interopRequireDefault(require("../../util/mixins"));
  18. var _helpers = require("../../util/helpers");
  19. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20. 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; }
  21. 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; }
  22. 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; }
  23. var baseMixins = (0, _mixins.default)(_bindsAttrs.default, _bootable.default, _colorable.default, (0, _registrable.inject)('list'), _toggleable.default);
  24. var _default = baseMixins.extend().extend({
  25. name: 'v-list-group',
  26. directives: {
  27. ripple: _ripple.default
  28. },
  29. props: {
  30. activeClass: {
  31. type: String,
  32. default: ''
  33. },
  34. appendIcon: {
  35. type: String,
  36. default: '$expand'
  37. },
  38. color: {
  39. type: String,
  40. default: 'primary'
  41. },
  42. disabled: Boolean,
  43. group: String,
  44. noAction: Boolean,
  45. prependIcon: String,
  46. ripple: {
  47. type: [Boolean, Object],
  48. default: true
  49. },
  50. subGroup: Boolean
  51. },
  52. computed: {
  53. classes: function classes() {
  54. return {
  55. 'v-list-group--active': this.isActive,
  56. 'v-list-group--disabled': this.disabled,
  57. 'v-list-group--no-action': this.noAction,
  58. 'v-list-group--sub-group': this.subGroup
  59. };
  60. }
  61. },
  62. watch: {
  63. isActive: function isActive(val) {
  64. /* istanbul ignore else */
  65. if (!this.subGroup && val) {
  66. this.list && this.list.listClick(this._uid);
  67. }
  68. },
  69. $route: 'onRouteChange'
  70. },
  71. created: function created() {
  72. this.list && this.list.register(this);
  73. if (this.group && this.$route && this.value == null) {
  74. this.isActive = this.matchRoute(this.$route.path);
  75. }
  76. },
  77. beforeDestroy: function beforeDestroy() {
  78. this.list && this.list.unregister(this);
  79. },
  80. methods: {
  81. click: function click(e) {
  82. var _this = this;
  83. if (this.disabled) return;
  84. this.isBooted = true;
  85. this.$emit('click', e);
  86. this.$nextTick(function () {
  87. return _this.isActive = !_this.isActive;
  88. });
  89. },
  90. genIcon: function genIcon(icon) {
  91. return this.$createElement(_VIcon.default, icon);
  92. },
  93. genAppendIcon: function genAppendIcon() {
  94. var icon = !this.subGroup ? this.appendIcon : false;
  95. if (!icon && !this.$slots.appendIcon) return null;
  96. return this.$createElement(_VListItemIcon.default, {
  97. staticClass: 'v-list-group__header__append-icon'
  98. }, [this.$slots.appendIcon || this.genIcon(icon)]);
  99. },
  100. genHeader: function genHeader() {
  101. return this.$createElement(_VListItem.default, {
  102. staticClass: 'v-list-group__header',
  103. attrs: {
  104. 'aria-expanded': String(this.isActive),
  105. role: 'button'
  106. },
  107. class: _defineProperty({}, this.activeClass, this.isActive),
  108. props: {
  109. inputValue: this.isActive
  110. },
  111. directives: [{
  112. name: 'ripple',
  113. value: this.ripple
  114. }],
  115. on: _objectSpread({}, this.listeners$, {
  116. click: this.click
  117. })
  118. }, [this.genPrependIcon(), this.$slots.activator, this.genAppendIcon()]);
  119. },
  120. genItems: function genItems() {
  121. var _this2 = this;
  122. return this.showLazyContent(function () {
  123. return [_this2.$createElement('div', {
  124. staticClass: 'v-list-group__items',
  125. directives: [{
  126. name: 'show',
  127. value: _this2.isActive
  128. }]
  129. }, (0, _helpers.getSlot)(_this2))];
  130. });
  131. },
  132. genPrependIcon: function genPrependIcon() {
  133. var icon = this.subGroup && this.prependIcon == null ? '$subgroup' : this.prependIcon;
  134. if (!icon && !this.$slots.prependIcon) return null;
  135. return this.$createElement(_VListItemIcon.default, {
  136. staticClass: 'v-list-group__header__prepend-icon'
  137. }, [this.$slots.prependIcon || this.genIcon(icon)]);
  138. },
  139. onRouteChange: function onRouteChange(to) {
  140. /* istanbul ignore if */
  141. if (!this.group) return;
  142. var isActive = this.matchRoute(to.path);
  143. /* istanbul ignore else */
  144. if (isActive && this.isActive !== isActive) {
  145. this.list && this.list.listClick(this._uid);
  146. }
  147. this.isActive = isActive;
  148. },
  149. toggle: function toggle(uid) {
  150. var _this3 = this;
  151. var isActive = this._uid === uid;
  152. if (isActive) this.isBooted = true;
  153. this.$nextTick(function () {
  154. return _this3.isActive = isActive;
  155. });
  156. },
  157. matchRoute: function matchRoute(to) {
  158. return to.match(this.group) !== null;
  159. }
  160. },
  161. render: function render(h) {
  162. return h('div', this.setTextColor(this.isActive && this.color, {
  163. staticClass: 'v-list-group',
  164. class: this.classes
  165. }), [this.genHeader(), h(_transitions.VExpandTransition, this.genItems())]);
  166. }
  167. });
  168. exports.default = _default;
  169. //# sourceMappingURL=VListGroup.js.map