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.

proxyable.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 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; }
  2. import Vue from 'vue';
  3. export function factory() {
  4. var prop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'value';
  5. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'change';
  6. return Vue.extend({
  7. name: 'proxyable',
  8. model: {
  9. prop: prop,
  10. event: event
  11. },
  12. props: _defineProperty({}, prop, {
  13. required: false
  14. }),
  15. data: function data() {
  16. return {
  17. internalLazyValue: this[prop]
  18. };
  19. },
  20. computed: {
  21. internalValue: {
  22. get: function get() {
  23. return this.internalLazyValue;
  24. },
  25. set: function set(val) {
  26. if (val === this.internalLazyValue) return;
  27. this.internalLazyValue = val;
  28. this.$emit(event, val);
  29. }
  30. }
  31. },
  32. watch: _defineProperty({}, prop, function (val) {
  33. this.internalLazyValue = val;
  34. })
  35. });
  36. }
  37. /* eslint-disable-next-line no-redeclare */
  38. var Proxyable = factory();
  39. export default Proxyable;
  40. //# sourceMappingURL=proxyable.js.map