Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devexpress/utils

Package Overview
Dependencies
Maintainers
37
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devexpress/utils - npm Package Compare versions

Comparing version 1.0.0-alpha-011 to 1.0.0-alpha-012

25

lib/geometry/rectangle.d.ts

@@ -12,14 +12,19 @@ import { Flag } from '../class/flag';

height: number;
static empty(): Rectangle;
constructor(x: number, y: number, width: number, height: number);
static fromGeometry(point: IPoint, size: ISize): Rectangle;
static fromPoints(pointA: IPoint, pointB: IPoint): Rectangle;
static fromPositions(x1: number, y1: number, x2: number, y2: number): Rectangle;
static fromCenter(center: Point, minRadius: number): Rectangle;
isCollapsed(): boolean;
isEmpty(): boolean;
toString(): string;
setPosition(pos: IPoint): this;
setSize(size: ISize): this;
setPoint(pos: IPoint): this;
moveRectangle(offset: IPoint): this;
setGeomerty(rect: IRectangle): this;
setHorizontalBounds(interval: FixedInterval): this;
setVerticalBounds(interval: FixedInterval): this;
static empty(): Rectangle;
moveRectangle(offsetX: number, offsetY: number): this;
moveRectangleByPoint(offset: IPoint): this;
resize(deltaX: number, deltaY: number): this;
normalizeSize(): this;
multiply(multiplierX: number, multiplierY: number): this;
equals(obj: IRectangle): boolean;

@@ -30,3 +35,2 @@ clone(): Rectangle;

containsRectangle(rectangle: Rectangle): boolean;
mergeWithRectangle(rectangle: IRectangle): this;
inflate(deltaX: number, deltaY?: number): this;

@@ -37,7 +41,10 @@ applyOffsetsInside(offsets: IOffsets): this;

applyConverter(converter: SimpleConverter<number>): this;
static fromCenter(center: Point, minRadius: number): Rectangle;
static fromPoints(pointA: IPoint, pointB: IPoint): Rectangle;
static fromGeometry(point: IPoint, size: ISize): Rectangle;
static getHorizIntersection(objA: IRectangle, objB: IRectangle): FixedInterval | null;
static getVertIntersection(objA: IRectangle, objB: IRectangle): FixedInterval | null;
static getIntersection(objA: IRectangle, objB: IRectangle): Rectangle | null;
static getHorNonCollapsedIntersection(objA: Rectangle, objB: Rectangle): FixedInterval | null;
static getVertNonCollapsedIntersection(objA: Rectangle, objB: Rectangle): FixedInterval | null;
static getNonCollapsedIntersection(objA: Rectangle, objB: Rectangle): Rectangle | null;
static isIntersect(rectA: IRectangle, rectB: IRectangle): boolean;
static union(rectA: IRectangle, rectB: IRectangle): Rectangle;
static equalsBinary(a: IRectangle, b: IRectangle): boolean;

@@ -44,0 +51,0 @@ static center(rect: IRectangle): Point;

@@ -15,4 +15,6 @@ "use strict";

