@pap-it/system-utils
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -29,4 +29,4 @@ export interface QueryOption<T extends Element> { | ||
} | ||
export declare function property(options?: Partial<PropertyOption>): (target: HTMLElement, propertyKey: string) => void; | ||
export declare function property(options?: Partial<PropertyOption>): (target: any, propertyKey: string) => void; | ||
export declare function convertFromString(value: string | null, type: Function): any; | ||
export {}; |
@@ -162,8 +162,9 @@ import { NextParent } from '../functions/helpers'; | ||
const constructor = target.constructor; | ||
if (!constructor.__propertyOptions) | ||
constructor.__propertyOptions = {}; | ||
// if (constructor.tagName === 'PAP-MENU') console.log('setting propertyoptions', attributeName, constructor.tagName) | ||
constructor.__propertyOptions[attributeName] = { | ||
if (!constructor.Properties) | ||
constructor.Properties = {}; | ||
constructor.Properties[attributeName] = { | ||
type: _options.type, | ||
typeName: _options.type.name, | ||
propertyKey, | ||
attribute: _options.attribute, | ||
}; | ||
@@ -182,18 +183,24 @@ // Observe attributes | ||
set(value) { | ||
if (!constructor.__propertyOptions) | ||
constructor.__propertyOptions = {}; | ||
if (!constructor.__propertyOptions[attributeName]) { | ||
if (!constructor.Properties) | ||
constructor.Properties = {}; | ||
if (!constructor.Properties[attributeName]) { | ||
// if (this.tagName === 'PAP-MENU') console.log('setting propertyoptions', attributeName, this.tagName) | ||
constructor.__propertyOptions[attributeName] = { | ||
constructor.Properties[attributeName] = { | ||
type: _options.type, | ||
typeName: _options.type.name, | ||
propertyKey, | ||
attribute: _options.attribute, | ||
}; | ||
} | ||
if (this[attributeName + "internal"]) { | ||
delete this[attributeName + "internal"]; | ||
return; | ||
} | ||
// if (this[attributeName + "internal"]) { | ||
// console.log('intenral udpate?') | ||
// delete this[attributeName + "internal"]; | ||
// return; | ||
// } | ||
if (options === null || options === void 0 ? void 0 : options.set) | ||
value = options.set.call(this, value); | ||
const valuestring = convertToString(value, _options.type); | ||
if (this.delayedAttributes[attributeName] && this.delayedAttributes[attributeName] === valuestring) { | ||
return; | ||
} | ||
const oldvaluestring = convertToString(this[`_${propertyKey}`], _options.type); | ||
@@ -208,5 +215,8 @@ if (oldvaluestring === valuestring) { | ||
this.delayedAttributes = {}; | ||
this.delayedAttributes[attributeName] = valuestring; | ||
if (this.updateAttribute) | ||
this.updateAttribute(); | ||
if (this.delayedAttributes[attributeName] !== valuestring) { | ||
// if (this.tagName === "PAP-INPUT") console.log("DECORATOR", attributeName) | ||
this.delayedAttributes[attributeName] = valuestring; | ||
if (this.updateAttribute) | ||
this.updateAttribute(); | ||
} | ||
} | ||
@@ -213,0 +223,0 @@ if (options === null || options === void 0 ? void 0 : options.before) |
@@ -12,1 +12,3 @@ import { Devices } from "../types"; | ||
export declare function DetectDevice(component: HTMLElement): Devices; | ||
export declare function lerp(a: number, b: number, t: number): number; | ||
export declare function lerpValue(value: number, min: number, max: number, newmin: number, newmax: number): number; |
@@ -103,2 +103,12 @@ export function debounce(execute, delay = 300) { | ||
} | ||
// value manipulation | ||
export function lerp(a, b, t) { | ||
return a + (b - a) * t; | ||
} | ||
export function lerpValue(value, min, max, newmin, newmax) { | ||
// Normalize 'value' to a [0, 1] range | ||
const t = (value - min) / (max - min); | ||
// Interpolate this normalized value to the new range | ||
return Math.min(newmax, Math.max(lerp(newmin, newmax, t), newmin)); | ||
} | ||
//# sourceMappingURL=helpers.js.map |
export type Size = 'small' | 'medium' | 'large'; | ||
export type Radius = 'none' | 'small' | 'medium' | 'large' | 'circular'; | ||
export type Devices = "mobile" | "pad" | "laptop" | "desktop"; | ||
export type PropertyConfig = { | ||
propertyKey: string; | ||
type: Function; | ||
typeName: string; | ||
attribute?: boolean | string; | ||
}; |
{ | ||
"name": "@pap-it/system-utils", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"scripts": { | ||
@@ -15,4 +15,3 @@ "init": "sh .scripts/init.sh", | ||
"asset/", | ||
"dist/", | ||
"react/" | ||
"dist/" | ||
], | ||
@@ -35,4 +34,4 @@ "exports": { | ||
"eslint": "^8.53.0", | ||
"@pap-it/system-showcase": "1.0.9", | ||
"@pap-it/typography": "1.0.9", | ||
"@pap-it/system-showcase": "1.0.11", | ||
"@pap-it/typography": "1.0.11", | ||
"typescript": "^5.0.4" | ||
@@ -39,0 +38,0 @@ }, |
@@ -5,4 +5,5 @@ # UtilsSystem | ||
Version: 1.0.8 | ||
Version: Version: 1.0.10 | ||
## Development | ||
@@ -9,0 +10,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95227
750
13