项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Mixins
  2. import { inject as RegistrableInject } from '../registrable';
  3. export function factory(namespace, child, parent) {
  4. // TODO: ts 3.4 broke directly returning this
  5. const R = RegistrableInject(namespace, child, parent).extend({
  6. name: 'groupable',
  7. props: {
  8. activeClass: {
  9. type: String,
  10. default() {
  11. if (!this[namespace]) return undefined;
  12. return this[namespace].activeClass;
  13. }
  14. },
  15. disabled: Boolean
  16. },
  17. data() {
  18. return {
  19. isActive: false
  20. };
  21. },
  22. computed: {
  23. groupClasses() {
  24. if (!this.activeClass) return {};
  25. return {
  26. [this.activeClass]: this.isActive
  27. };
  28. }
  29. },
  30. created() {
  31. this[namespace] && this[namespace].register(this);
  32. },
  33. beforeDestroy() {
  34. this[namespace] && this[namespace].unregister(this);
  35. },
  36. methods: {
  37. toggle() {
  38. this.$emit('change');
  39. }
  40. }
  41. });
  42. return R;
  43. }
  44. /* eslint-disable-next-line no-redeclare */
  45. const Groupable = factory('itemGroup');
  46. export default Groupable;
  47. //# sourceMappingURL=index.js.map