@zcomponent/core 0.0.16 → 0.0.18

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.
@@ -91,4 +91,32 @@
91
91
 
92
92
  .zcomponent-hc-vc {
93
93
  transform: translate(-50%, -50%);
94
+ }
95
+
96
+ .zcomponent-textalert-container {
97
+ position: absolute;
98
+ bottom: 30px;
99
+ left: 50%;
100
+ transform: translate(-50%, 0);
101
+ display: flex;
102
+ flex-direction: column;
103
+ justify-content: end;
104
+ align-items: center;
105
+ row-gap: 24px;
106
+ max-width: 80%;
107
+ }
108
+
109
+ .zcomponent-textalert {
110
+ transition: opacity 0.5s;
111
+ background-color: black;
112
+ border-radius: 10px;
113
+ padding: 20px;
114
+ color: white;
115
+ font-family: sans-serif;
116
+ opacity: 0;
117
+ text-align: center;
118
+ }
119
+
120
+ .zcomponent-textalert-shown {
121
+ opacity: 1;
94
122
  }
package/lib/behavior.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare class Behavior<InstanceType extends Component = Component> extend
16
16
  */
17
17
  constructor(contextManager: ContextManager, instance: InstanceType);
18
18
  private _updateEnabledResolved;
19
+ dispose(): never;
19
20
  }
20
21
  export declare function shouldBehaviorRunAtDesignTime(b: BehaviorConstructor): boolean;
21
22
  export declare function registerBehaviorRunAtDesignTime(b: BehaviorConstructor): Set<new (contextManager: ContextManager, instance: Component<any, import("./component").ConstructorProps>, ...args: any[]) => Behavior<Component<any, import("./component").ConstructorProps>>>;
package/lib/behavior.js CHANGED
@@ -17,9 +17,14 @@ export class Behavior extends Entity {
17
17
  this.enabledResolved.value = newValue;
18
18
  }
19
19
  };
20
+ instance.addBehavior(this);
20
21
  this.register(this.enabled, this._updateEnabledResolved, { bindWhenDisabled: true });
21
22
  this.register(instance.enabledResolved, this._updateEnabledResolved, { bindWhenDisabled: true });
22
23
  }
24
+ dispose() {
25
+ this.instance.removeBehavior(this);
26
+ return super.dispose();
27
+ }
23
28
  }
24
29
  const behaviorsToRunAtDesignTime = new Set();
