UNPKG

@enact/core

Version:

Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.

43 lines (42 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = exports.Handlers = void 0; function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var Handlers = exports.Handlers = /*#__PURE__*/function () { function Handlers(_handlers) { var _this = this; _classCallCheck(this, Handlers); this.props = {}; this.context = {}; this._handlers = {}; if (_handlers) { Object.keys(_handlers).forEach(function (fn) { _this._handlers[fn] = function (ev) { return _handlers[fn](ev, _this.props, _this.context); }; _this._handlers[fn].displayName = fn; }); } } return _createClass(Handlers, [{ key: "handlers", get: function get() { return this._handlers; } }, { key: "setContext", value: function setContext() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; this.props = props; this.context = context; } }]); }(); var _default = exports["default"] = Handlers;