New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dom-render

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-render - npm Package Compare versions

Comparing version 1.0.57 to 1.0.58

dist/validators/AllCheckedValidatorArray.d.ts

1

dist/DomRenderProxy.d.ts

@@ -11,2 +11,3 @@ import { RawSet } from './RawSet';

constructor(_domRender_origin: T, target?: Node, config?: Config | undefined);
static unFinal<T = any>(obj: T): T;
static final<T = any>(obj: T): T;

@@ -13,0 +14,0 @@ static isFinal<T = any>(obj: T): boolean;

@@ -22,2 +22,3 @@ export declare class RangeResult implements IteratorResult<number> {

static range(first: number | string, last?: number, step?: number): Range;
toArray(): number[];
}

18

dist/validators/Validator.d.ts
export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean;
export declare abstract class Validator<T = any, E = Element> {
protected _value?: T | undefined;
target?: E | undefined;
event?: Event | undefined;
autoValid: boolean;
constructor(_value?: T | undefined, target?: E | undefined, event?: Event | undefined, autoValid?: boolean);
private _target?;
private _event?;
private _autoValid;
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean);
getAutoValid(): boolean;
setAutoValid(autoValid: boolean): this;
getEvent(): Event | undefined;
setEvent(event: Event | undefined): this;
getTarget(): E | undefined;
setTarget(target: E | undefined): this;
get value(): T | undefined;
set value(value: T | undefined);
set(value?: T, target?: E, event?: Event): void;
changeValue(value: T | undefined): void;
getOriginTarget(): any;
get checked(): boolean;

@@ -20,2 +26,4 @@ set checked(checked: boolean);

inValid(): boolean;
allValid(): boolean;
allInValid(): boolean;
childValids(): boolean;

@@ -22,0 +30,0 @@ childInValids(): boolean;

import { Validator } from './Validator';
export declare type MakeValidator<T = any, E = Element> = (value: T, target: E, event?: Event) => Validator<T, E>;
export declare abstract class ValidatorArray<T = any, E = Element> extends Validator<Validator<T, E>[], E> {
event?: Event | undefined;
autoValid: boolean;
constructor(value?: Validator<T, E>[], target?: E, event?: Event | undefined, autoValid?: boolean);
private _makeValidatorFactory;
constructor(value?: Validator<T, E>[], target?: E, event?: Event, autoValid?: boolean);
getMakeValidatorFactory(): MakeValidator<T, E>;
setMakeValidatorFactory(value: MakeValidator<T, E>): this;
setArrayValue(target: E, value: T, event?: Event): void;
addValidator(value: T, target: E, event?: Event): void;
allChecked(checked: boolean): void;
getValidators(): Validator<T, E>[] | undefined;
setValue(target: E, value: T, event?: Event): void;
addValidator(value: T, target: E, event?: Event): void;
getValidator(e: E): Validator<T, E> | undefined;
getValidatorByValue(value: T): Validator<T, E>;
getValidatorByValues(value: T): Validator<T, E>[];
removeElement(e: E): void;
makeValidator(value: T, target: E, event?: Event): Validator<T, E>;
}

@@ -11,2 +11,3 @@ import { RawSet } from './RawSet';

constructor(_domRender_origin: T, target?: Node, config?: Config | undefined);
static unFinal<T = any>(obj: T): T;
static final<T = any>(obj: T): T;

@@ -13,0 +14,0 @@ static isFinal<T = any>(obj: T): boolean;

@@ -17,14 +17,9 @@ import { RawSet } from './RawSet';

}
DomRenderProxy.unFinal = function (obj) {
delete obj._DomRender_isFinal;
return obj;
};
DomRenderProxy.final = function (obj) {
return new Proxy(obj, {
get: function (target, p, receiver) {
if (p === '_DomRender_origin') {
return obj;
}
return target[p];
},
has: function (target, p) {
return p === '_DomRender_isFinal' || p in target;
}
});
obj._DomRender_isFinal = true;
return obj;
};