25
30
  export function shouldBehaviorRunAtDesignTime(b) {
@@ -0,0 +1,22 @@
1
+ import { ActionBehavior } from "../actionbehavior";
2
+ /**
3
+ * Outputs a message to the console log.
4
+ *
5
+ * @zbehavior
6
+ * @zicon terminal
7
+ * @zgroup Actions
8
+ */
9
+ export declare class ConsoleLog extends ActionBehavior {
10
+ /**
11
+ * The text to log
12
+ * @zprop
13
+ */
14
+ text: string;
15
+ /**
16
+ * If true, the event name will be logged in addition to the text
17
+ * @zprop
18
+ * @zdefault true
19
+ */
20
+ includeEventName: boolean;
21
+ perform(): void;
22
+ }
@@ -0,0 +1,18 @@
1
+ import { ActionBehavior } from "../actionbehavior";
2
+ import { registerBehaviorRunAtDesignTime } from "../behavior";
3
+ /**
4
+ * Outputs a message to the console log.
5
+ *
6
+ * @zbehavior
7
+ * @zicon terminal
8
+ * @zgroup Actions
9
+ */
10
+ export class ConsoleLog extends ActionBehavior {
11
+ perform() {
12
+ if (this.includeEventName ?? true)
13
+ console.log(this.constructorProps.event, this.text);
14
+ else
15
+ console.log(this.text);
16
+ }
17
+ }
18
+ registerBehaviorRunAtDesignTime(ConsoleLog);
@@ -5,6 +5,7 @@ import { ActionBehavior } from "../actionbehavior";
5
5
  * **Important Note**: Safari on iOS will not open URLs in new tabs for pointer events except `onPointerUp`.
6
6
  *
7
7
  * @zbehavior
8
+ * @zicon open_in_new
8
9
  * @zgroup Actions
9
10
  */
10
11
  export declare class LaunchURL extends ActionBehavior {
@@ -5,6 +5,7 @@ import { ActionBehavior } from "../actionbehavior";
5
5
  * **Important Note**: Safari on iOS will not open URLs in new tabs for pointer events except `onPointerUp`.
6
6
  *
7
7
  * @zbehavior
8
+ * @zicon open_in_new
8
9
  * @zgroup Actions
9
10
  */
10
11
  export class LaunchURL extends ActionBehavior {
@@ -5,6 +5,7 @@ import { ActionBehavior } from "../actionbehavior";
5
5
  * Note: you must have added an analytics provider to the Hierarchy in one of your components for this behavior to have any effect.
6
6
  *
7
7
  * @zbehavior
8
+ * @zicon analytics
8
9
  * @zgroup Actions
9
10
  */
10
11
  export declare class LogAnalyticsEvent extends ActionBehavior {
@@ -6,6 +6,7 @@ import { logEvent } from "../contexts/analyticscontext";
6
6
  * Note: you must have added an analytics provider to the Hierarchy in one of your components for this behavior to have any effect.
7
7
  *
8
8
  * @zbehavior
9
+ * @zicon analytics
9
10
  * @zgroup Actions
10
11
  */
11
12
  export class LogAnalyticsEvent extends ActionBehavior {
@@ -13,6 +13,7 @@ export interface PlaySoundProps extends ActionBehaviorConstructorProps {
13
13
  * Plays a sound
14
14
  *
15
15
  * @zbehavior
16
+ * @zicon volume_up
16
17
  * @zgroup Actions
17
18
  */
18
19
  export declare class PlaySound extends ActionBehavior<PlaySoundProps> {
@@ -5,6 +5,7 @@ import { registerLoadable } from "../contexts/loadcontext";
5
5
  * Plays a sound
6
6
  *
7
7
  * @zbehavior
8
+ * @zicon volume_up
8
9
  * @zgroup Actions
9
10
  */
10
11
  export class PlaySound extends ActionBehavior {
@@ -0,0 +1,62 @@
1
+ import { ActionBehavior } from "../actionbehavior";
2
+ import { Observable } from "../observable";
3
+ /**
4
+ * Displays a pop-up text alert on screen.
5
+ *
6
+ * @zbehavior
7
+ * @zicon sms
8
+ * @zgroup Actions
9
+ */
10
+ export declare class ShowTextAlert extends ActionBehavior {
11
+ /**
12
+ * The text to show in the alert
13
+ * @zprop
14
+ * @zgroup ShowTextAlert
15
+ * @zgrouppriority 20
16
+ */
17
+ text: Observable<string, never>;
18
+ /**
19
+ * The time (in milliseconds) that the text alert should remain on screen
20
+ *
21
+ * @zprop
22
+ * @zgroup Appearance
23
+ * @zgrouppriority 10
24
+ * @zdefault 3000
25
+ */
26
+ timeout: Observable<number, never>;
27
+ /**
28
+ * The color of the background of the text alert
29
+ *
30
+ * @zprop
31
+ * @zgroup Appearance
32
+ * @zgrouppriority 10
33
+ * @zdefault black
34
+ * @ztype color-hex
35
+ */
36
+ backgroundColor: Observable<string, never>;
37
+ /**
38
+ * The color of the text of the text alert
39
+ *
40
+ * @zprop
41
+ * @zgroup Appearance
42
+ * @zgrouppriority 10
43
+ * @zdefault #ffffff
44
+ * @ztype color-hex
45
+ */
46
+ textColor: Observable<string, never>;
47
+ /**
48
+ * Additional CSS class names to add to the alert DOM element
49
+ *
50
+ * @zprop
51
+ * @zgroup Appearance
52
+ * @zgrouppriority 10
53
+ * @zdefault []
54
+ */
55
+ classNames: Observable<string[], never>;
56
+ /**
57
+ * How long the alert will apear on the screen
58
+ */
59
+ perform(): void;
60
+ /** @zprop */
61
+ preview(): void;
62
+ }
@@ -0,0 +1,77 @@
1
+ import { ActionBehavior } from "../actionbehavior";
2
+ import { registerBehaviorRunAtDesignTime } from "../behavior";
3
+ import { showTextAlert } from "../contexts/textalertcontext";
4
+ import { Observable } from "../observable";
5
+ /**
6
+ * Displays a pop-up text alert on screen.
7
+ *
8
+ * @zbehavior
9
+ * @zicon sms
10
+ * @zgroup Actions
11
+ */
12
+ export class ShowTextAlert extends ActionBehavior {
13
+ constructor() {
14
+ super(...arguments);
15
+ /**
16
+ * The text to show in the alert
17
+ * @zprop
18
+ * @zgroup ShowTextAlert
19
+ * @zgrouppriority 20
20
+ */
21
+ this.text = new Observable('');
22
+ /**
23
+ * The time (in milliseconds) that the text alert should remain on screen
24
+ *
25
+ * @zprop
26
+ * @zgroup Appearance
27
+ * @zgrouppriority 10
28
+ * @zdefault 3000
29
+ */
30
+ this.timeout = new Observable(3000);
31
+ /**
32
+ * The color of the background of the text alert
33
+ *
34
+ * @zprop
35
+ * @zgroup Appearance
36
+ * @zgrouppriority 10
37
+ * @zdefault black
38
+ * @ztype color-hex
39
+ */
40
+ this.backgroundColor = new Observable('#000000');
41
+ /**
42
+ * The color of the text of the text alert
43
+ *
44
+ * @zprop
45
+ * @zgroup Appearance
46
+ * @zgrouppriority 10
47
+ * @zdefault #ffffff
48
+ * @ztype color-hex
49
+ */
50
+ this.textColor = new Observable('#ffffff');
51
+ /**
52
+ * Additional CSS class names to add to the alert DOM element
53
+ *
54
+ * @zprop
55
+ * @zgroup Appearance
56
+ * @zgrouppriority 10
57
+ * @zdefault []
58
+ */
59
+ this.classNames = new Observable([]);
60
+ }
61
+ /**
62
+ * How long the alert will apear on the screen
63
+ */
64
+ perform() {
65
+ showTextAlert(this.contextManager, this.text.value, {
66
+ backgroundColor: this.backgroundColor.value,
67
+ textColor: this.textColor.value,
68
+ classNames: this.classNames.value,
69
+ timeout: this.timeout.value
70
+ });
71
+ }
72
+ /** @zprop */
73
+ preview() {
74
+ this.perform();
75
+ }
76
+ }
77
+ registerBehaviorRunAtDesignTime(ShowTextAlert);
@@ -1,6 +1,7 @@
1
1
  import { ContextManager } from './context';
2
2
  import { Entity } from './entity';
3
3
  import { Observable } from './observable';
4
+ import type { Behavior, BehaviorConstructor } from './behavior';
4
5
  export type ConstructorPropsOfComponent<ComponentType> = ComponentType extends Component<any, infer R> ? R : never;
5
6
  export type ComponentConstructor<ConstructorPropsType extends ConstructorProps, ComponentType extends Component> = new (props: ConstructorPropsType, contextManager: ContextManager) => ComponentType;
6
7
  export type ConstructorForComponent<ComponentType extends Component = Component> = new (contextManager: ContextManager, props: ComponentType extends Component<any, infer PropsType> ? PropsType : never) => ComponentType;
@@ -21,6 +22,7 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
21
22
  */
22
23
  element?: ElementType;
23
24
  readonly children: Component[];
25
+ readonly behaviors: Behavior[];
24
26
  parent?: Component;
25
27
  constructor(contextManager: ContextManager, constructorProps?: ConstructorPropsType | undefined);
26
28
  constructChildren(children: ComponentChildren, contextManager?: ContextManager): void;
@@ -39,6 +41,10 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
39
41
  * Removes this component from its parent component.
40
42
  */
41
43
  remove(): void;
44
+ addBehavior(b: Behavior): void;
45
+ removeBehavior(b: Behavior): void;
46
+ getBehavior<T extends BehaviorConstructor>(type: T): InstanceType<T> | undefined;
47
+ getBehaviors<T extends BehaviorConstructor>(type: T): InstanceType<T>[];
42
48
  /**
43
49
  * An array of the elements that this component instance exposes. In the case that this component
44
50
  * does not expose any elements of its own, this will be an array of the elements
package/lib/component.js CHANGED
@@ -6,6 +6,7 @@ export class Component extends Entity {
6
6
  super(contextManager);
7
7
  this.constructorProps = constructorProps;
8
8
  this.children = [];
9
+ this.behaviors = [];
9
10
  /**
10
11
  * An array of string 'tags' assocated with this component.
11
12
  *
@@ -81,6 +82,23 @@ export class Component extends Entity {
81
82
  remove() {
82
83
  this.parent?.removeChild(this);
83
84
  }
85
+ addBehavior(b) {
86
+ this.behaviors.push(b);
87
+ }
88
+ removeBehavior(b) {
89
+ const indx = this.behaviors.indexOf(b);
90
+ if (indx >= 0)
91
+ this.behaviors.splice(indx, 1);
92
+ }
93
+ getBehavior(type) {
94
+ for (const behavior of this.behaviors) {
95
+ if (behavior instanceof type)
96
+ return behavior;
97
+ }
98
+ }
99
+ getBehaviors(type) {
100
+ return this.behaviors.filter(entry => entry instanceof type);
101
+ }
84
102
  /**
85
103
  * An array of the elements that this component instance exposes. In the case that this component
86
104
  * does not expose any elements of its own, this will be an array of the elements
@@ -2,6 +2,8 @@ import { Component, ConstructorProps } from "../component";
2
2
  import { ContextManager } from "../context";
3
3
  /**
4
4
  * @zcomponent
5
+ * @zgroup Advanced
6
+ * @zicon list
5
7
  */
6
8
  export declare class Children extends Component {
7
9
  constructor(contextManager: ContextManager, props: ConstructorProps);
@@ -1,6 +1,8 @@
1
1
  import { Component } from "../component";
2
2
  /**
3
3
  * @zcomponent
4
+ * @zgroup Advanced
5
+ * @zicon list
4
6
  */
5
7
  export class Children extends Component {
6
8
  constructor(contextManager, props) {
@@ -35,15 +35,17 @@ export declare class DefaultLoader extends Component {
35
35
  */
36
36
  subtitle: Observable<string>;
37
37
  /** @zprop
38
- * @zdefault black
38
+ * @zdefault #000000
39
39
  * @zgroup Appearance
40
40
  * @zgrouppriority 10
41
+ * @ztype color-hex
41
42
  */
42
43
  backgroundColor: Observable<string>;
43
44
  /** @zprop
44
- * @zdefault white
45
+ * @zdefault #ffffff
45
46
  * @zgroup Appearance
46
47
  * @zgrouppriority 10
48
+ * @ztype color-hex
47
49
  */
48
50
  textColor: Observable<string>;
49
51
  /** @zprop
@@ -56,8 +56,8 @@ export class DefaultLoader extends Component {
56
56
  this._percentageElement = this.element.querySelector("#zcomponent-defaultloader-progress-percentage") || document.createElement("div");
57
57
  this.title = new Observable('', t => titleElement.innerText = t);
58
58
  this.subtitle = new Observable('', t => subtitleElement.innerText = t);
59
- this.textColor = new Observable('white', t => this.element.style.color = t ?? 'white');
60
- this.backgroundColor = new Observable('black', t => this.element.style.backgroundColor = t ?? 'black');
59
+ this.textColor = new Observable('#ffffff', t => this.element.style.color = t);
60
+ this.backgroundColor = new Observable('#000000', t => this.element.style.backgroundColor = t);
61
61
  this.zIndex = new Observable(1000, t => this.element.style.zIndex = t.toString());
62
62
  this.register(this.preview, this._updatePercentage);
63
63
  this.register(this.preview, this._updateVisibility);
@@ -11,6 +11,7 @@ export interface GamepadButtonEvent {
11
11
  }
12
12
  /**
13
13
  * @zcomponent
14
+ * @zicon sports_esports
14
15
  */
15
16
  export declare class Gamepad extends Component {
16
17
  /** @zprop */
@@ -6,6 +6,7 @@ import { Event } from "../event";
6
6
  import { Observable } from "../observable";
7
7
  /**
8
8
  * @zcomponent
9
+ * @zicon sports_esports
9
10
  */
10
11
  export class Gamepad extends Component {
11
12
  constructor(contextManager, props) {
@@ -1,4 +1,4 @@
1
- import { Component, ContextManager } from "..";
1
+ import { Component, ContextManager, Event } from "..";
2
2
  export interface LongLoadConstructorProps {
3
3
  /**
4
4
  * The number of loading processes to simulate
@@ -41,5 +41,7 @@ export interface LongLoadConstructorProps {
41
41
  * @zgroup Advanced
42
42
  */
43
43
  export declare class LongLoad extends Component<any, LongLoadConstructorProps> {
44
+ /** @zui */
45
+ onLoad: Event<[]>;
44
46
  constructor(contextManager: ContextManager, props: LongLoadConstructorProps);
45
47
  }
@@ -1,4 +1,4 @@
1
- import { Component, isDevelopmentBuild, registerLoadable } from "..";
1
+ import { Component, Event, isDevelopmentBuild, registerLoadable } from "..";
2
2
  /**
3
3
  * Simulates long random loading times to facilitate development and debugging of loading processes.
4
4
  *
@@ -9,12 +9,15 @@ import { Component, isDevelopmentBuild, registerLoadable } from "..";
9
9
  export class LongLoad extends Component {
10
10
  constructor(contextManager, props) {
11
11
  super(contextManager, props);
12
+ /** @zui */
13
+ this.onLoad = new Event();
12
14
  if (!props.runInProduction && !isDevelopmentBuild(contextManager))
13
15
  return;
14
16
  const minimumLoadTime = props.minimumLoadTime ?? 500;
15
17
  const maximumLoadTime = props.maximumLoadTime ?? 5000;
18
+ const all = [];
16
19
  for (let i = 0; i < (props.numberOfLoads ?? 10); i++) {
17
- registerLoadable(contextManager, new Promise(resolve => {
20
+ const promise = new Promise(resolve => {
18
21
  if (this.disposed)
19
22
  return;
20
23
  setTimeout(() => {
@@ -22,7 +25,14 @@ export class LongLoad extends Component {
22
25
  return;
23
26
  resolve();
24
27
  }, minimumLoadTime + Math.random() * (maximumLoadTime - minimumLoadTime));
25
- }));
28
+ });
29
+ registerLoadable(contextManager, promise);
30
+ all.push(promise);
26
31
  }
32
+ Promise.all(all).then(() => {
33
+ if (this.disposed)
34
+ return;
35
+ this.onLoad.emit();
36
+ });
27
37
  }
28
38
  }
@@ -0,0 +1,13 @@
1
+ import { ContextManager, Context } from '../context';
2
+ export declare class TextAlertContext extends Context {
3
+ private _container;
4
+ constructor(contextManager: ContextManager);
5
+ showTextAlert(txt: string, options?: TextAlertOptions): void;
6
+ }
7
+ export interface TextAlertOptions {
8
+ classNames?: string[];
9
+ timeout?: number;
10
+ backgroundColor?: string;
11
+ textColor?: string;
12
+ }
13
+ export declare function showTextAlert(mgr: ContextManager, txt: string, options?: TextAlertOptions): void;
@@ -0,0 +1,36 @@
1
+ import { Context } from '../context';
2
+ import { useOverlay } from './canvascontext';
3
+ export class TextAlertContext extends Context {
4
+ constructor(contextManager) {
5
+ super(contextManager, {});
6
+ this._container = document.createElement('div');
7
+ this._container.classList.add('zcomponent-textalert-container');
8
+ useOverlay(contextManager).addListener(val => {
9
+ val.appendChild(this._container);
10
+ });
11
+ }
12
+ showTextAlert(txt, options) {
13
+ const entry = document.createElement('div');
14
+ entry.classList.add('zcomponent-textalert');
15
+ options?.classNames?.forEach(val => entry.classList.add(val));
16
+ entry.innerText = txt;
17
+ entry.style.backgroundColor = options?.backgroundColor ?? 'black';
18
+ entry.style.color = options?.textColor ?? 'white';
19
+ entry.addEventListener('click', evt => {
20
+ entry.remove();
21
+ evt.stopPropagation();
22
+ });
23
+ this._container.appendChild(entry);
24
+ const timeout = options?.timeout ?? 3000;
25
+ setTimeout(() => {
26
+ entry.classList.add('zcomponent-textalert-shown');
27
+ }, 30);
28
+ setTimeout(() => {
29
+ entry.classList.remove('zcomponent-textalert-shown');
30
+ setTimeout(() => entry.remove(), 1000);
31
+ }, timeout);
32
+ }
33
+ }
34
+ export function showTextAlert(mgr, txt, options) {
35
+ return mgr.get(TextAlertContext).showTextAlert(txt, options);
36
+ }
package/lib/selectors.js CHANGED
@@ -212,22 +212,39 @@ export default Comp;
212
212
  `;
213
213
  };
214
214
  function makeCommentSafe(c) {
215
- return c.replaceAll('*/', '').split('\n').join('\n\t* ');
215
+ return c.replaceAll('*/', '');
216
+ }
217
+ function getJSDocForProp(prop) {
218
+ let lines = [];
219
+ for (const comment of (prop.comments ?? [])) {
220
+ lines.push(...comment.split('\n'));
221
+ }
222
+ if (lines.length > 0)
223
+ lines.push('');
224
+ lines.push('@zprop');
225
+ if (prop.default !== undefined)
226
+ lines.push(`@zdefault ${JSON.stringify(prop.default)}`);
227
+ if (prop.group)
228
+ lines.push('@zgroup ' + prop.group);
229
+ if (prop.groupPriority)
230
+ lines.push('@zgrouppriority ' + prop.groupPriority);
231
+ if (prop.type.typeHint)
232
+ lines.push('@ztype ' + prop.type.typeHint);
233
+ if (prop.values) {
234
+ for (const val of prop.values) {
235
+ lines.push('@zvalues ' + val.type + ' ' + val.param);
236
+ }
237
+ }
238
+ lines = lines.map(makeCommentSafe);
239
+ lines = lines.map(entry => '\t * ' + entry);
240
+ return `\t/**\n${lines.join('\n')}\n\t */`;
216
241
  }
217
242
  function typeOutputForProp(prop) {
218
- const comments = (prop.comments && prop.comments.length > 0) ? '\n\t* ' + prop.comments.map(makeCommentSafe).join('\n\t*\n\t* ') + '\n\t* ' : '';
219
- return ` /**${comments}
220
- * @zprop
221
- * ${prop.default !== undefined ? `@zdefault ${JSON.stringify(prop.default)}` : ''}
222
- */
243
+ return `${getJSDocForProp(prop)}
223
244
  public ${prop.name}: Observable<${outputForType(prop.type, true)}>;`;
224
245
  }
225
246
  function typeOutputForConstructorProp(prop) {
226
- const comments = (prop.comments && prop.comments.length > 0) ? '\n\t* ' + prop.comments.map(makeCommentSafe).join('\n\t*\n\t* ') + '\n\t* ' : '';
227
- return ` /**${comments}
228
- * @zprop
229
- * ${prop.default !== undefined && `@zdefault ${JSON.stringify(prop.default)}`}
230
- */
247
+ return `${getJSDocForProp(prop)}
231
248
  ${prop.name}: ${outputForType(prop.type, true)};`;
232
249
  }
233
250
  export function getSafeKeyName(n) {
package/lib/types.d.ts CHANGED
@@ -55,10 +55,20 @@ export declare enum TypeHint {
55
55
  "proportion" = "proportion",
56
56
  'color-norm-rgb' = "color-norm-rgb",
57
57
  'color-unnorm-rgb' = "color-unnorm-rgb",
58
- 'color-hex' = "color-hex"
58
+ 'color-hex' = "color-hex",
59
+ 'color-css' = "color-css"
60
+ }
61
+ export declare enum ValuesType {
62
+ 'files' = "files",
63
+ 'animations' = "animations",
64
+ 'morphTargets' = "morphTargets",
65
+ 'events' = "events",
66
+ 'parentNodes' = "parentNodes",
67
+ 'nodelabels' = "nodelabels",
68
+ 'nodeids' = "nodeids"
59
69
  }
60
70
  export interface Values {
61
- type: 'files' | 'animations' | 'morphTargets' | 'events' | 'parentNodes' | 'nodelabels';
71
+ type: ValuesType;
62
72
  param: string;
63
73
  }
64
74
  export interface Prop {
@@ -104,6 +114,13 @@ export interface ValueInfo {
104
114
  type: Type;
105
115
  comments?: string[];
106
116
  }
117
+ export interface PreviewInfo {
118
+ name: string;
119
+ file: string;
120
+ isDefault?: string;
121
+ comments?: string[];
122
+ filePattern: string;
123
+ }
107
124
  export interface SourceFileTypeInfo {
108
125
  components: {
109
126
  [id: string]: ComponentInfo;
@@ -111,6 +128,9 @@ export interface SourceFileTypeInfo {
111
128
  values: {
112
129
  [id: string]: ValueInfo;
113
130
  };
131
+ previewers: {
132
+ [id: string]: PreviewInfo;
133
+ };
114
134
  }
115
135
  export type TypeInfoByFileName = {
116
136
  [id: string]: SourceFileTypeInfo;
@@ -124,6 +144,11 @@ export interface TemplateInfo {
124
144
  content: string;
125
145
  extn?: string;
126
146
  }
147
+ export interface FileGenerator {
148
+ name: string;
149
+ url: string;
150
+ icon?: string;
151
+ }
127
152
  export declare function symbolPathFromFilename(f: string): string;
128
153
  export declare function isValidValueForType(def: any, t: Type, allowUndefined?: boolean): boolean;
129
154
  export declare function outputForType(t: Type, alwaysBasic?: boolean): string;
package/lib/types.js CHANGED
@@ -6,7 +6,18 @@ export var TypeHint;
6
6
  TypeHint["color-norm-rgb"] = "color-norm-rgb";
7
7
  TypeHint["color-unnorm-rgb"] = "color-unnorm-rgb";
8
8
  TypeHint["color-hex"] = "color-hex";
9
+ TypeHint["color-css"] = "color-css";
9
10
  })(TypeHint || (TypeHint = {}));
11
+ export var ValuesType;
12
+ (function (ValuesType) {
13
+ ValuesType["files"] = "files";
14
+ ValuesType["animations"] = "animations";
15
+ ValuesType["morphTargets"] = "morphTargets";
16
+ ValuesType["events"] = "events";
17
+ ValuesType["parentNodes"] = "parentNodes";
18
+ ValuesType["nodelabels"] = "nodelabels";
19
+ ValuesType["nodeids"] = "nodeids";
20
+ })(ValuesType || (ValuesType = {}));
10
21
  function valuesCompatible(l, r) {
11
22
  if (!l && !r)
12
23
  return true;
@@ -1,4 +1,4 @@
1
- import { Component, ComponentChildren, ConstructorProps } from './component';
1
+ import { Component, ComponentChildren, ConstructorForComponent, ConstructorProps } from './component';
2
2
  import { ContextManager, Context } from './context';
3
3
  import { Entity } from './entity';
4
4
  import { ZComponentData } from './interfaces';
@@ -48,6 +48,7 @@ export declare class ZComponent<RootType = any> extends Component<RootType> {
48
48
  constructor(contextManager: ContextManager, constructorProps: ConstructorProps, _opts: ZComponentOptions);
49
49
  private _constructorForNode;
50
50
  private _constructorForBehavior;
51
+ resolveNodeID<T extends Component = Component>(id: string, type?: ConstructorForComponent<T>): T | undefined;
51
52
  private _inflateBehaviors;
52
53
  private _wrapBehaviors;
53
54
  notifyPropsChanged(entries: Map<string, Set<string>>): void;
package/lib/zcomponent.js CHANGED
@@ -178,6 +178,18 @@ export class ZComponent extends Component {
178
178
  }
179
179
  };
180
180
  }
181
+ resolveNodeID(id, type) {
182
+ const entity = this.entityByID.get(id);
183
+ if (!entity)
184
+ return this.getZComponentInstance()?.resolveNodeID(id, type);
185
+ if (!(entity instanceof Component))
186
+ return undefined;
187
+ if (!type)
188
+ return entity;
189
+ if (entity instanceof type)
190
+ return entity;
191
+ return undefined;
192
+ }
181
193
  _inflateBehaviors() {
182
194
  for (const [nodeID, impl, ctx] of this._behaviorsToInitialize) {
183
195
  this._wrapBehaviors(nodeID, impl, ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zcomponent/core",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",