common.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
  3. exports.__esModule = true;
  4. var _exportNames = {
  5. isObjectValueEqual: true,
  6. parsePadding: true,
  7. directionEnabled: true,
  8. upperFirst: true,
  9. lowerFirst: true,
  10. isString: true,
  11. isNumber: true,
  12. isBoolean: true,
  13. isFunction: true,
  14. isDate: true,
  15. isArray: true,
  16. isNil: true,
  17. isObject: true,
  18. isPlainObject: true,
  19. isEqual: true,
  20. deepMix: true,
  21. mix: true,
  22. each: true,
  23. uniq: true,
  24. find: true,
  25. Array: true
  26. };
  27. exports.isObjectValueEqual = isObjectValueEqual;
  28. exports.parsePadding = parsePadding;
  29. exports.directionEnabled = directionEnabled;
  30. exports.Array = void 0;
  31. var _util = require("@antv/util");
  32. exports.upperFirst = _util.upperFirst;
  33. exports.lowerFirst = _util.lowerFirst;
  34. exports.isString = _util.isString;
  35. exports.isNumber = _util.isNumber;
  36. exports.isBoolean = _util.isBoolean;
  37. exports.isFunction = _util.isFunction;
  38. exports.isDate = _util.isDate;
  39. exports.isArray = _util.isArray;
  40. exports.isNil = _util.isNil;
  41. exports.isObject = _util.isObject;
  42. exports.isPlainObject = _util.isPlainObject;
  43. exports.isEqual = _util.isEqual;
  44. exports.deepMix = _util.deepMix;
  45. exports.mix = _util.mix;
  46. exports.each = _util.each;
  47. exports.uniq = _util.uniq;
  48. exports.find = _util.find;
  49. var ArrayUtil = _interopRequireWildcard(require("./array"));
  50. exports.Array = ArrayUtil;
  51. var _dom = require("./dom");
  52. Object.keys(_dom).forEach(function (key) {
  53. if (key === "default" || key === "__esModule") return;
  54. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  55. exports[key] = _dom[key];
  56. });
  57. /**
  58. * @fileOverview Utility for F2
  59. * @author dxq613 @gmail.com
  60. * @author sima.zhang1990@gmail.com
  61. */
  62. function isObjectValueEqual(a, b) {
  63. // for vue.js
  64. a = Object.assign({}, a);
  65. b = Object.assign({}, b);
  66. var aProps = Object.getOwnPropertyNames(a);
  67. var bProps = Object.getOwnPropertyNames(b);
  68. if (aProps.length !== bProps.length) {
  69. return false;
  70. }
  71. for (var i = 0, len = aProps.length; i < len; i++) {
  72. var propName = aProps[i];
  73. if (a[propName] !== b[propName]) {
  74. return false;
  75. }
  76. }
  77. return true;
  78. }
  79. function parsePadding(padding) {
  80. var top;
  81. var right;
  82. var bottom;
  83. var left;
  84. if ((0, _util.isNumber)(padding) || (0, _util.isString)(padding)) {
  85. top = bottom = left = right = padding;
  86. } else if ((0, _util.isArray)(padding)) {
  87. top = padding[0];
  88. right = !(0, _util.isNil)(padding[1]) ? padding[1] : padding[0];
  89. bottom = !(0, _util.isNil)(padding[2]) ? padding[2] : padding[0];
  90. left = !(0, _util.isNil)(padding[3]) ? padding[3] : right;
  91. }
  92. return [top, right, bottom, left];
  93. }
  94. function directionEnabled(mode, dir) {
  95. if (mode === undefined) {
  96. return true;
  97. } else if (typeof mode === 'string') {
  98. return mode.indexOf(dir) !== -1;
  99. }
  100. return false;
  101. }