@@ -31,0 +26,0 @@ DomRenderProxy.isFinal = function (obj) {

@@ -22,2 +22,3 @@ export declare class RangeResult implements IteratorResult<number> {

static range(first: number | string, last?: number, step?: number): Range;
toArray(): number[];
}

@@ -17,2 +17,11 @@ var __read = (this && this.__read) || function (o, n) {

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var RangeResult = (function () {

@@ -75,4 +84,7 @@ function RangeResult(value, done) {

};
Range.prototype.toArray = function () {
return __spreadArray([], __read(this), false);
};
return Range;
}());
export { Range };
{
"name": "dom-render",
"version": "1.0.57",
"version": "1.0.58",
"main": "DomRender.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -179,2 +179,6 @@ var __read = (this && this.__read) || function (o, n) {

RawSet.drFormOtherMoveAttr(element_2, 'name', 'temp-name');
var data = ScriptUtils.evalReturn("" + drAttr_1.drForm, obj);
if (data instanceof Validator) {
data.setTarget(element_2);
}
element_2.querySelectorAll('[name]').forEach(function (it) {

@@ -186,16 +190,15 @@ var _a;

if (varpath != null) {
var data = ScriptUtils.evalReturn("" + drAttr_1.drForm + (varpath ? '.' + varpath : ''), obj);
if (data instanceof ValidatorArray) {
var data_1 = ScriptUtils.evalReturn("" + drAttr_1.drForm + (varpath ? '.' + varpath : ''), obj);
if (data_1 instanceof ValidatorArray) {
varpath = drAttr_1.drForm + '.' + varpath;
it.setAttribute(attrEventName, varpath + ".setValue($target, $target.value, $event);");
data.addValidator(it.value, it);
it.setAttribute(attrEventName, varpath + ".setArrayValue($target, $target.value, $event);");
data_1.addValidator(it.value, it);
}
else if (data instanceof Validator) {
var target = drAttr_1.drForm + '.' + varpath + '.target';
var event_1 = drAttr_1.drForm + '.' + varpath + '.event';
else if (data_1 instanceof Validator) {
var fieldPath = drAttr_1.drForm + '.' + varpath;
varpath += (varpath ? '.value' : 'value');
varpath = drAttr_1.drForm + '.' + varpath;
it.setAttribute(attrEventName, varpath + " = $target.value; " + target + "=$target; " + event_1 + "=$event;");
data.target = it;
data.value = it.value;
it.setAttribute(attrEventName, varpath + " = $target.value; " + fieldPath + ".setTarget($target); " + fieldPath + ".setEvent($event);");
data_1.setTarget(it);
data_1.value = it.value;
}

@@ -202,0 +205,0 @@ else {

@@ -240,3 +240,3 @@ ![Single Page Application Framworks](assets/banner.png)

```typescript
class PageValidator extends Validator {
class PageValidator extends FormValidator {
required = new RequiredValidator();

@@ -255,6 +255,2 @@ notEmpty = new NotEmptyValidator();

});
valid(): boolean {
return super.childValids();
}
}

@@ -266,2 +262,6 @@ class User {

}
changeData() {
this.form.required.value = 'new value';
}
}

@@ -293,13 +293,45 @@ ```

- ValidatorArray (abstract)
- ValidValidator
- ValidMultipleValidator
- ValidValidatorArray
- BlockValidator
- AllCheckedValidatorArray
- AllUnCheckedValidatorArray
- CheckedValidator
- CountEqualsCheckedValidatorArray
- CountEqualsUnCheckedValidatorArray
- CountGreaterThanCheckedValidatorArray
- CountGreaterThanEqualsCheckedValidatorArray
- CountGreaterThanEqualsUnCheckedValidatorArray
- CountGreaterThanUnCheckedValidatorArray
- CountLessThanCheckedValidatorArray
- CountLessThanEqualsCheckedValidatorArray
- CountLessThanEqualsUnCheckedValidatorArray
- CountLessThanUnCheckedValidatorArray
- CountUnCheckedValidatorArray
- EmptyValidator
- ExcludeCheckedValidatorArray
- FormValidator
- IncludeCheckedValidatorArray
- MultipleValidator
- NonPassValidator
- NotEmptyValidator
- NotRegExpTestValidator
- PassValidator
- RegExpTestValidator
- RequiredValidator
- SkipValidator
- UnCheckedValidator
- ValidMultipleValidator
- ValidValidator
- ValidValidatorArray
- ValueEqualsValidator
- ValueNotEqualsValidator
# Class
## Range
```typescript
const range = new Range(100,55, 10);
for (let data of new Range(100,55, 10)) {
console.log(data);
}
const rangeArray = new Range(100,55, 10).toArray();
```
# Detect Get, Set

@@ -306,0 +338,0 @@ OnBeforeReturnSet

@@ -25,3 +25,3 @@ var __extends = (this && this.__extends) || (function () {

var _a, _b;
return (_b = (_a = this.target) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
};

@@ -28,0 +28,0 @@ return CheckedValidator;

@@ -23,7 +23,3 @@ var __extends = (this && this.__extends) || (function () {

_this.validators = validators;
_this.validators.forEach(function (it) {
it.value = _this.value;
it.target = _this.target;
it.event = _this.event;
});
_this.validators.forEach(function (it) { return it.set(_this.value, _this.getTarget(), _this.getEvent()); });
return _this;

@@ -33,7 +29,3 @@ }

var _this = this;
this.validators.forEach(function (it) {
it.value = value;
it.target = _this.target;
it.event = _this.event;
});
this.validators.forEach(function (it) { return it.set(_this.value, _this.getTarget(), _this.getEvent()); });
};

@@ -40,0 +32,0 @@ MultipleValidator.prototype.valid = function () {

export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean;
export declare abstract class Validator<T = any, E = Element> {
protected _value?: T | undefined;
target?: E | undefined;
event?: Event | undefined;
autoValid: boolean;
constructor(_value?: T | undefined, target?: E | undefined, event?: Event | undefined, autoValid?: boolean);
private _target?;
private _event?;
private _autoValid;
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean);
getAutoValid(): boolean;
setAutoValid(autoValid: boolean): this;
getEvent(): Event | undefined;
setEvent(event: Event | undefined): this;
getTarget(): E | undefined;
setTarget(target: E | undefined): this;
get value(): T | undefined;
set value(value: T | undefined);
set(value?: T, target?: E, event?: Event): void;
changeValue(value: T | undefined): void;
getOriginTarget(): any;
get checked(): boolean;

@@ -20,2 +26,4 @@ set checked(checked: boolean);

inValid(): boolean;
allValid(): boolean;
allInValid(): boolean;
childValids(): boolean;

@@ -22,0 +30,0 @@ childInValids(): boolean;

@@ -17,2 +17,3 @@ var __read = (this && this.__read) || function (o, n) {

};
import { DomRenderProxy } from '../DomRenderProxy';
var Validator = (function () {

@@ -22,18 +23,47 @@ function Validator(_value, target, event, autoValid) {

this._value = _value;
this.target = target;
this.event = event;
this.autoValid = autoValid;
this.setTarget(target);
this.setEvent(event);
this.setAutoValid(autoValid);
}
Validator.prototype.getAutoValid = function () {
return this._autoValid;
};
Validator.prototype.setAutoValid = function (autoValid) {
this._autoValid = autoValid;
return this;
};
Validator.prototype.getEvent = function () {
return this._event;
};
Validator.prototype.setEvent = function (event) {
if (event) {
this._event = DomRenderProxy.final(event);
}
return this;
};
Validator.prototype.getTarget = function () {
return this._target;
};
Validator.prototype.setTarget = function (target) {
if (target) {
this._target = DomRenderProxy.final(target);
}
return this;
};
Object.defineProperty(Validator.prototype, "value", {
get: function () {
var _a;
if (this._value === undefined || this._value === null) {
this._value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
}
return this._value;
},
set: function (value) {
var _a;
this._value = value;
this.changeValue(value);
if ((_a = this.target) === null || _a === void 0 ? void 0 : _a.value) {
this.target.value = this._value;
var target = this.getTarget();
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) {
target.value = this._value;
}
if (this.autoValid) {
if (this.getAutoValid()) {
this.valid();

@@ -45,15 +75,19 @@ }

});
Validator.prototype.set = function (value, target, event) {
this.value = value;
this.setTarget(target);
this.setEvent(event);
};
Validator.prototype.changeValue = function (value) {
};
Validator.prototype.getOriginTarget = function () {
var _a, _b;
return ((_b = (_a = this.target) === null || _a === void 0 ? void 0 : _a._DomRender_origin) !== null && _b !== void 0 ? _b : this.target);
};
Object.defineProperty(Validator.prototype, "checked", {
get: function () {
var _a, _b;
return (_b = (_a = this.target) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
},
set: function (checked) {
this.target.checked = checked;
var target = this.getTarget();
if (target) {
target.checked = checked;
}
},

@@ -66,6 +100,9 @@ enumerable: false,

var _a, _b;
return (_b = (_a = this.target) === null || _a === void 0 ? void 0 : _a.selectedIndex) !== null && _b !== void 0 ? _b : -1;
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.selectedIndex) !== null && _b !== void 0 ? _b : -1;
},
set: function (selectedIndex) {
this.target.selectedIndex = selectedIndex;
var target = this.getTarget();
if (target) {
target.selectedIndex = selectedIndex;
}
},

@@ -77,7 +114,7 @@ enumerable: false,

var _a;
return (_a = this.target) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
};
Validator.prototype.querySelectorALL = function (selector) {
var _a;
return (_a = this.target) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
};

@@ -88,2 +125,8 @@ Validator.prototype.inValid = function () {

;
Validator.prototype.allValid = function () {
return this.valid() && this.childInValids();
};
Validator.prototype.allInValid = function () {
return !this.allValid();
};
Validator.prototype.childValids = function () {

@@ -90,0 +133,0 @@ return !this.childInValids();

import { Validator } from './Validator';
export declare type MakeValidator<T = any, E = Element> = (value: T, target: E, event?: Event) => Validator<T, E>;
export declare abstract class ValidatorArray<T = any, E = Element> extends Validator<Validator<T, E>[], E> {
event?: Event | undefined;
autoValid: boolean;
constructor(value?: Validator<T, E>[], target?: E, event?: Event | undefined, autoValid?: boolean);
private _makeValidatorFactory;
constructor(value?: Validator<T, E>[], target?: E, event?: Event, autoValid?: boolean);
getMakeValidatorFactory(): MakeValidator<T, E>;
setMakeValidatorFactory(value: MakeValidator<T, E>): this;
setArrayValue(target: E, value: T, event?: Event): void;
addValidator(value: T, target: E, event?: Event): void;
allChecked(checked: boolean): void;
getValidators(): Validator<T, E>[] | undefined;
setValue(target: E, value: T, event?: Event): void;
addValidator(value: T, target: E, event?: Event): void;
getValidator(e: E): Validator<T, E> | undefined;
getValidatorByValue(value: T): Validator<T, E>;
getValidatorByValues(value: T): Validator<T, E>[];
removeElement(e: E): void;
makeValidator(value: T, target: E, event?: Event): Validator<T, E>;
}

@@ -17,3 +17,3 @@ var __extends = (this && this.__extends) || (function () {

import { Validator } from './Validator';
import { BlockValidator } from './BlockValidator';
import { NonPassValidator } from './NonPassValidator';
var ValidatorArray = (function (_super) {

@@ -24,14 +24,19 @@ __extends(ValidatorArray, _super);

var _this = _super.call(this, value, target, event, autoValid) || this;
_this.event = event;
_this.autoValid = autoValid;
_this._makeValidatorFactory = function (value, target, event) {
return new NonPassValidator(value, target, event);
};
return _this;
}
ValidatorArray.prototype.getValidators = function () {
return this._value;
ValidatorArray.prototype.getMakeValidatorFactory = function () {
return this._makeValidatorFactory;
};
ValidatorArray.prototype.setValue = function (target, value, event) {
ValidatorArray.prototype.setMakeValidatorFactory = function (value) {
this._makeValidatorFactory = value;
return this;
};
ValidatorArray.prototype.setArrayValue = function (target, value, event) {
var _a;
(_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) {
if (it.target) {
return it.target === target || it.target._DomRender_origin === target;
if (it.getTarget()) {
return it.getTarget() === target;
}

@@ -42,4 +47,3 @@ else {

}).forEach(function (it) {
it.value = value;
it.event = event;
it.set(value, target, event);
});

@@ -59,14 +63,32 @@ };

};
ValidatorArray.prototype.allChecked = function (checked) {
var _a;
this.checked = checked;
(_a = this.value) === null || _a === void 0 ? void 0 : _a.forEach(function (it) {
it.checked = checked;
});
};
ValidatorArray.prototype.getValidators = function () {
return this._value;
};
ValidatorArray.prototype.getValidator = function (e) {
var _a;
return (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) { var _a, _b; return ((_b = (_a = it.target) === null || _a === void 0 ? void 0 : _a._DomRender_origin) !== null && _b !== void 0 ? _b : it.target) === e; })[0];
return (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) { return it.getTarget() === e; })[0];
};
ValidatorArray.prototype.getValidatorByValue = function (value) {
var validatorByValue = this.getValidatorByValues(value)[0];
return validatorByValue;
};
ValidatorArray.prototype.getValidatorByValues = function (value) {
var _a, _b;
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) { return it.value === value; })) !== null && _b !== void 0 ? _b : [];
};
ValidatorArray.prototype.removeElement = function (e) {
var value = this.value;
if (value) {
this.value = value.filter(function (it) { var _a, _b; return ((_b = (_a = it.target) === null || _a === void 0 ? void 0 : _a._DomRender_origin) !== null && _b !== void 0 ? _b : it.target) !== e; });
this.value = value.filter(function (it) { return it.getTarget() !== e; });
}
};
ValidatorArray.prototype.makeValidator = function (value, target, event) {
return new BlockValidator(value, target, event);
return this._makeValidatorFactory(value, target, event);
};

@@ -73,0 +95,0 @@ ;

@@ -27,3 +27,3 @@ var __extends = (this && this.__extends) || (function () {

ValidMultipleValidator.prototype.valid = function () {
return this.validMultipleCallback(this.validators, this.value, this.target, this.event);
return this.validMultipleCallback(this.validators, this.value, this.getTarget(), this.getEvent());
};

@@ -30,0 +30,0 @@ return ValidMultipleValidator;

@@ -26,3 +26,3 @@ var __extends = (this && this.__extends) || (function () {

ValidValidatorArray.prototype.valid = function () {
return this.validCallBack(this.value, this.target, this.event);
return this.validCallBack(this.value, this.getTarget(), this.getEvent());
};

@@ -29,0 +29,0 @@ return ValidValidatorArray;

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

Sorry, the diff of this file is not supported yet

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