TComponents. View_A

new View_A(parent, propsopt)

Base view component extending Component_A. Manages activation state, identification, icon, content, and child component mapping.

Parameters:
NameTypeAttributesDefaultDescription
parentHTMLElement

The parent DOM element to which this view will attach.

propsTComponents.ViewProps<optional>
{}

Initial properties for the view.

Example
const view = new TComponents.View_A(document.body, {
  name: 'My View',
  icon: 'view-icon',
  content: 'This is the view content',
  children: [new TComponents.Component_A()]
});

Extends

Members

children :Array.<TComponents.Component_A>

List of child components in the view. The obtained value should be treated as a read-only property and should not be used for manipulation.

icon :string

Set the view's icon.

Type:
  • string
Example
const view = new TComponents.View_A(document.body, {
  name: 'My View',
  icon: 'view-icon',
  content: 'This is the view content',
  children: [new TComponents.Component_A()]
});
view.icon = 'new-icon';

Methods

appendChild(t, nameopt) → {void}

Appends a new child (component or HTMLElement) to the container.

Parameters:
NameTypeAttributesDefaultDescription
tTComponents.Component_A | HTMLElement

The child instance to append. Can be a TComponent or a DOM element.

namestring<optional>
''

Optional identifier for the child. If omitted and t is a TComponent, t.compId is used.

Returns:
Type: 
void
Example
const view = new TComponents.View_A(null, {});
const child = new TComponents.Button(null, {});
view.appendChild(child, 'test');

(protected) defaultProps() → {TComponents.ViewProps}

Default property values for the view. Overrides parent defaults; not including inherited props.

Returns:
Type: 
TComponents.ViewProps

mapComponents() → {TComponents.ViewChildProps|object}

Map and return child components when the view is active. Iterates over child prop and returns Tcomponents or global instances.

Returns:

Mapped child components by key.

Type: 
TComponents.ViewChildProps | object

(async) onInit() → {Promise.<void>}

Lifecycle method called when the component is initialized. Override to perform async setup logic.

Returns:
Type: 
Promise.<void>

onRender() → {void}

Lifecycle method called when rendering the component. Override to implement custom render behavior.

Returns:
Type: 
void

removeChild(value) → {void}

Removes a previously added child from the internal _newChildren registry.

Parameters:
NameTypeDescription
valueTComponents.Component_A | HTMLElement

The child instance to remove. Must match the reference used in appendChild.

Returns:
Type: 
void
Example
const view = new TComponents.View_A(null, {});
const child = new TComponents.Button(null, {});
view.appendChild(child, 'test');
view.removeChild(child);

(static) createViewProps() → {TComponents.ViewProps}

Creates a default set of properties for a new view.

Returns:

A fresh view props object.

Type: 
TComponents.ViewProps