@pap-it/system-base
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -1,6 +0,7 @@ | ||
import { Config, FunctionCallback, RenderType, PropertyConfig } from "./types"; | ||
import { PropertyConfig } from "@pap-it/system-utils"; | ||
import { Config, FunctionCallback, RenderType } from "./types"; | ||
export declare class Base extends HTMLElement { | ||
static style?: string; | ||
static styles?: string[]; | ||
static __propertyOptions: Record<string, PropertyConfig>; | ||
static Properties: Record<string, PropertyConfig>; | ||
protected callAfterUpdate: (Function | FunctionCallback)[]; | ||
@@ -22,2 +23,3 @@ protected render_mode: 'greedy' | 'smart'; | ||
firstUpdate(): void; | ||
getProperties(): Record<string, PropertyConfig>; | ||
protected handleblur: () => void; | ||
@@ -24,0 +26,0 @@ protected handlefocus: () => void; |
@@ -37,2 +37,3 @@ import { __decorate } from "tslib"; | ||
this.callAfterUpdate.push(this.firstUpdate); | ||
return this; | ||
} | ||
@@ -50,14 +51,21 @@ connectedCallback() { | ||
attributeChangedCallback(name, oldValue, newValue) { | ||
if (oldValue === newValue) | ||
// if (this.tagName === "PAP-INPUT") console.log(name, oldValue === newValue) | ||
if (oldValue === newValue) { | ||
delete this.delayedAttributes[name]; | ||
return; | ||
} | ||
// implement something | ||
if (!this.delayedAttributes[name]) { | ||
if (Base.__propertyOptions[name]) { | ||
this[name + "internal"] = true; | ||
this[Base.__propertyOptions[name].propertyKey] = convertFromString(newValue, Base.__propertyOptions[name].type); | ||
// console.log('delayed attribute found', name, Base.Properties[name]) | ||
if (Base.Properties[name]) { | ||
// (this as any)[name + "internal"] = true; | ||
this[Base.Properties[name].propertyKey] = convertFromString(newValue, Base.Properties[name].type); | ||
} | ||
else { | ||
console.warn("[BASE]: not delayed not prop options", name); | ||
} | ||
} | ||
else { | ||
// this[Base.Properties[name].propertyKey as keyof this] = convertFromString(newValue, Base.Properties[name].type); | ||
delete this.delayedAttributes[name]; | ||
this[Base.__propertyOptions[name].propertyKey] = convertFromString(newValue, Base.__propertyOptions[name].type); | ||
} | ||
@@ -69,2 +77,9 @@ } | ||
} | ||
getProperties() { | ||
const properties = {}; | ||
for (let attribute in Base.Properties) { | ||
properties[Base.Properties[attribute].propertyKey] = Base.Properties[attribute]; | ||
} | ||
return properties; | ||
} | ||
getStyle() { | ||
@@ -145,7 +160,7 @@ var _a; | ||
const name = a[i].name; | ||
if (Base.__propertyOptions[name]) { | ||
if (Base.Properties[name]) { | ||
let value = a[i].value; | ||
if (value === "") | ||
value = "true"; | ||
this[Base.__propertyOptions[name].propertyKey] = convertFromString(value, Base.__propertyOptions[name].type); | ||
this[Base.Properties[name].propertyKey] = convertFromString(value, Base.Properties[name].type); | ||
} | ||
@@ -226,4 +241,2 @@ } | ||
const clone = this.templateComperator.cloneNode(true); | ||
if (this.tagName === "PAP-SIDEBAR-ITEM") | ||
console.log(clone.outerHTML, clone.innerHTML); | ||
clone.querySelectorAll('*:not(style)').forEach(node => { | ||
@@ -277,4 +290,6 @@ const path = this.getComposedPath(clone, node); | ||
const shadowValue = shadowNode.getAttribute(name); | ||
if (shadowValue !== value) | ||
if (shadowValue !== value) { | ||
// TODO mayby we want to keep its value? O.o | ||
shadowNode.setAttribute(name, value); | ||
} | ||
} | ||
@@ -337,4 +352,6 @@ // NOTE | ||
if (!templateNode) { | ||
// needs to go! | ||
node.parentNode.removeChild(node); | ||
// needs to go! (if not render-greedy) | ||
if (!path.some(p => /render-greedy/.test(p))) { | ||
node.parentNode.removeChild(node); | ||
} | ||
} | ||
@@ -381,4 +398,8 @@ }); | ||
selector.push(`[part="${node.getAttribute("part")}"]`); | ||
else if (node.className) | ||
else if (typeof node.className === "string" && node.className) { | ||
selector.push("." + node.className.trim().replace(/ /g, ".")); | ||
} | ||
// we store the render greedy so we need not to traverse DOM | ||
if (node.hasAttribute('render-greedy')) | ||
selector.push('[render-greedy]'); | ||
// NOTE there's a big problem with class selection when a class can dynamically arrive.. | ||
@@ -424,5 +445,5 @@ if (selector.length === 1) { | ||
} | ||
Base.__propertyOptions = {}; | ||
Base.Properties = {}; | ||
__decorate([ | ||
property({ rerender: false, type: Boolean }) | ||
], Base.prototype, "hasFocus", void 0); |
@@ -11,6 +11,2 @@ export type FunctionCallback = { | ||
}; | ||
export type PropertyConfig = { | ||
propertyKey: string; | ||
type: Function; | ||
}; | ||
export {}; |
{ | ||
"name": "@pap-it/system-base", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"scripts": { | ||
@@ -17,4 +17,3 @@ "init": "sh .scripts/init.sh", | ||
"asset/", | ||
"dist/", | ||
"react/" | ||
"dist/" | ||
], | ||
@@ -24,3 +23,3 @@ "exports": { | ||
"./wc": "./dist/register.bundle.mjs", | ||
"./react": "./react/index.ts" | ||
"./react": "./dist/react/index.ts" | ||
}, | ||
@@ -39,8 +38,9 @@ "author": "Henry Pap", | ||
"dependencies": { | ||
"@pap-it/system-utils": "1.0.9" | ||
"@pap-it/system-utils": "1.0.10", | ||
"@pap-it/system-react": "0.0.5" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.53.0", | ||
"@pap-it/system-showcase": "1.0.10", | ||
"@pap-it/typography": "1.0.10", | ||
"@pap-it/system-showcase": "1.0.11", | ||
"@pap-it/typography": "1.0.11", | ||
"esbuild": "^0.17.18", | ||
@@ -47,0 +47,0 @@ "node-html-parser": "^6.1.5", |
@@ -5,5 +5,6 @@ # Base | ||
Version: Version: 1.0.10 | ||
Version: Version: Version: 1.0.11 | ||
## Development | ||
@@ -10,0 +11,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44900
561
14
2
+ Added@pap-it/system-react@0.0.5
+ Added@pap-it/system-react@0.0.5(transitive)
+ Added@pap-it/system-utils@1.0.10(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedreact@18.3.1(transitive)
- Removed@pap-it/system-utils@1.0.9(transitive)
Updated@pap-it/system-utils@1.0.10