@zcomponent/core 1.18.0 → 1.19.1-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/lib/behaviors/SetLayerOff.d.ts +1 -1
- package/lib/behaviors/SetLayerOff.js +1 -1
- package/lib/component.d.ts +8 -0
- package/lib/component.js +6 -0
- package/lib/data/animation.d.ts +1 -0
- package/lib/data/change.d.ts +3 -0
- package/lib/data/change.js +19 -18
- package/lib/data/core.d.ts +1 -0
- package/lib/types.js +11 -0
- package/lib/zcomponent.js +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { ActionBehavior, ActionBehaviorConstructorProps } from '../actionbehavio
|
|
|
2
2
|
import { Component } from '../component';
|
|
3
3
|
import { ContextManager } from '../context';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Deactivates a layer
|
|
6
6
|
* @zbehavior
|
|
7
7
|
* @zicon toggle_off
|
|
8
8
|
* @zgroup Animation Actions
|
package/lib/component.d.ts
CHANGED
|
@@ -73,6 +73,10 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
|
|
|
73
73
|
* The parent of this component.
|
|
74
74
|
*/
|
|
75
75
|
parent?: Component;
|
|
76
|
+
/**
|
|
77
|
+
* If true, this component can't be selected at design time in the 3D preview.
|
|
78
|
+
*/
|
|
79
|
+
locked?: boolean;
|
|
76
80
|
/**
|
|
77
81
|
* Creates an instance of Component.
|
|
78
82
|
* @param contextManager The current ContextManager
|
|
@@ -128,6 +132,10 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
|
|
|
128
132
|
* exposed by this component's children.
|
|
129
133
|
*/
|
|
130
134
|
get elementsResolved(): any[];
|
|
135
|
+
/**
|
|
136
|
+
* Returns true if this component, or any of its parents, are marked as locked.
|
|
137
|
+
*/
|
|
138
|
+
get lockedResolved(): boolean;
|
|
131
139
|
/**
|
|
132
140
|
* An array of string 'tags' assocated with this component.
|
|
133
141
|
*
|
package/lib/component.js
CHANGED
|
@@ -159,6 +159,12 @@ export class Component extends Entity {
|
|
|
159
159
|
}
|
|
160
160
|
return ret;
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns true if this component, or any of its parents, are marked as locked.
|
|
164
|
+
*/
|
|
165
|
+
get lockedResolved() {
|
|
166
|
+
return (this.locked ?? false) || (this.parent?.lockedResolved ?? false);
|
|
167
|
+
}
|
|
162
168
|
/**
|
|
163
169
|
* Dispose of this component and all of its children.
|
|
164
170
|
*/
|
package/lib/data/animation.d.ts
CHANGED
package/lib/data/change.d.ts
CHANGED
|
@@ -241,3 +241,6 @@ export interface BehaviorDataCombined extends EntityDataCombined {
|
|
|
241
241
|
* @returns A unique label for the node.
|
|
242
242
|
*/
|
|
243
243
|
export declare function getUniqueLabel(zcomp: ZComponentData, label: string): string;
|
|
244
|
+
export declare function getUniqueName(n: string, requireUniqueIn: string[] | {
|
|
245
|
+
[k: string]: any;
|
|
246
|
+
}): string;
|
package/lib/data/change.js
CHANGED
|
@@ -551,7 +551,6 @@ export function forEachNodeAncestor(zcomp, id, fn) {
|
|
|
551
551
|
fn(node.parent.id);
|
|
552
552
|
forEachNodeAncestor(zcomp, node.parent.id, fn);
|
|
553
553
|
}
|
|
554
|
-
const lastNumberRegex = new RegExp(/[0-9]*$/);
|
|
555
554
|
/**
|
|
556
555
|
* Generates a unique label for a node in ZComponentData.
|
|
557
556
|
*
|
|
@@ -560,23 +559,25 @@ const lastNumberRegex = new RegExp(/[0-9]*$/);
|
|
|
560
559
|
* @returns A unique label for the node.
|
|
561
560
|
*/
|
|
562
561
|
export function getUniqueLabel(zcomp, label) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
startIndex = num + 1;
|
|
570
|
-
label = label.substring(0, result.index);
|
|
571
|
-
}
|
|
562
|
+
return getUniqueName(label, zcomp.entitiesByLabel ?? {});
|
|
563
|
+
}
|
|
564
|
+
export function getUniqueName(n, requireUniqueIn) {
|
|
565
|
+
const existing = new Set(Array.isArray(requireUniqueIn) ? requireUniqueIn : Object.keys(requireUniqueIn));
|
|
566
|
+
if (n === undefined || n.length === 0) {
|
|
567
|
+
n = 'Item';
|
|
572
568
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
569
|
+
if (!existing.has(n)) {
|
|
570
|
+
return n;
|
|
571
|
+
}
|
|
572
|
+
const endNumberString = n.match(/\d+$/)?.[0];
|
|
573
|
+
const nameString = n.slice(0, endNumberString ? endNumberString.length * -1 : undefined);
|
|
574
|
+
let num = parseInt(endNumberString ?? '1');
|
|
575
|
+
if (!isNaN(num)) {
|
|
576
|
+
num++;
|
|
577
|
+
}
|
|
578
|
+
const name = `${nameString}${endNumberString ? '' : ' '}${num}`;
|
|
579
|
+
if (existing.has(name)) {
|
|
580
|
+
return getUniqueName(name, requireUniqueIn);
|
|
580
581
|
}
|
|
581
|
-
return
|
|
582
|
+
return name;
|
|
582
583
|
}
|
package/lib/data/core.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -146,6 +146,17 @@ export function areTypesCompatible(a, b) {
|
|
|
146
146
|
return false;
|
|
147
147
|
if (a.ret && bt.ret)
|
|
148
148
|
return areTypesCompatible(a.ret, bt.ret);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 'event': {
|
|
152
|
+
const bt = b;
|
|
153
|
+
if (a.children.length !== bt.children.length)
|
|
154
|
+
return false;
|
|
155
|
+
for (let i = 0; i < a.children.length; i++) {
|
|
156
|
+
if (!areTypesCompatible(a.children[i], bt.children[i]))
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
149
160
|
}
|
|
150
161
|
}
|
|
151
162
|
return true;
|
package/lib/zcomponent.js
CHANGED
|
@@ -149,6 +149,7 @@ export class ZComponent extends Component {
|
|
|
149
149
|
};
|
|
150
150
|
setCurrentZComponentConstruction(that);
|
|
151
151
|
super(contextManager, constructorProps);
|
|
152
|
+
this.locked = that._opts.data.nodes[nodeId]?.locked;
|
|
152
153
|
that.entityByID.set(nodeId, this);
|
|
153
154
|
if (node?.label) {
|
|
154
155
|
that.entityByLabel.set(node.label, this);
|