structured-fw 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/system/client/ClientComponent.js +7 -8
- package/build/system/server/Component.d.ts +2 -4
- package/build/system/server/Component.js +8 -1
- package/build/system/server/Document.js +7 -0
- package/build/system/server/Layout.js +7 -1
- package/build/system/server/Request.js +1 -0
- package/build/system/server/dom/DOMNode.d.ts +1 -0
- package/build/system/server/dom/DOMNode.js +6 -0
- package/build/system/types/component.types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -588,10 +588,10 @@ export class ClientComponent extends EventEmitter {
|
|
|
588
588
|
}
|
|
589
589
|
show(domNode, enableTransition = true) {
|
|
590
590
|
if (!enableTransition) {
|
|
591
|
-
domNode.
|
|
591
|
+
domNode.classList.remove('structured-hidden');
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
|
-
if (domNode.
|
|
594
|
+
if (!domNode.classList.contains('structured-hidden')) {
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
597
597
|
const transitions = this.transitionAttributes(domNode).show;
|
|
@@ -602,11 +602,10 @@ export class ClientComponent extends EventEmitter {
|
|
|
602
602
|
prev[key] = transitions[key];
|
|
603
603
|
return prev;
|
|
604
604
|
}, {});
|
|
605
|
+
domNode.classList.remove('structured-hidden');
|
|
605
606
|
if (Object.keys(transitionsActive).length === 0) {
|
|
606
|
-
domNode.style.display = '';
|
|
607
607
|
return;
|
|
608
608
|
}
|
|
609
|
-
domNode.style.display = '';
|
|
610
609
|
const onTransitionEnd = (e) => {
|
|
611
610
|
domNode.style.opacity = '1';
|
|
612
611
|
domNode.style.transition = '';
|
|
@@ -652,10 +651,10 @@ export class ClientComponent extends EventEmitter {
|
|
|
652
651
|
}
|
|
653
652
|
hide(domNode, enableTransition = true) {
|
|
654
653
|
if (!enableTransition) {
|
|
655
|
-
domNode.
|
|
654
|
+
domNode.classList.add('structured-hidden');
|
|
656
655
|
return;
|
|
657
656
|
}
|
|
658
|
-
if (domNode.
|
|
657
|
+
if (domNode.classList.contains('structured-hidden')) {
|
|
659
658
|
return;
|
|
660
659
|
}
|
|
661
660
|
const transitions = this.transitionAttributes(domNode).hide;
|
|
@@ -667,11 +666,11 @@ export class ClientComponent extends EventEmitter {
|
|
|
667
666
|
return prev;
|
|
668
667
|
}, {});
|
|
669
668
|
if (Object.keys(transitionsActive).length === 0) {
|
|
670
|
-
domNode.
|
|
669
|
+
domNode.classList.add('structured-hidden');
|
|
671
670
|
}
|
|
672
671
|
else {
|
|
673
672
|
const onTransitionEnd = (e) => {
|
|
674
|
-
domNode.
|
|
673
|
+
domNode.classList.add('structured-hidden');
|
|
675
674
|
domNode.style.opacity = '1';
|
|
676
675
|
domNode.style.transition = '';
|
|
677
676
|
domNode.style.transformOrigin = 'unset';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Document } from './Document.js';
|
|
2
2
|
import { LooseObject } from '../types/general.types.js';
|
|
3
|
-
import { ComponentEntry } from "../types/component.types.js";
|
|
3
|
+
import { ComponentEntry, ComponentEvents } from "../types/component.types.js";
|
|
4
4
|
import { DOMNode } from './dom/DOMNode.js';
|
|
5
5
|
import { EventEmitter } from '../EventEmitter.js';
|
|
6
|
-
export declare class Component<Events extends Record<string, any> = {
|
|
7
|
-
'componentCreated': Component;
|
|
8
|
-
}> extends EventEmitter<Events> {
|
|
6
|
+
export declare class Component<Events extends Record<string, any> = ComponentEvents> extends EventEmitter<Events> {
|
|
9
7
|
id: string;
|
|
10
8
|
name: string;
|
|
11
9
|
document: Document;
|
|
@@ -134,9 +134,16 @@ export class Component extends EventEmitter {
|
|
|
134
134
|
if (this.isRoot) {
|
|
135
135
|
const dataIf = this.dom.queryByHasAttribute('data-if');
|
|
136
136
|
for (let i = 0; i < dataIf.length; i++) {
|
|
137
|
-
dataIf[i].
|
|
137
|
+
const className = dataIf[i].getAttribute('class');
|
|
138
|
+
if (typeof className === 'string') {
|
|
139
|
+
dataIf[i].setAttribute('class', `${className} structured-hidden`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
dataIf[i].setAttribute('class', 'structured-hidden');
|
|
143
|
+
}
|
|
138
144
|
}
|
|
139
145
|
}
|
|
146
|
+
await this.emit('ready');
|
|
140
147
|
}
|
|
141
148
|
setAttributes(attributes, prefix = '', encode = true) {
|
|
142
149
|
if (typeof attributes === 'object' && attributes !== null) {
|
|
@@ -19,6 +19,13 @@ export class Document extends Component {
|
|
|
19
19
|
this.document = this;
|
|
20
20
|
this.head = new DocumentHead(title);
|
|
21
21
|
this.head.addJS('/assets/client-js/client/Client.js', 0, { type: 'module' });
|
|
22
|
+
this.head.add(`
|
|
23
|
+
<style>
|
|
24
|
+
.structured-hidden {
|
|
25
|
+
display: none !important;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
28
|
+
`);
|
|
22
29
|
this.application.emit('documentCreated', this);
|
|
23
30
|
}
|
|
24
31
|
push(response) {
|
|
@@ -29,7 +29,13 @@ export class Layout {
|
|
|
29
29
|
await component.init(`<${componentName}></${componentName}>`, data);
|
|
30
30
|
const conditionals = component.dom.queryByHasAttribute('data-if');
|
|
31
31
|
for (let i = 0; i < conditionals.length; i++) {
|
|
32
|
-
conditionals[i].
|
|
32
|
+
const className = conditionals[i].getAttribute('class');
|
|
33
|
+
if (typeof className === 'string') {
|
|
34
|
+
conditionals[i].setAttribute('class', `${className} structured-hidden`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
conditionals[i].setAttribute('class', 'structured-hidden');
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
return doc;
|
|
35
41
|
}
|
|
@@ -131,6 +131,7 @@ export class Request {
|
|
|
131
131
|
},
|
|
132
132
|
show404: async () => {
|
|
133
133
|
this.app.emit('pageNotFound', context);
|
|
134
|
+
response.statusCode = 404;
|
|
134
135
|
const res = await this.pageNotFoundCallback.apply(this.app, [context]);
|
|
135
136
|
if (res instanceof Document) {
|
|
136
137
|
context.respondWith(res);
|
|
@@ -25,6 +25,7 @@ export declare class DOMNode {
|
|
|
25
25
|
potentialComponentChildren: Array<DOMNode>;
|
|
26
26
|
constructor(root: DOMFragment | null, parentNode: DOMNode | null, tagName: string);
|
|
27
27
|
appendChild(node: DOMNode | string): void;
|
|
28
|
+
getAttribute(attrName: string): string | true | null;
|
|
28
29
|
setAttribute(attributeName: string, attributeValue: string | true): void;
|
|
29
30
|
hasAttribute(attributeName: string): boolean;
|
|
30
31
|
queryByTagName(...tagNames: Array<string>): Array<DOMNode>;
|
|
@@ -30,6 +30,12 @@ export class DOMNode {
|
|
|
30
30
|
}
|
|
31
31
|
this.children.push(node);
|
|
32
32
|
}
|
|
33
|
+
getAttribute(attrName) {
|
|
34
|
+
if (!this.hasAttribute(attrName)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return this.attributeMap[attrName].value;
|
|
38
|
+
}
|
|
33
39
|
setAttribute(attributeName, attributeValue) {
|
|
34
40
|
const attributeExisting = this.attributeMap[attributeName];
|
|
35
41
|
if (!attributeExisting) {
|
|
@@ -36,6 +36,10 @@ export interface ComponentScaffold<T extends LooseObject = LooseObject, K extend
|
|
|
36
36
|
getData: (this: ComponentScaffold, data: LooseObject, ctx: undefined | RequestContext, app: Application, component: Component) => Promise<T | void>;
|
|
37
37
|
[key: string]: any;
|
|
38
38
|
}
|
|
39
|
+
export type ComponentEvents = {
|
|
40
|
+
componentCreated: Component;
|
|
41
|
+
ready: undefined;
|
|
42
|
+
};
|
|
39
43
|
export type ClientComponentTransition = {
|
|
40
44
|
fade: false | number;
|
|
41
45
|
slide: false | number;
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "build/index",
|
|
22
|
-
"version": "1.2.
|
|
22
|
+
"version": "1.2.1",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"develop": "tsc --watch",
|
|
25
25
|
"startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,hbs,css index.js",
|