this.height = height;
return this;
}
Rectangle.empty = function () {
return new Rectangle(0, 0, 0, 0);
};
Object.defineProperty(Rectangle.prototype, "right", {

@@ -74,2 +76,22 @@ get: function () {

});
Rectangle.fromGeometry = function (point, size) {
return new Rectangle(point.x, point.y, size.width, size.height);
};
Rectangle.fromPoints = function (pointA, pointB) {
var x = Math.min(pointA.x, pointB.x);
var y = Math.min(pointA.y, pointB.y);
var width = Math.abs(pointA.x - pointB.x);
var height = Math.abs(pointA.y - pointB.y);
return new Rectangle(x, y, width, height);
};
Rectangle.fromPositions = function (x1, y1, x2, y2) {
var x = Math.min(x1, x2);
var y = Math.min(y1, y2);
var width = Math.abs(x2 - x1);
var height = Math.abs(y2 - y1);
return new Rectangle(x, y, width, height);
};
Rectangle.fromCenter = function (center, minRadius) {
return new Rectangle(center.x - minRadius, center.y - minRadius, minRadius * 2, minRadius * 2);
};
Rectangle.prototype.isCollapsed = function () {

@@ -85,8 +107,3 @@ return this.width === 0 || this.height === 0;

};
Rectangle.prototype.setSize = function (size) {
this.width = size.width;
this.height = size.height;
return this;
};
Rectangle.prototype.setPoint = function (pos) {
Rectangle.prototype.setPosition = function (pos) {
this.x = pos.x;

@@ -96,5 +113,5 @@ this.y = pos.y;

};
Rectangle.prototype.moveRectangle = function (offset) {
this.x += offset.x;
this.y += offset.y;
Rectangle.prototype.setSize = function (size) {
this.width = size.width;
this.height = size.height;
return this;

@@ -109,14 +126,16 @@ };

};
Rectangle.prototype.setHorizontalBounds = function (interval) {
this.x = interval.start;
this.width = interval.length;
Rectangle.prototype.moveRectangle = function (offsetX, offsetY) {
this.x += offsetX;
this.y += offsetY;
return this;
};
Rectangle.prototype.setVerticalBounds = function (interval) {
this.y = interval.start;
this.height = interval.length;
Rectangle.prototype.moveRectangleByPoint = function (offset) {
this.x += offset.x;
this.y += offset.y;
return this;
};
Rectangle.empty = function () {
return new Rectangle(0, 0, 0, 0);
Rectangle.prototype.resize = function (deltaX, deltaY) {
this.width += deltaX;
this.height += deltaY;
return this;
};

@@ -130,2 +149,9 @@ Rectangle.prototype.normalizeSize = function () {

};
Rectangle.prototype.multiply = function (multiplierX, multiplierY) {
this.x *= multiplierX;
this.y *= multiplierY;
this.width *= multiplierX;
this.height *= multiplierY;
return this;
};
Rectangle.prototype.equals = function (obj) {

@@ -154,11 +180,2 @@ return Rectangle.equalsBinary(this, obj);

};
Rectangle.prototype.mergeWithRectangle = function (rectangle) {
var right = Math.max(this.right, rectangle.x + rectangle.width);
var bottom = Math.max(this.bottom, rectangle.y + rectangle.height);
this.x = Math.min(this.x, rectangle.x);
this.y = Math.min(this.y, rectangle.y);
this.width = right - this.x;
this.height = bottom - this.y;
return this;
};
Rectangle.prototype.inflate = function (deltaX, deltaY) {

@@ -222,15 +239,8 @@ if (deltaY === void 0) { deltaY = deltaX; }

};
Rectangle.fromCenter = function (center, minRadius) {
return new Rectangle(center.x - minRadius, center.y - minRadius, minRadius * 2, minRadius * 2);
Rectangle.getHorizIntersection = function (objA, objB) {
return algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.x, objA.width), new fixed_1.FixedInterval(objB.x, objB.width));
};
Rectangle.fromPoints = function (pointA, pointB) {
var x = Math.min(pointA.x, pointB.x);
var y = Math.min(pointA.y, pointB.y);
var width = Math.abs(pointA.x - pointB.x);
var height = Math.abs(pointA.y - pointB.y);
return new Rectangle(x, y, width, height);
Rectangle.getVertIntersection = function (objA, objB) {
return algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.y, objA.height), new fixed_1.FixedInterval(objB.y, objB.height));
};
Rectangle.fromGeometry = function (point, size) {
return new Rectangle(point.x, point.y, size.width, size.height);
};
Rectangle.getIntersection = function (objA, objB) {

@@ -245,2 +255,10 @@ var horInters = algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.x, objA.width), new fixed_1.FixedInterval(objB.x, objB.width));

};
Rectangle.getHorNonCollapsedIntersection = function (objA, objB) {
var inters = Rectangle.getHorizIntersection(objA, objB);
return inters && !inters.isCollapsed() ? inters : null;
};
Rectangle.getVertNonCollapsedIntersection = function (objA, objB) {
var inters = Rectangle.getVertIntersection(objA, objB);
return inters && !inters.isCollapsed() ? inters : null;
};
Rectangle.getNonCollapsedIntersection = function (objA, objB) {

@@ -250,2 +268,13 @@ var inters = Rectangle.getIntersection(objA, objB);

};
Rectangle.isIntersect = function (rectA, rectB) {
return !(rectA.x > rectB.x + rectB.width || rectB.x > rectA.x + rectA.width) &&
!(rectA.y > rectB.y + rectB.height || rectB.y > rectA.y + rectA.height);
};
Rectangle.union = function (rectA, rectB) {
var right = Math.max(rectA.x + rectA.width, rectB.x + rectB.width);
var bottom = Math.max(rectA.y + rectA.height, rectB.y + rectB.height);
var x = Math.min(rectA.x, rectB.x);
var y = Math.min(rectA.y, rectB.y);
return new Rectangle(x, y, right - x, bottom - y);
};
Rectangle.equalsBinary = function (a, b) {

@@ -252,0 +281,0 @@ return a.x === b.x &&

@@ -16,3 +16,3 @@ export declare enum Base64MimeType {

static normalizeToDataUrl(base64: string, mimeType: string): string;
static prependByDataUrl(base64: string, mimeType?: string): string;
static prependByDataUrl(base64: string, mimeType: string): string;
static checkPrependDataUrl(base64: string): boolean;

@@ -19,0 +19,0 @@ static deleteDataUrlPrefix(base64DataUrl: string): string;

@@ -26,3 +26,2 @@ "use strict";

Base64Utils.prependByDataUrl = function (base64, mimeType) {
if (mimeType === void 0) { mimeType = 'image/png'; }
return "data:" + mimeType + ";base64," + base64;

@@ -29,0 +28,0 @@ };

@@ -21,4 +21,5 @@ import { IPoint, IRectangle, ISize } from '../geometry/interfaces';

static hasClassName(element: Element, className: string): boolean;
static addClassName(element: HTMLElement, className: string): void;
static removeClassName(element: HTMLElement, className: string): void;
static addClassName(element: Element, className: string): void;
static removeClassName(element: Element, className: string): void;
static toggleClassName(element: Element, className: string, toggle?: boolean): void;
static pxToInt(px: string): number;

@@ -25,0 +26,0 @@ static pxToFloat(px: string): number;

@@ -140,5 +140,6 @@ "use strict";

else {
if (!element.className)
var elementClassName = element.getAttribute && element.getAttribute('class');
if (!elementClassName)
return false;
var elementClasses = element.className.split(' ');
var elementClasses = elementClassName.split(' ');
for (var i = classNames.length - 1; i >= 0; i--) {

@@ -156,12 +157,28 @@ if (elementClasses.indexOf(classNames[i]) < 0)

DomUtils.addClassName = function (element, className) {
className = className.trim();
if (!DomUtils.hasClassName(element, className) && className !== '')
element.className = (element.className === '') ? className : element.className + " " + className;
if (!DomUtils.hasClassName(element, className)) {
var elementClassName = element.getAttribute && element.getAttribute('class');
element.setAttribute('class', elementClassName === '' ? className : elementClassName + " " + className);
}
};
DomUtils.removeClassName = function (element, className) {
var updClassName = " " + element.className + " ";
var elementClassName = element.getAttribute && element.getAttribute('class');
var updClassName = " " + elementClassName + " ";
var newClassName = updClassName.replace(" " + className + " ", ' ');
if (updClassName.length !== newClassName.length)
element.className = string_1.StringUtils.trim(newClassName);
element.setAttribute('class', string_1.StringUtils.trim(newClassName));
};
DomUtils.toggleClassName = function (element, className, toggle) {
if (toggle === undefined) {
if (DomUtils.hasClassName(element, className))
DomUtils.removeClassName(element, className);
else
DomUtils.addClassName(element, className);
}
else {
if (toggle)
DomUtils.addClassName(element, className);
else
DomUtils.removeClassName(element, className);
}
};
DomUtils.pxToInt = function (px) {

@@ -168,0 +185,0 @@ return pxToNumber(px, parseInt);

export declare class EvtUtils {
static preventEvent(evt: Event): boolean;
static preventEvent(evt: Event): void;
static getEventSource(evt: Event): HTMLElement | null;
static getEventSourceByPosition(evt: MouseEvent | TouchEvent): HTMLElement | null;
static getMouseWheelEventName(): string;

@@ -5,0 +6,0 @@ static isLeftButtonPressed(evt: Event): boolean;

@@ -16,3 +16,2 @@ "use strict";

evt.returnValue = false;
return false;
};

@@ -24,2 +23,9 @@ EvtUtils.getEventSource = function (evt) {

};
EvtUtils.getEventSourceByPosition = function (evt) {
if (!common_1.isDefined(evt))
return null;
if (document.elementFromPoint && EvtUtils.getEventX(evt) !== undefined && EvtUtils.getEventY(evt) !== undefined)
return document.elementFromPoint(EvtUtils.getEventX(evt), EvtUtils.getEventY(evt));
return evt.srcElement ? evt.srcElement : evt.target;
};
EvtUtils.getMouseWheelEventName = function () {

@@ -26,0 +32,0 @@ if (browser_1.Browser.Safari)

@@ -25,2 +25,3 @@ import { ExtendedMin, ExtendedMinMax, MinMax, ExtendedMax } from '../class/min-max';

static equals<T extends IEquatable<T>>(a: T[], b: T[]): boolean;
static equalsByReference(a: any[], b: any[]): boolean;
static unique<T>(list: T[], cmp: CmpFunc<T>, equal?: CmpFunc<T>, finalizeObj?: (obj: T) => void): T[];

@@ -27,0 +28,0 @@ static uniqueNumber(list: number[]): number[];

@@ -125,2 +125,13 @@ "use strict";

};
ListUtils.equalsByReference = function (a, b) {
var aLen = a.length;
var bLen = a.length;
if (aLen !== bLen)
return false;
for (var i = 0; i < aLen; i++) {
if (a[i] !== b[i])
return false;
}
return true;
};
ListUtils.unique = function (list, cmp, equal, finalizeObj) {

@@ -127,0 +138,0 @@ if (equal === void 0) { equal = cmp; }

{
"name": "@devexpress/utils",
"version": "1.0.0-alpha-011",
"version": "1.0.0-alpha-012",
"description": "DevExpress utils",

@@ -5,0 +5,0 @@ "author": "DevExpress Inc.",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc