Q2 Tecton Framework Wrappers
q2-tecton-framework-wrappers is a core package within the Q2 Tecton micro-frontend ecosystem, designed to facilitate the integration of Stencil-generated web components into various JavaScript frameworks like React, Vue, and Angular. It acts as a set of framework-specific helpers, abstracting away the complexities of direct web component usage. The Tecton system, upon which this package relies, emphasizes isolated execution contexts via iframes and provides a consistent UI/UX for embedded applications within the Q2 UUX banking platform. This package is currently at version 1.66.0 and is part of a frequently updated suite of libraries, with releases often tied to broader Tecton system updates. Its key differentiator is its role in enabling seamless adoption of Tecton's custom elements across diverse frontend frameworks, offering features like `v-model` support for Vue wrappers.
Common errors
-
Error: Uncaught (in promise): Error: A custom element with name 'tct-button' has already been defined.
cause Attempting to call `defineCustomElements()` multiple times, or importing the Tecton elements bundle more than once in a single execution context.fixEnsure `defineCustomElements()` is called only once in your application. Check for duplicate imports of Tecton element bundles or loaders. -
[Vue warn]: Unknown custom element: <tct-button> - did you register the component correctly?
cause The underlying custom element `tct-button` was not registered before the Vue wrapper attempted to use it, or Vue is not configured to recognize custom elements.fixCall `defineCustomElements()` from `q2-tecton-elements/loader` at the application's entry point. For Vue, ensure `app.config.isCustomElement = (tag) => tag.startsWith('tct-')` is configured if you're not using the wrappers and interacting with raw web components.
Warnings
- breaking The Tecton system dropped support for Internet Explorer with version 1.0. Applications targeting IE11 or older browsers will no longer function as expected without significant polyfills or alternative strategies.
- breaking All events emitted by Tecton components were prefixed with `tct` starting from Tecton v1.65.0. This is a breaking change for existing event listeners.
- gotcha Custom elements must be defined globally before framework wrappers can instantiate them. Forgetting to call `defineCustomElements()` or calling it too late will result in errors.
Install
-
npm install q2-tecton-framework-wrappers -
yarn add q2-tecton-framework-wrappers -
pnpm add q2-tecton-framework-wrappers
Imports
- defineCustomElements
import { defineCustomElements } from 'q2-tecton-framework-wrappers';import { defineCustomElements } from 'q2-tecton-elements/loader'; - applyPolyfills
import { applyPolyfills, defineCustomElements } from 'q2-tecton-elements/loader'; - TctButton
import { TctButton } from 'q2-tecton-elements';import { TctButton } from 'q2-tecton-framework-wrappers/vue'; // or import { TctButton } from 'q2-tecton-framework-wrappers/react';
Quickstart
import { defineCustomElements } from 'q2-tecton-elements/loader';
import { createApp } from 'vue';
import { TctButton } from 'q2-tecton-framework-wrappers/vue';
defineCustomElements();
const app = createApp({
template: `
<div>
<h1>Q2 Tecton Integration</h1>
<p>This example demonstrates integrating a Tecton button using Vue wrappers.</p>
<TctButton @tctClick="handleClick" :disabled="isDisabled" ref="myButton">
{{ buttonText }}
</TctButton>
<p>Button is currently {{ isDisabled ? 'disabled' : 'enabled' }}.</p>
<button @click="toggleDisable">Toggle Button State</button>
</div>
`,
components: {
TctButton
},
data() {
return {
buttonText: 'Click Me!',
isDisabled: false
};
},
methods: {
handleClick(event) {
console.log('TctButton clicked!', event);
alert('Tecton Button was clicked!');
},
toggleDisable() {
this.isDisabled = !this.isDisabled;
if (this.isDisabled) {
this.buttonText = 'Disabled';
} else {
this.buttonText = 'Click Me!';
}
}
},
mounted() {
console.log('TctButton instance:', this.$refs.myButton);
}
});
app.mount('#app');