htmlrapier
Advanced tools
+1
-1
| { | ||
| "name": "htmlrapier", | ||
| "version": "26.0.0", | ||
| "version": "27.0.0", | ||
| "private": false, | ||
@@ -5,0 +5,0 @@ "dependencies": { |
+9
-54
@@ -71,7 +71,5 @@ "use strict"; | ||
| /** | ||
| * Get the data on the form. If you set a prototype | ||
| * it will be used as the prototype of the returned | ||
| * object. | ||
| * Get the data on the form. You can pass existing data that will be extended. | ||
| */ | ||
| getData(): T; | ||
| getData(exising?: T): T; | ||
@@ -86,9 +84,2 @@ /** | ||
| /** | ||
| * Set the prototype object to use when getting the | ||
| * form data with getData. | ||
| * @param proto The prototype object. | ||
| */ | ||
| setPrototype(proto: T): void; | ||
| /** | ||
| * Set the schema for this form. This will add any properties found in the | ||
@@ -124,6 +115,2 @@ * schema that you did not already define on the form. It will match the form | ||
| /** | ||
| * Set the data on the form. | ||
| * @param data The data to set. | ||
| */ | ||
| public setData(data: T): void { | ||
@@ -138,5 +125,2 @@ if(this.loadedSchema){ | ||
| /** | ||
| * Remove all data from the form. | ||
| */ | ||
| public clear(): void { | ||
@@ -146,9 +130,4 @@ this.wrapped.clear(); | ||
| /** | ||
| * Get the data on the form. If you set a prototype | ||
| * it will be used as the prototype of the returned | ||
| * object. | ||
| */ | ||
| public getData(): T { | ||
| return this.wrapped.getData(); | ||
| public getData(exising?: T): T { | ||
| return this.wrapped.getData(exising); | ||
| } | ||
@@ -160,17 +139,2 @@ | ||
| /** | ||
| * Set the prototype object to use when getting the | ||
| * form data with getData. | ||
| * @param proto The prototype object. | ||
| */ | ||
| public setPrototype(proto: T): void { | ||
| this.wrapped.setPrototype(proto); | ||
| } | ||
| /** | ||
| * Set the schema for this form. This will add any properties found in the | ||
| * schema that you did not already define on the form. It will match the form | ||
| * property names to the name attribute on the elements. If you had a blank form | ||
| * this would generate the whole thing for you from the schema. | ||
| */ | ||
| public setSchema(schema: JsonSchema, componentName?: string): void { | ||
@@ -207,3 +171,2 @@ this.wrapped.setSchema(schema, componentName); | ||
| class Form<T> implements IForm<T> { | ||
| private proto: T; | ||
| private baseLevel: string = undefined; | ||
@@ -263,3 +226,3 @@ private formValues: formHelper.IFormValues; | ||
| public getData(): T { | ||
| public getData(exising?: T): T { | ||
| this.beforeGetDataEvent.fire({ | ||
@@ -270,6 +233,6 @@ source: this | ||
| if (this.formValues) { //If there are form values, use them to read the data. | ||
| data = <T>this.formValues.recoverData(this.proto); | ||
| data = this.formValues.recoverData(exising); | ||
| } | ||
| else { //Otherwise read the form raw | ||
| data = <T>formHelper.serialize(this.form, this.proto, this.baseLevel); | ||
| data = formHelper.serialize(this.form, this.baseLevel, exising); | ||
| } | ||
@@ -297,3 +260,3 @@ | ||
| //Since there is no formvalues, we must serialize the entire form and return the result. | ||
| var data = <T>formHelper.serialize(this.form, this.proto, this.baseLevel); | ||
| var data = formHelper.serialize<T>(this.form, this.baseLevel); | ||
| return data[name]; | ||
@@ -305,6 +268,2 @@ } | ||
| public setPrototype(proto: T): void { | ||
| this.proto = proto; | ||
| } | ||
| public setSchema(schema: JsonSchema, componentName?: string): void{ | ||
@@ -385,10 +344,6 @@ if (componentName === undefined) { | ||
| public getData() { | ||
| public getData(exising?: T) { | ||
| return <T>null; | ||
| } | ||
| public setPrototype(proto: T): void { | ||
| } | ||
| public setSchema(schema: JsonSchema, componentName?: string): void{ | ||
@@ -395,0 +350,0 @@ |
@@ -98,5 +98,5 @@ "use strict"; | ||
| public recoverData(proto: {} | null): any { | ||
| public recoverData<T>(existing?: T): T { | ||
| if (this.complexValues) { | ||
| var data = Object.create(proto || null); | ||
| var data = existing ?? Object.create(null); | ||
@@ -259,4 +259,4 @@ for (var i = 0; i < this.values.length; ++i) { | ||
| public getData(): any { | ||
| var data = this.formValues.recoverData(null); | ||
| public getData<T>(existing?: T): T { | ||
| var data = this.formValues.recoverData(existing); | ||
| if (typeIds.isObject(data)) { | ||
@@ -266,3 +266,3 @@ for (var key in data) { //This will pass if there is a key in data | ||
| } | ||
| return null; //Return null if the data returned has no keys in it, which means it is empty. | ||
| return existing ?? null; //Return the original input or null if the data returned has no keys in it, which means it is empty. | ||
| } | ||
@@ -269,0 +269,0 @@ |
@@ -48,3 +48,3 @@ import * as domQuery from './domquery'; | ||
| */ | ||
| export function serialize(form: HTMLElement, proto?: any, level?: string): any { | ||
| export function serialize<T>(form: HTMLElement, level?: string, existing?: T): T { | ||
| //This is from https://code.google.com/archive/p/form-serialize/downloads | ||
@@ -60,3 +60,3 @@ //Modified to return an object instead of a query string | ||
| } | ||
| var i, j, q = Object.create(proto || null); | ||
| var i, j, q = existing ?? Object.create(null); | ||
| var elementsLength = formElements.length; | ||
@@ -257,3 +257,3 @@ for (i = 0; i < elementsLength; ++i) { | ||
| recoverData(proto: {} | null): any; | ||
| recoverData<T>(existing?: T): T; | ||
@@ -260,0 +260,0 @@ getFormValue(buildName: string): IFormValue; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
306390
-0.39%7440
-0.53%