diff --git a/docs/components/api.md b/docs/components/api.md
index 3019c08ef..8d866e650 100644
--- a/docs/components/api.md
+++ b/docs/components/api.md
@@ -25,6 +25,7 @@ Once all the metadata has been collected, all the decorators are removed from th
- [@Listen()](./events.md#listen-decorator) listens for DOM events
- [@AttrDeserialize()](./serialization-deserialization.md#the-attrdeserialize-decorator-attrdeserialize) declares a hook to translate a component's attribute string to its JS property
- [@PropSerialize()](./serialization-deserialization.md#the-propserialize-decorator-propserialize) declares a hook that translates a component's JS property to its attribute string
+- [@AttachInternals()](./attach-internals.md) attaches ElementInternals to a component
## Lifecycle hooks
diff --git a/docs/components/attach-internals.md b/docs/components/attach-internals.md
new file mode 100644
index 000000000..b624e569e
--- /dev/null
+++ b/docs/components/attach-internals.md
@@ -0,0 +1,68 @@
+---
+title: Attach Internals
+sidebar_label: Attach Internals
+description: attach internals decorator
+slug: /attach-internals
+---
+
+# Attach Internals Decorator
+
+The `@AttachInternals` decorator is used to attach [ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) to a Stencil component.
+This allows you to leverage features such as [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) and [Form Association](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals#form_association).
+
+## Form Association
+
+Read the dedicated guide on [Form Associated Components](./form-associated.md) and how to use `@AttachInternals` there.
+
+## Custom States
+
+You can use the `@AttachInternals` decorator to define [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) for your component.
+
+```tsx
+import { Component, h, AttachInternals } from '@stencil/core';
+/**
+ * My Element component
+ */
+@Component({
+ tag: 'my-element',
+ styleUrl: 'my-element.css',
+})
+export class MyElement {
+ @AttachInternals({
+ states: {
+ /** A custom state for my element */
+ 'my-custom-state': true,
+ /** Another custom state for my element */
+ 'another-state': false
+ }
+ }) internals: ElementInternals;
+ render() {
+ return
My Element
;
+ }
+}
+```
+
+In the example above, we define two custom states: `my-custom-state` and `another-state`.
+
+The initial values of the custom states can be set via the `states` object and
+later on, you can update the states dynamically using the `internals.states` property. For example:
+
+```tsx
+handleClick() {
+ this.internals.states.add('another-state'); // to add a state
+ this.internals.states.delete('my-custom-state'); // to remove a state
+}
+```
+
+You or your element users can then use custom states in CSS like so:
+
+```css
+/* Use them internally... */
+:host(:state(my-custom-state)) {
+ background-color: yellow;
+}
+/* ... Or use them externally */
+my-element:state(another-state) {
+ border: 2px solid red;
+}
+```
diff --git a/docs/components/templating-and-jsx.md b/docs/components/templating-and-jsx.md
index cd49442f2..74f92c3a2 100644
--- a/docs/components/templating-and-jsx.md
+++ b/docs/components/templating-and-jsx.md
@@ -468,6 +468,23 @@ export class AppHome {
In this example we are using `ref` to get a reference to our input `ref={(el) => this.textInput = el as HTMLInputElement}`. We can then use that ref to do things such as grab the value from the text input directly `this.textInput.value`.
+## Explicitly setting attributes or properties
+
+By default, Stencil tries to intelligently determine whether to set an attribute or (more commonly) a property on an element when using JSX.
+However, in some cases you may want to explicitly set one or the other. You can do this by using the `attr:` or `prop:` prefixes. For example:
+
+```tsx
+
+```
+
+will set the `value` attribute on the input element, while:
+
+```tsx
+
+```
+
+will explicitly set the `value` property on the input element.
+
## Avoid Shared JSX Nodes
diff --git a/docs/documentation-generation/01-overview.md b/docs/documentation-generation/01-overview.md
index 2ea2375f6..d080402c2 100644
--- a/docs/documentation-generation/01-overview.md
+++ b/docs/documentation-generation/01-overview.md
@@ -9,6 +9,7 @@ slug: /doc-generation
- [`docs-readme`: Documentation readme files formatted in markdown](./docs-readme.md)
- [`docs-json`: Documentation data formatted in JSON](./docs-json.md)
+- [`docs-custom-elements-manifest`: Custom Elements Manifest (CEM) format](./docs-custom-elements-manifest.md)
- [`docs-custom`: Custom documentation generation](./docs-custom.md)
- [`docs-vscode`: Documentation generation for VS Code](./docs-vscode.md)
- [`stats`: Stats about the compiled files](./docs-stats.md)
diff --git a/docs/documentation-generation/docs-custom-elements-manifest.md b/docs/documentation-generation/docs-custom-elements-manifest.md
new file mode 100644
index 000000000..d0bb5ad93
--- /dev/null
+++ b/docs/documentation-generation/docs-custom-elements-manifest.md
@@ -0,0 +1,213 @@
+---
+title: Docs Custom Elements Manifest Output Target
+sidebar_label: CEM (docs-custom-elements-manifest)
+description: Custom Elements Manifest
+slug: /docs-custom-elements-manifest
+---
+
+# Generating Documentation in Custom Elements Manifest (CEM) format
+
+Since Stencil v4.42, Stencil supports automatically generating a [Custom Elements Manifest (CEM)](https://custom-elements-manifest.open-wc.org/)
+file in your project. The CEM format is a standardized JSON format for describing
+custom elements and is supported by a variety of tools in the web components ecosystem.
+
+
+```tsx title="stencil.config.ts"
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ outputTargets: [
+ {
+ type: 'docs-custom-elements-manifest',
+ file: 'path/to/cem.json'
+ }
+ ]
+};
+```
+
+The JSON file output by Stencil conforms to the [CEM Schema interface](https://github.com/webcomponents/custom-elements-manifest/blob/main/schema.d.ts).
+
+## Properties, Methods, Events, and Attributes
+
+The CEM output target includes information about your components' properties,
+methods, events, and attributes based on the decorators you use in your Stencil
+components.
+
+## CSS Properties
+
+Stencil can document CSS variables if you annotate them with JSDoc-style
+comments in your CSS/SCSS files. If, for instance, you had a component with a
+CSS file like the following:
+
+```css title="src/components/my-button/my-button.css"
+:host {
+ /**
+ * @prop --background: Background of the button
+ * @prop --background-activated: Background of the button when activated
+ * @prop --background-focused: Background of the button when focused
+ */
+ --background: pink;
+ --background-activated: aqua;
+ --background-focused: fuchsia;
+}
+```
+
+Then you'd get the following in the JSON output:
+
+```json title="Example docs-custom-elements-manifest Output"
+[
+ {
+ "cssProperties": [
+ {
+ "name": "background",
+ "description": "Background of the button"
+ },
+ {
+ "name": "background-activated",
+ "description": "Background of the button when activated"
+ },
+ {
+ "name": "background-focused",
+ "description": "Background of the button when focused"
+ }
+ ]
+ }
+]
+```
+
+## Slots and CSS Parts
+
+If one of your Stencil components makes use of
+[slots](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot) for
+rendering children or [CSS Parts](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) for styling,
+you can document them by using the `@slot` and `@part` JSDoc tags in the
+component's comments.
+
+For instance, if you had a `my-button` component with a slot you might document
+it like so:
+
+```tsx title="src/components/my-button/my-button.tsx"
+import { Component, h } from '@stencil/core';
+
+/**
+ * @slot buttonContent - Slot for the content of the button
+ *
+ * @part button - The button element
+ */
+@Component({
+ tag: 'my-button',
+ styleUrl: 'my-button.css',
+ shadow: true,
+})
+export class MyButton {
+ render() {
+ return
+ }
+}
+```
+
+This would show up in the generated JSON file like so:
+
+```json
+"slots": [
+ {
+ "name": "buttonContent",
+ "description": "Slot for the content of the button"
+ }
+],
+"cssParts": [
+ {
+ "name": "button",
+ "description": "The button element"
+ }
+]
+```
+
+:::caution
+Stencil does not check that the slots you document in a component's JSDoc
+comment using the `@slot` tag are actually present in the JSX returned by the
+component's `render` function.
+
+It is up to you as the component author to ensure the `@slot` tags on a
+component are kept up to date.
+:::
+
+## Custom States
+
+You can document [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) for your components using the `@AttachInternals` decorator
+and JSDoc comments.
+
+For example:
+
+```tsx title="src/components/my-element/my-element.tsx"
+import { Component, h, AttachInternals } from '@stencil/core';
+/**
+ * My Element component
+ */
+@Component({
+ tag: 'my-element',
+ styleUrl: 'my-element.css',
+ shadow: true,
+})
+export class MyElement {
+ @AttachInternals({
+ states: {
+ new: true,
+ /** If this item is older than 6 months old. Use via `:state(archived)` */
+ archived: false
+ },
+ }) internals!: ElementInternals;
+```
+
+This would show up in the generated JSON file like so:
+
+```json
+"customStates": [
+ {
+ "name": "new",
+ "description": ""
+ },
+ {
+ "name": "archived",
+ "description": "If this item is older than 6 months old. Use via `:state(archived)"
+ }
+]
+```
+
+## Demos
+
+You can save demos for a component in the `usage/` subdirectory within
+that component's directory. The content of these files will be added to the
+`demos` property of the generated JSON. This allows you to keep examples right
+next to the code, making it easy to include them in a documentation site or
+other downstream consumer(s) of your docs.
+
+:::caution
+Stencil doesn't check that your demos are up-to-date! If you make any
+changes to your component's API you'll need to remember to update your demos
+manually.
+:::
+
+If, for instance, you had a usage example like this:
+
+````md title="src/components/my-button/usage/my-button-usage.md"
+# How to use `my-button`
+
+A button is often a great help in adding interactivity to an app!
+
+You could use it like this:
+
+```html
+My Button!
+```
+````
+
+
+You'd get the following in the JSON output under the `"usage"` key:
+
+```json
+"demos": [{
+ "url": "my-button-usage.md",
+ "description": "# How to use `my-button`\n\nA button is often a great help in adding interactivity to an app!\n\nYou could use it like this:\n\n```html\nMy Button!\n```\n"
+}]
+```
diff --git a/docs/documentation-generation/docs-custom.md b/docs/documentation-generation/docs-custom.md
index 61da15c79..da64b8a84 100644
--- a/docs/documentation-generation/docs-custom.md
+++ b/docs/documentation-generation/docs-custom.md
@@ -68,8 +68,8 @@ The generated docs JSON data will in the type of `JsonDocs` which consists of ma
| `events` | Array of metadata objects for each usage of the [`@Event` decorator](../components/events.md#event-decorator) on the current component. |
| `listeners` | Array of metadata objects for each usage of the [`@Listen` decorator](../components/events.md#listen-decorator) on the current component. |
| `styles` | Array of objects documenting annotated [CSS variables](./docs-json.md#css-variables) used in the current component's CSS. |
-| `slots` | Array of objects documenting [slots](./docs-json.md#slots) which are tagged with `@slot` in the current component's JSDoc comment. |
-| `parts` | Array of objects derived from `@part` tags in the current component's JSDoc comment. |
+| `slots` | Array of objects documenting [slots](./docs-json.md#slots-and-css-parts) which are tagged with `@slot` in the current component's JSDoc comment. |
+| `parts` | Array of objects documenting [CSS Parts](./docs-json.md#slots-and-css-parts) which are derived from `@part` tags in the current component's JSDoc comment. |
| `dependents` | Array of components where current component is used |
| `dependencies` | Array of components which is used in current component |
| `dependencyGraph` | Describes a tree of components coupling |
diff --git a/docs/documentation-generation/docs-json.md b/docs/documentation-generation/docs-json.md
index 418c21399..a9a6fccc0 100644
--- a/docs/documentation-generation/docs-json.md
+++ b/docs/documentation-generation/docs-json.md
@@ -101,7 +101,7 @@ CSS file like the following:
Then you'd get the following in the JSON output:
```json title="Example docs-json Output"
-[
+"styles": [
{
"name": "--background",
"annotation": "prop",
@@ -153,12 +153,13 @@ latter you'll need to have the
and configured.
:::
-## Slots
+## Slots and CSS Parts
If one of your Stencil components makes use of
[slots](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot) for
-rendering children you can document them by using the `@slot` JSDoc tag in the
-component's comment.
+rendering children or [CSS Parts](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) for styling,
+you can document them by using the `@slot` and `@part` JSDoc tags in the
+component's comments.
For instance, if you had a `my-button` component with a slot you might document
it like so:
@@ -168,6 +169,8 @@ import { Component, h } from '@stencil/core';
/**
* @slot buttonContent - Slot for the content of the button
+ *
+ * @part button - The button element
*/
@Component({
tag: 'my-button',
@@ -176,7 +179,7 @@ import { Component, h } from '@stencil/core';
})
export class MyButton {
render() {
- return
+ return
}
}
```
@@ -184,10 +187,18 @@ export class MyButton {
This would show up in the generated JSON file like so:
```json
-"slots": {
- "name": "buttonContent",
- "docs": "Slot for the content of the button"
-}
+"slots": [
+ {
+ "name": "buttonContent",
+ "docs": "Slot for the content of the button"
+ }
+],
+"parts": [
+ {
+ "name": "button",
+ "docs": "The button element"
+ }
+]
```
:::caution
@@ -199,6 +210,49 @@ It is up to you as the component author to ensure the `@slot` tags on a
component are kept up to date.
:::
+## Custom States
+
+You can document [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) for your components using the `@AttachInternals` decorator
+and JSDoc comments.
+
+For example:
+
+```tsx title="src/components/my-element/my-element.tsx"
+import { Component, h, AttachInternals } from '@stencil/core';
+/**
+ * My Element component
+ */
+@Component({
+ tag: 'my-element',
+ styleUrl: 'my-element.css',
+ shadow: true,
+})
+export class MyElement {
+ @AttachInternals({
+ states: {
+ new: true,
+ /** If this item is older than 6 months old. Use via `:state(archived)` */
+ archived: false
+ },
+ }) internals!: ElementInternals;
+```
+
+This would show up in the generated JSON file like so:
+
+```json
+"states": [
+ {
+ "name": "new",
+ "initialValue": true,
+ "description": ""
+ },
+ {
+ "name": "archived",
+ "initialValue": false,
+ "description": "If this item is older than 6 months old. Use via `:state(archived)"
+ }
+]
+```
## Usage
diff --git a/docs/documentation-generation/docs-readme.md b/docs/documentation-generation/docs-readme.md
index 54e4967b6..6a692047f 100644
--- a/docs/documentation-generation/docs-readme.md
+++ b/docs/documentation-generation/docs-readme.md
@@ -466,6 +466,44 @@ The shadow parts section will be placed after the [@Slot Details](#slot-details)
If a component's top-level JSDoc does not use `@part` tags, this section will be omitted from the generated README.
+### Custom States
+
+You can document [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) for your components using the `@AttachInternals` decorator
+and JSDoc comments.
+
+For example:
+
+```tsx title="src/components/my-element/my-element.tsx"
+import { Component, h, AttachInternals } from '@stencil/core';
+/**
+ * My Element component
+ */
+@Component({
+ tag: 'my-element',
+ styleUrl: 'my-element.css',
+ shadow: true,
+})
+export class MyElement {
+ @AttachInternals({
+ states: {
+ new: true,
+ /** If this item is older than 6 months old */
+ archived: false
+ },
+ }) internals!: ElementInternals;
+```
+
+The following table will be generated:
+
+```md
+## Custom States
+
+| State | Initial Value | Description |
+| ------------------ | ------------- | ---------------------------------------------------------- |
+| `:state(new)` | `true` | |
+| `:state(archived)` | `false` | If this item is older than 6 months old |
+```
+
### Styling Details
Styling in CSS files can be documented in Stencil components as well.
diff --git a/versioned_docs/version-v4.42/build-variables.md b/versioned_docs/version-v4.42/build-variables.md
new file mode 100644
index 000000000..30cc41d9e
--- /dev/null
+++ b/versioned_docs/version-v4.42/build-variables.md
@@ -0,0 +1,48 @@
+---
+title: Build Constants
+description: Stencil has a number of add-ons that you can use with the build process.
+slug: /build-variables
+---
+
+# Build Constants
+
+Build Constants in Stencil allow you to run specific code only when Stencil is running in development mode. This code is stripped from your bundles when doing a production build, therefore keeping your bundles as small as possible.
+
+### Using Build Constants
+
+Lets dive in and look at an example of how to use our build constants:
+
+```tsx
+import { Component, Build } from '@stencil/core';
+
+@Component({
+ tag: 'stencil-app',
+ styleUrl: 'stencil-app.scss'
+})
+export class StencilApp {
+
+ componentDidLoad() {
+ if (Build.isDev) {
+ console.log('im in dev mode');
+ } else {
+ console.log('im running in production');
+ }
+
+ if (Build.isBrowser) {
+ console.log('im in the browser');
+ } else {
+ console.log('im in prerendering (server)');
+ }
+ }
+}
+```
+
+As you can see from this example, we just need to import `Build` from `@stencil/core` and then we can use the `isDev` constant to detect when we are running in dev mode or production mode.
+
+### Use Cases
+
+Some use cases we have come up with are:
+
+- Diagnostics code that runs in dev to make sure logic is working like you would expect
+- `console.log()`'s that may be useful for debugging in dev mode but that you don't want to ship
+- Disabling auth checks when in dev mode
diff --git a/versioned_docs/version-v4.42/components/_category_.json b/versioned_docs/version-v4.42/components/_category_.json
new file mode 100644
index 000000000..57bbce615
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/_category_.json
@@ -0,0 +1,4 @@
+{
+ "label": "Components",
+ "position": 2
+}
diff --git a/versioned_docs/version-v4.42/components/api.md b/versioned_docs/version-v4.42/components/api.md
new file mode 100644
index 000000000..8d866e650
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/api.md
@@ -0,0 +1,312 @@
+---
+title: Component API
+sidebar_label: API
+description: Component API
+slug: /api
+---
+
+# Component API
+
+The whole API provided by stencil can be condensed in a set of decorators, lifecycles hooks and rendering methods.
+
+
+## Decorators
+
+Decorators are a pure compiler-time construction used by stencil to collect all the metadata about a component, the properties, attributes and methods it might expose, the events it might emit or even the associated stylesheets.
+Once all the metadata has been collected, all the decorators are removed from the output, so they don't incur any runtime overhead.
+
+- [@Component()](./component.md) declares a new web component
+- [@Prop()](./properties.md#the-prop-decorator-prop) declares an exposed property/attribute
+- [@State()](./state.md#the-state-decorator-state) declares an internal state of the component
+- [@Watch()](./reactive-data.md#the-watch-decorator-watch) declares a hook that runs when a property or state changes
+- [@Element()](./host-element.md#element-decorator) declares a reference to the host element
+- [@Method()](./methods.md) declares an exposed public method
+- [@Event()](./events.md#event-decorator) declares a DOM event the component might emit
+- [@Listen()](./events.md#listen-decorator) listens for DOM events
+- [@AttrDeserialize()](./serialization-deserialization.md#the-attrdeserialize-decorator-attrdeserialize) declares a hook to translate a component's attribute string to its JS property
+- [@PropSerialize()](./serialization-deserialization.md#the-propserialize-decorator-propserialize) declares a hook that translates a component's JS property to its attribute string
+- [@AttachInternals()](./attach-internals.md) attaches ElementInternals to a component
+
+
+## Lifecycle hooks
+
+- [connectedCallback()](./component-lifecycle.md#connectedcallback)
+- [disconnectedCallback()](./component-lifecycle.md#disconnectedcallback)
+- [componentWillLoad()](./component-lifecycle.md#componentwillload)
+- [componentDidLoad()](./component-lifecycle.md#componentdidload)
+- [componentShouldUpdate(newValue, oldValue, propName): boolean](./component-lifecycle.md#componentshouldupdate)
+- [componentWillRender()](./component-lifecycle.md#componentwillrender)
+- [componentDidRender()](./component-lifecycle.md#componentdidrender)
+- [componentWillUpdate()](./component-lifecycle.md#componentwillupdate)
+- [componentDidUpdate()](./component-lifecycle.md#componentdidupdate)
+- **[render()](./templating-and-jsx.md)**
+
+## componentOnReady()
+
+This isn't a true "lifecycle" method that would be declared on the component class definition, but instead is a utility method that
+can be used by an implementation consuming your Stencil component to detect when a component has finished its first render cycle.
+
+This method returns a promise which resolves after `componentDidRender()` on the _first_ render cycle.
+
+:::note
+`componentOnReady()` only resolves once per component lifetime. If you need to hook into subsequent render cycle, use
+`componentDidRender()` or `componentDidUpdate()`.
+:::
+
+Executing code after `componentOnReady()` resolves could look something like this:
+
+```ts
+// Get a reference to the element
+const el = document.querySelector('my-component');
+
+el.componentOnReady().then(() => {
+ // Place any code in here you want to execute when the component is ready
+ console.log('my-component is ready');
+});
+```
+
+The availability of `componentOnReady()` depends on the component's compiled output type. This method is only available for lazy-loaded
+distribution types ([`dist`](../output-targets/dist.md) and [`www`](../output-targets/www.md)) and, as such, is not available for
+[`dist-custom-elements`](../output-targets/custom-elements.md) output. If you want to simulate the behavior of `componentOnReady()` for non-lazy builds,
+you can implement a helper method to wrap the functionality similar to what the Ionic Framework does [here](https://github.com/ionic-team/ionic-framework/blob/main/core/src/utils/helpers.ts#L60-L79).
+
+## The `appload` event
+
+In addition to component-specific lifecycle hooks, a special event called `appload` will be emitted when the app and all of its child components have finished loading. You can listen for it on the `window` object.
+
+If you have multiple apps on the same page, you can determine which app emitted the event by checking `event.detail.namespace`. This will be the value of the [namespace config option](../config/01-overview.md#namespace) you've set in your Stencil config.
+
+```tsx
+window.addEventListener('appload', (event) => {
+ console.log(event.detail.namespace);
+});
+```
+
+## Other
+
+The following primitives can be imported from the `@stencil/core` package and used within the lifecycle of a component:
+
+### [**Host**](./host-element.md):
+
+``, is a functional component that can be used at the root of the render function to set attributes and event listeners to the host element itself. Refer to the [Host Element](./host-element.md) page for usage info.
+
+### **Fragment**:
+
+``, often used via `<>...>` syntax, lets you group elements without a wrapper node.
+
+ To use this feature, ensure that the following TypeScript compiler options are set:
+ - [`jsxFragmentFactory` is set](https://www.typescriptlang.org/tsconfig#jsxFragmentFactory) to "Fragment"
+ - [`jsxFactory` is set](https://www.typescriptlang.org/tsconfig#jsxFactory) to "h"
+
+ __Type:__ `FunctionalComponent`
+ __Example:__
+ ```tsx
+ import { Component, Fragment, h } from '@stencil/core'
+ @Component({
+ tag: 'cmp-fragment',
+ })
+ export class CmpFragment {
+ render() {
+ return (
+ <>
+
...
+
...
+
...
+ >
+ );
+ }
+ }
+ ```
+
+### [**h()**](./templating-and-jsx.md):
+
+Turns JSX syntax into Virtual DOM elements. Read more on the [Templating and JSX](./templating-and-jsx.md#the-h-and-fragment-functions) page.
+
+### **render()**:
+
+A utility method to render a virtual DOM created by `h()` into a container.
+
+ __Type:__ `(vnode: VNode, container: Element) => void`
+ __Example:__
+ ```tsx
+ import { render } from '@stencil/core'
+ const vdom = (
+
Hello World!
+ )
+ render(vdom, document.body)
+ ```
+
+### [**readTask()**](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing):
+
+Schedules a DOM-read task. The provided callback will be executed in the best moment to perform DOM reads without causing layout thrashing.
+
+ __Type:__ `(task: Function) => void`
+
+### [**writeTask()**](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing):
+
+Schedules a DOM-write task. The provided callback will be executed in the best moment to perform DOM mutations without causing layout thrashing.
+
+ __Type:__ `(task: Function) => void`
+
+### **forceUpdate()**:
+
+Schedules a new render of the given instance or element even if no state changed. Notice `forceUpdate()` is not synchronous and might perform the DOM render in the next frame.
+
+ __Type:__ `(ref: any) => void`
+ __Example:__
+ ```ts
+ import { forceUpdate } from '@stencil/core'
+
+ // inside a class component function
+ forceUpdate(this);
+ ```
+
+### **getAssetPath()**:
+
+ Gets the path to local assets. Refer to the [Assets](../guides/assets.md#getassetpath) page for usage info.
+
+ __Type:__ `(path: string) => string`
+ __Example:__
+ ```tsx
+ import { Component, Prop, getAssetPath, h } from '@stencil/core'
+ @Component({
+ tag: 'cmp-asset',
+ })
+ export class CmpAsset {
+ @Prop() icon: string;
+
+ render() {
+ return (
+
+ );
+ }
+ }
+ ```
+
+### **setAssetPath()**:
+
+Sets the path for Stencil to resolve local assets. Refer to the [Assets](../guides/assets.md#setassetpath) page for usage info.
+
+ __Type:__ `(path: string) => string`
+ __Example:__
+ ```ts
+ import { setAssetPath } from '@stencil/core';
+ setAssetPath(`{window.location.origin}/`);
+ ```
+
+ ### **setMode()**:
+
+ Sets the style mode of a component. Refer to the [Styling](./styling.md#style-modes) page for usage info.
+
+ __Type:__ `((elm: HTMLElement) => string | undefined | null) => void`
+ __Example:__
+ ```ts
+ import { setMode } from '@stencil/core'
+
+ // set mode based on a property
+ setMode((el) => el.getAttribute('mode'));
+ ```
+
+### **getMode()**:
+
+Get the current style mode of your application. Refer to the [Styling](./styling.md#style-modes) page for usage info.
+
+ __Type:__ `(ref: any) => string | undefined`
+ __Example:__
+ ```ts
+ import { getMode } from '@stencil/core'
+
+ getMode(this);
+ ```
+
+### **getElement()**:
+
+Retrieve a Stencil element for a given reference.
+
+ __Type:__ `(ref: any) => HTMLStencilElement`
+ __Example:__
+ ```ts
+ import { getElement } from '@stencil/core'
+
+ const stencilComponent = getElement(document.querySelector('my-cmp'))
+ if (stencilComponent) {
+ stencilComponent.componentOnReady().then(() => { ... })
+ }
+ ```
+
+ ### **resolveVar()**:
+
+ Because Stencil's decorators rely heavily on static analysis, you cannot use dynamic variables within them. `resolveVar` provides a deterministic way to find the string value of a given variable at compile time:
+
+ __Type:__ `(variable: T) => string`
+ __Example:__
+ ```tsx
+ import { Listen, Event, resolveVar } from '@stencil/core`
+
+ const COMPONENT_A_EVENT: string = 'componentAEvent';
+ const EVENTS = {
+ COMPONENT_B_EVENT: 'componentBEvent',
+ };
+
+ // inside an @Component class
+
+ @Component({
+ tag: 'dynamic-event-names',
+ })
+ export class DynamicEventNames {
+ @Event({ eventName: resolveVar(COMPONENT_A_EVENT) }) myEvent;
+
+ @Listen(resolveVar(EVENTS.COMPONENT_B_EVENT))
+ listenHandler(){
+ //
+ }
+ }
+ ```
+
+### **Mixin()**:
+
+Compose multiple classes into a single constructor using factory functions.
+
+ __Type:__
+ ```ts
+ (
+ ...mixinFactories: TMixins
+ ): abstract new (...args: any[]) => UnionToIntersection>>;
+ ```
+ __Example:__
+ ```ts
+ import { Mixin, MixedInCtor, Component, h, Prop, State } from '@stencil/core'
+
+ const aFactory = (Base: B) => {
+ class A extends Base { propA = 'A' };
+ return A;
+ }
+ const bFactory = (Base: B) => {
+ class B extends Base { @Prop() propB = 'B' };
+ return B;
+ }
+ const cFactory = (Base: B) => {
+ class C extends Base { @State() propC = 'C' };
+ return C;
+ }
+
+ @Component({
+ tag: 'its-mixing-time',
+ })
+ export class X extends Mixin(aFactory, bFactory, cFactory) {
+ render() {
+ return
{this.propA} {this.propB} {this.propC}
+ }
+ }
+ ```
+
+:::caution
+If your Stencil component library uses `Mixin()` (or `extends`) and *might* be used by other Stencil component libraries, ensure that all mixed-in factories are imported directly and **not** via [barrel files](https://basarat.gitbook.io/typescript/main-1/barrel).
+The static-analysis that Stencil uses to find mixed-in classes does not work within 3rd party (node_module) barrel files.
+:::
+
+For detailed guidance on using `Mixin()` and `extends` for component architecture, including when to use inheritance vs composition patterns, see the [Extends & Mixins](../guides/extends.md) guide.
+
+### [**setTagTransformer()** and **transformTag()**](../guides/tag-transformation.md):
+
+Manage tag name transformation at runtime. Refer to the [Tag Transformation](../guides/tag-transformation.md) page for usage info.
\ No newline at end of file
diff --git a/versioned_docs/version-v4.42/components/attach-internals.md b/versioned_docs/version-v4.42/components/attach-internals.md
new file mode 100644
index 000000000..b624e569e
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/attach-internals.md
@@ -0,0 +1,68 @@
+---
+title: Attach Internals
+sidebar_label: Attach Internals
+description: attach internals decorator
+slug: /attach-internals
+---
+
+# Attach Internals Decorator
+
+The `@AttachInternals` decorator is used to attach [ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) to a Stencil component.
+This allows you to leverage features such as [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) and [Form Association](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals#form_association).
+
+## Form Association
+
+Read the dedicated guide on [Form Associated Components](./form-associated.md) and how to use `@AttachInternals` there.
+
+## Custom States
+
+You can use the `@AttachInternals` decorator to define [Custom States](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet) for your component.
+
+```tsx
+import { Component, h, AttachInternals } from '@stencil/core';
+/**
+ * My Element component
+ */
+@Component({
+ tag: 'my-element',
+ styleUrl: 'my-element.css',
+})
+export class MyElement {
+ @AttachInternals({
+ states: {
+ /** A custom state for my element */
+ 'my-custom-state': true,
+ /** Another custom state for my element */
+ 'another-state': false
+ }
+ }) internals: ElementInternals;
+ render() {
+ return
My Element
;
+ }
+}
+```
+
+In the example above, we define two custom states: `my-custom-state` and `another-state`.
+
+The initial values of the custom states can be set via the `states` object and
+later on, you can update the states dynamically using the `internals.states` property. For example:
+
+```tsx
+handleClick() {
+ this.internals.states.add('another-state'); // to add a state
+ this.internals.states.delete('my-custom-state'); // to remove a state
+}
+```
+
+You or your element users can then use custom states in CSS like so:
+
+```css
+/* Use them internally... */
+:host(:state(my-custom-state)) {
+ background-color: yellow;
+}
+/* ... Or use them externally */
+my-element:state(another-state) {
+ border: 2px solid red;
+}
+```
diff --git a/versioned_docs/version-v4.42/components/component-lifecycle.md b/versioned_docs/version-v4.42/components/component-lifecycle.md
new file mode 100644
index 000000000..72609e476
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/component-lifecycle.md
@@ -0,0 +1,182 @@
+---
+title: Component Lifecycle Methods
+sidebar_label: Lifecycle Methods
+description: Component Lifecycle Methods
+slug: /component-lifecycle
+---
+
+# Component Lifecycle Methods
+
+Components have numerous lifecycle methods which can be used to know when the component "will" and "did" load, update, and render. These methods can be added to a component to hook into operations at the right time.
+
+Implement one of the following methods within a component class and Stencil will automatically call them in the right order:
+
+import LifecycleMethodsChart from '@site/src/components/LifecycleMethodsChart';
+
+
+
+## connectedCallback()
+
+Called every time the component is connected to the DOM.
+When the component is first connected, this method is called before `componentWillLoad`.
+
+It's important to note that this method can be called more than once, every time, the element is **attached** or **moved** in the DOM. For logic that needs to run every time the element is attached or moved in the DOM, it is considered a best practice to use this lifecycle method.
+
+```tsx
+const el = document.createElement('my-cmp');
+document.body.appendChild(el);
+// connectedCallback() called
+// componentWillLoad() called (first time)
+
+el.remove();
+// disconnectedCallback()
+
+document.body.appendChild(el);
+// connectedCallback() called again, but `componentWillLoad()` is not.
+```
+
+
+This `lifecycle` hook follows the same semantics as the one described by the [Custom Elements Spec](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)
+
+## disconnectedCallback()
+
+Called every time the component is disconnected from the DOM, ie, it can be dispatched more than once, DO not confuse with a "onDestroy" kind of event.
+
+This `lifecycle` hook follows the same semantics as the one described by the [Custom Elements Spec](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements).
+
+## componentWillLoad()
+
+Called once just after the component is first connected to the DOM. Since this method is only called once, it's a good place to load data asynchronously and to setup the state without triggering extra re-renders.
+
+A promise can be returned, that can be used to wait for the first `render()`.
+
+## componentDidLoad()
+
+Called once just after the component is fully loaded and the first `render()` occurs.
+
+## componentShouldUpdate()
+
+This hook is called when a component's [`Prop`](./properties.md) or [`State`](./state.md) property changes and a rerender is about to be requested. This hook receives three arguments: the new value, the old value and the name of the changed state. It should return a boolean to indicate if the component should rerender (`true`) or not (`false`).
+
+A couple of things to notice is that this method will not be executed before the initial render, that is, when the component is first attached to the dom, nor when a rerender is already scheduled in the next frame.
+
+Let’s say the following two props of a component change synchronously:
+
+```tsx
+component.somePropA = 42;
+component.somePropB = 88;
+```
+
+The `componentShouldUpdate` will be first called with arguments: `42`, `undefined` and `somePropA`. If it does return `true`, the hook will not be called again since the rerender is already scheduled to happen. Instead, if the first hook returned `false`, then `componentShouldUpdate` will be called again with `88`, `undefined` and `somePropB` as arguments, triggered by the `component.somePropB = 88` mutation.
+
+Since the execution of this hook might be conditioned, it's not good to rely on it to watch for prop changes, instead use the `@Watch` decorator for that.
+
+## componentWillRender()
+
+Called before every `render()`.
+
+A promise can be returned, that can be used to wait for the upcoming render.
+
+## componentDidRender()
+
+Called after every `render()`.
+
+
+## componentWillUpdate()
+
+Called when the component is about to be updated because some `Prop()` or `State()` changed.
+It's never called during the first `render()`.
+
+A promise can be returned, that can be used to wait for the next render.
+
+
+## componentDidUpdate()
+
+Called just after the component updates.
+It's never called during the first `render()`.
+
+
+## Rendering State
+
+It's always recommended to make any rendered state updates within `componentWillRender()`, since this is the method which get called _before_ the `render()` method. Alternatively, updating rendered state with the `componentDidLoad()`, `componentDidUpdate()` and `componentDidRender()` methods will cause another rerender, which isn't ideal for performance.
+
+If state _must_ be updated in `componentDidUpdate()` or `componentDidRender()`, it has the potential of getting components stuck in an infinite loop. If updating state within `componentDidUpdate()` is unavoidable, then the method should also come with a way to detect if the props or state is "dirty" or not (is the data actually different or is it the same as before). By doing a dirty check, `componentDidUpdate()` is able to avoid rendering the same data, and which in turn calls `componentDidUpdate()` again.
+
+
+## Lifecycle Hierarchy
+
+A useful feature of lifecycle methods is that they take their child component's lifecycle into consideration too. For example, if the parent component, `cmp-a`, has a child component, `cmp-b`, then `cmp-a` isn't considered "loaded" until `cmp-b` has finished loading. Another way to put it is that the deepest components finish loading first, then the `componentDidLoad()` calls bubble up.
+
+It's also important to note that even though Stencil can lazy-load components, and has asynchronous rendering, the lifecycle methods are still called in the correct order. So while the top-level component could have already been loaded, all of its lifecycle methods are still called in the correct order, which means it'll wait for a child components to finish loading. The same goes for the exact opposite, where the child components may already be ready while the parent isn't.
+
+In the example below we have a simple hierarchy of components. The numbered list shows the order of which the lifecycle methods will fire.
+
+```markup
+
+
+
+
+
+```
+
+1. `cmp-a` - `componentWillLoad()`
+2. `cmp-b` - `componentWillLoad()`
+3. `cmp-c` - `componentWillLoad()`
+4. `cmp-c` - `componentDidLoad()`
+5. `cmp-b` - `componentDidLoad()`
+6. `cmp-a` - `componentDidLoad()`
+
+Even if some components may or may not be already loaded, the entire component hierarchy waits on its child components to finish loading and rendering.
+
+
+## Async Lifecycle Methods
+
+Some lifecycle methods, e.g. `componentWillRender`, `componentWillLoad` and `componentWillUpdate`, can also return promises which allows the method to asynchronously retrieve data or perform any async tasks. A great example of this is fetching data to be rendered in a component. For example, this very site you're reading first fetches content data before rendering. But because `fetch()` is async, it's important that `componentWillLoad()` returns a `Promise` to ensure its parent component isn't considered "loaded" until all of its content has rendered.
+
+Below is a quick example showing how `componentWillLoad()` is able to have its parent component wait on it to finish loading its data.
+
+```tsx
+componentWillLoad() {
+ return fetch('/some-data.json')
+ .then(response => response.json())
+ .then(data => {
+ this.content = data;
+ });
+}
+```
+
+## Example
+
+This simple example shows a clock and updates the current time every second. The timer is started when the component is added to the DOM. Once it's removed from the DOM, the timer is stopped.
+
+```tsx
+import { Component, State, h } from '@stencil/core';
+
+@Component({
+ tag: 'custom-clock'
+})
+export class CustomClock {
+
+ timer: number;
+
+ @State() time: number = Date.now();
+
+ connectedCallback() {
+ this.timer = window.setInterval(() => {
+ this.time = Date.now();
+ }, 1000);
+ }
+
+ disconnectedCallback() {
+ window.clearInterval(this.timer);
+ }
+
+ render() {
+ const time = new Date(this.time).toLocaleTimeString();
+
+ return (
+ { time }
+ );
+ }
+}
+```
diff --git a/versioned_docs/version-v4.42/components/component.md b/versioned_docs/version-v4.42/components/component.md
new file mode 100644
index 000000000..c3b97580e
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/component.md
@@ -0,0 +1,400 @@
+---
+title: Component Decorator
+sidebar_label: Component
+description: Documentation for the @Component decorator
+slug: /component
+---
+
+# Component Decorator
+
+`@Component()` is a decorator that designates a TypeScript class as a Stencil component.
+Every Stencil component gets transformed into a web component at build time.
+
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ // additional options
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+## Component Options
+
+The `@Component()` decorator takes one argument, an object literal containing configuration options for the component.
+This allows each component to be individually configured to suit the unique needs of each project.
+
+Each option, its type, and whether it's required is described below.
+
+### tag
+
+**Required**
+
+**Type: `string`**
+
+**Details:**
+This value sets the name of the custom element that Stencil will generate.
+To adhere to the [HTML spec](https://html.spec.whatwg.org/#valid-custom-element-name), the tag name must contain a dash ('-').
+
+Ideally, the tag name is a globally unique value.
+Having a globally unique value helps prevent naming collisions with the global `CustomElementsRegistry`, where all custom elements are defined.
+It's recommended to choose a unique prefix for all your components within the same collection.
+
+**Example**:
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+After compilation, the component defined in `TodoList` can be used in HTML or another TSX file:
+```html
+
+
+```
+```tsx
+{/* Here we use the component in a TSX file */}
+
+```
+
+### assetsDirs
+
+**Optional**
+
+**Type: `string[]`**
+
+**Details:**
+`assetsDirs` is an array of relative paths from the component to a directory containing the static files (assets) the component requires.
+
+**Example**:
+Below is an example project's directory structure containing an example component and assets directory.
+
+```
+src/
+└── components/
+ ├── assets/
+ │ └── sunset.jpg
+ └── todo-list.tsx
+```
+
+Below, the `todo-list` component will correctly load the `sunset.jpg` image from the `assets/` directory, using Stencil's [`getAssetPath()`](../guides/assets.md#getassetpath).
+
+```tsx
+import { Component, Prop, getAssetPath, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ // 1. assetsDirs lists the 'assets' directory as a relative (sibling)
+ // directory
+ assetsDirs: ['assets']
+})
+export class TodoList {
+ image = "sunset.jpg";
+
+ render() {
+ // 2. the asset path is retrieved relative to the asset base path to use in
+ // the tag
+ const imageSrc = getAssetPath(`./assets/${this.image}`);
+ return
+ }
+}
+```
+
+In the example above, the following allows `todo-list` to display the provided asset:
+1. The `TodoList`'s `@Component()` decorator has the `assetsDirs` property, and lists the file's sibling directory, `assets/`.
+ This will copy the `assets` directory over to the distribution directory.
+2. Stencil's [`getAssetPath()`](../guides/assets.md#getassetpath) is used to retrieve the path to the image to be used in the `` tag
+
+For more information on configuring assets, please see Stencil's [Assets Guide](../guides/assets.md)
+
+
+### formAssociated
+
+**Optional**
+
+**Type: `boolean`**
+
+**Default: `false`**
+
+If `true` the component will be
+[form-associated](https://html.spec.whatwg.org/dev/custom-elements.html#form-associated-custom-element),
+allowing you to take advantage of the
+[`ElementInternals`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals)
+API to enable your Stencil component to participate in forms.
+
+A minimal form-associated Stencil component could look like this:
+
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'form-associated',
+ formAssociated: true
+})
+export class FormAssociated {
+ render() {
+ return form associated!
+ }
+}
+```
+
+See the documentation for [form-associated components](./form-associated.md)
+for more info and examples.
+
+### scoped
+
+**Optional**
+
+**Type: `boolean`**
+
+**Default: `false`**
+
+**Details:**
+If `true`, the component will use [scoped stylesheets](./styling.md#scoped-css).
+
+Scoped CSS is an alternative to using the native [shadow DOM](./styling.md#shadow-dom) style encapsulation.
+It appends a data attribute to your styles to make them unique and thereby scope them to your component.
+It does not, however, prevent styles from the light DOM from seeping into your component.
+
+To use the native [shadow DOM](./styling.md#shadow-dom), see the configuration for [`shadow`](#shadow).
+
+This option cannot be set to `true` if `shadow` is enabled.
+
+**Example**:
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ scoped: true
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+### shadow
+
+**Optional**
+
+**Type: `boolean | { delegatesFocus?: boolean, slotAssignment?: 'manual' | 'named' }`**
+
+**Default: `false`**
+
+**Details:**
+If `true`, the component will use [native Shadow DOM encapsulation](./styling.md#shadow-dom).
+It will fall back to `scoped` if the browser does not support shadow-dom natively.
+
+`delegatesFocus` is a property that [provides focus](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus) to the first focusable entry in a component using Shadow DOM.
+If an object literal containing `delegatesFocus` is provided, the component will use [native Shadow DOM encapsulation](./styling.md#shadow-dom), regardless of the value assigned to `delegatesFocus`.
+
+When `delegatesFocus` is set to `true`, the component will have `delegatesFocus: true` added to its shadow DOM.
+
+When `delegatesFocus` is `true` and a non-focusable part of the component is clicked:
+- the first focusable part of the component is given focus
+- the component receives any available `focus` styling
+
+When `slotAssignment` is set to `'manual'` or `'named'`, the component will have `slotAssignment` added to its shadow DOM.
+
+`slotAssignment: 'manual'` enables [manual slot assignment](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/slotAssignment) (otherwise known as [imperative slot assignment](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Imperative-Shadow-DOM-Distribution-API.md)) for the component.
+
+If `shadow` is set to `false`, the component will not use native shadow DOM encapsulation.
+
+This option cannot be set to enabled if `scoped` is enabled.
+
+**Example 1**:
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ shadow: true
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+**Example 2**:
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ shadow: {
+ delegatesFocus: true,
+ }
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+### styleUrl
+
+**Optional**
+
+**Type: `string`**
+
+**Details:**
+Relative URL to an external stylesheet containing styles to apply to your component.
+Out of the box, Stencil will only process CSS files (files ending with `.css`).
+Support for additional CSS variants, like Sass, can be added via [a plugin](https://stenciljs.com/docs/plugins#related-plugins).
+
+**Example**:
+Below is an example project's directory structure containing an example component and stylesheet.
+```
+src/
+└── components/
+ ├── todo-list.css
+ └── todo-list.tsx
+```
+
+By setting `styleUrl`, Stencil will apply the `todo-list.css` stylesheet to the `todo-list` component:
+
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ styleUrl: './todo-list.css',
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+### styleUrls
+
+**Optional**
+
+**Type: `string[] | { [modeName: string]: string | string[]; }`**
+
+**Details:**
+A list of relative URLs to external stylesheets containing styles to apply to your component.
+
+Alternatively, an object can be provided that maps a named "mode" to one or more stylesheets.
+
+Out of the box, Stencil will only process CSS files (ending with `.css`).
+Support for additional CSS variants, like Sass, can be added via [a plugin](https://stenciljs.com/docs/plugins#related-plugins).
+
+**Example**:
+Below is an example project's directory structure containing an example component and stylesheet.
+```
+src/
+└── components/
+ ├── todo-list-1.css
+ ├── todo-list-2.css
+ └── todo-list.tsx
+```
+
+By setting `styleUrls`, Stencil will apply both stylesheets to the `todo-list` component:
+
+```tsx title="Using an array of styles"
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ styleUrls: ['./todo-list-1.css', './todo-list-2.css']
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+```tsx title="Using modes"
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ styleUrls: {
+ ios: 'todo-list-1.ios.scss',
+ md: 'todo-list-2.md.scss',
+ }
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+Read more on styling modes in the Components [Styling](./styling.md#style-modes) section.
+
+### styles
+
+**Optional**
+
+**Type: `string | { [modeName: string]: any }`**
+
+**Details:**
+A string that contains inlined CSS instead of using an external stylesheet.
+The performance characteristics of this feature are the same as using an external stylesheet.
+
+When using `styles`, only CSS is permitted.
+See [`styleUrl`](#styleurl) if you need more advanced features.
+
+**Example**:
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+ styles: 'div { background-color: #fff }'
+})
+export class TodoList {
+ // implementation omitted
+}
+```
+
+## Embedding or Nesting Components
+
+Components can be composed easily by adding the HTML tag to the JSX code. Since the components are just HTML tags, nothing needs to be imported to use a Stencil component within another Stencil component.
+
+Here's an example of using a component within another component:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'my-embedded-component'
+})
+export class MyEmbeddedComponent {
+ @Prop() color: string = 'blue';
+
+ render() {
+ return (
+
+ );
+ }
+}
+```
+
+The `my-parent-component` includes a reference to the `my-embedded-component` in the `render()` function.
+
+## Component Architecture Patterns
+
+Stencil supports advanced component architecture patterns including class inheritance and composition. Learn more about organizing component logic with controllers in the [Extends & Mixins](../guides/extends.md) guide.
diff --git a/versioned_docs/version-v4.42/components/events.md b/versioned_docs/version-v4.42/components/events.md
new file mode 100644
index 000000000..96ed92f07
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/events.md
@@ -0,0 +1,225 @@
+---
+title: Events
+sidebar_label: Events
+description: Events
+slug: /events
+---
+
+# Events
+
+There is **NOT** such a thing as *stencil events*, instead, Stencil encourages the use of [DOM events](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events).
+However, Stencil does provide an API to specify the events a component can emit, and the events a component listens to. It does so with the `Event()` and `Listen()` decorators.
+
+## Event Decorator
+
+Components can emit data and events using the Event Emitter decorator.
+
+To dispatch [Custom DOM events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events) for other components to handle, use the `@Event()` decorator.
+
+```tsx
+import { Event, EventEmitter } from '@stencil/core';
+
+...
+export class TodoList {
+
+ @Event() todoCompleted: EventEmitter;
+
+ todoCompletedHandler(todo: Todo) {
+ this.todoCompleted.emit(todo);
+ }
+}
+```
+
+The code above will dispatch a custom DOM event called `todoCompleted`.
+
+The `Event(opts: EventOptions)` decorator optionally accepts an options object to shape the behavior of dispatched events. The options and defaults are described below.
+
+```tsx
+export interface EventOptions {
+ /**
+ * A string custom event name to override the default.
+ */
+ eventName?: string;
+ /**
+ * A Boolean indicating whether the event bubbles up through the DOM or not.
+ */
+ bubbles?: boolean;
+
+ /**
+ * A Boolean indicating whether the event is cancelable.
+ */
+ cancelable?: boolean;
+
+ /**
+ * A Boolean value indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM.
+ */
+ composed?: boolean;
+}
+```
+
+Example:
+
+```tsx
+import { Event, EventEmitter } from '@stencil/core';
+
+...
+export class TodoList {
+
+ // Event called 'todoCompleted' that is "composed", "cancellable" and it will bubble up!
+ @Event({
+ eventName: 'todoCompleted',
+ composed: true,
+ cancelable: true,
+ bubbles: true,
+ }) todoCompleted: EventEmitter;
+
+ todoCompletedHandler(todo: Todo) {
+ const event = this.todoCompleted.emit(todo);
+ if(!event.defaultPrevented) {
+ // if not prevented, do some default handling code
+ }
+ }
+}
+```
+
+:::note
+In the case where the Stencil `Event` type conflicts with the native web `Event` type, there are two possible solutions:
+
+1. Import aliasing:
+```tsx
+import { Event as StencilEvent, EventEmitter } from '@stencil/core';
+
+@StencilEvent() myEvent: EventEmitter<{value: string, ev: Event}>;
+```
+
+2. Namespace the native web `Event` type with `globalThis`:
+```tsx
+@Event() myEvent: EventEmitter<{value: string, ev: globalThis.Event}>;
+```
+:::
+
+## Listen Decorator
+
+The `Listen()` decorator is for listening to DOM events, including the ones dispatched from `@Events`. The event listeners are automatically added and removed when the component gets added or removed from the DOM.
+
+In the example below, assume that a child component, `TodoList`, emits a `todoCompleted` event using the `EventEmitter`.
+
+```tsx
+import { Listen } from '@stencil/core';
+
+...
+export class TodoApp {
+
+ @Listen('todoCompleted')
+ todoCompletedHandler(event: CustomEvent) {
+ console.log('Received the custom todoCompleted event: ', event.detail);
+ }
+}
+```
+
+### Listen's options
+
+The `@Listen(eventName, opts?: ListenOptions)` includes a second optional argument that can be used to configure how the DOM event listener is attached.
+
+```tsx
+export interface ListenOptions {
+ target?: 'body' | 'document' | 'window';
+ capture?: boolean;
+ passive?: boolean;
+}
+```
+
+The available options are `target`, `capture` and `passive`:
+
+
+#### target
+
+Handlers can also be registered for an event other than the host itself.
+The `target` option can be used to change where the event listener is attached, this is useful for listening to application-wide events.
+
+In the example below, we're going to listen for the scroll event, emitted from `window`:
+
+```tsx
+ @Listen('scroll', { target: 'window' })
+ handleScroll(ev) {
+ console.log('the body was scrolled', ev);
+ }
+```
+
+#### passive
+
+By default, Stencil uses several heuristics to determine if it must attach a `passive` event listener or not. The `passive` option can be used to change the default behavior.
+
+Please check out [https://developers.google.com/web/updates/2016/06/passive-event-listeners](https://developers.google.com/web/updates/2016/06/passive-event-listeners) for further information.
+
+
+#### capture
+
+Event listener attached with `@Listen` does not "capture" by default.
+When a event listener is set to "capture", it means the event will be dispatched during the "capture phase".
+Check out [https://www.quirksmode.org/js/events_order.html](https://www.quirksmode.org/js/events_order.html) for further information.
+
+
+```tsx
+ @Listen('click', { capture: true })
+ handleClick(ev) {
+ console.log('click');
+ }
+```
+
+## Keyboard events
+
+For keyboard events, you can use the standard `keydown` event in `@Listen()` and use `event.keyCode` or `event.which` to get the key code, or `event.key` for the string representation of the key.
+
+```tsx
+@Listen('keydown')
+handleKeyDown(ev: KeyboardEvent){
+ if (ev.key === 'ArrowDown'){
+ console.log('down arrow pressed')
+ }
+}
+```
+More info on event key strings can be found in the [w3c spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values).
+
+
+## Using events in JSX
+
+Within a stencil compiled application or component you can also bind listeners to events directly in JSX. This works very similar to normal DOM events such as `onClick`.
+
+Let's use our TodoList component from above:
+
+```tsx
+import { Event, EventEmitter } from '@stencil/core';
+
+...
+export class TodoList {
+
+ @Event() todoCompleted: EventEmitter;
+
+ todoCompletedHandler(todo: Todo) {
+ this.todoCompleted.emit(todo);
+ }
+}
+```
+
+We can now listen to this event directly on the component in our JSX using the following syntax:
+
+```tsx
+ this.someMethod(ev)} />
+```
+
+This property is generated automatically and is prefixed with "on". For example, if the event emitted is called `todoDeleted` the property will be called `onTodoDeleted`:
+
+```tsx
+ this.someOtherMethod(ev)} />
+```
+
+## Listening to events from a non-JSX element
+
+```tsx
+
+
+```
diff --git a/versioned_docs/version-v4.42/components/form-associated.md b/versioned_docs/version-v4.42/components/form-associated.md
new file mode 100644
index 000000000..a60fa6806
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/form-associated.md
@@ -0,0 +1,289 @@
+---
+title: Form-Associated Components
+sidebar_label: Form-Associated Components
+description: Form-Associated Stencil Components
+slug: /form-associated
+---
+
+# Building Form-Associated Components in Stencil
+
+As of v4.5.0, Stencil has support for form-associated custom elements. This
+allows Stencil components to participate in a rich way in HTML forms,
+integrating with native browser features for validation and accessibility while
+maintaining encapsulation and control over their styling and presentation.
+
+## Creating a Form-Associated Component
+
+A form-associated Stencil component is one which sets the new [`formAssociated`](./component.md#formassociated)
+option in the argument to the `@Component`
+decorator to `true`, like so:
+
+```tsx
+import { Component } from '@stencil/core';
+
+@Component({
+ tag: 'my-face',
+ formAssociated: true,
+})
+export class MyFACE {
+}
+```
+
+This element will now be marked as a form-associated custom element via the
+[`formAssociated`](https://html.spec.whatwg.org/#custom-elements-face-example)
+static property, but by itself this is not terribly useful.
+
+In order to meaningfully interact with a `
+```
+
+then it will automatically be linked up to the surrounding form. The
+`ElementInternals` object found at `this.internals` will have a bunch of
+methods on it for interacting with that form and getting key information out of
+it.
+
+In our `` example above we use the
+[`setFormValue`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue)
+method to set a value in the surrounding form. This will read the `name`
+attribute off of the element and use it when setting the value, so the value
+typed by a user into the `input` will added to the form under the
+`"my-custom-input"` name.
+
+This example just scratches the surface, and a great deal more is possible with
+the `ElementInternals` API, including [setting the element's
+validity](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity),
+reading the validity state of the form, reading other form values, and more.
+
+## Lifecycle Callbacks
+
+Stencil allows developers building form-associated custom elements to define a
+[standard series of lifecycle
+callbacks](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions)
+which enable their components to react dynamically to events in their
+lifecycle. These could allow fetching data when a form loads, changing styles
+when a form's `disabled` state is toggled, resetting form data cleanly, and more.
+
+### `formAssociatedCallback`
+
+This callback is called when the browser both associates the element with and
+disassociates the element from a form element. The function is called with the
+form element as an argument. This could be used to set an `ariaLabel` when the
+form is ready to use, like so:
+
+```tsx title='src/components/form-associated-cb.tsx'
+import { Component, h, AttachInternals } from '@stencil/core';
+
+@Component({
+ tag: 'form-associated',
+ formAssociated: true,
+})
+export class FormAssociatedCmp {
+ @AttachInternals()
+ internals: ElementInternals;
+
+ formAssociatedCallback(form) {
+ form.ariaLabel = 'formAssociated called';
+ }
+
+ render() {
+ return ;
+ }
+}
+```
+
+### `formDisabledCallback`
+
+This is called whenever the `disabled` state on the element _changes_. This
+could be used to keep a CSS class in sync with the disabled state, like so:
+
+```tsx title='src/components/form-disabled-cb.tsx'
+import { Component, h, State } from '@stencil/core';
+
+@Component({
+ tag: 'form-disabled-cb',
+ formAssociated: true,
+})
+export class MyComponent {
+ @State() cssClass: string = "";
+
+ formDisabledCallback(disabled: boolean) {
+ if (disabled) {
+ this.cssClass = "background-mode";
+ } else {
+ this.cssClass = "";
+ }
+ }
+
+ render() {
+ return
+ }
+}
+```
+
+### `formResetCallback`
+
+This is called when the form is reset, and should be used to reset the
+form-associated component's internal state and validation. For example, you
+could do something like the following:
+
+```tsx title="src/components/form-reset-cb.tsx"
+import { Component, h, AttachInternals } from '@stencil/core';
+
+@Component({
+ tag: 'form-reset-cb',
+ formAssociated: true,
+})
+export class MyComponent {
+ @AttachInternals()
+ internals: ElementInternals;
+
+ formResetCallback() {
+ this.internals.setValidity({});
+ this.internals.setFormValue("");
+ }
+
+ render() {
+ return
+ }
+}
+```
+
+### `formStateRestoreCallback`
+
+This method will be called in the event that the browser automatically fills
+out your form element, an event that could take place in two different
+scenarios. The first is that the browser can restore the state of an element
+after navigating or restarting, and the second is that an input was made using a
+form auto-filling feature.
+
+In either case, in order to correctly reset itself your form-associated component
+will need the previously selected value, but other state may also be necessary.
+For instance, the form value to be submitted for a date picker component would
+be a specific date, but in order to correctly restore the component's visual
+state it might also be necessary to know whether the picker should display a
+week or month view.
+
+The
+[`setFormValue`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue)
+method on `ElementInternals` provides some support for this use-case, allowing
+you to submit both a _value_ and a _state_, where the _state_ is not added to
+the form data sent to the server but could be used for storing some
+client-specific state. For instance, a pseudocode sketch of a date picker
+component that correctly restores whether the 'week' or 'month' view is active
+could look like:
+
+```tsx title="src/components/fa-date-picker.tsx"
+import { Component, h, State, AttachInternals } from '@stencil/core';
+
+@Component({
+ tag: 'fa-date-picker',
+ formAssociated: true,
+})
+export class MyDatePicker {
+ @State() value: string = "";
+ @State() view: "weeks" | "months" = "weeks";
+
+ @AttachInternals()
+ internals: ElementInternals;
+
+ onInputChange(e) {
+ e.preventDefault();
+ const date = e.target.value;
+ this.setValue(date);
+ }
+
+ setValue(date: string) {
+ // second 'state' parameter is used to store both
+ // the input value (`date`) _and_ the current view
+ this.internals.setFormValue(date, `${date}#${this.view}`);
+ }
+
+ formStateRestoreCallback(state, _mode) {
+ const [date, view] = state.split("#");
+ this.view = view;
+ this.setValue(date);
+ }
+
+ render() {
+ return
+ Mock Date Picker, mode: {this.view}
+ this.onInputChange(e)}>
+
+ }
+}
+```
+
+Note that the `formStateRestoreCallback` also receives a second argument,
+`mode`, which can be either `"restore"` or `"autocomplete"`, indicating the
+reason for the form restoration.
+
+For more on form restoration, including a complete example, check out [this
+great blog post on the
+subject](https://web.dev/articles/more-capable-form-controls#restoring-form-state).
+
+## Resources
+
+- [WHATWG specification for form-associated custom elements](https://html.spec.whatwg.org/dev/custom-elements.html#form-associated-custom-elements)
+- [ElementInternals and Form-Associated Custom Elements](https://webkit.org/blog/13711/elementinternals-and-form-associated-custom-elements/) from the WebKit blog
+- [Web.dev post detailing how form-associated lifecycle callbacks work](https://web.dev/articles/more-capable-form-controls#lifecycle_callbacks)
+
diff --git a/versioned_docs/version-v4.42/components/functional-components.md b/versioned_docs/version-v4.42/components/functional-components.md
new file mode 100644
index 000000000..cd3b27af2
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/functional-components.md
@@ -0,0 +1,108 @@
+---
+title: Functional Components
+sidebar_label: Functional Components
+description: Functional Components
+slug: /functional-components
+---
+
+# Working with Functional Components
+
+Functional components are quite different to normal Stencil web components because they are a part of Stencil's JSX compiler. A functional component is basically a function that takes an object of props and turns it into JSX.
+
+```tsx
+const Hello = props =>
Hello, {props.name}!
;
+```
+
+When the JSX transpiler encounters such a component, it will take its attributes, pass them into the function as the `props` object, and replace the component with the JSX that is returned by the function.
+
+```tsx
+
+```
+
+Functional components also accept a second argument `children`.
+
+```tsx
+const Hello = (props, children) => [
+
Hello, {props.name}
,
+ children
+];
+```
+
+The JSX transpiler passes all child elements of the component as an array into the function's `children` argument.
+
+```tsx
+
+
I'm a child element.
+
+```
+
+Stencil provides a `FunctionalComponent` generic type that allows to specify an interface for the component's properties.
+
+```tsx
+// Hello.tsx
+
+import { FunctionalComponent, h } from '@stencil/core';
+
+interface HelloProps {
+ name: string;
+}
+
+export const Hello: FunctionalComponent = ({ name }) => (
+
Hello, {name}!
+);
+```
+
+## Working with children
+
+The second argument of a functional component receives the passed children, but in order to work with them, `FunctionalComponent` provides a utils object that exposes a `map()` method to transform the children, and a `forEach()` method to read them. Reading the `children` array is not recommended since the stencil compiler can rename the vNode properties in prod mode.
+
+```tsx
+export interface FunctionalUtilities {
+ forEach: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => void) => void;
+ map: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => ChildNode) => VNode[];
+}
+export interface ChildNode {
+ vtag?: string | number | Function;
+ vkey?: string | number;
+ vtext?: string;
+ vchildren?: VNode[];
+ vattrs?: any;
+ vname?: string;
+}
+```
+
+**Example:**
+
+```tsx
+export const AddClass: FunctionalComponent = (_, children, utils) => (
+ utils.map(children, child => ({
+ ...child,
+ vattrs: {
+ ...child.vattrs,
+ class: `${child.vattrs.class} add-class`
+ }
+ }
+ ))
+);
+```
+
+:::note
+When using a functional component in JSX, its name must start with a capital letter. Therefore it makes sense to export it as such.
+:::
+
+
+## Disclaimer
+
+There are a few major differences between functional components and class components. Since functional components are just syntactic sugar within JSX, they...
+
+* aren't compiled into web components,
+* don't create a DOM node,
+* don't have a Shadow DOM or scoped styles,
+* don't have lifecycle hooks,
+* are stateless.
+
+When deciding whether to use functional components, one concept to keep in mind is that often the UI of your application can be a function of its state, i. e., given the same state, it always renders the same UI. If a component has to hold state, deal with events, etc, it should probably be a class component. If a component's purpose is to simply encapsulate some markup so it can be reused across your app, it can probably be a functional component (especially if you're using a component library and thus don't need to style it).
+
+:::caution
+Stencil does not support re-exporting a functional component from a "barrel file" and dynamically rendering it in another component. This is a [known limitation](https://github.com/ionic-team/stencil/issues/5246) within Stencil. Instead, either use class components and remove the import or import the functional component directly.
+:::
\ No newline at end of file
diff --git a/versioned_docs/version-v4.42/components/host-element.md b/versioned_docs/version-v4.42/components/host-element.md
new file mode 100644
index 000000000..c391fbe35
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/host-element.md
@@ -0,0 +1,159 @@
+---
+title: Working with host elements
+sidebar_label: Host Element
+description: Working with host elements
+slug: /host-element
+---
+
+# Working with host elements
+
+Stencil components render their children declaratively in their `render` method [using JSX](./templating-and-jsx.md). Most of the time, the `render()` function describes the children elements that are about to be rendered, but it can also be used to render attributes of the host element itself.
+
+
+## ``
+
+The `Host` functional component can be used at the root of the render function to set attributes and event listeners to the host element itself. This works just like any other JSX:
+
+```tsx
+// Host is imported from '@stencil/core'
+import { Component, Host, h } from '@stencil/core';
+
+@Component({tag: 'todo-list'})
+export class TodoList {
+ @Prop() open = false;
+ render() {
+ return (
+
+ )
+ }
+}
+```
+
+If `this.open === true`, it will render:
+```tsx
+
+```
+
+similarly, if `this.open === false`:
+
+```tsx
+
+```
+
+`` is a virtual component, a virtual API exposed by stencil to declaratively set the attributes of the host element, it will never be rendered in the DOM, i.e. you will never see `` in Chrome Dev Tools for instance.
+
+
+### `` can work as a ``
+
+`` can also be used when more than one component needs to be rendered at the root level for example:
+
+It could be achieved by a `render()` method like this:
+
+```tsx
+@Component({tag: 'my-cmp'})
+export class MyCmp {
+ render() {
+ return (
+
+
Title
+
Message
+
+ );
+ }
+}
+```
+
+This JSX would render the following HTML:
+
+```markup
+
+
Title
+
Message
+
+```
+
+Even if we don't use `` to render any attribute in the host element, it's a useful API to render many elements at the root level.
+
+## Element Decorator
+
+The `@Element()` decorator is how to get access to the host element within the class instance. This returns an instance of an `HTMLElement`, so standard DOM methods/events can be used here.
+
+```tsx
+import { Element } from '@stencil/core';
+
+...
+export class TodoList {
+
+ @Element() el: HTMLElement;
+
+ getListHeight(): number {
+ return this.el.getBoundingClientRect().height;
+ }
+}
+```
+
+In order to reference the host element when initializing a class member you'll need to use TypeScript's definite assignment assertion modifier to avoid a
+type error:
+
+```tsx
+import { Element } from '@stencil/core';
+
+...
+export class TodoList {
+
+ @Element() el!: HTMLElement;
+
+ private listHeight = this.el.getBoundingClientRect().height;
+}
+```
+
+If you need to update the host element in response to prop or state changes, you should do so in the `render()` method using the `` element.
+
+## Styling
+
+See full information about styling on the [Styling page](./styling.md#shadow-dom-in-stencil).
+
+CSS can be applied to the `` element by using its component tag defined in the `@Component` decorator.
+
+```tsx
+@Component({
+ tag: 'my-cmp',
+ styleUrl: 'my-cmp.css'
+})
+...
+```
+
+my-cmp.css:
+
+```css
+my-cmp {
+ width: 100px;
+}
+```
+
+### Shadow DOM
+
+Something to beware of is that Styling the `` element when using shadow DOM does not work quite the same. Instead of using the `my-cmp` element selector you must use `:host`.
+
+```tsx
+@Component({
+ tag: 'my-cmp',
+ styleUrl: 'my-cmp.css',
+ shadow: true
+})
+...
+```
+
+my-cmp.css:
+
+```css
+:host {
+ width: 100px;
+}
+```
diff --git a/versioned_docs/version-v4.42/components/methods.md b/versioned_docs/version-v4.42/components/methods.md
new file mode 100644
index 000000000..931839b91
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/methods.md
@@ -0,0 +1,98 @@
+---
+title: Methods
+sidebar_label: Methods
+description: methods
+slug: /methods
+---
+
+# Method Decorator
+
+The `@Method()` decorator is used to expose methods on the public API. Functions decorated with the `@Method()` decorator can be called directly from the element, i.e. they are intended to be callable from the outside!
+
+:::note
+Developers should try to rely on publicly exposed methods as little as possible, and instead default to using properties and events as much as possible. As an app scales, we've found it's easier to manage and pass data through @Prop rather than public methods.
+:::
+
+```tsx
+import { Method } from '@stencil/core';
+
+export class TodoList {
+
+ @Method()
+ async showPrompt() {
+ // show a prompt
+ }
+}
+```
+
+Call the method like this:
+
+:::note
+Developers should ensure that the component is defined by using the whenDefined method of the custom element registry before attempting to call public methods.
+:::
+
+```tsx
+(async () => {
+ await customElements.whenDefined('todo-list');
+ const todoListElement = document.querySelector('todo-list');
+ await todoListElement.showPrompt();
+})();
+```
+
+## Public methods must be async
+
+Stencil's architecture is async at all levels which allows for many performance benefits and ease of use. By ensuring publicly exposed methods using the `@Method` decorator return a promise:
+
+- Developers can call methods before the implementation was downloaded without componentOnReady(), which queues the method calls and resolves after the component has finished loading.
+
+- Interaction with the component is the same whether it still needs to be lazy-loaded, or is already fully hydrated.
+
+- By keeping a component's public API async, apps could move the components transparently to [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the API would still be the same.
+
+- Returning a promise is only required for publicly exposed methods which have the `@Method` decorator. All other component methods are private to the component and are not required to be async.
+
+
+```tsx
+// VALID: using async
+@Method()
+async myMethod() {
+ return 42;
+}
+
+// VALID: using Promise.resolve()
+@Method()
+myMethod2() {
+ return Promise.resolve(42);
+}
+
+// VALID: even if it returns nothing, it needs to be async
+@Method()
+async myMethod3() {
+ console.log(42);
+}
+
+// INVALID
+@Method()
+notOk() {
+ return 42;
+}
+```
+
+## Private methods
+
+Non-public methods can still be used to organize the business logic of your component and they do NOT have to return a Promise.
+
+```tsx
+class Component {
+ // Since `getData` is not a public method exposed with @Method
+ // it does not need to be async
+ getData() {
+ return this.someData;
+ }
+ render() {
+ return (
+
{this.getData()}
+ );
+ }
+}
+```
diff --git a/versioned_docs/version-v4.42/components/properties.md b/versioned_docs/version-v4.42/components/properties.md
new file mode 100644
index 000000000..72ffab61a
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/properties.md
@@ -0,0 +1,1020 @@
+---
+title: Properties
+sidebar_label: Properties
+description: Properties
+slug: /properties
+---
+
+# Properties
+
+Props are custom attributes/properties exposed publicly on an HTML element. They allow developers to pass data to a
+component to render or otherwise use.
+
+## The Prop Decorator (`@Prop()`)
+
+Props are declared on a component using Stencil's `@Prop()` decorator, like so:
+
+```tsx
+// First, we import Prop from '@stencil/core'
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+})
+export class TodoList {
+ // Second, we decorate a class member with @Prop()
+ @Prop() name: string;
+
+ render() {
+ // Within the component's class, its props are
+ // accessed via `this`. This allows us to render
+ // the value passed to `todo-list`
+ return
To-Do List Name: {this.name}
+ }
+}
+```
+
+In the example above, `@Prop()` is placed before (decorates) the `name` class member, which is a string. By adding
+`@Prop()` to `name`, Stencil will expose `name` as an attribute on the element, which can be set wherever the component
+is used:
+
+```tsx
+{/* Here we use the component in a TSX file */}
+
+```
+```html
+
+
+```
+
+In the example above the `todo-list` component is used almost identically in TSX and HTML. The only difference between
+the two is that in TSX, the value assigned to a prop (in this case, `name`) is wrapped in curly braces. In some cases
+however, the way props are passed to a component differs slightly between HTML and TSX.
+
+## Variable Casing
+
+In the JavaScript ecosystem, it's common to use 'camelCase' when naming variables. The example component below has a
+class member, `thingToDo` that is camelCased.
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ // thingToDo is 'camelCased'
+ @Prop() thingToDo: string;
+
+ render() {
+ return
{this.thingToDo}
;
+ }
+}
+```
+
+Since `thingToDo` is a prop, we can provide a value for it when we use our `todo-list-item` component. Providing a
+value to a camelCased prop like `thingToDo` is nearly identical in TSX and HTML.
+
+When we use our component in a TSX file, an attribute uses camelCase:
+
+```tsx
+
+```
+
+In HTML, the attribute must use 'dash-case' like so:
+
+```html
+
+```
+
+## Data Flow
+
+Props should be used to pass data down from a parent component to its child component(s).
+
+The example below shows how a `todo-list` component uses three `todo-list-item` child components to render a ToDo list.
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list',
+})
+export class TodoList {
+ render() {
+ return (
+
+
To-Do List Name: Stencil To Do List
+
+ {/* Below are three Stencil components that are children of `todo-list`, each representing an item on our list */}
+
+
+
+
;
+ }
+}
+```
+
+:::note
+Children components should not know about or reference their parent components. This allows Stencil to
+efficiently re-render your components. Passing a reference to a component as a prop may cause unintended side effects.
+:::
+
+## Mutability
+
+A Prop is by default immutable from inside the component logic. Once a value is set by a user, the component cannot
+update it internally. For more advanced control over the mutability of a prop, please see the
+[mutable option](#prop-mutability-mutable) section of this document.
+
+## Types
+
+Props can be a `boolean`, `number`, `string`, or even an `Object` or `Array`. The example below expands the
+`todo-list-item` to add a few more props with different types.
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+// `MyHttpService` is an `Object` in this example
+import { MyHttpService } from '../some/local/directory/MyHttpService';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() isComplete: boolean;
+ @Prop() timesCompletedInPast: number;
+ @Prop() thingToDo: string;
+ @Prop() myHttpService: MyHttpService;
+}
+```
+
+### Boolean Props
+
+A property on a Stencil component that has a type of `boolean` may be declared as:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() isComplete: boolean;
+}
+```
+
+To use this version of `todo-list-item` in HTML, we pass the string `"true"`/`"false"` to the component:
+```html
+
+
+
+
+```
+
+To use this version of `todo-list-item` in TSX, `true`/`false` is used, surrounded by curly braces:
+```tsx
+// Set isComplete to 'true'
+
+// Set isComplete to 'false'
+
+```
+
+There are a few ways in which Stencil treats props that are of type `boolean` that are worth noting:
+
+1. The value of a boolean prop will be `false` if provided the string `"false"` in HTML
+
+```html
+
+
+```
+2. The value of a boolean prop will be `true` if provided a string that is not `"false"` in HTML
+
+```html
+
+
+
+
+
+```
+3. The value of a boolean prop will be `undefined` if it has no [default value](#default-values) and one of
+the following applies:
+ 1. the prop is not included when using the component
+ 2. the prop is included when using the component, but is not given a value
+
+```html
+
+
+
+
+```
+
+### Number Props
+
+A property on a Stencil component that has a type of `number` may be declared as:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() timesCompletedInPast: number;
+}
+```
+
+To use this version of `todo-list-item` in HTML, we pass the numeric value as a string to the component:
+```html
+
+
+
+
+```
+
+To use this version of `todo-list-item` in TSX, a number surrounded by curly braces is passed to the component:
+```tsx
+// Set timesCompletedInPast to '0'
+
+// Set timesCompletedInPast to '23'
+
+```
+
+### String Props
+
+A property on a Stencil component that has a type of `string` may be declared as:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() thingToDo: string;
+}
+```
+
+To use this version of `todo-list-item` in HTML, we pass the value as a string to the component:
+```html
+
+
+
+
+```
+
+To use this version of `todo-list-item` in TSX, we pass the value as a string to the component. Curly braces aren't
+required when providing string values to props in TSX, but are permitted:
+```tsx
+// Set thingToDo to 'Learn about Stencil Props'
+
+// Set thingToDo to 'Write some Stencil Code with Props'
+
+// Set thingToDo to 'Write some Stencil Code with Props' with curly braces
+
+```
+
+### Object Props
+
+A property on a Stencil component that has a type of `Object` may be declared as:
+
+```tsx
+// TodoListItem.tsx
+import { Component, Prop, h } from '@stencil/core';
+import { MyHttpService } from '../path/to/MyHttpService';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ // Use `@Prop()` to declare the `httpService` class member
+ @Prop() httpService: MyHttpService;
+}
+```
+```tsx
+// MyHttpService.ts
+export class MyHttpService {
+ // This implementation intentionally left blank
+}
+```
+
+In TypeScript, `MyHttpService` is both an `Object` and a 'type'. When using user-defined types like `MyHttpService`, the
+type must always be exported using the `export` keyword where it is declared. The reason for this is Stencil needs to
+know what type the prop `httpService` is when passing an instance of `MyHttpService` to `TodoListItem` from a parent
+component.
+
+To set `httpService` in TSX, assign the property name in the custom element's tag to the desired value like so:
+```tsx
+// TodoList.tsx
+import { Component, h } from '@stencil/core';
+import { MyHttpService } from '../MyHttpService';
+
+@Component({
+ tag: 'todo-list',
+ styleUrl: 'todo-list.css',
+ shadow: true,
+})
+export class ToDoList {
+ private httpService = new MyHttpService();
+
+ render() {
+ return ;
+ }
+}
+```
+Note that the prop name is using `camelCase`, and the value is surrounded by curly braces.
+
+It is not possible to set `Object` props via an HTML attribute like so:
+```html
+
+
+```
+The reason for this is that Stencil will not attempt to serialize object-like strings written in HTML into a JavaScript object.
+Similarly, Stencil does not have any support for deserializing objects from JSON.
+Doing either can be expensive at runtime, and runs the risk of losing references to other nested JavaScript objects.
+
+Instead, properties may be set via `
+```
+
+
+### Array Props
+
+A property on a Stencil component that is an Array may be declared as:
+
+```tsx
+// TodoList.tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() itemLabels: string[];
+}
+```
+
+To set `itemLabels` in TSX, assign the prop name in the custom element's tag to the desired value like so:
+```tsx
+// TodoList.tsx
+import { Component, h } from '@stencil/core';
+import { MyHttpService } from '../MyHttpService';
+
+@Component({
+ tag: 'todo-list',
+ styleUrl: 'todo-list.css',
+ shadow: true,
+})
+export class ToDoList {
+ private labels = ['non-urgent', 'weekend-only'];
+
+ render() {
+ return ;
+ }
+}
+```
+Note that the prop name is using `camelCase`, and the value is surrounded by curly braces.
+
+It is not possible to set `Array` props via an HTML attribute like so:
+```html
+
+
+```
+The reason for this is that Stencil will not attempt to serialize array-like strings written in HTML into a JavaScript object.
+Doing so can be expensive at runtime, and runs the risk of losing references to other nested JavaScript objects.
+
+Instead, properties may be set via `
+```
+
+### Advanced Prop Types
+
+#### `any` Type
+
+TypeScript's [`any` type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any) is a special type
+that may be used to prevent type checking of a specific value. Because `any` is a valid type in TypeScript, Stencil
+props can also be given a type of `any`. The example below demonstrates three different ways of using props with type
+`any`:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ // isComplete has an explicit type annotation
+ // of `any`, and no default value
+ @Prop() isComplete: any;
+ // label has an explicit type annotation of
+ // `any` with a default value of 'urgent',
+ // which is a string
+ @Prop() label: any = 'urgent';
+ // thingToDo has no type and no default value,
+ // and will be considered to be type `any` by
+ // TypeScript
+ @Prop() thingToDo;
+
+ render() {
+ return (
+
+
isComplete has a value of - {this.isComplete} - and a typeof value of "{typeof this.isComplete}"
+
label has a value of - {this.label} - and a typeof value of "{typeof this.label}"
+
thingToDo has a value of - {this.thingToDo} - and a typeof value of "{typeof this.thingToDo}"
+
+ );
+ }
+}
+```
+
+When using a Stencil prop typed as `any` (implicitly or explicitly), the value that is provided to a prop retains its
+own type information. Neither Stencil nor TypeScript will try to change the type of the prop. To demonstrate, let's use
+`todo-list-item` twice, each with different prop values:
+
+```tsx
+{/* Using todo-list-item in TSX using differnt values each time */}
+
+
+```
+
+The following will be rendered from the usage example above:
+```md
+- isComplete has a value of - 42 - and a typeof value of "number"
+- label has a value of - - and a typeof value of "object"
+- thingToDo has a value of - Learn about any-typed props - and a typeof value of "string"
+
+- isComplete has a value of - 42 - and a typeof value of "string"
+- label has a value of - 1 - and a typeof value of "number"
+- thingToDo has a value of - Learn about any-typed props - and a typeof value of "string"
+```
+
+In the first usage of `todo-list-item`, `isComplete` is provided a number value of 42, whereas in the second usage it
+receives a string containing "42". The types on `isComplete` reflect the type of the value it was provided, 'number' and
+'string', respectively.
+
+Looking at `label`, it is worth noting that although the prop has a [default value](#default-values), it does
+not narrow the type of `label` to be of type 'string'. In the first usage of `todo-list-item`, `label` is provided a
+value of null, whereas in the second usage it receives a number value of 1. The types of the values stored in `label`
+are correctly reported as 'object' and 'number', respectively.
+
+#### Optional Types
+
+TypeScript allows members to be marked optional by appending a `?` at the end of the member's name. The example below
+demonstrates making each a component's props optional:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ // completeMsg is optional, has an explicit type
+ // annotation of `string`, and no default value
+ @Prop() completeMsg?: string;
+ // label is optional, has no explicit type
+ // annotation, but does have a default value
+ // of 'urgent'
+ @Prop() label? = 'urgent';
+ // thingToDo has no type annotation and no
+ // default value
+ @Prop() thingToDo?;
+
+ render() {
+ return (
+
+
completeMsg has a value of - {this.completeMsg} - and a typeof value of "{typeof this.completeMsg}"
+
label has a value of - {this.label} - and a typeof value of "{typeof this.label}"
+
thingToDo has a value of - {this.thingToDo} - and a typeof value of "{typeof this.thingToDo}"
+
+ );
+ }
+}
+```
+
+When using a Stencil prop that is marked as optional, Stencil will try to infer the type of the prop if a type is
+not explicitly given. In the example above, Stencil is able to understand that:
+
+- `completeMsg` is of type string, because it has an explicit type annotation
+- `label` is of type string, because it has a [default value](#default-values) that is of type string
+- `thingToDo` [is of type `any`](#any-type), because it has no explicit type annotation, nor default value
+
+Because Stencil can infer the type of `label`, the following will fail to compile due to a type mismatch:
+
+```tsx
+{/* This fails to compile with the error "Type 'number' is not assignable to type 'string'" for the label prop. */}
+
+```
+
+It is worth noting that when using a component in an HTML file, such type checking is unavailable. This is a constraint
+on HTML, where all values provided to attributes are of type string:
+
+```html
+
+
+```
+renders:
+```md
+- completeMsg has a value of - 42 - and a typeof value of "string"
+- label has a value of - null - and a typeof value of "string"
+- thingToDo has a value of - Learn about any-typed props - and a typeof value of "string"
+```
+
+#### Union Types
+
+Stencil allows props types be [union types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types),
+which allows you as the developer to combine two or more pre-existing types to create a new one. The example below shows
+a `todo-list-item` who accepts a `isComplete` prop that can be either a string or boolean.
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() isComplete: string | boolean;
+}
+```
+
+This component can be used in both HTML:
+```html
+
+
+
+
+```
+and TSX:
+```tsx
+
+
+```
+
+When using union types, the type of a component's `@Prop()` value can be ambiguous at runtime.
+In the provided example, under what circumstances does `@Prop() isComplete` function as a `string`, and when does it serve as a `boolean`?
+
+When using a component in HTML, the runtime value of a `@Prop()` is a string whenever an attribute is set.
+This is a result of setting the HTML attribute for the custom element.
+```html
+
+
+
+
+
+
+
+
+```
+However, if an attribute is not specified, the runtime value of the property will be `undefined`:
+```html
+
+
+```
+
+When the attribute on a component is set using `setAttribute`, the runtime value of a `@Prop()` is always [coerced to a string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion).
+```html
+
+```
+
+However, if the property of a custom element is directly changed, its type will match the value that was provided.
+```html
+
+```
+
+When using a component in TSX, a `@Prop()`'s type will match the value that was provided.
+```tsx
+// Since this is TSX, the value of `isComplete` in `ToDoListItem`
+// depends on the type of the value passed to the component.
+//
+// Set the property `isComplete` to `true` (boolean)
+
+// Set the property `isComplete` to "true" (string)
+
+// Set the property `isComplete` to `false` (boolean)
+
+// Set the property `isComplete` to "false" (string)
+
+```
+
+## Default Values
+
+Stencil props can be given a default value as a fallback in the event a prop is not provided:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'component-with-some-props',
+})
+export class ComponentWithSomeProps {
+ @Prop() aNumber = 42;
+ @Prop() aString = 'defaultValue';
+
+ render() {
+ return
The number is {this.aNumber} and the string is {this.aString}
+ }
+}
+```
+Regardless of if we use this component in HTML or TSX, "The number is 42 and the string is defaultValue" is displayed
+when no values are passed to our component:
+```html
+
+```
+
+The default values on a component can be overridden by specifying a value for a prop with a default value. For the
+example below, "The number is 7 and the string is defaultValue" is rendered. Note how the value provided to `aNumber`
+overrides the default value, but the default value of `aString` remains the same:
+```html
+
+```
+
+### Inferring Types from Default Values
+
+When a default value is provided, Stencil is able to infer the type of the prop from the default value:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+@Component({
+ tag: 'component-with-many-props',
+})
+export class ComponentWithManyProps {
+ // both props below are of type 'boolean'
+ @Prop() boolean1: boolean;
+ @Prop() boolean2 = true;
+
+ // both props below are of type 'number'
+ @Prop() number1: number;
+ @Prop() number2 = 42;
+
+ // both props below are of type 'string'
+ @Prop() string1: string;
+ @Prop() string2 = 'defaultValue';
+}
+```
+
+## Required Properties
+
+By placing a `!` after a prop name, Stencil mark that the attribute/property as required. This ensures that when the
+component is used in TSX, the property is used:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ // Note the '!' after the variable name.
+ @Prop() thingToDo!: string;
+}
+```
+
+## Prop Validation
+
+To do validation of a Prop, you can use the [@Watch()](./reactive-data.md#the-watch-decorator-watch) decorator:
+
+```tsx
+import { Component, Prop, Watch, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class TodoList {
+ // Mark the prop as required, to make sure it is provided when we use `todo-list-item`.
+ // We want stricter guarantees around the contents of the string, so we'll use `@Watch` to perform additional validation.
+ @Prop() thingToDo!: string;
+
+ @Watch('thingToDo')
+ validateName(newValue: string, _oldValue: string) {
+ // don't allow `thingToDo` to be the empty string
+ const isBlank = typeof newValue !== 'string' || newValue === '';
+ if (isBlank) {
+ throw new Error('thingToDo is a required property and cannot be empty')
+ };
+ // don't allow `thingToDo` to be a string with a length of 1
+ const has2chars = typeof newValue === 'string' && newValue.length >= 2;
+ if (!has2chars) {
+ throw new Error('thingToDo must have a length of more than 1 character')
+ };
+ }
+}
+```
+
+Alternatively, you could do validation within a setter. [Read about using `get()` / `set()` methods with decorated props](#prop-getters-and-setters)
+
+## @Prop() Options
+
+The `@Prop()` decorator accepts an optional argument to specify certain options to modify how a prop on a component
+behaves. `@Prop()`'s optional argument is an object literal containing one or more of the following fields:
+
+```tsx
+export interface PropOptions {
+ attribute?: string;
+ mutable?: boolean;
+ reflect?: boolean;
+}
+```
+
+### Attribute Name (`attribute`)
+
+Properties and component attributes are strongly connected but not necessarily the same thing. While attributes are an
+HTML concept, properties are a JavaScript concept inherent to Object-Oriented Programming.
+
+In Stencil, the `@Prop()` decorator applied to a **property** will instruct the Stencil compiler to also listen for
+changes in a DOM attribute.
+
+Usually, the name of a property is the same as the attribute, but this is not always the case. Take the following
+component as example:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+// `MyHttpService` is an `Object` in this example
+import { MyHttpService } from '../some/local/directory/MyHttpService';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop() isComplete: boolean;
+ @Prop() thingToDo: string;
+ @Prop() httpService: MyHttpService;
+}
+```
+
+This component has **3 properties**, but the compiler will create **only 2 attributes**: `is-complete` and
+`thing-to-do`.
+
+```html
+
+```
+
+Notice that the `httpService` type is not a primitive (e.g. not a `number`, `boolean`, or `string`). Since DOM
+attributes can only be strings, it does not make sense to have an associated DOM attribute called `"http-service"`.
+Stencil will not attempt to serialize object-like strings written in HTML into a JavaScript object.
+See [Object Props](#object-props) for guidance as to how to configure `httpService`.
+
+At the same time, the `isComplete` & `thingToDo` properties follow 'camelCase' naming, but attributes are
+case-insensitive, so the attribute names will be `is-complete` & `thing-to-do` by default.
+
+Fortunately, this "default" behavior can be changed using the `attribute` option of the `@Prop()` decorator:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+// `MyHttpService` is an `Object` in this example
+import { MyHttpService } from '../some/local/directory/MyHttpService';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop({ attribute: 'complete' }) isComplete: boolean;
+ @Prop({ attribute: 'thing' }) thingToDo: string;
+ @Prop({ attribute: 'my-service' }) httpService: MyHttpService;
+}
+```
+
+By using this option, we are being explicit about which properties have an associated DOM attribute and the name of it
+when using the component in HTML.
+
+```html
+
+```
+
+### Prop Mutability (`mutable`)
+
+A Prop is by default immutable from inside the component logic.
+However, it's possible to explicitly allow a Prop to be mutated from inside the component, by declaring it as mutable, as in the example below:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop({ mutable: true }) thingToDo: string;
+
+ componentDidLoad() {
+ this.thingToDo = 'Ah! A new value!';
+ }
+}
+```
+
+#### Mutable Arrays and Objects
+
+Stencil compares Props by reference in order to efficiently rerender components.
+Setting `mutable: true` on a Prop that is an object or array allows the _reference_ to the Prop to change inside the component and trigger a render.
+It does not allow a mutable change to an existing object or array to trigger a render.
+
+For example, to update an array Prop:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'my-component',
+})
+export class MyComponent {
+ @Prop({mutable: true}) contents: string[] = [];
+ timer: NodeJS.Timer;
+
+ connectedCallback() {
+ this.timer = setTimeout(() => {
+ // this does not create a new array. when stencil
+ // attempts to see if any of its Props have changed,
+ // it sees the reference to its `contents` Prop is
+ // the same, and will not trigger a render
+
+ // this.contents.push('Stencil')
+
+ // this does create a new array, and therefore a
+ // new reference to the Prop. Stencil will pick up
+ // this change and rerender
+ this.contents = [...this.contents, 'Stencil'];
+ // after 3 seconds, the component will re-render due
+ // to the reference change in `this.contents`
+ }, 3000);
+ }
+
+ disconnectedCallback() {
+ if (this.timer) {
+ clearTimeout(this.timer);
+ }
+ }
+
+ render() {
+ return
Hello, World! I'm {this.contents[0]}
;
+ }
+}
+```
+
+In the example above, updating the Prop in place using `this.contents.push('Stencil')` would have no effect.
+Stencil does not see the change to `this.contents`, since it looks at the _reference_ of the Prop, and sees that it has not changed.
+This is done for performance reasons.
+If Stencil had to walk every slot of the array to determine if it changed, it would incur a performance hit.
+Rather, it is considered better for performance and more idiomatic to re-assign the Prop (in the example above, we use the spread operator).
+
+The same holds for objects as well.
+Rather than mutating an existing object in-place, a new object should be created using the spread operator. This object will be different-by-reference and therefore will trigger a re-render:
+
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+export type MyContents = {name: string};
+
+@Component({
+ tag: 'my-component',
+})
+export class MyComponent {
+ @Prop({mutable: true}) contents: MyContents;
+ timer: NodeJS.Timer;
+
+ connectedCallback() {
+ this.timer = setTimeout(() => {
+ // this does not create a new object. when stencil
+ // attempts to see if any of its Props have changed,
+ // it sees the reference to its `contents` Prop is
+ // the same, and will not trigger a render
+
+ // this.contents.name = 'Stencil';
+
+ // this does create a new object, and therefore a
+ // new reference to the Prop. Stencil will pick up
+ // this change and rerender
+ this.contents = {...this.contents, name: 'Stencil'};
+ // after 3 seconds, the component will re-render due
+ // to the reference change in `this.contents`
+ }, 3000);
+ }
+
+ disconnectedCallback() {
+ if (this.timer) {
+ clearTimeout(this.timer);
+ }
+ }
+
+ render() {
+ return
Hello, World! I'm {this.contents.name}
;
+ }
+}
+```
+
+### Reflect Properties Values to Attributes (`reflect`)
+
+In some cases it may be useful to keep a Prop in sync with an attribute. In this case you can set the `reflect` option
+in the `@Prop()` decorator to `true`. When a prop is reflected, it will be rendered in the DOM as an HTML attribute.
+
+Take the following component as example:
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'todo-list-item',
+})
+export class ToDoListItem {
+ @Prop({ reflect: false }) isComplete: boolean = false;
+ @Prop({ reflect: true }) timesCompletedInPast: number = 2;
+ @Prop({ reflect: true }) thingToDo: string = "Read Reflect Section of Stencil Docs";
+}
+```
+
+The component in the example above uses [default values](#default-values), and can be used in HTML like so:
+```html
+
+
+```
+
+When rendered in the DOM, the properties configured with `reflect: true` will be reflected in the DOM:
+
+```html
+
+```
+
+While the properties not set to "reflect", such as `isComplete`, are not rendered as attributes, it does not mean it's
+not there - the `isComplete` property still contains the `false` value as assigned:
+
+```tsx
+const cmp = document.querySelector('todo-list-item');
+console.log(cmp.isComplete); // it prints 'false'
+```
+
+### Prop Getters and Setters
+
+`@Prop` decorated members can additionally be used with `get()` and `set()` methods which can be useful for validation
+([as an alternative to using a @Watch decorator](#prop-validation)), transforming incoming-data or exposing read-only properties.
+
+```tsx
+import { Component, Prop, h } from '@stencil/core';
+
+@Component({
+ tag: 'get-set-props',
+})
+export class GetSetProps {
+ // A read-only prop
+ private internalValue = 'should not change';
+ @Prop()
+ get readOnlyProp () { return this.internalValue; }
+
+ // A validated prop
+ private safeValue: 'this' | 'or maybe this' = 'this';
+ @Prop()
+ get validatedProp () {
+ return this.safeValue;
+ }
+ set validatedProp (incomingDodgyValue: any) {
+ if (['this', 'or maybe this'].includes(incomingDodgyValue)) {
+ this.safeValue = incomingDodgyValue;
+ }
+ }
+
+ private dateValue: Date = new Date();
+ // A transformed prop
+ @Prop()
+ get transformedProp () {
+ return this.dateValue;
+ }
+ set transformedProp (incomingStringVal: string) {
+ this.dateValue = new Date(Date.parse(incomingStringVal));
+ }
+}
+```
+
+Most of the documentation referring to [types](#types) and [options](#prop-options) also apply to get / set `@Prop`s
+(with the exception of [mutable](#prop-mutability-mutable) as this makes little logical sense).
diff --git a/versioned_docs/version-v4.42/components/reactive-data.md b/versioned_docs/version-v4.42/components/reactive-data.md
new file mode 100644
index 000000000..a973e244d
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/reactive-data.md
@@ -0,0 +1,255 @@
+---
+title: Reactive Data, Handling arrays and objects
+sidebar_label: Reactive Data
+description: Reactive Data, Handling arrays and objects
+slug: /reactive-data
+---
+
+# Reactive Data
+
+Stencil components update when props or state on a component change.
+
+## Rendering methods
+
+When props or state change on a component, the [`render()` method](./templating-and-jsx.md) is scheduled to run.
+
+## The Watch Decorator (`@Watch()`)
+
+`@Watch()` is a decorator that is applied to a method of a Stencil component.
+The decorator's first required argument is the name of a class member that is decorated with `@Prop()` or `@State()`, or
+a host attribute. A method decorated with `@Watch()` will automatically run when its associated class member or attribute changes.
+
+```tsx
+// We import Prop & State to show how `@Watch()` can be used on
+// class members decorated with either `@Prop()` or `@State()`
+import { Component, Prop, State, Watch } from '@stencil/core';
+
+@Component({
+ tag: 'loading-indicator'
+})
+export class LoadingIndicator {
+ // We decorate a class member with @Prop() so that we
+ // can apply @Watch()
+ @Prop() activated: boolean;
+ // We decorate a class member with @State() so that we
+ // can apply @Watch()
+ @State() busy: boolean;
+
+ // Apply @Watch() for the component's `activated` member.
+ // Whenever `activated` changes, this method will fire.
+ @Watch('activated')
+ watchPropHandler(newValue: boolean, oldValue: boolean) {
+ console.log('The old value of activated is: ', oldValue);
+ console.log('The new value of activated is: ', newValue);
+ }
+
+ // Apply @Watch() for the component's `busy` member.
+ // Whenever `busy` changes, this method will fire.
+ @Watch('busy')
+ watchStateHandler(newValue: boolean, oldValue: boolean) {
+ console.log('The old value of busy is: ', oldValue);
+ console.log('The new value of busy is: ', newValue);
+ }
+
+ @Watch('activated')
+ @Watch('busy', {immediate: true})
+ watchMultiple(newValue: boolean, oldValue: boolean, propName:string) {
+ console.log(`The new value of ${propName} is: `, newValue);
+ }
+}
+```
+
+In the example above, there are four `@Watch()` decorators:
+- The first decorates `watchPropHandler`, which will fire when the class member `activated` changes.
+- The second decorates `watchStateHandler`, which will fire when the class member `busy` changes.
+- The third and fourth decorators both decorate `watchMultiple`, which will fire when either `activated` or `busy` change.
+
+Passing `{immediate: true}` as the second argument to `@Watch()` causes the decorated
+method to fire when the component initially loads, in addition to when the watched member changes.
+
+When fired, the decorated method will receive the old and new values of the prop/state.
+This is useful for validation or the handling of side effects.
+
+:::info
+By default, the `@Watch()` decorator does not fire when a component initially loads.
+Use `@Watch('propName', {immediate: true})` to have the decorated method fire when the component first loads.
+`immediate` watchers will be invoked before the component's first render, so be careful when trying to access DOM elements
+that may not yet be available.
+:::
+
+### Watching Native HTML Attributes
+
+Stencil's `@Watch()` decorator also allows you to watch native HTML attributes on the constructed host element. Simply
+include the attribute name as the argument to the decorator (this is case-sensitive):
+
+```tsx
+@Watch('aria-label')
+onAriaLabelChange(newVal: string, oldVal: string) {
+ console.log('Label changed:', newVal, oldVal);
+}
+```
+
+:::note
+Since native attributes are not `@Prop()` or `State()` members of the Stencil component, they will not automatically trigger a
+re-render when changed. If you wish to re-render a component in this instance, you can leverage the `forceUpdate()` method:
+
+```tsx
+import { Component, forceUpdate, h } from '@stencil/core';
+
+@Watch('aria-label')
+onAriaLabelChange() {
+ forceUpdate(this); // Forces a re-render
+}
+```
+:::
+
+## Handling Arrays and Objects
+
+When Stencil checks if a class member decorated with `@Prop()` or `@State()` has changed, it checks if the reference to the class member has changed.
+When a class member is an object or array, and is marked with `@Prop()` or `@State`, in-place mutation of an existing entity will _not_ cause `@Watch()` to fire, as it does not change the _reference_ to the class member.
+
+### Updating Arrays
+
+For arrays, the standard mutable array operations such as `push()` and `unshift()` won't trigger a component update.
+These functions will change the content of the array, but won't change the reference to the array itself.
+
+In order to make changes to an array, non-mutable array operators should be used.
+Non-mutable array operators return a copy of a new array that can be detected in a performant manner.
+These include `map()` and `filter()`, and the [spread operator syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).
+The value returned by `map()`, `filter()`, etc., should be assigned to the `@Prop()` or `@State()` class member being watched.
+
+For example, to push a new item to an array, create a new array with the existing values and the new value at the end:
+
+```tsx
+import { Component, State, Watch, h } from '@stencil/core';
+
+@Component({
+ tag: 'rand-numbers'
+})
+export class RandomNumbers {
+ // We decorate a class member with @State() so that we
+ // can apply @Watch(). This will hold a list of randomly
+ // generated numbers
+ @State() randNumbers: number[] = [];
+
+ private timer: NodeJS.Timer;
+
+ // Apply @Watch() for the component's `randNumbers` member.
+ // Whenever `randNumbers` changes, this method will fire.
+ @Watch('randNumbers')
+ watchStateHandler(newValue: number[], oldValue: number[]) {
+ console.log('The old value of randNumbers is: ', oldValue);
+ console.log('The new value of randNumbers is: ', newValue);
+ }
+
+ connectedCallback() {
+ this.timer = setInterval(() => {
+ // generate a random whole number
+ const newVal = Math.ceil(Math.random() * 100);
+
+ /**
+ * This does not create a new array. When stencil
+ * attempts to see if any Watched members have changed,
+ * it sees the reference to its `randNumbers` State is
+ * the same, and will not trigger `@Watch` or a re-render
+ */
+ // this.randNumbers.push(newVal)
+
+ /**
+ * Using the spread operator, on the other hand, does
+ * create a new array. `randNumbers` is reassigned
+ * using the value returned by the spread operator.
+ * The reference to `randNumbers` has changed, which
+ * will trigger `@Watch` and a re-render
+ */
+ this.randNumbers = [...this.randNumbers, newVal]
+ }, 1000)
+ }
+
+ disconnectedCallback() {
+ if (this.timer) {
+ clearInterval(this.timer)
+ }
+ }
+
+ render() {
+ return(
+
+ )
+ }
+}
+```
+
+### Updating an object
+
+The spread operator should be used to update objects.
+As with arrays, mutating an object will not trigger a view update in Stencil.
+However, using the spread operator and assigning its return value to the `@Prop()` or `@State()` class member being watched will.
+Below is an example:
+
+```tsx
+import { Component, State, Watch, h } from '@stencil/core';
+
+export type NumberContainer = {
+ val: number,
+}
+
+@Component({
+ tag: 'rand-numbers'
+})
+export class RandomNumbers {
+ // We decorate a class member with @State() so that we
+ // can apply @Watch(). This will hold a randomly generated
+ // number.
+ @State() numberContainer: NumberContainer = { val: 0 };
+
+ private timer: NodeJS.Timer;
+
+ // Apply @Watch() for the component's `numberContainer` member.
+ // Whenever `numberContainer` changes, this method will fire.
+ @Watch('numberContainer')
+ watchStateHandler(newValue: NumberContainer, oldValue: NumberContainer) {
+ console.log('The old value of numberContainer is: ', oldValue);
+ console.log('The new value of numberContainer is: ', newValue);
+ }
+
+ connectedCallback() {
+ this.timer = setInterval(() => {
+ // generate a random whole number
+ const newVal = Math.ceil(Math.random() * 100);
+
+ /**
+ * This does not create a new object. When stencil
+ * attempts to see if any Watched members have changed,
+ * it sees the reference to its `numberContainer` State is
+ * the same, and will not trigger `@Watch` or are-render
+ */
+ // this.numberContainer.val = newVal;
+
+ /**
+ * Using the spread operator, on the other hand, does
+ * create a new object. `numberContainer` is reassigned
+ * using the value returned by the spread operator.
+ * The reference to `numberContainer` has changed, which
+ * will trigger `@Watch` and a re-render
+ */
+ this.numberContainer = {...this.numberContainer, val: newVal};
+ }, 1000)
+ }
+
+ disconnectedCallback() {
+ if (this.timer) {
+ clearInterval(this.timer)
+ }
+ }
+
+ render() {
+ return
;
+ }
+}
+```
diff --git a/versioned_docs/version-v4.42/components/serialization-deserialization.md b/versioned_docs/version-v4.42/components/serialization-deserialization.md
new file mode 100644
index 000000000..586cc1613
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/serialization-deserialization.md
@@ -0,0 +1,196 @@
+---
+title: Serialization & Deserialization
+sidebar_label: Serialization & Deserialization
+description: Serialization & Deserialization
+slug: /serialization
+---
+
+# Serialization & Deserialization
+
+Custom elements interact with the DOM either via HTML [attributes](https://open-wc.org/guides/knowledge/attributes-and-properties/#attributes) (always strings) or JavaScript [properties](https://open-wc.org/guides/knowledge/attributes-and-properties/#properties). Stencil automatically tries to keep properties and attributes in-sync when possible via **serialization** (turning properties into strings) and **deserialization** (turning strings back into properties).
+
+For example, if you have a component defined like this:
+
+```tsx
+@Component({
+ tag: 'my-component',
+})
+export class MyComponent {
+ // Stencil 'sees' this as a number type.
+ // Numbers are easy to convert to/from strings
+ @Prop({ reflect: true }) myNumber: number;
+}
+```
+
+When the property is set via JavaScript:
+
+```js
+const myComponent = document.querySelector('my-component');
+myComponent.myNumber = 42;
+```
+
+Stencil will automatically serialize `myNumber` to an attribute:
+
+```html
+
+```
+
+Conversely, if the attribute is set in HTML:
+
+```html
+
+
+
+
+```
+
+Stencil will automatically deserialize the attribute back to the property:
+
+```js
+console.log(myComponent.myNumber); // 43
+```
+
+Most of the time Stencil's automatic serialization and deserialization is enough - especially with primitive data types, however there are cases where you might want to customize this behavior, especially when dealing with complex data.
+
+
+## The PropSerialize Decorator (`@PropSerialize()`)
+
+The `@PropSerialize()` decorator allows you to define custom serialization logic; converting a JavaScript property to a attribute string. The decorator accepts a single argument; the name of the class member `@Prop()` it is associated with. A method decorated with `@PropSerialize()` will automatically run when its associated property changes.
+
+```tsx
+import { Component, Prop, PropSerialize } from '@stencil/core';
+
+@Component({
+ tag: 'my-component',
+})
+export class MyComponent {
+ @Prop() aStringArray: string[];
+
+ @PropSerialize('aStringArray')
+ serializeStringArray(value: string[]) {
+ try {
+ return JSON.stringify(value); // must return a string
+ } catch (e) {
+ return null; // returning null removes the attribute
+ }
+ }
+}
+```
+
+In the example above, the `serializeStringArray` method will run whenever the `aStringArray` property changes - the returned value will be used to update the attribute (no need to set `{reflect: true}` on the `@Prop()` decorator). E.g.
+
+```js
+const myComponent = document.querySelector('my-component');
+myComponent.aStringArray = ['Hello', 'World'];
+```
+
+Becomes:
+
+```html
+
+```
+
+## The AttrDeserialize Decorator (`@AttrDeserialize()`)
+
+The `@AttrDeserialize()` decorator allows you to define custom deserialization logic; converting an attribute string to a JavaScript property. The decorator accepts a single argument; the name of the class member `@Prop()` it is associated with. A method decorated with `@AttrDeserialize()` will automatically run when its associated attribute changes.
+
+```tsx
+import { Component, Prop, AttrDeserialize } from '@stencil/core';
+
+@Component({
+ tag: 'my-component',
+})
+export class MyComponent {
+ @Prop() aStringArray: string[];
+
+ @AttrDeserialize('aStringArray')
+ deserializeStringArray(value: string): string[] | null {
+ try {
+ return JSON.parse(value);
+ } catch (e) {
+ return null;
+ }
+ }
+}
+```
+
+In the example above, the `deserializeStringArray` method will run whenever the `a-string-array` attribute changes. The method takes the new value of the attribute as an argument and must return the deserialized value.
+
+Now, when you set the attribute in HTML:
+
+```html
+
+```
+
+Stencil will automatically deserialize the attribute back to the property:
+
+```js
+const myComponent = document.querySelector('my-component');
+console.log(myComponent.aStringArray); // ['Hello', 'World']
+```
+
+## Practical uses of PropSerialize
+
+Practically speaking, there is little disadvantage in using a `@AttrDeserialize()` on a complex property; it just adds another method for users to provide data to your component.
+
+The use-cases around using `@PropSerialize()` is slightly less obvious as in general, [it is not considered best practice to reflect complex data (like objects or arrays) as attributes](https://web.dev/articles/custom-elements-best-practices#aim-to-only-accept-rich-data-objects,-arrays-as-properties.)
+
+The following example illustrates a practical use case for `@PropSerialize()` using the [hydrate script output](../guides/hydrate-app.md) on a server we can fetch and serialize complex data to an attribute. When the same component loads in a browser, the component can de-serialize the data immediately without having to do another fetch.
+
+```tsx
+import { AttrDeserialize, Build, Component, h, Prop, PropSerialize } from '@stencil/core';
+
+interface User {
+ userName: string;
+ avatarUrl: string;
+ posts: any[]
+}
+
+@Component({
+ tag: 'user-login-panel',
+})
+export class UserLogin {
+ @Prop() user: User;
+
+ // On the server *only* let's represent the user's data as an attribute
+ // this allows the browser to get the data immediately without having to do a client-side fetch
+
+ @PropSerialize('user')
+ userSerialize(newVal: User) {
+ if (Build.isBrowser) {
+ return null;
+ }
+ try { return JSON.stringify(newVal); }
+ catch (e) { return null; }
+ }
+
+ // Whenever we have an attribute (including on client init)
+ // let's turn it back into an object that we can use and render
+
+ @AttrDeserialize('user')
+ userDeserialize(newVal: string) {
+ try { return JSON.parse(newVal); }
+ catch (e) { return null; }
+ }
+
+ async componentWillLoad() {
+
+ // On the server *only*, let's do a secret login involving private keys etc.
+
+ if (Build.isServer) {
+ // Because we have a serializer method,
+ // setting a value automatically reflects it to the dom attribute
+
+ this.user = login(credentials);
+ }
+ }
+
+ render() {
+ if (this.user) return (`Welcome ${this.user.userName}!`);
+ else return (`Please login`);
+ }
+}
+```
\ No newline at end of file
diff --git a/versioned_docs/version-v4.42/components/state.md b/versioned_docs/version-v4.42/components/state.md
new file mode 100644
index 000000000..5a78b0447
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/state.md
@@ -0,0 +1,265 @@
+---
+title: Internal state
+sidebar_label: Internal State
+description: Use the State() for component's internal state
+slug: /state
+---
+
+# State
+
+'State' is a general term that refers to the values and objects that are stored on a class or an instance of a class for
+use now or in the future.
+
+Like a regular TypeScript class, a Stencil component may have one or more internal class members for holding value(s)
+that make up the component's state. Stencil allows developers to optionally mark class members holding some part of the
+class's state with the `@State()` decorator to trigger a rerender when the state changes.
+
+## The State Decorator (`@State`)
+
+Stencil provides a decorator to trigger a rerender when certain class members change. A component's class members that
+should trigger a rerender must be decorated using Stencil's `@State()` decorator, like so:
+```tsx
+// First, we import State from '@stencil/core'
+import { Component, State, h } from '@stencil/core';
+
+@Component({
+ tag: 'current-time',
+})
+export class CurrentTime {
+ // Second, we decorate a class member with @State()
+ // When `currentTime` changes, a rerender will be
+ // triggered
+ @State() currentTime: number = Date.now();
+
+ render() {
+ // Within the component's class, its members are
+ // accessed via `this`. This allows us to render
+ // the value stored in `currentTime`
+ const time = new Date(this.currentTime).toLocaleTimeString();
+
+ return (
+ {time}
+ );
+ }
+}
+```
+
+In the example above, `@State()` is placed before (decorates) the `currentTime` class member, which is a number. This
+marks `currentTime` so that any time its value changes, the component rerenders.
+
+However, the example above doesn't demonstrate the real power of using `@State`. `@State` members are meant to only be
+updated within a class, which the example above never does after the initial assignment of `currentTime`. This means
+that our `current-time` component will never rerender! We fix that in the example below to update `current-time` every
+1000 milliseconds (1 second):
+
+```tsx
+import { Component, State, h } from '@stencil/core';
+
+@Component({
+ tag: 'current-time',
+})
+export class CurrentTime {
+ timer: number;
+
+ // `currentTime` is decorated with `@State()`,
+ // as we need to trigger a rerender when its
+ // value changes to show the latest time
+ @State() currentTime: number = Date.now();
+
+ connectedCallback() {
+ this.timer = window.setInterval(() => {
+ // the assignment to `this.currentTime`
+ // will trigger a re-render
+ this.currentTime = Date.now();
+ }, 1000);
+ }
+
+ disconnectedCallback() {
+ window.clearInterval(this.timer);
+ }
+
+ render() {
+ const time = new Date(this.currentTime).toLocaleTimeString();
+
+ return (
+ {time}
+ );
+ }
+}
+```
+
+The example above makes use of the [connectedCallback() lifecycle method](./component-lifecycle.md#connectedcallback)
+to set `currentTime` to the value of `Date.now()` every 1000 milliseconds (or, every one second). Because the value of
+`currentTime` changes every second, Stencil calls the `render` function on `current-time`, which pretty-prints the
+current time.
+
+The example above also makes use of the
+[disconnectedCallback() lifecycle method](./component-lifecycle.md#disconnectedcallback) to properly clean up the timer
+that was created using `setInterval` in `connectedCallback()`. This isn't necessary for using `@State`, but is a general
+good practice when using `setInterval`.
+
+## When to Use `@State()`?
+
+`@State()` should be used for all class members that should trigger a rerender when they change. However, not all
+internal state might need to be decorated with `@State()`. If you know for sure that the value will either not change or
+that it does not need to trigger a re-rendering, `@State()` is not necessary. It is considered a 'best practice' to
+only use `@State()` when absolutely necessary. Revisiting our `current-time` component:
+
+```tsx
+import { Component, State, h } from '@stencil/core';
+
+@Component({
+ tag: 'current-time',
+})
+export class CurrentTime {
+ // `timer` is not decorated with `@State()`, as
+ // we do not wish to trigger a rerender when its
+ // value changes
+ timer: number;
+
+ // `currentTime` is decorated with `@State()`,
+ // as we need to trigger a rerender when its
+ // value changes to show the latest time
+ @State() currentTime: number = Date.now();
+
+ connectedCallback() {
+ // the assignment to `this.timer` will not
+ // trigger a re-render
+ this.timer = window.setInterval(() => {
+ // the assignment to `this.currentTime`
+ // will trigger a re-render
+ this.currentTime = Date.now();
+ }, 1000);
+ }
+
+ disconnectedCallback() {
+ window.clearInterval(this.timer);
+ }
+
+ render() {
+ const time = new Date(this.currentTime).toLocaleTimeString();
+
+ return (
+ {time}
+ );
+ }
+}
+```
+
+## Examples
+
+### Using `@State()` with `@Listen()`
+
+This example makes use of `@State` and [`@Listen`](./events.md#listen-decorator) decorators. We define a class member
+called `isOpen` and decorate it with `@State()`. With the use of `@Listen()`, we respond to click events toggling the
+value of `isOpen`.
+
+```tsx
+import { Component, Listen, State, h } from '@stencil/core';
+
+@Component({
+ tag: 'my-toggle-button'
+})
+export class MyToggleButton {
+ // `isOpen` is decorated with `@State()`,
+ // changes to it will trigger a rerender
+ @State() isOpen: boolean = true;
+
+ @Listen('click', { capture: true })
+ handleClick() {
+ // whenever a click event occurs on
+ // the component, update `isOpen`,
+ // triggering the rerender
+ this.isOpen = !this.isOpen;
+ }
+
+ render() {
+ return ;
+ }
+}
+```
+
+### Complex Types
+
+For more advanced use cases, `@State()` can be used with a complex type. In the example below, we print a list of `Item`
+entries. Although we start with zero `Item`s initially, we use the same pattern as we did before to add a new `Item` to
+`ItemList`'s `items` array once every 2000 milliseconds (2 seconds). Every time a new entry is added to `items`, a
+rerender occurs:
+
+```tsx
+import { Component, State, h } from '@stencil/core';
+
+// a user defined, complex type describing an 'Item'
+type Item = {
+ id: number;
+ description: string,
+}
+
+@Component({
+ tag: 'item-list',
+})
+export class ItemList {
+ // `timer` is not decorated with `@State()`, as
+ // we do not wish to trigger a rerender when its
+ // value changes
+ timer: number;
+
+ // `items` will trigger a rerender if
+ // the value assigned to the variable changes
+ @State() items: Item[] = [];
+
+ connectedCallback() {
+ // the assignment to `this.timer` will not
+ // trigger a re-render
+ this.timer = window.setInterval(() => {
+ const newTodo: Item = {
+ description: "Item",
+ id: this.items.length + 1
+ };
+ // the assignment to `this.items` will
+ // trigger a re-render. the assignment
+ // using '=' is important here, as we
+ // need that to make sure the rerender
+ // occurs
+ this.items = [...this.items, newTodo];
+ }, 2000);
+ }
+
+ disconnectedCallback() {
+ window.clearInterval(this.timer);
+ }
+
+ render() {
+ return (
+
+
To-Do List
+
+ {this.items.map((todo) =>
{todo.description} #{todo.id}
)}
+
+
+ );
+ }
+}
+```
+
+It's important to note that it's the reassignment of `this.items` that is causing the rerender in `connectedCallback()`:
+```ts
+this.items = [...this.items, newTodo];
+```
+
+Mutating the existing reference to `this.items` like in the examples below will not cause a rerender, as Stencil will
+not know that the contents of the array has changed:
+```ts
+// updating `items` either of these ways will not
+// cause a rerender
+this.items.push(newTodo);
+this.items[this.items.length - 1] = newTodo;
+```
+
+Similar to the examples above, this code sample makes use of the
+[connectedCallback() lifecycle method](./component-lifecycle.md#connectedcallback) to create a new `Item` and add
+it to `items` every 2000 milliseconds (every two seconds). The example above also makes use of the
+[disconnectedCallback() lifecycle method](./component-lifecycle.md#disconnectedcallback) to properly clean up the timer
+that was created using `setInterval` in `connectedCallback()`.
diff --git a/versioned_docs/version-v4.42/components/styling.md b/versioned_docs/version-v4.42/components/styling.md
new file mode 100644
index 000000000..1da0f41c4
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/styling.md
@@ -0,0 +1,374 @@
+---
+title: Styling Components
+sidebar_label: Styling
+description: Styling Components
+slug: /styling
+---
+
+# Styling Components
+
+## Shadow DOM
+
+### What is the Shadow DOM?
+
+The [shadow DOM](https://developers.google.com/web/fundamentals/web-components/shadowdom) is an API built into the browser that allows for DOM encapsulation and style encapsulation. It is a core aspect of the Web Component standards. The shadow DOM shields a component's styles, markup, and behavior from its surrounding environment. This means that we do not need to be concerned about scoping our CSS to our component, nor worry about a component's internal DOM being interfered with by anything outside the component.
+
+When talking about the shadow DOM, we use the term "light DOM" to refer to the "regular" DOM. The light DOM encompasses any part of the DOM that does not use the shadow DOM.
+
+### Shadow DOM in Stencil
+
+The shadow DOM hides and separates the DOM of a component in order to prevent clashing styles or unwanted side effects. We can use the shadow DOM in our Stencil components to ensure our components won't be affected by the applications in which they are used.
+
+To use the Shadow DOM in a Stencil component, you can set the `shadow` option to `true` in the component decorator.
+
+```tsx
+@Component({
+ tag: 'shadow-component',
+ styleUrl: 'shadow-component.css',
+ shadow: true,
+})
+export class ShadowComponent {}
+```
+
+If you'd like to learn more about enabling and configuring the shadow DOM, see the [shadow field of the component api](./component.md#component-options).
+
+By default, components created with the [`stencil generate` command](../config/cli.md#stencil-generate) use the shadow DOM.
+
+### Styling with the Shadow DOM
+
+With the shadow DOM enabled, elements within the shadow root are scoped, and styles outside of the component do not apply. As a result, CSS selectors inside the component can be simplified, as they will only apply to elements within the component. We do not have to include any specific selectors to scope styles to the component.
+
+```css
+:host {
+ color: black;
+}
+
+div {
+ background: blue;
+}
+```
+
+:::note
+The `:host` pseudo-class selector is used to select the [`Host` element](./host-element.md) of the component
+:::
+
+With the shadow DOM enabled, only these styles will be applied to the component. Even if a style in the light DOM uses a selector that matches an element in the component, those styles will not be applied.
+
+### Shadow DOM QuerySelector
+
+When using Shadow DOM and you want to query an element inside your web component, you must first use the [`@Element` decorator](./host-element.md#element-decorator) to gain access to the host element, and then you can use the `shadowRoot` property to perform the query. This is because all of your DOM inside your web component is in a shadowRoot that Shadow DOM creates. For example:
+
+```tsx
+import { Component, Element } from '@stencil/core';
+
+@Component({
+ tag: 'shadow-component',
+ styleUrl: 'shadow-component.css',
+ shadow: true
+})
+export class ShadowComponent {
+
+ @Element() el: HTMLElement;
+
+ componentDidLoad() {
+ const elementInShadowDom = this.el.shadowRoot.querySelector('.a-class-selector');
+
+ ...
+ }
+
+}
+```
+
+### Shadow DOM Browser Support
+
+The shadow DOM is currently natively supported in the following browsers:
+
+- Chrome
+- Firefox
+- Safari
+- Edge (v79+)
+- Opera
+
+In browsers which do not support the shadow DOM we fall back to scoped CSS. This gives you the style encapsulation that comes along with the shadow DOM but without loading in a huge shadow DOM polyfill.
+
+### Scoped CSS
+
+An alternative to using the shadow DOM is using scoped components. You can use scoped components by setting the `scoped` option to `true` in the component decorator.
+
+```tsx
+@Component({
+ tag: 'scoped-component',
+ styleUrl: 'scoped-component.css',
+ scoped: true,
+})
+export class ScopedComponent {}
+```
+
+Scoped CSS is a proxy for style encapsulation. It works by appending a data attribute to your styles to make them unique and thereby scope them to your component. It does not, however, prevent styles from the light DOM from seeping into your component.
+
+## CSS Custom Properties
+
+CSS custom properties, also often referred to as CSS variables, are used to contain values that can then be used in multiple CSS declarations. For example, we can create a custom property called `--color-primary` and assign it a value of `blue`.
+
+```css
+:host {
+ --color-primary: blue;
+}
+```
+
+And then we can use that custom property to style different parts of our component
+
+```css
+h1 {
+ color: var(--color-primary);
+}
+```
+
+### Customizing Components with Custom Properties
+
+CSS custom properties can allow the consumers of a component to customize a component's styles from the light DOM. Consider a `shadow-card` component that uses a custom property for the color of the card heading.
+
+```css
+:host {
+ --heading-color: black;
+}
+
+.heading {
+ color: var(--heading-color);
+}
+```
+
+:::note
+CSS custom properties must be declared on the `Host` element (`:host`) in order for them to be exposed to the consuming application.
+:::
+
+The `shadow-card` heading will have a default color of `black`, but this can now be changed in the light DOM by selecting the `shadow-card` and changing the value of the `--heading-color` custom property.
+
+```css
+shadow-card {
+ --heading-color: blue;
+}
+```
+
+## CSS Parts
+
+CSS custom properties can be helpful for customizing components from the light DOM, but they are still a little limiting as they only allow a user to modify specific properties. For situations where users require a higher degree of flexibility, we recommend using the [CSS `::part()` pseudo-element](https://developer.mozilla.org/en-US/docs/Web/CSS/::part). You can define parts on elements of your component with the "part" attribute.
+
+```tsx
+@Component({
+ tag: 'shadow-card',
+ styleUrl: 'shadow-card.css',
+ shadow: true,
+})
+export class ShadowCard {
+ @Prop() heading: string;
+
+ render() {
+ return (
+
+
{this.heading}
+
+
+ );
+ }
+}
+```
+
+Then you can use the `::part()` pseudo-class on the host element to give any styles you want to the element with the corresponding part.
+
+```css
+shadow-card::part(heading) {
+ text-transform: uppercase;
+}
+```
+
+This allows for greater flexibility in styling as any styles can now be added to this element.
+
+### Exportparts
+
+If you have a Stencil component nested within another component, any `part` specified on elements of the child component will not be exposed through the parent component. In order to expose the `part`s of the child component, you need to use the `exportparts` attribute. Consider this `OuterComponent` which contains the `InnerComponent`.
+
+```tsx
+@Component({
+ tag: 'outer-component',
+ styleUrl: 'outer-component.css',
+ shadow: true,
+})
+export class OuterComponent {
+ render() {
+ return (
+
+
+
+ );
+ }
+}
+```
+
+By specifying "inner-text" as the value of the `exportparts` attribute, elements of the `InnerComponent` with a `part` of "inner-text" can now be styled in the light DOM. Even though the `InnerComponent` is not used directly, we can style its parts through the `OuterComponent`.
+
+```html
+
+
+
+```
+
+## Style Modes
+
+Component Style Modes enable you to create versatile designs for your components by utilizing different styling configurations. This is achieved by assigning the styleUrls property of a component to a collection of style mode names, each linked to their respective CSS files.
+
+### Example: Styling a Button Component
+
+Consider a basic button component that supports both iOS and Material Design aesthetics:
+
+```tsx title="Using style modes to style a component"
+@Component({
+ tag: 'simple-button',
+ styleUrls: {
+ md: './simple-button.md.css', // styles for Material Design
+ ios: './simple-button.ios.css' // styles for iOS
+ },
+})
+export class SimpleButton {
+ // ...
+}
+```
+
+In the example above, two different modes are declared. One mode is named `md` (for 'Material Design') and refers back to a Material Design-specific stylesheet. Likewise, the other is named `ios` (for iOS) and references a different stylesheet for iOS-like styling. Both stylesheets are relative paths to the file that declares the component. While we have chosen short names in the above example, there's no limitation to the keys used in the `styleUrls` object.
+
+To dictate the style mode (Material Design or iOS) in which the button should be rendered, you must initialize the desired mode before any component rendering occurs. This can be done as follows:
+
+```ts
+import { setMode } from '@stencil/core';
+setMode(() => 'ios'); // Setting iOS as the default mode for all components
+```
+
+The `setMode` function processes all elements, enabling the assignment of modes individually based on specific element attributes. For instance, by assigning the `mode` attribute to a component:
+
+```html
+
+```
+
+You can conditionally set the style mode based on the `mode` property:
+
+```ts
+import { setMode } from '@stencil/core';
+
+const defaultMode = 'md'; // Default to Material Design
+setMode((el) => el.getAttribute('mode') || defaultMode);
+```
+
+The reason for deciding which mode to apply can be very arbitrary and based on your requirements, using an element property called `mode` is just one example.
+
+### Important Considerations
+
+- __Initialization:__ Style modes must be defined at the start of the component lifecycle and cannot be changed thereafter. If you like to change the components mode dynamically you will have to re-render it entirely.
+- __Usage Requirement:__ A style mode must be set to ensure the component loads with styles. Without specifying a style mode, the component will not apply any styles.
+- __Input Validation:__ Verify a style mode is supported by a component you are setting it for. Setting an un-supported style mode keeps the component unstyled.
+- __Querying Style Mode:__ To check the current style mode and e.g. provide different functionality based on the mode, use the `getMode` function:
+
+```ts
+import { getMode } from '@stencil/core';
+
+const simpleButton = document.queryElement('simple-button')
+console.log(getMode(simpleButton)); // Outputs the current style mode of component
+```
+
+This approach ensures your components are adaptable and can dynamically switch between different styles, enhancing the user experience across various platforms and design preferences.
+
+## Global styles
+
+While most styles are usually scoped to each component, sometimes it's useful to have styles that are available to all the components in your project. To create styles that are globally available, start by creating a global stylesheet. For example, you can create a folder in your `src` directory called `global` and create a file called `global.css` within that. Most commonly, this file is used to declare CSS custom properties on the root element via the `:root` pseudo-class. This is because styles provided via the `:root` pseudo-class can pass through the shadow boundary. For example, you can define a primary color that all your components can use.
+
+```css
+:root {
+ --color-primary: blue;
+}
+```
+
+In addition to CSS custom properties, other use cases for a global stylesheet include
+
+- Theming: defining CSS variables used across the app
+- Load fonts with `@font-face`
+- App wide font-family
+- CSS resets
+
+To make the global styles available to all the components in your project, the `stencil.config.ts` file comes with an optional [`globalStyle` setting](../config/01-overview.md#globalstyle) that accepts the path to your global stylesheet.
+
+```tsx
+export const config: Config = {
+ namespace: 'app',
+ globalStyle: 'src/global/global.css',
+ outputTarget: [
+ {
+ type: 'www',
+ },
+ ],
+};
+```
+
+The compiler will run the same minification, autoprefixing, and plugins over `global.css` and generate an output file for the [`www`](../output-targets/www.md) and [`dist`](../output-targets/dist.md) output targets. The generated file will always have the `.css` extension and be named as the specified `namespace`.
+
+In the example above, since the namespace is `app`, the generated global styles file will be located at: `./www/build/app.css`.
+
+This file must be manually imported in the `index.html` of your application.
+
+```html
+
+```
+
+### Constructable Stylesheets
+
+In addition to being available in the light DOM, global styles are automatically registered to every shadow root via [constructable stylesheets](https://web.dev/constructable-stylesheets/). This means that your global styles can target and style shadow DOM components directly.
+
+This allows you to apply styles to specific component types using the `:host()` pseudo-class with a tag name selector. For example, you can target all instances of a specific component:
+
+```css
+/* In your global stylesheet */
+:host(my-button) {
+ --button-border-radius: 8px;
+ display: inline-block;
+}
+
+:host(my-card) {
+ --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+ margin: 16px 0;
+}
+
+/* You can also use attribute selectors */
+:host(my-input[type="password"]) {
+ --input-font-family: monospace;
+}
+```
+
+The `:host()` function allows you to select the host element of a component when it matches the given selector. This is particularly useful for:
+
+- Setting default CSS custom properties for specific component types
+- Applying consistent spacing or layout styles across all instances of a component
+- Theming components based on their tag names or attributes
+
+:::note
+The `:host()` selector in global styles will only affect components that use shadow DOM. For scoped components, you should use regular tag selectors in your global styles.
+:::
+
+This behavior can be turned off via the [`extras.addGlobalStyleToComponents`](../config/extras.md#addglobalstyletocomponents) flag.
diff --git a/versioned_docs/version-v4.42/components/templating-and-jsx.md b/versioned_docs/version-v4.42/components/templating-and-jsx.md
new file mode 100644
index 000000000..74f92c3a2
--- /dev/null
+++ b/versioned_docs/version-v4.42/components/templating-and-jsx.md
@@ -0,0 +1,540 @@
+---
+title: Using JSX
+sidebar_label: Using JSX
+description: Using JSX
+slug: /templating-jsx
+---
+
+# Using JSX
+
+Stencil components are rendered using JSX, a popular, declarative template syntax. Each component has a `render` function that returns a tree of components that are rendered to the DOM at runtime.
+
+## Basics
+
+### The `h` and `Fragment` functions
+
+The `h` function (short for "hyperscript") is a factory function that creates virtual DOM elements. When you write JSX like `
Hello
`, it gets transformed into function calls like `h('div', null, 'Hello')`. The `Fragment` function is used to group a list of children without adding extra nodes to the DOM.
+
+#### Set up in Stencil
+
+Within your Stencil project, make sure to add or modify your `tsconfig.json` file, adding:
+
+```json
+{
+ "compilerOptions": {
+ "jsx": "react",
+ "jsxFactory": "h",
+ "jsxFragmentFactory": "Fragment"
+ }
+}
+```
+
+You will then need to import `h` (and `Fragment` if you plan to use it) from `@stencil/core` at the top of your component file:
+
+```tsx
+import { h, Fragment, Component } from '@stencil/core';
+
+@Component({
+ tag: 'my-component',
+})
+class MyComponent { ... }
+```
+
+(Read more about using the `Fragment` component in the [Complex Template Content](#complex-template-content) section below.)
+
+### `jsxImportSource` alternative
+
+`jsxImportSource` is a more modern approach that automatically imports the necessary JSX runtime functions instead of manually importing `h`; the compiler automatically imports what it needs from the specified package.
+
+#### Set up in Stencil
+
+To use `jsxImportSource`, modify your `tsconfig.json` file as follows:
+
+```json
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "jsxImportSource": "@stencil/core"
+ }
+}
+```
+
+Using this approach means you do not need to manually import `h` or `Fragment` in your component files.
+
+### The `render` function
+
+The `render` function is used within your component to output a tree of elements that will be drawn to the screen.
+
+```tsx
+class MyComponent {
+ render() {
+ return (
+
+
Hello World
+
This is JSX!
+
+ );
+ }
+}
+```
+
+In this example we're returning the JSX representation of a `div`, with two child elements: an `h1` and a `p`.
+
+### Host Element
+
+If you want to modify the host element itself, such as adding a class or an attribute to the component itself, use the `` functional component. Check for more details [here](./host-element.md)
+
+
+## Data Binding
+
+Components often need to render dynamic data. To do this in JSX, use `{ }` around a variable:
+
+```tsx
+render() {
+ return (
+
Hello {this.name}
+ )
+}
+```
+
+:::note
+If you're familiar with ES6 template variables, JSX variables are very similar, just without the `$`:
+:::
+
+```tsx
+//ES6
+`Hello ${this.name}`
+
+//JSX
+Hello {this.name}
+```
+
+
+## Conditionals
+
+If we want to conditionally render different content, we can use JavaScript if/else statements:
+Here, if `name` is not defined, we can just render a different element.
+
+```tsx
+render() {
+ if (this.name) {
+ return (
Hello {this.name}
)
+ } else {
+ return (
Hello, World
)
+ }
+}
+```
+
+Additionally, inline conditionals can be created using the JavaScript ternary operator:
+
+```tsx
+render() {
+ return (
+
+ {this.name
+ ?
Hello {this.name}
+ :
Hello World
+ }
+
+ );
+}
+```
+
+**Please note:** Stencil reuses DOM elements for better performance. Consider the following code:
+
+```tsx
+{someCondition
+ ?
+ :
+}
+```
+
+The above code behaves exactly the same as the following code:
+
+```tsx
+
+```
+
+Thus, if `someCondition` changes, the internal state of `` won't be reset and its lifecycle methods such as `componentWillLoad()` won't fire. Instead, the conditional merely triggers an update to the very same component.
+
+If you want to destroy and recreate a component in a conditional, you can assign the `key` attribute. This tells Stencil that the components are actually different siblings:
+
+```tsx
+{someCondition
+ ?
+ :
+}
+```
+
+This way, if `someCondition` changes, you get a new `` component with fresh internal state that also runs the lifecycle methods `componentWillLoad()` and `componentDidLoad()`.
+
+
+## Slots
+
+Components often need to render dynamic children in specific locations in their component tree, allowing a developer to supply child content when using our component, with our component placing that child component in the proper location.
+
+To do this, you can use the [Slot](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot) tag inside of your `my-component`.
+
+```tsx
+// my-component.tsx
+
+render() {
+ return (
+
+
A Component
+
+
+ );
+}
+
+```
+
+Then, if a user passes child components when creating our component `my-component`, then `my-component` will place that
+component inside of the second `
` above:
+
+```tsx
+render(){
+ return(
+
+
Child Element
+
+ )
+}
+```
+
+Slots can also have `name`s to allow for specifying slot output location:
+
+```tsx
+// my-component.tsx
+
+render(){
+ return [
+ ,
+
+
+ )
+}
+```
+
+### Slots Outside Shadow DOM
+
+:::caution
+Slots are native to the [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM), but Stencil polyfills
+the behavior to work for non-shadow components as well. However, you may encounter issues using slots outside the Shadow DOM especially with
+component trees mixing shadow and non-shadow components, or when passing a slot through many levels of components. In many cases, this behavior can
+be remedied by wrapping the `slot` in an additional element (like a `div` or `span`) so the Stencil runtime can correctly "anchor" the relocated
+content in its new location.
+:::
+
+There are known use cases that the Stencil runtime is not able to support:
+
+- Forwarding slotted content to another slot with a different name:
+ It is recommended that slot names stay consistent when slotting content through multiple levels of components. **Avoid** defining slot tags like
+ ``.
+
+## Dealing with Children
+
+The children of a node in JSX correspond at runtime to an array of nodes,
+whether they are created by mapping across an array with
+[`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
+or simply declared as siblings directly in JSX. This means that at runtime the
+children of the two top-level divs below (`.todo-one` and `.todo-two`) will be
+represented the same way:
+
+
+```tsx
+render() {
+ return (
+ <>
+
+ >
+ )
+}
+```
+
+If this array of children is dynamic, i.e., if any nodes may be added,
+removed, or reordered, then it's a good idea to set a unique `key` attribute on
+each element like so:
+
+```tsx
+render() {
+ return (
+
+ {this.todos.map((todo) => (
+
+
{todo.taskName}
+
+ ))}
+
+ )
+}
+```
+
+When nodes in a children array are rearranged Stencil makes an effort to
+preserve DOM nodes across renders but it isn't able to do so in all cases.
+Setting a `key` attribute lets Stencil ensure it can match up new and old
+children across renders and thereby avoid recreating DOM nodes unnecessarily.
+
+:::caution
+Do not use an array index or some other non-unique value as a key. Try to
+ensure that each child has a key which does not change and which is unique
+among all its siblings.
+:::
+
+### Automatic Key Insertion
+
+During compilation Stencil will automatically add key attributes to any JSX
+nodes in your component's render method which are not nested within curly
+braces. This allows Stencil’s runtime to accurately reconcile children when
+their order changes or when a child is conditionally rendered.
+
+For instance, consider a render method looking something like this:
+
+```tsx
+ render() {
+ return (
+
+ { this.disabled &&
no key!
}
+
+
+
+
+ );
+ }
+```
+
+While it might seem like adding a key attribute to the `#slot-wrapper` div
+could help ensure that elements will be matched up correctly when the component
+re-renders, this is actually superfluous because Stencil will automatically add
+a key to that element when it compiles your component.
+
+:::note
+The Stencil compiler can only safely perform automatic key insertion in certain
+scenarios where there is no danger of the keys accidentally causing elements to
+be considered different when they should be treated the same (or vice versa).
+
+In particular, the compiler will not automatically insert `key` attributes if a
+component's `render` method has more than one `return` statement or if it
+returns a [conditional
+expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator).
+Additionally, the compiler will not add key attributes to any JSX which is
+found within curly braces (`{ }`).
+:::
+
+## Handling User Input
+
+Stencil uses native [DOM events](https://developer.mozilla.org/en-US/docs/Web/Events).
+
+Here's an example of handling a button click. Note the use of the [Arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions).
+
+```tsx
+...
+export class MyComponent {
+ private handleClick = () => {
+ alert('Received the button click!');
+ }
+
+ render() {
+ return (
+
+ );
+ }
+}
+```
+
+Here's another example of listening to input `change`. Note the use of the [Arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions).
+
+```tsx
+...
+export class MyComponent {
+ private inputChanged = (event: Event) => {
+ console.log('input changed: ', (event.target as HTMLInputElement).value);
+ }
+
+ render() {
+ return (
+
+ );
+ }
+}
+```
+
+
+## Complex Template Content
+
+So far we've seen examples of how to return only a single root element. We can also nest elements inside our root element
+
+In the case where a component has multiple "top level" elements, the `render` function can return an array.
+Note the comma in between the `
` elements.
+
+```tsx
+render() {
+ return ([
+ // first top level element
+
+
+
Item 1
+
Item 2
+
Item 3
+
+
,
+
+ // second top level element, note the , above
+
+ ... more html content ...
+
+ ]);
+}
+```
+
+Alternatively you can use the `Fragment` functional component, in which case you won't need to add commas:
+
+```tsx
+import { Fragment } from '@stencil/core';
+...
+render() {
+ return (
+ // first top level element
+
+
+
Item 1
+
Item 2
+
Item 3
+
+
+
+
+ ... more html content ...
+
+ );
+}
+```
+
+It is also possible to use `innerHTML` to inline content straight into an element. This can be helpful when, for example, loading an svg dynamically and then wanting to render that inside of a `div`. This works just like it does in normal HTML:
+
+```markup
+
+```
+
+## Getting a reference to a DOM element
+
+In cases where you need to get a direct reference to an element, like you would normally do with `document.querySelector`, you might want to use a `ref` in JSX. Lets look at an example of using a `ref` in a form:
+
+```tsx
+@Component({
+ tag: 'app-home',
+})
+export class AppHome {
+
+ textInput!: HTMLInputElement;
+
+ handleSubmit = (event: Event) => {
+ event.preventDefault();
+ console.log(this.textInput.value);
+ }
+
+ render() {
+ return (
+
+ );
+ }
+}
+```
+
+In this example we are using `ref` to get a reference to our input `ref={(el) => this.textInput = el as HTMLInputElement}`. We can then use that ref to do things such as grab the value from the text input directly `this.textInput.value`.
+
+## Explicitly setting attributes or properties
+
+By default, Stencil tries to intelligently determine whether to set an attribute or (more commonly) a property on an element when using JSX.
+However, in some cases you may want to explicitly set one or the other. You can do this by using the `attr:` or `prop:` prefixes. For example:
+
+```tsx
+
+```
+
+will set the `value` attribute on the input element, while:
+
+```tsx
+
+```
+
+will explicitly set the `value` property on the input element.
+
+
+## Avoid Shared JSX Nodes
+
+The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be shared within the same renderer.
+
+In the example below, the `sharedNode` variable is reused multiple times within the `render()` function. The renderer is able to optimize its DOM element lookups by caching the reference, however, this causes issues when nodes are reused. Instead, it's recommended to always generate unique nodes like the changed example below.
+
+```diff
+@Component({
+ tag: 'my-cmp',
+})
+export class MyCmp {
+
+ render() {
+- const sharedNode =
Text
;
+ return (
+
+- {sharedNode}
+- {sharedNode}
++
Text
++
Text
+
+ );
+ }
+}
+```
+
+Alternatively, creating a factory function to return a common JSX node could be used instead since the returned value would be a unique instance. For example:
+
+```tsx
+@Component({
+ tag: 'my-cmp',
+})
+export class MyCmp {
+
+ getText() {
+ return
Text
;
+ }
+
+ render() {
+ return (
+
+ {this.getText()}
+ {this.getText()}
+
+ );
+ }
+}
+```
+
+## Other Resources
+
+- [Understanding JSX for StencilJS Applications](https://www.joshmorony.com/understanding-jsx-for-stencil-js-applications/)
diff --git a/versioned_docs/version-v4.42/config/01-overview.md b/versioned_docs/version-v4.42/config/01-overview.md
new file mode 100644
index 000000000..dc96c76fe
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/01-overview.md
@@ -0,0 +1,586 @@
+---
+title: Config
+sidebar_label: Overview
+description: Config
+slug: /config
+---
+
+# Stencil Config
+
+In most cases, the `stencil.config.ts` file does not require any customization since Stencil comes with great default values out-of-the-box. In general, it's preferred to keep the config as minimal as possible. In fact, you could even delete the `stencil.config.ts` file entirely and an app would compile just fine. But at the same time, the compiler can be configured at the lowest levels using this config. Below are the many *optional* config properties.
+
+Example `stencil.config.ts`:
+
+```tsx
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ namespace: 'MyApp',
+ srcDir: 'src'
+};
+```
+
+## buildDist
+
+*default: true (prod), false (dev)*
+
+Sets whether or not Stencil will execute output targets and write output to
+`dist/` when `stencil build` is called. Defaults to `false` when building for
+development and `true` when building for production. If set to `true` then
+Stencil will always build all output targets, regardless of whether the build
+is in dev or prod mode or using watch mode.
+
+```tsx
+buildDist: true
+```
+
+## buildEs5
+
+Sets if the ES5 build should be generated or not.
+It defaults to `false`.
+Setting `buildEs5` to `true` will also create ES5 builds for both dev and prod modes.
+Setting `buildEs5` to `prod` will only build ES5 in prod mode.
+
+```tsx
+buildEs5: boolean | 'prod'
+```
+
+## bundles
+
+By default, Stencil will statically analyze the application and generate a component graph of how all the components are interconnected. From the component graph it is able to best decide how components should be grouped depending on their usage with one another within the app. By doing so it's able to bundle components together in order to reduce network requests. However, bundles can be manually generated using the `bundles` config.
+
+The `bundles` config is an array of objects that represent how components are grouped together in lazy-loaded bundles. This config is rarely needed as Stencil handles this automatically behind the scenes.
+
+```tsx
+bundles: [
+ { components: ['ion-button'] },
+ { components: ['ion-card', 'ion-card-header'] }
+]
+```
+
+## cacheDir
+
+*default: '.stencil'*
+
+The directory where sub-directories will be created for caching when [`enableCache`](#enablecache) is set `true` or if using
+[Stencil's Screenshot Connector](../testing/stencil-testrunner/07-screenshot-connector.md).
+
+A Stencil config like the following:
+
+```ts title='stencil.config.ts'
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ ...,
+ enableCache: true,
+ cacheDir: '.cache',
+ testing: {
+ screenshotConnector: 'connector.js'
+ }
+}
+```
+
+Will result in the following file structure:
+
+```tree
+stencil-project-root
+└── .cache
+ ├── .build <-- Where build related file caching is written
+ |
+ └── screenshot-cache.json <-- Where screenshot caching is written
+```
+
+## devServer
+
+Please see the [Dev-Server docs](./dev-server.md).
+
+## docs
+
+Please see the [docs config](./docs.md).
+
+## enableCache
+
+*default: `true`*
+
+Stencil will cache build results in order to speed up rebuilds. To disable this feature, set `enableCache` to `false`.
+
+```tsx
+enableCache: true
+```
+
+## excludeComponents
+
+*default: `[]`*
+
+An array of component tag names to exclude from production builds.
+Useful to remove test, demo or experimental components from final output.
+
+Supports glob patterns for matching multiple components:
+- `['demo-*']` - Excludes all components starting with "demo-"
+- `['*-test', '*-demo']` - Excludes components ending with "-test" or "-demo"
+- `['my-component']` - Excludes a specific component
+
+Components matching these patterns will be completely excluded from all output targets when *not* using the `--dev` flag.
+
+## extras
+
+Please see the [Extras docs](./extras.md).
+
+## env
+
+*default: `{}`*
+
+An object that can hold environment variables for your components to import and use. These variables can hold data objects depending on the environment you compile the components for. For example, let's say we want to provide an URL to our API based on a specific environment, we could provide it as such:
+
+```ts title="stencil.config.ts"
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ ...,
+ env: {
+ API_BASE_URL: process.env.API_BASE_URL
+ }
+}
+```
+
+Now when you build your components with this environment variable set, you can import it in your component as follows:
+
+```ts
+import { Component, h, Env, Host } from '@stencil/core';
+
+@Component({
+ tag: 'api-component',
+})
+export class APIComponent {
+ async connectedCallback () {
+ const res = await fetch(Env.API_BASE_URL)
+ // ...
+ }
+}
+```
+
+## generateExportMaps
+
+*default: `false`*
+
+Stencil will generate [export maps](https://nodejs.org/api/packages.html#packages_exports) that correspond with various output target outputs. This includes the root
+entry point based on the [primary output target](../output-targets/01-overview.md#primary-package-output-target-validation) (or first eligible output target if not specified),
+the entry point for the lazy-loader (if using the `dist` output target), and entry points for each component (if using `dist-custom-elements`).
+
+## globalScript
+
+The global script config option takes a file path as a string.
+
+The global script runs once before your library/app loads, so you can do things like setting up a connection to an external service or configuring a library you are using.
+
+The code to be executed should be placed within a default function that is exported by the global script. Ensure all of the code in the global script is wrapped in the function that is exported:
+
+```javascript
+export default function() { // or export default async function()
+ initServerConnection();
+}
+```
+
+:::note
+The exported function can also be `async` but be aware that this can have implications on the performance of your application as all rendering operations will be deferred until after the global script finishes.
+:::
+
+Imported methods from Stencil, such as `setMode`, `BUILD` and others, can only be accessed within the function exported by the script. They will not be available in the global scope outside of this function.
+
+```javascript
+import { setMode, BUILD } from '@stencil/core';
+
+// ❌ This won't work as Stencil primitives are not initialized at this point
+// console.log('Build mode:', BUILD.isDev);
+
+export default function() {
+ // ✅ This works - Stencil methods are available within the exported function
+ if (BUILD.isDev) {
+ console.log('Development mode detected');
+ setMode((elm) => elm.getAttribute('mode') || 'dev');
+ } else {
+ console.log('Production mode');
+ setMode((elm) => elm.getAttribute('mode') || 'prod');
+ }
+}
+```
+
+## globalStyle
+
+Stencil is traditionally used to compile many components into an app, and each component comes with its own compartmentalized styles. However, it's still common to have styles which should be "global" across all components and the website. A global CSS file is often useful to set [CSS Variables](../components/styling.md).
+
+Additionally, the `globalStyle` config can be used to precompile styles with Sass, PostCSS, etc.
+
+Below is an example folder structure containing a webapp's global css file, named `app.css`.
+
+```bash
+src/
+ components/
+ global/
+ app.css
+```
+
+The global style config takes a file path as a string. The output from this build will go to the `buildDir`. In this example it would be saved to `www/build/app.css`. Additionally, these global styles are automatically applied to all components with shadow roots via constructable stylesheets, allowing you to style shadow DOM components directly.
+
+```tsx
+globalStyle: 'src/global/app.css'
+```
+
+Check out the [styling docs](../components/styling.md#global-styles) of how to use global styles in your app.
+
+## hashedFileNameLength
+
+*default: `8`*
+
+When the `hashFileNames` config is set to `true`, and it is a production build, the `hashedFileNameLength` config is used to determine how many characters the file name's hash should be.
+
+```tsx
+hashedFileNameLength: 8
+```
+
+## hashFileNames
+
+*default: `true`*
+
+During production builds, the content of each generated file is hashed to represent the content, and the hashed value is used as the filename. If the content isn't updated between builds, then it receives the same filename. When the content is updated, then the filename is different. By doing this, deployed apps can "forever-cache" the build directory and take full advantage of content delivery networks (CDNs) and heavily caching files for faster apps.
+
+```tsx
+hashFileNames: true
+```
+
+## hydratedFlag
+
+When using the [lazy build](https://stenciljs.com/docs/distribution) Stencil
+has support for automatically applying a class or attribute to a component and
+all of its child components when they have finished hydrating. This can be used
+to prevent a [flash of unstyled content
+(FOUC)](https://en.wikipedia.org/wiki/Flash_of_unstyled_content), a
+typically-undesired 'flicker' of unstyled HTML that might otherwise occur
+during component rendering while various components are asynchronously
+downloaded and rendered.
+
+By default, Stencil will add the `hydrated` CSS class to elements to indicate
+hydration. The `hydratedFlag` config field allows this behavior to be
+customized, by changing the name of the applied CSS class, setting it to use an
+attribute to indicate hydration, or changing which type of CSS properties and
+values are assigned before and after hydrating. This config can also be used to
+turn off this behavior by setting it to `null`.
+
+If a Stencil configuration does not supply a value for `hydratedFlag` then
+Stencil will automatically generate the following default configuration:
+
+```ts
+const defaultHydratedFlag: HydratedFlag = {
+ hydratedValue: 'inherit',
+ initialValue: 'hidden',
+ name: 'hydrated',
+ property: 'visibility',
+ selector: 'class',
+};
+```
+
+If `hydratedFlag` is explicitly set to `null`, Stencil will not set a default
+configuration and the behavior of marking hydration with a class or attribute
+will be disabled.
+
+```tsx
+hydratedFlag: null | {
+ name?: string,
+ selector?: 'class' | 'attribute',
+ property?: string,
+ initialValue?: string,
+ hydratedValue?: string
+}
+```
+
+The supported options are as follows:
+
+### name
+
+*default: 'hydrated'*
+
+The name which Stencil will use for the attribute or class that it sets on
+elements to indicate that they are hydrated.
+
+```tsx
+name: string
+```
+
+### selector
+
+*default: 'class'*
+
+The way that Stencil will indicate that a component has been hydrated. When
+`'class'`, Stencil will set the `name` option on the element as a class, and
+when `'attribute'`, Stencil will similarly set the `name` option as an
+attribute.
+
+```tsx
+selector: 'class' | 'attribute'
+```
+
+### property
+
+*default: 'visibility'*
+
+The CSS property used to show and hide components. This defaults to the CSS
+`visibility` property. Other possible CSS properties might include `display`
+with the `initialValue` setting as `none`, or `opacity` with the `initialValue`
+as `0`. Defaults to `visibility`.
+
+```tsx
+property: string
+```
+
+### initialValue
+
+*default: 'hidden'*
+
+This is the value which should be set for the property specified by `property`
+on all components before hydration.
+
+```tsx
+initialValue: string
+```
+
+### hydratedValue
+
+*default: 'inherit'*
+
+This is the value which should be set for the property specified by `property`
+on all components once they've completed hydration.
+
+```tsx
+hydratedValue: string
+```
+
+## invisiblePrehydration
+
+*default: `true`*
+
+When `true`, `invisiblePrehydration` will visually hide components before they are hydrated by adding an automatically injected style tag to the document's head. Setting `invisiblePrehydration` to `false` will not inject the style tag into the head, allowing you to style your web components pre-hydration.
+
+:::note
+Setting `invisiblePrehydration` to `false` will cause everything to be visible when your page is loaded, causing a more prominent Flash of Unstyled Content (FOUC). However, you can style your web component's fallback content to your preference.
+:::
+
+```tsx
+invisiblePrehydration: true
+```
+
+## minifyCss
+
+_default: `true` in production_
+
+When `true`, the browser CSS file will be minified.
+
+## minifyJs
+
+_default: `true` in production_
+
+When `true`, the browser JS files will be minified. Stencil uses [Terser](https://terser.org/) under-the-hood for file minification.
+
+## namespace
+
+*default: `App`*
+
+The `namespace` config is a `string` representing a namespace for the app. For apps that are not meant to be a library of reusable components, the default of `App` is just fine. However, if the app is meant to be consumed as a third-party library, such as `Ionic`, a unique namespace is required.
+
+```tsx
+namespace: "Ionic"
+```
+## outputTargets
+
+Please see the [Output Target docs](../output-targets/01-overview.md).
+
+## plugins
+
+Please see the [Plugin docs](./plugins.md).
+
+## preamble
+
+*default: `undefined`*
+
+Used to help to persist a banner or add relevant information about the resulting build, the `preamble` configuration
+field is a `string` that will be converted into a pinned comment and placed at the top of all emitted JavaScript files,
+with the exception of any emitted polyfills. Escaped newlines may be placed in the provided value for this field and
+will be honored by Stencil.
+
+Example:
+```tsx
+preamble: 'Built with Stencil\nCopyright (c) SomeCompanyInc.'
+```
+Will generate the following comment:
+```tsx
+/*!
+ * Built with Stencil
+ * Copyright (c) SomeCompanyInc.
+ */
+```
+
+## sourceMap
+
+*default: `'dev'`*
+
+- Set to `true` to always generate source maps,
+- Set to `false` to never generate source maps
+- Set to `'dev'` to only generate source maps during development (`--dev`) builds.
+
+```tsx
+sourceMap: true | false | 'dev'
+```
+
+Sourcemaps create a translation between Stencil components that are written in TypeScript/JSX and the resulting
+JavaScript that is output by Stencil. Enabling source maps in your project allows for an improved debugging experience
+for Stencil components. For example, they allow external tools (such as an Integrated Development Environment) to add
+breakpoints directly in the original source code, which allows you to 'step through' your code line-by-line, to inspect
+the values held in variables, to observe logic flow, and more.
+
+Please note: Stencil will always attempt to minify a component's source code as much as possible during compilation.
+When `sourceMap` is enabled, it is possible that a slightly different minified result will be produced by Stencil when
+compared to the minified result produced when `sourceMap` is not enabled.
+
+Developers are responsible for determining whether or not they choose to serve sourcemaps in each environment their
+components are served and implementing their decision accordingly.
+
+## srcDir
+
+*default: `src`*
+
+The `srcDir` config specifies the directory which should contain the source typescript files for each component. The standard for Stencil apps is to use `src`, which is the default.
+
+```tsx
+srcDir: 'src'
+```
+
+## taskQueue
+
+*default: `async`*
+
+Sets the task queue used by stencil's runtime. The task queue schedules DOM read and writes
+across the frames to efficiently render and reduce layout thrashing. By default, the
+`async` is used. It's recommended to also try each setting to decide which works
+best for your use-case. In all cases, if your app has many CPU intensive tasks causing the
+main thread to periodically lock-up, it's always recommended to try
+[Web Workers](../guides/workers.md) for those tasks.
+
+* `congestionAsync`: DOM reads and writes are scheduled in the next frame to prevent layout
+ thrashing. When the app is heavily tasked and the queue becomes congested it will then
+ split the work across multiple frames to prevent blocking the main thread. However, it can
+ also introduce unnecessary reflows in some cases, especially during startup. `congestionAsync`
+ is ideal for apps running animations while also simultaneously executing intensive tasks
+ which may lock-up the main thread.
+
+* `async`: DOM read and writes are scheduled in the next frame to prevent layout thrashing.
+ During intensive CPU tasks it will not reschedule rendering to happen in the next frame.
+ `async` is ideal for most apps, and if the app has many intensive tasks causing the main
+ thread to lock-up, it's recommended to try [Web Workers](../guides/workers.md)
+ rather than the congestion async queue.
+
+* `immediate`: Makes writeTask() and readTask() callbacks to be executed synchronously. Tasks
+ are not scheduled to run in the next frame, but do note there is at least one microtask.
+ The `immediate` setting is ideal for apps that do not provide long-running and smooth
+ animations. Like the async setting, if the app has intensive tasks causing the main thread
+ to lock-up, it's recommended to try [Web Workers](../guides/workers.md).
+
+```tsx
+taskQueue: 'async'
+```
+
+## testing
+
+Please see the [testing config docs](../testing/stencil-testrunner/02-config.md).
+
+## transformAliasedImportPaths
+
+*default: `true`*
+
+This sets whether or not Stencil should transform [path aliases](
+https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) set
+in a project's `tsconfig.json` from the assigned module aliases to resolved
+relative paths. This will not transform external imports (like `@stencil/core`) or
+relative imports (like `'../utils'`).
+
+This option applies globally and will affect all code processed by Stencil,
+including `.d.ts` files and spec tests.
+
+An example of path transformation could look something like the following.
+
+First, a set of `paths` aliases in `tsconfig.json`:
+
+```json title="tsconfig.json"
+{
+ "compilerOptions": {
+ "paths": {
+ "@utils": [
+ "../path/to/utils"
+ ]
+ }
+ }
+}
+```
+
+Then with the following input:
+
+```ts title="src/my-module.ts"
+import { utilFunc, UtilInterface } from '@utils'
+
+export function util(arg: UtilInterface) {
+ utilFunc(arg)
+}
+```
+
+Stencil will produce the following output:
+
+```js title="dist/my-module.js"
+import { utilFunc } from '../path/to/utils';
+export function util(arg) {
+ utilFunc(arg);
+}
+```
+
+```ts title="dist/my-module.d.ts"
+import { UtilInterface } from '../path/to/utils';
+export declare function util(arg: UtilInterface): void;
+```
+
+## validatePrimaryPackageOutputTarget
+
+*default: `false`*
+
+When `true`, validation for common `package.json` fields will occur based on setting an output target's `isPrimaryPackageOutputTarget` flag.
+For more information on package validation, please see the [output target docs](../output-targets/01-overview.md#primary-package-output-target-validation).
+
+## rollupConfig
+
+Passes custom configuration down to rollup itself. The following options can be overwritten:
+
+- `inputOptions`: [`context`](https://rollupjs.org/configuration-options/#context), [`external`](https://rollupjs.org/configuration-options/#external), [`moduleContext`](https://rollupjs.org/configuration-options/#modulecontext) [`treeshake`](https://rollupjs.org/configuration-options/#treeshake)
+- `outputOptions`: [`globals`](https://rollupjs.org/configuration-options/#output-globals)
+
+*default: `{}`*
+
+## watchIgnoredRegex
+
+*default: `[]`*
+
+*type: `RegExp | RegExp[]`*
+
+A regular expression (or array of regular expressions) that can be used to omit files from triggering a rebuild in watch mode. During compile-time, each file in the Stencil
+project will be tested against each regular expression to determine if changes to the file (or directory) should trigger a project rebuild.
+
+:::note
+If you want to ignore TS files such as `.ts`/`.js` or `.tsx`/`.jsx` extensions, these files will also need to be specified in your project's tsconfig's
+[`watchOptions`](https://www.typescriptlang.org/docs/handbook/configuring-watch.html#configuring-file-watching-using-a-tsconfigjson) _in addition_ to the
+`watchIgnoredRegex` option. For instance, if we wanted to ignore the `my-component.tsx` file, we'd specify:
+
+```json title="tsconfig.json"
+{
+ ...,
+ "watchOptions": {
+ "excludeFiles": ["src/components/my-component/my-component.tsx"]
+ }
+}
+```
+
+:::
diff --git a/versioned_docs/version-v4.42/config/_category_.json b/versioned_docs/version-v4.42/config/_category_.json
new file mode 100644
index 000000000..b9de453d1
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/_category_.json
@@ -0,0 +1,4 @@
+{
+ "label": "Config",
+ "position": 5
+}
diff --git a/versioned_docs/version-v4.42/config/cli.md b/versioned_docs/version-v4.42/config/cli.md
new file mode 100644
index 000000000..445c42996
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/cli.md
@@ -0,0 +1,111 @@
+---
+title: Stencil CLI
+sidebar_label: CLI
+description: Stencil CLI
+slug: /cli
+---
+
+# Command Line Interface (CLI)
+
+Stencil's command line interface (CLI) is how developers can build their projects, run tests, and more.
+Stencil's CLI is included in the compiler, and can be invoked with the `stencil` command in a project where `@stencil/core` is installed.
+
+## `stencil build`
+
+Builds a Stencil project. The flags below are the available options for the `build` command.
+
+| Flag | Description | Alias |
+|------|-------------|-------|
+| `--ci` | Run a build using recommended settings for a Continuous Integration (CI) environment. Defaults the number of workers to 4, allows for extra time if taking screenshots via the tests and modifies the console logs. | |
+| `--config` | Path to the `stencil.config.ts` file. This flag is not needed in most cases since Stencil will find the config. Additionally, a Stencil config is not required. | `-c` |
+| `--debug` | Adds additional runtime code to help debug, and sets the log level for more verbose output. | |
+| `--dev` | Runs a development build. | |
+| `--docs` | Generate all docs based on the component types, properties, methods, events, JSDocs, CSS Custom Properties, etc. | |
+| `--es5` | Creates an ES5 compatible build. By default ES5 builds are not created during development in order to improve build times. However, ES5 builds are always created during production builds. Use this flag to create ES5 builds during development. | |
+| `--log` | Write logs for the `stencil build` into `stencil-build.log`. The log file is written in the same location as the config. | |
+| `--prerender` | Prerender the application using the `www` output target after the build has completed. | |
+| `--prod` | Runs a production build which will optimize each file, improve bundling, remove unused code, minify, etc. A production build is the default, this flag is only used to override the `--dev` flag. | |
+| `--max-workers` | Max number of workers the compiler should use. Defaults to use the same number of CPUs the Operating System has available. | |
+| `--next` | Opt-in to test the "next" Stencil compiler features. | |
+| `--no-cache` | Disables using the cache. | |
+| `--no-open` | By default the `--serve` command will open a browser window. Using the `--no-open` command will not automatically open a browser window. | |
+| `--port` | Port for the [Integrated Dev Server](./dev-server.md). Defaults to `3333`. | `-p` |
+| `--serve` | Starts the [Integrated Dev Server](./dev-server.md). | |
+| `--stats` | Write stats about the project to `stencil-stats.json`. The stats file is written in the same location as the config. | |
+| `--verbose` | Logs additional information about each step of the build. | |
+| `--watch` | Watches files during development and triggers a rebuild when files are updated. | |
+
+## `stencil docs`
+
+Performs a one-time generation of documentation for your project.
+For more information on documentation generation, please see the [Documentation Generation section](../documentation-generation/01-overview.md).
+
+:::info
+This command runs with dev mode enabled, which does not run a full build. As a result, documentation that needs to be built first, like CSS styles, will not be generated. You will need to run `npx stencil build --docs` to generate documentation that requires building.
+:::
+
+## `stencil generate`
+
+Alias: `stencil g`
+
+Starts the interactive generator for a new Stencil component.
+The generator will ask you for a name for your component, and whether any stylesheets or testing files should be generated.
+
+If you wish to skip the interactive generator, a component tag name may be provided on the command line:
+```shell
+stencil generate my-new-component
+```
+
+All components will be generated within the `src/components` folder.
+Within `src/components`, a directory will be created with the same name as the component tag name you provided containing the generated files.
+For example, if you specify `page-home` as the component tag name, the files will be generated in `src/components/page-home`:
+```plain
+src
+└── components
+ └── page-home
+ ├── page-home.css
+ ├── page-home.e2e.ts
+ ├── page-home.spec.ts
+ └── page-home.tsx
+```
+
+It is also possible to specify one or more sub-folders to generate the component in.
+For example, if you specify `pages/page-home` as the component tag name, the files will be generated in `src/components/pages/page-home`:
+```shell
+stencil generate pages/page-home
+```
+The command above will result in the following directory structure:
+```plain
+src
+└── components
+ └── pages
+ └── page-home
+ ├── page-home.css
+ ├── page-home.e2e.ts
+ ├── page-home.spec.ts
+ └── page-home.tsx
+```
+
+## `stencil help`
+
+Aliases: `stencil --help`, `stencil -h`
+
+Prints various tasks that can be run and their associated flags to the terminal.
+
+## `stencil test`
+
+Tests a Stencil project. The flags below are the available options for the `test` command.
+
+| Flag | Description |
+|------|-------------|
+| `--spec` | Tests `.spec.ts` files using [Jest](https://jestjs.io/). |
+| `--e2e` | Tests `.e2e.ts` files using [Puppeteer](https://developers.google.com/web/tools/puppeteer) and [Jest](https://jestjs.io/). |
+| `--no-build` | Skips the build process before running end-to-end tests. When using this flag, it is assumed that your Stencil project has been built prior to running `stencil test`. Unit tests do not require this flag. |
+| `--devtools` | Opens the dev tools panel in Chrome for end-to-end tests. Setting this flag will disable `--headless` |
+| `--headless` | Sets the headless mode to use in Chrome for end-to-end tests. `--headless` and `--headless=true` will enable the "old" headless mode in Chrome, that was used by default prior to Chrome v112. `--headless=new` will enable the new headless mode introduced in Chrome v112. See [this article](https://developer.chrome.com/articles/new-headless/) for more information on Chrome's new headless mode. |
+
+## `stencil version`
+
+Aliases: `stencil -v`, `stencil --version`
+
+Prints the version of Stencil to the terminal.
diff --git a/versioned_docs/version-v4.42/config/dev-server.md b/versioned_docs/version-v4.42/config/dev-server.md
new file mode 100644
index 000000000..705b32724
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/dev-server.md
@@ -0,0 +1,162 @@
+---
+title: Integrated Dev Server Config
+sidebar_label: Dev Server
+description: Integrated Dev Server Config
+slug: /dev-server
+---
+
+# Integrated Dev Server
+
+Stencil comes with an integrated dev server in order to simplify development. By integrating the build process and the dev server, Stencil is able to drastically improve the development experience without requiring complicated build scripts and configuration. As app builds and re-builds take place, the compiler is able to communicate with the dev server, and vice versa.
+
+## Hot Module Replacement
+
+The compiler already provides a watch mode, but coupled with the dev server it's able to go one step farther by reloading only what has changed within the browser. Hot Module Replacement allows the app to keep its state within the browser, while switching out individual components with their updated logic after file saves.
+
+## Style Replacement
+
+Web components can come with their own css, can use shadow dom, and can have individual style tags. Traditionally, live-reload external css links usually does the trick, however, updating components with inline styles within shadow roots has been a challenge. With the integrated dev server, Stencil is able to dynamically update styles for all components, whether they're using shadow dom or not, without requiring a page refresh.
+
+## Development Errors
+
+When errors happen during development, such as printing an error for invalid syntax, Stencil will not only log the error and the source of the error in the console, but also overlay the app with the error so it's easier to read.
+
+## Open In Editor
+
+When a development error is shown and overlays the project within the browser, line numbers pointing to the source text are clickable,
+which will open the source file directly in your IDE.
+
+## Dev Server Config
+
+### `address`
+
+**Optional**
+
+**Type: `string`**
+
+**Default: `0.0.0.0`**
+
+IP address used by the dev server. The default is `0.0.0.0`, which points to all IPv4 addresses on the local machine, such as `localhost`.
+
+### `basePath`
+
+**Optional**
+
+**Type: `string`**
+
+**Default: `/`**
+
+Base path to be used by the server. Defaults to the root pathname.
+
+### `https`
+
+**Optional**
+
+**Type: `{ key: string; cert: string; } | false`**
+
+**Default: `false`**
+
+By default the dev server runs over the http protocol. Instead you can run it over https by providing your own SSL certificate and key (see example below).
+
+#### Example
+
+```tsx
+import { readFileSync } from 'fs';
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ devServer: {
+ reloadStrategy: 'pageReload',
+ port: 4444,
+ https: {
+ cert: readFileSync('cert.pem', 'utf8'),
+ key: readFileSync('key.pem', 'utf8'),
+ },
+ },
+};
+```
+
+### `initialLoadUrl`
+
+**Optional**
+
+**Type: `string`**
+
+**Default: `/`**
+
+The URL the dev server should first open to.
+
+### `logRequests`
+
+**Optional**
+
+**Type: `boolean`**
+
+**Default: `false`**
+
+Every request to the server will be logged within the terminal.
+
+### `openBrowser`
+
+**Optional**
+
+**Type: `boolean`**
+
+**Default: `true`**
+
+By default, when dev server is started the local dev URL is opened in your default browser. However, to prevent this URL to be opened change this value to `false`.
+
+### `pingRoute`
+
+**Optional**
+
+**Type: `string | null`**
+
+**Default: `/ping`**
+
+Route to be registered on the dev server that will respond with a 200 OK response once the Stencil build has completed. The Stencil dev server will "spin up"
+before the build process has completed, which can cause issues with processes that rely on the compiled and served output (like E2E testing). This route provides
+a way for these processes to know when the build has finished and is ready to be accessed.
+
+If set to `null`, no route will be registered.
+
+### `port`
+
+**Optional**
+
+**Type: `number`**
+
+**Default: `3333`**
+
+Sets the server's port.
+
+### `strictPort`
+
+**Optional**
+
+**Type: `boolean`**
+
+**Default: `false`**
+
+When set to `true`, the dev server will fail to start if the specified `port` is already in use. When set to `false`, the dev server will try the next available port if the specified port is in use.
+
+### `reloadStrategy`
+
+**Optional**
+
+**Type: `'hmr' | 'pageReload' | null`**
+
+**Default: `hmr`**
+
+When files are watched and updated, by default the dev server will use `hmr` (Hot Module Replacement) to update the page without a full page refresh.
+To have the page do a full refresh use `pageReload`. To disable any reloading, use `null`.
+
+### `root`
+
+**Optional**
+
+**Type: `string`**
+
+**Default: `www` output directory if exists, project root otherwise**
+
+The directory to serve files from.
diff --git a/versioned_docs/version-v4.42/config/docs.md b/versioned_docs/version-v4.42/config/docs.md
new file mode 100644
index 000000000..2ceb4458c
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/docs.md
@@ -0,0 +1,44 @@
+---
+title: Documentation Generation Config
+sidebar_label: Docs Config
+description: Documentation Generation Config
+slug: /docs-config
+---
+
+# Docs Config
+
+The `docs` config option allows global configuration of certain behaviors related to [documentation generation output targets](../documentation-generation/01-overview.md).
+
+:::note
+These configurations are **global** and will be applied to all output target instances including those defined in the [`outputTargets`](../output-targets/01-overview.md)
+configuration, as well as those injected by CLI flags (like `--docs`).
+:::
+
+## markdown
+
+The `markdown` config object allows certain customizations for markdown files generated by the [`docs-readme` output target](../documentation-generation/docs-readme.md) or the
+`--docs` CLI flag.
+
+### targetComponent
+
+**Optional**
+
+**Default: `{ textColor: '#333', background: '#f9f' }`**
+
+This option allows you to change the colors used when generating the dependency graph mermaid diagrams for components. Any hex color string is a valid
+value.
+
+```tsx title="stencil.config.ts"
+import { Config } from '@stencil/core';
+
+export const config: Config = {
+ docs: {
+ markdown: {
+ targetComponent: {
+ textColor: '#fff',
+ background: '#000',
+ },
+ },
+ },
+};
+```
diff --git a/versioned_docs/version-v4.42/config/extras.md b/versioned_docs/version-v4.42/config/extras.md
new file mode 100644
index 000000000..70085fc9e
--- /dev/null
+++ b/versioned_docs/version-v4.42/config/extras.md
@@ -0,0 +1,188 @@
+---
+title: Extras Config
+sidebar_label: Extras
+description: Extras Config
+slug: /config-extras
+---
+
+# Extras
+
+The `extras` config contains options to enable new/experimental features in
+Stencil, add & remove runtime for DOM features that require manipulations to
+polyfills, etc. For example, not all DOM APIs are fully polyfilled when using
+the Slot polyfill. Most of these are opt-in, since not all users require the
+additional runtime.
+
+### appendChildSlotFix
+
+By default, the slot polyfill does not update `appendChild()` so that it appends new child nodes into the correct child slot like how shadow dom works. This is an opt-in polyfill for those who need it.
+
+### cloneNodeFix
+
+By default, the runtime does not polyfill `cloneNode()` when cloning a component that uses the slot polyfill. This is an opt-in polyfill for those who need it.
+
+### tagNameTransform
+
+The `tagNameTransform` option in the `extras` config enables support for customizing the tag names of your Stencil components at runtime. This is especially useful if you want to add a prefix, suffix, or otherwise modify the tag names when registering your custom elements, for example to avoid naming conflicts.
+
+When `tagNameTransform` is enabled in your `stencil.config.ts`:
+
+```typescript
+extras: {
+ tagNameTransform: true
+}
+```
+
+You can use the `transformTagName` function when calling `defineCustomElements` in your consuming project:
+
+```typescript
+import { defineCustomElements } from 'my-button/loader';
+
+defineCustomElements(window, {
+ transformTagName: (tagName: string) => `${tagName}`
+} as never);
+```
+
+In this example, the function simply returns the original tag name, but you can customize it as needed. For example, to add a suffix:
+
+```typescript
+defineCustomElements(window, {
+ transformTagName: (tagName: string) => `${tagName}-v1`
+} as never);
+```
+
+With this configuration, a component originally named `` would be registered as ``.
+
+**Note:**
+- The `tagNameTransform` option in your Stencil config enables this feature at build time.
+- The `transformTagName` function is used at runtime when registering the components.
+
+### enableImportInjection
+
+In some cases, it can be difficult to lazily load Stencil components in a separate project that uses a bundler such as
+[Vite](https://vitejs.dev/).
+
+Enabling this flag will allow downstream projects that consume a Stencil library and use a bundler such as Vite to lazily load the Stencil library's components.
+
+In order for this flag to work:
+
+1. The Stencil library must expose lazy loadable components, such as those created with the
+ [`dist` output target](../output-targets/dist.md)
+2. The Stencil library must be recompiled with this flag set to `true`
+
+This flag works by creating dynamic import statements for every lazily loadable component in a Stencil project.
+Users of this flag should note that they may see an increase in their bundle size.
+
+Defaults to `false`.
+
+### experimentalImportInjection
+
+:::caution
+This flag has been deprecated in favor of [`enableImportInjection`](#enableimportinjection), which provides the same
+functionality. `experimentalImportInjection` will be removed in a future major version of Stencil.
+:::
+
+In some cases, it can be difficult to lazily load Stencil components in a separate project that uses a bundler such as
+[Vite](https://vitejs.dev/).
+
+This is an experimental flag that, when set to `true`, will allow downstream projects that consume a Stencil library
+and use a bundler such as Vite to lazily load the Stencil library's components.
+
+In order for this flag to work:
+
+1. The Stencil library must expose lazy loadable components, such as those created with the
+ [`dist` output target](../output-targets/dist.md)
+2. The Stencil library must be recompiled with this flag set to `true`
+
+This flag works by creating dynamic import statements for every lazily loadable component in a Stencil project.
+Users of this flag should note that they may see an increase in their bundle size.
+
+Defaults to `false`.
+
+### experimentalScopedSlotChanges
+
+This option updates runtime behavior for Stencil's support of slots in **scoped** components to match more closely with
+the native Shadow DOM behaviors.
+
+When set to `true`, the following behaviors will be applied:
+
+- Stencil will hide projected nodes that do not have a destination `slot` ([#2778](https://github.com/ionic-team/stencil/issues/2877)) (since v4.10.0)
+- The `textContent` getter will return the text content of all nodes located in a slot (since v4.10.0)
+- The `textContent` setter will overwrite all nodes located in a slot (since v4.10.0)
+
+Defaults to `false`.
+
+:::note
+These behaviors only apply to components using scoped encapsulation!
+:::
+
+### experimentalSlotFixes
+
+This option enables all current and future slot-related fixes. When enabled it
+will enable the following options, overriding their values if they are
+specified separately:
+
+- [`slotChildNodesFix`](#slotchildnodesfix)
+- [`scopedSlotTextContentFix`](#scopedslottextcontentfix).
+- [`appendChildSlotFix`](#appendchildslotfix)
+- [`cloneNodeFix`](#clonenodefix)
+
+Slot-related fixes to the runtime will be added over the course of Stencil v4,
+with the intent of making these the default behavior in Stencil v5. When set to
+`true` fixes for the following issues will be applied:
+
+- Elements rendered outside of slot when shadow not enabled [(#2641)](https://github.com/ionic-team/stencil/issues/2641) (since v4.2.0)
+- A slot gets the attribute hidden when it shouldn't [(#4523)](https://github.com/ionic-team/stencil/issues/4523) (since v4.7.0)
+- Nested slots mis-ordered when not using Shadow DOM [(#2997)](https://github.com/ionic-team/stencil/issues/2997) (since v4.7.0)
+- Inconsistent behavior: slot-fb breaks styling of default slot content in component with 'shadow: false' [(#2937)](https://github.com/ionic-team/stencil/issues/2937) (since v4.7.2)
+- Slot content went missing within dynamic component [(#4284)](https://github.com/ionic-team/stencil/issues/4284) (since v4.8.2)
+- Slot element loses its parent reference and disappears when its parent is rendered conditionally [(#3913)](https://github.com/ionic-team/stencil/issues/3913) (since v4.8.2)
+- Failed to execute 'removeChild' on 'Node' [(#3278)](https://github.com/ionic-team/stencil/issues/3278) (since v4.9.0)
+- React fails to manage children in Stencil slot [(#2259)](https://github.com/ionic-team/stencil/issues/2259) (since v4.9.0)
+- Slot name is not updated when it is bind to a prop [(#2982)](https://github.com/ionic-team/stencil/issues/2982) (since 4.12.1)
+- Conditionally rendered slots not working [(#5335)](https://github.com/ionic-team/stencil/issues/5335) (since 4.13.0)
+
+:::note
+New fixes enabled by this experimental flag are not subject to Stencil's
+[semantic versioning policy](../reference/versioning.md).
+:::
+
+### lifecycleDOMEvents
+
+Dispatches component lifecycle events. By default these events are not dispatched, but by enabling this to `true` these events can be listened for on `window`. Mainly used for testing.
+
+| Event Name | Description |
+| ----------------------------- | ------------------------------------------------------ |
+| `stencil_componentWillLoad` | Dispatched for each component's `componentWillLoad`. |
+| `stencil_componentWillUpdate` | Dispatched for each component's `componentWillUpdate`. |
+| `stencil_componentWillRender` | Dispatched for each component's `componentWillRender`. |
+| `stencil_componentDidLoad` | Dispatched for each component's `componentDidLoad`. |
+| `stencil_componentDidUpdate` | Dispatched for each component's `componentDidUpdate`. |
+| `stencil_componentDidRender` | Dispatched for each component's `componentDidRender`. |
+
+### scopedSlotTextContentFix
+
+An experimental flag that when set to `true`, aligns the behavior of invoking the `textContent` getter/setter on a scoped component to act more like a component that uses the shadow DOM. Specifically, invoking `textContent` on a component will adhere to the return values described in [MDN's article on textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#description). Defaults to `false`.
+
+### scriptDataOpts
+
+:::caution
+This option has been deprecated and will be removed in the next major Stencil release.
+:::
+
+It is possible to assign data to the actual `
+
+
+
+
+