ui.menu_base.edit.strategy.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * DevExtreme (ui/context_menu/ui.menu_base.edit.strategy.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var _renderer = require("../../core/renderer");
  11. var _renderer2 = _interopRequireDefault(_renderer);
  12. var _iterator = require("../../core/utils/iterator");
  13. var _uiCollection_widgetEditStrategy = require("../collection/ui.collection_widget.edit.strategy.plain");
  14. var _uiCollection_widgetEditStrategy2 = _interopRequireDefault(_uiCollection_widgetEditStrategy);
  15. function _interopRequireDefault(obj) {
  16. return obj && obj.__esModule ? obj : {
  17. "default": obj
  18. }
  19. }
  20. function _typeof(obj) {
  21. "@babel/helpers - typeof";
  22. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  23. return typeof obj
  24. } : function(obj) {
  25. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
  26. }, _typeof(obj)
  27. }
  28. function _classCallCheck(instance, Constructor) {
  29. if (!(instance instanceof Constructor)) {
  30. throw new TypeError("Cannot call a class as a function")
  31. }
  32. }
  33. function _defineProperties(target, props) {
  34. for (var i = 0; i < props.length; i++) {
  35. var descriptor = props[i];
  36. descriptor.enumerable = descriptor.enumerable || false;
  37. descriptor.configurable = true;
  38. if ("value" in descriptor) {
  39. descriptor.writable = true
  40. }
  41. Object.defineProperty(target, descriptor.key, descriptor)
  42. }
  43. }
  44. function _createClass(Constructor, protoProps, staticProps) {
  45. if (protoProps) {
  46. _defineProperties(Constructor.prototype, protoProps)
  47. }
  48. if (staticProps) {
  49. _defineProperties(Constructor, staticProps)
  50. }
  51. Object.defineProperty(Constructor, "prototype", {
  52. writable: false
  53. });
  54. return Constructor
  55. }
  56. function _inherits(subClass, superClass) {
  57. if ("function" !== typeof superClass && null !== superClass) {
  58. throw new TypeError("Super expression must either be null or a function")
  59. }
  60. subClass.prototype = Object.create(superClass && superClass.prototype, {
  61. constructor: {
  62. value: subClass,
  63. writable: true,
  64. configurable: true
  65. }
  66. });
  67. Object.defineProperty(subClass, "prototype", {
  68. writable: false
  69. });
  70. if (superClass) {
  71. _setPrototypeOf(subClass, superClass)
  72. }
  73. }
  74. function _setPrototypeOf(o, p) {
  75. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
  76. o.__proto__ = p;
  77. return o
  78. };
  79. return _setPrototypeOf(o, p)
  80. }
  81. function _createSuper(Derived) {
  82. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  83. return function() {
  84. var result, Super = _getPrototypeOf(Derived);
  85. if (hasNativeReflectConstruct) {
  86. var NewTarget = _getPrototypeOf(this).constructor;
  87. result = Reflect.construct(Super, arguments, NewTarget)
  88. } else {
  89. result = Super.apply(this, arguments)
  90. }
  91. return _possibleConstructorReturn(this, result)
  92. }
  93. }
  94. function _possibleConstructorReturn(self, call) {
  95. if (call && ("object" === _typeof(call) || "function" === typeof call)) {
  96. return call
  97. } else {
  98. if (void 0 !== call) {
  99. throw new TypeError("Derived constructors may only return object or undefined")
  100. }
  101. }
  102. return _assertThisInitialized(self)
  103. }
  104. function _assertThisInitialized(self) {
  105. if (void 0 === self) {
  106. throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  107. }
  108. return self
  109. }
  110. function _isNativeReflectConstruct() {
  111. if ("undefined" === typeof Reflect || !Reflect.construct) {
  112. return false
  113. }
  114. if (Reflect.construct.sham) {
  115. return false
  116. }
  117. if ("function" === typeof Proxy) {
  118. return true
  119. }
  120. try {
  121. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  122. return true
  123. } catch (e) {
  124. return false
  125. }
  126. }
  127. function _getPrototypeOf(o) {
  128. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
  129. return o.__proto__ || Object.getPrototypeOf(o)
  130. };
  131. return _getPrototypeOf(o)
  132. }
  133. var MenuBaseEditStrategy = function(_PlainEditStrategy) {
  134. _inherits(MenuBaseEditStrategy, _PlainEditStrategy);
  135. var _super = _createSuper(MenuBaseEditStrategy);
  136. function MenuBaseEditStrategy() {
  137. _classCallCheck(this, MenuBaseEditStrategy);
  138. return _super.apply(this, arguments)
  139. }
  140. _createClass(MenuBaseEditStrategy, [{
  141. key: "_getPlainItems",
  142. value: function() {
  143. return (0, _iterator.map)(this._collectionWidget.option("items"), function getMenuItems(item) {
  144. return item.items ? [item].concat((0, _iterator.map)(item.items, getMenuItems)) : item
  145. })
  146. }
  147. }, {
  148. key: "_stringifyItem",
  149. value: function(item) {
  150. var _this = this;
  151. return JSON.stringify(item, function(key, value) {
  152. if ("template" === key) {
  153. return _this._getTemplateString(value)
  154. }
  155. return value
  156. })
  157. }
  158. }, {
  159. key: "_getTemplateString",
  160. value: function(template) {
  161. var result;
  162. if ("object" === _typeof(template)) {
  163. result = (0, _renderer2.default)(template).text()
  164. } else {
  165. result = template.toString()
  166. }
  167. return result
  168. }
  169. }]);
  170. return MenuBaseEditStrategy
  171. }(_uiCollection_widgetEditStrategy2.default);
  172. module.exports = MenuBaseEditStrategy;