@zcomponent/core 1.6.1-beta → 1.7.0-beta
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/css/socialshare.css +2 -0
- package/lib/components/SnapshotUI.d.ts +4 -0
- package/lib/components/SnapshotUI.js +12 -1
- package/lib/types.d.ts +4 -1
- package/lib/types.js +3 -0
- package/lib/zcomponent.d.ts +21 -0
- package/lib/zcomponent.js +49 -6
- package/package.json +1 -1
package/css/socialshare.css
CHANGED
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
border-radius: 100%;
|
|
57
57
|
background-color: #ffffff;
|
|
58
58
|
opacity: 0;
|
|
59
|
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
.zee-social-share-ring {
|
|
@@ -67,6 +68,7 @@
|
|
|
67
68
|
border-radius: 100%;
|
|
68
69
|
border: 0.5em solid #ffffff;
|
|
69
70
|
opacity: 0.8;
|
|
71
|
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
.zee-photo-button .zee-social-share-circle .zee-photo-button .zee-social-share-ring {
|
|
@@ -22,6 +22,17 @@ export class SnapshotUI extends Component {
|
|
|
22
22
|
this.onSave = new Event();
|
|
23
23
|
/** @zui */
|
|
24
24
|
this.onShare = new Event();
|
|
25
|
+
/** @zprop
|
|
26
|
+
* @zdefault true
|
|
27
|
+
*/
|
|
28
|
+
this.visible = new Observable(true, visible => {
|
|
29
|
+
if (visible) {
|
|
30
|
+
this.captureButton.show();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.captureButton.hide();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
25
36
|
/**
|
|
26
37
|
* The format of the image to capture.
|
|
27
38
|
* @zprop
|
|
@@ -223,7 +234,7 @@ class ShareDivElement {
|
|
|
223
234
|
<button id="zee-save-button" class="zee-social-share-button">
|
|
224
235
|
<img src="${download_src}">
|
|
225
236
|
</button>
|
|
226
|
-
${withShareButton ? `<
|
|
237
|
+
${withShareButton ? `<button id="zee-share-button" class="zee-social-share-button"><img src="${share_src}"></button>` : ''}
|
|
227
238
|
</div>
|
|
228
239
|
<div id="zee-social-share-close-wrapper">
|
|
229
240
|
<button id="zee-close-button" class="zee-social-share-button">
|
package/lib/types.d.ts
CHANGED
|
@@ -79,7 +79,10 @@ export declare enum TypeHint {
|
|
|
79
79
|
'color-css' = "color-css",
|
|
80
80
|
'text-multiline' = "text-multiline",
|
|
81
81
|
'angle-degrees' = "angle-degrees",
|
|
82
|
-
'angle-radians' = "angle-radians"
|
|
82
|
+
'angle-radians' = "angle-radians",
|
|
83
|
+
'time-seconds' = "time-seconds",
|
|
84
|
+
'time-milliseconds' = "time-milliseconds",
|
|
85
|
+
'time-hertz' = "time-hertz"
|
|
83
86
|
}
|
|
84
87
|
export declare enum ValuesType {
|
|
85
88
|
'files' = "files",
|
package/lib/types.js
CHANGED
|
@@ -28,6 +28,9 @@ export var TypeHint;
|
|
|
28
28
|
TypeHint["text-multiline"] = "text-multiline";
|
|
29
29
|
TypeHint["angle-degrees"] = "angle-degrees";
|
|
30
30
|
TypeHint["angle-radians"] = "angle-radians";
|
|
31
|
+
TypeHint["time-seconds"] = "time-seconds";
|
|
32
|
+
TypeHint["time-milliseconds"] = "time-milliseconds";
|
|
33
|
+
TypeHint["time-hertz"] = "time-hertz";
|
|
31
34
|
})(TypeHint || (TypeHint = {}));
|
|
32
35
|
export var ValuesType;
|
|
33
36
|
(function (ValuesType) {
|
package/lib/zcomponent.d.ts
CHANGED
|
@@ -70,5 +70,26 @@ export declare class ZComponent<RootType = any> extends Component<RootType> {
|
|
|
70
70
|
private _setEntityPropPath;
|
|
71
71
|
_getNodeById(id: string): Component | undefined;
|
|
72
72
|
resolveStreamID(id: string): Stream | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Traverses the component tree starting from the current component,
|
|
75
|
+
* moving down the tree using either Breadth-First Search (BFS) or Depth-First Search (DFS),
|
|
76
|
+
* and invokes the given callback function on each component.
|
|
77
|
+
*
|
|
78
|
+
* Breadth-first chosen for traversal can be specifying `true` for the second parameter
|
|
79
|
+
*
|
|
80
|
+
* Example usage:
|
|
81
|
+
* ```
|
|
82
|
+
* component.traverse((comp) => {
|
|
83
|
+
* // Your logic here, e.g.
|
|
84
|
+
* console.log(comp.name);
|
|
85
|
+
* }, true);
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @param callback A function that will be called for each component in the traversal. The current component is passed as a parameter to the callback.
|
|
89
|
+
* @param breadthFirst If traversal should be breadth-first. Defaults to `false` (depth-first).
|
|
90
|
+
*/
|
|
91
|
+
traverse(callback: (comp: Component<any>) => void, breadthFirst?: boolean): void;
|
|
92
|
+
private _traverseBFS;
|
|
93
|
+
private _traverseDFS;
|
|
73
94
|
dispose(): never;
|
|
74
95
|
}
|
package/lib/zcomponent.js
CHANGED
|
@@ -28,7 +28,7 @@ export class ZComponent extends Component {
|
|
|
28
28
|
this.entityByID = new Map();
|
|
29
29
|
this.entityByLabel = new Map();
|
|
30
30
|
this.nodeByLabel = new Map();
|
|
31
|
-
this.constructed = new Promise(resolve => this._constructedResolve = resolve);
|
|
31
|
+
this.constructed = new Promise(resolve => (this._constructedResolve = resolve));
|
|
32
32
|
this.isConstructed = false;
|
|
33
33
|
this.animation = new Animation(false);
|
|
34
34
|
/**
|
|
@@ -54,9 +54,7 @@ export class ZComponent extends Component {
|
|
|
54
54
|
populateAnimationStructureFromData(this, this.animation, this._opts.data.animation);
|
|
55
55
|
const rootConstructor = this._constructorForNode(this._opts.data.root);
|
|
56
56
|
if (rootConstructor) {
|
|
57
|
-
this.constructChildren([
|
|
58
|
-
[rootConstructor, {}]
|
|
59
|
-
], contextManagerForChildren);
|
|
57
|
+
this.constructChildren([[rootConstructor, {}]], contextManagerForChildren);
|
|
60
58
|
}
|
|
61
59
|
this._inflateBehaviors();
|
|
62
60
|
this._initializeComponentProps();
|
|
@@ -104,7 +102,7 @@ export class ZComponent extends Component {
|
|
|
104
102
|
...(that._opts.data.entityConstructorProps?.[nodeId] ?? {}),
|
|
105
103
|
...(that._opts.constructorPropReplacement?.[nodeId] ?? {}),
|
|
106
104
|
...(that._constructorPropOverridesByEntityID.get(nodeId) ?? {}),
|
|
107
|
-
children
|
|
105
|
+
children,
|
|
108
106
|
};
|
|
109
107
|
setCurrentZComponentConstruction(that);
|
|
110
108
|
super(contextManager, constructorProps);
|
|
@@ -244,7 +242,7 @@ export class ZComponent extends Component {
|
|
|
244
242
|
new constructor(ctx, impl);
|
|
245
243
|
}
|
|
246
244
|
catch (err) {
|
|
247
|
-
const nodeName = this._opts.data.nodes[nodeID]?.label ??
|
|
245
|
+
const nodeName = this._opts.data.nodes[nodeID]?.label ?? 'Unknown node';
|
|
248
246
|
const behaviorType = this._opts.data.behaviors[behaviorID]?.type;
|
|
249
247
|
console.log('An error occurred when constructing behavior of type:', behaviorType, 'for node:', nodeName, err);
|
|
250
248
|
}
|
|
@@ -392,6 +390,51 @@ export class ZComponent extends Component {
|
|
|
392
390
|
}
|
|
393
391
|
return obj;
|
|
394
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Traverses the component tree starting from the current component,
|
|
395
|
+
* moving down the tree using either Breadth-First Search (BFS) or Depth-First Search (DFS),
|
|
396
|
+
* and invokes the given callback function on each component.
|
|
397
|
+
*
|
|
398
|
+
* Breadth-first chosen for traversal can be specifying `true` for the second parameter
|
|
399
|
+
*
|
|
400
|
+
* Example usage:
|
|
401
|
+
* ```
|
|
402
|
+
* component.traverse((comp) => {
|
|
403
|
+
* // Your logic here, e.g.
|
|
404
|
+
* console.log(comp.name);
|
|
405
|
+
* }, true);
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @param callback A function that will be called for each component in the traversal. The current component is passed as a parameter to the callback.
|
|
409
|
+
* @param breadthFirst If traversal should be breadth-first. Defaults to `false` (depth-first).
|
|
410
|
+
*/
|
|
411
|
+
traverse(callback, breadthFirst = false) {
|
|
412
|
+
if (breadthFirst) {
|
|
413
|
+
this._traverseBFS(callback);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
this._traverseDFS(callback);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
_traverseBFS(callback) {
|
|
420
|
+
const queue = [this];
|
|
421
|
+
while (queue.length > 0) {
|
|
422
|
+
const currentComponent = queue.shift();
|
|
423
|
+
if (currentComponent) {
|
|
424
|
+
callback(currentComponent);
|
|
425
|
+
queue.push(...currentComponent.children);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
_traverseDFS(callback) {
|
|
430
|
+
const dfs = (comp) => {
|
|
431
|
+
if (comp) {
|
|
432
|
+
callback(comp);
|
|
433
|
+
comp.children.forEach(dfs);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
dfs(this);
|
|
437
|
+
}
|
|
395
438
|
dispose() {
|
|
396
439
|
this.animation.dispose();
|
|
397
440
|
for (const entity of this.entityByID.values()) {
|