Ohm-Management - Projektarbeit B-ME
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.

VRadio.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Styles
  6. // Components
  7. // Mixins
  8. require('../../../src/stylus/components/_radios.styl');
  9. var _VIcon = require('../VIcon');
  10. var _VIcon2 = _interopRequireDefault(_VIcon);
  11. var _VLabel = require('../VLabel');
  12. var _VLabel2 = _interopRequireDefault(_VLabel);
  13. var _colorable = require('../../mixins/colorable');
  14. var _colorable2 = _interopRequireDefault(_colorable);
  15. var _rippleable = require('../../mixins/rippleable');
  16. var _rippleable2 = _interopRequireDefault(_rippleable);
  17. var _themeable = require('../../mixins/themeable');
  18. var _themeable2 = _interopRequireDefault(_themeable);
  19. var _selectable = require('../../mixins/selectable');
  20. var _selectable2 = _interopRequireDefault(_selectable);
  21. var _registrable = require('../../mixins/registrable');
  22. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  24. /* @vue/component */
  25. exports.default = {
  26. name: 'v-radio',
  27. mixins: [_colorable2.default, _rippleable2.default, (0, _registrable.inject)('radio', 'v-radio', 'v-radio-group'), _themeable2.default],
  28. inheritAttrs: false,
  29. props: {
  30. color: {
  31. type: String,
  32. default: 'accent'
  33. },
  34. disabled: Boolean,
  35. label: String,
  36. onIcon: {
  37. type: String,
  38. default: '$vuetify.icons.radioOn'
  39. },
  40. offIcon: {
  41. type: String,
  42. default: '$vuetify.icons.radioOff'
  43. },
  44. readonly: Boolean,
  45. value: null
  46. },
  47. data: function data() {
  48. return {
  49. isActive: false,
  50. isFocused: false,
  51. parentError: false
  52. };
  53. },
  54. computed: {
  55. computedData: function computedData() {
  56. return this.setTextColor(!this.parentError && this.isActive && this.color, {
  57. staticClass: 'v-radio',
  58. 'class': _extends({
  59. 'v-radio--is-disabled': this.isDisabled,
  60. 'v-radio--is-focused': this.isFocused
  61. }, this.themeClasses)
  62. });
  63. },
  64. computedColor: function computedColor() {
  65. return this.isActive ? this.color : this.radio.validationState || false;
  66. },
  67. computedIcon: function computedIcon() {
  68. return this.isActive ? this.onIcon : this.offIcon;
  69. },
  70. hasState: function hasState() {
  71. return this.isActive || !!this.radio.validationState;
  72. },
  73. isDisabled: function isDisabled() {
  74. return this.disabled || !!this.radio.disabled;
  75. },
  76. isReadonly: function isReadonly() {
  77. return this.readonly || !!this.radio.readonly;
  78. }
  79. },
  80. mounted: function mounted() {
  81. this.radio.register(this);
  82. },
  83. beforeDestroy: function beforeDestroy() {
  84. this.radio.unregister(this);
  85. },
  86. methods: {
  87. genInput: function genInput() {
  88. var _Selectable$options$m;
  89. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  90. args[_key] = arguments[_key];
  91. }
  92. // We can't actually use the mixin directly because
  93. // it's made for standalone components, but its
  94. // genInput method is exactly what we need
  95. return (_Selectable$options$m = _selectable2.default.options.methods.genInput).call.apply(_Selectable$options$m, [this].concat(_toConsumableArray(args)));
  96. },
  97. genLabel: function genLabel() {
  98. return this.$createElement(_VLabel2.default, {
  99. on: { click: this.onChange },
  100. attrs: {
  101. for: this.id
  102. },
  103. props: {
  104. color: this.radio.validationState || '',
  105. dark: this.dark,
  106. focused: this.hasState,
  107. light: this.light
  108. }
  109. }, this.$slots.label || this.label);
  110. },
  111. genRadio: function genRadio() {
  112. return this.$createElement('div', {
  113. staticClass: 'v-input--selection-controls__input'
  114. }, [this.genInput('radio', _extends({
  115. name: this.radio.name || (this.radio._uid ? 'v-radio-' + this.radio._uid : false),
  116. value: this.value
  117. }, this.$attrs)), this.genRipple(this.setTextColor(this.computedColor)), this.$createElement(_VIcon2.default, this.setTextColor(this.computedColor, {
  118. props: {
  119. dark: this.dark,
  120. light: this.light
  121. }
  122. }), this.computedIcon)]);
  123. },
  124. onFocus: function onFocus(e) {
  125. this.isFocused = true;
  126. this.$emit('focus', e);
  127. },
  128. onBlur: function onBlur(e) {
  129. this.isFocused = false;
  130. this.$emit('blur', e);
  131. },
  132. onChange: function onChange() {
  133. if (this.isDisabled || this.isReadonly) return;
  134. if (!this.isDisabled && (!this.isActive || !this.radio.mandatory)) {
  135. this.$emit('change', this.value);
  136. }
  137. },
  138. onKeydown: function onKeydown() {}
  139. },
  140. render: function render(h) {
  141. return h('div', this.computedData, [this.genRadio(), this.genLabel()]);
  142. }
  143. };
  144. //# sourceMappingURL=VRadio.js.map