`
Description: Optionally apply an external linked style sheet (called from connectedCallback)
Parameters:
- `url`: The URL for the linked style sheet (from description, not signature)
- `ensureId(): void`
Description: Ensure that the component instance has a unique ID & check again if uib loaded
- `prependStylesheet(cssText: string, order?: number): Element`
Description: Attaches a new stylesheet before all other stylesheets in the light DOM
Parameters:
- `cssText`: CSS text to inject directly
- `order`: Optional order/priority for stylesheet placement. Lower numbers = higher priority (inserted first). Defaults to 0.
- `uibSend(evtName: string, data: string): void`
Description: Send a message to the Node-RED server via uibuilder if available. NB: These web components are NEVER dependent on Node-RED or uibuilder.
Parameters:
- `evtName`: The event name to send
- `data`: The data to send
Slots:
- (unnamed):
Description: Container contents. See https://github.com/runem/web-component-analyzer?tab=readme-ov-file#-how-to-document-your-components-using-jsdoc
```
--------------------------------
### Set JSON Property on syntax-highlight Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/Beta.html
Example demonstrating how to set the `json` property on an instance of the `syntax-highlight` web component using JavaScript.
```JavaScript
const showMsg = document.getElementsByTagName('syntax-highlight')[0]
showMsg.json({....})
```
--------------------------------
### Basic Usage of component-template Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/readme/component-template.md
Demonstrates the basic HTML usage of the `component-template` web component, showing how to instantiate it and link an external stylesheet.
```html
```
--------------------------------
### Execute Web Component Development Workflow Commands
Source: https://github.com/totallyinformation/web-components/blob/main/docs/dev.md
This snippet outlines the essential `npm` commands used throughout the web component development lifecycle, from continuous watching and building to testing and preparing documentation bundles. These commands automate compilation, testing, and deployment preparation.
```Shell
npm run watch
npm run build
npm run test
npm run buildDocBundle
```
--------------------------------
### Overriding labelled-value CSS Variables in HTML
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/beta/labelled-value.md
Shows examples of how to override the default CSS variables for specific `labelled-value` instances directly within the HTML `style` attribute.
```html
```
--------------------------------
### Example Usage of State Timeline Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/alpha_state-timeline.js.html
Demonstrates how to embed the `state-timeline` web component into an HTML page for displaying state changes.
```HTML
```
--------------------------------
### HTML Usage Example for simple-container Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/alpha/simple-container.md
Demonstrates how to embed the `simple-container` web component in an HTML document, acting as a flexible wrapper for other custom elements like `simple-card`.
```html
This is a simple card.
This is another simple card.
```
--------------------------------
### syntax-highlight Web Component API Reference
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/beta/syntax-highlight.md
Comprehensive API documentation for the `syntax-highlight` web component, detailing its configurable attributes, accessible properties, and utility methods for programmatically highlighting data.
```APIDOC
syntax-highlight Web Component API:
Attributes:
auto:
Description: Automatically highlight JSON or JavaScript objects. Default is `true`.
Properties:
auto: boolean
Attribute: `auto`
Default: `true`
Description: Automatically highlight JSON or JavaScript objects.
json: string | object
Attribute: N/A
Default: ""
Description: The JSON or JavaScript object to highlight.
Methods:
highlight(data: any): HTMLElement (Static)
Description: Returns highlighted JSON wrapped in a `` tag.
```
--------------------------------
### Web Component Analyzer CLI Commands for Documentation Generation
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/alpha_uib-theme-changer.js.html
Provides command-line interface (CLI) examples for using `web-component-analyzer` to generate and update documentation for web components. This includes commands for creating JSDoc-based documentation and generating VS Code custom data files, facilitating consistent and automated documentation workflows.
```Shell
npx web-component-analyzer ./components/button-send.js
```
```Shell
npx web-component-analyzer ./components/*.js --format vscode --outFile ./vscode-descriptors/ti-web-components.html-data.json
```
--------------------------------
### syntax-highlight Web Component Properties API
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/Beta.html
Detailed API reference for the `syntax-highlight` web component, outlining its configurable properties, their types, and descriptions.
```APIDOC
"syntax-highlight" Component Properties:
inherit-style: string | boolean
Optional. Load external styles into component (only useful if using template). If present but empty, will default to './index.css'. Optionally give a URL to load.
name: string
Optional. HTML name attribute. Included in output _meta prop. Other watched attributes: None PROPS FROM BASE: (see TiBaseComponent) OTHER STANDARD PROPS:
componentVersion: string
Static. The component version string (date updated). Also has a getter that returns component and base version strings. Other props:
json: object | JSON | string
JSON to convert. By default, all attributes are also created as properties.
```
--------------------------------
### Basic Usage of simple-card Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/alpha/simple-card.md
Demonstrates how to embed the `simple-card` web component in HTML, including examples for basic content display and utilizing the optional `header` and `footer` slots for structured content.
```HTML
Some content in a card.
```
```HTML
Hello, in a card
Some other header
Some footer
```
--------------------------------
### SyntaxHighlight Class API Reference
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/SyntaxHighlight.html
Detailed API documentation for the `SyntaxHighlight` custom element, including its constructor, properties, and methods for managing and displaying syntax-highlighted JSON.
```APIDOC
Class: SyntaxHighlight
Constructor:
new SyntaxHighlight()
- Description: Initializes a new SyntaxHighlight instance. Note: Attributes are not available directly in the constructor; use `connectedCallback` for attribute references.
Members:
componentVersion
- Type: string
- Description: The version string of the component.
json
- Type: object | JSON
- Description: Property to set a JSON object for display. Example usage: `Element.json = {...}`.
(static) observedAttributes
- Type: Array
- Description: A static property that defines which HTML attributes the component should observe for changes. When these attributes change, `attributeChangedCallback` is invoked.
Methods:
attributeChangedCallback(attrib: string, oldVal: string, newVal: string)
- Description: Invoked when one of the `observedAttributes` changes. Note: all attribute values are always strings.
- Parameters:
- `attrib`: (string) The name of the watched attribute that has changed.
- `oldVal`: (string) The previous value of the attribute.
- `newVal`: (string) The new value of the attribute.
connectedCallback()
- Description: Lifecycle callback invoked when the custom element is first connected to the document's DOM.
disconnectedCallback()
- Description: Lifecycle callback invoked when the custom element is disconnected from the document's DOM.
(static) highlight(json: object | JSON) -> HTMLElement
- Description: A static method that takes a JSON object and returns its formatted HTML representation, typically wrapped in a `` tag for display.
- Parameters:
- `json`: (object | JSON) The JSON object to be converted and highlighted.
- Returns:
- `HTMLElement`: An HTML element containing the syntax-highlighted JSON.
```
--------------------------------
### SmartTable: Build Column Metadata
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/SmartTable.html
An internal method responsible for constructing the column metadata for the `SmartTable`. It can optionally derive column definitions directly from the provided data, simplifying table setup.
```APIDOC
_buildCols(fromData)
- Description: Builds the column metadata for the table.
- Parameters:
- fromData: boolean - If true, columns are calculated and built based on the provided data.
```
--------------------------------
### Visual Log Web Component (`visual-log`)
Source: https://github.com/totallyinformation/web-components/blob/main/docs/roadmap.md
Describes a component that creates an on-page log element. This log expands to a set number of lines and then drops older entries from the start.
```APIDOC
visual-log:
Description: Creates a log element on-page that expands to a set number of lines then drops from the start.
```
--------------------------------
### Test Release Process with Dry Run
Source: https://github.com/totallyinformation/web-components/blob/main/libs/RELEASE.md
Command to perform a dry run of the release process. This allows users to preview all actions the script would take without actually making any changes, useful for testing and validation.
```bash
npm run release:dry-run
```
--------------------------------
### chart-statetrail Range Mapping Object Schema and Default
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/experiments/chart-statetrail.md
Defines the required JSON array structure for mapping input values to colors and titles, used by the `chart-statetrail` component for visual representation. Includes a default example.
```APIDOC
Range mapping object:
[
{ "range": [, ], "title": , "color": },
...
]
Default example:
[
{ "range": [0, 0.3], "title": "Off", "color": "var(--failure, red)" },
{ "range": [0.3, 0.6], "title": "Partial", "color": "var(--warning, #c8b421)" },
{ "range": [0.6, 1], "title": "On", "color": "var(--success, green)" }
]
```
--------------------------------
### syntax-highlight Web Component API Reference
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/Beta.html
Comprehensive API documentation for the `syntax-highlight` web component, detailing its custom events and properties. This zero-dependency component converts JSON objects into HTML for display.
```APIDOC
syntax-highlight Web Component API
Custom Events:
- "component-template:connected"
Description: Triggered when an instance of the component is attached to the DOM.
Details: `evt.details` contains the details of the element.
- "component-template:ready"
Description: Alias for "component-template:connected". Indicates the instance is ready to handle property & attribute changes.
- "component-template:disconnected"
Description: Triggered when an instance of the component is removed from the DOM.
Details: `evt.details` contains the details of the element.
- "component-template:attribChanged"
Description: Triggered when a watched attribute changes.
Details: `evt.details.data` contains the details of the change.
Note: Listeners can be attached either to the `document` or to the specific element instance.
Properties:
- `inherit-style`
Type: string | boolean
Description: Optional. Loads external styles into the component (only useful if using a template). If present but empty, defaults to './index.css'. Can also be a URL to load.
- `name`
Type: string
Description: Optional. HTML name attribute. Included in the output `_meta` property.
- `componentVersion`
Type: string
Description: Static. The component version string (date updated). Has a getter returning component and base version strings.
- `json`
Type: object | JSON | string
Description: The JSON data to convert. By default, all attributes are also created as properties.
```
--------------------------------
### API Methods for visible-console Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/readme/component-template.md
Comprehensive documentation for all public methods available on the `visible-console` web component, including their signatures, descriptions, parameters, and return types.
```APIDOC
Methods:
checkType(input: *): string
- Description: Find out the input JavaScript var type
- Parameters:
- input: The JavaScript var to type
- Returns: string
config(config: object|undefined): object
- Description: OPTIONAL. Update runtime configuration, return complete config
- Parameters:
- config: If present, partial or full set of options. If undefined, fn returns the current full option settings
- Returns: object
createHTMLVisualizer(input: *): HTMLDivElement
- Description: Creates an HTML visualisation of the input
- Parameters:
- input: Input data value to visualise
- Returns: HTMLDivElement
createShadowSelectors(): void
- Description: Creates the $ and $$ fns that do css selections against the shadow dom
- Returns: void
doInheritStyles(): Promise
- Description: Optionally apply an external linked style sheet (called from connectedCallback)
- Parameters:
- url: The URL for the linked style sheet
- Returns: Promise
ensureId(): void
- Description: Ensure that the component instance has a unique ID & check again if uib loaded
- Returns: void
newLog(type: string, args: string): void
- Description: Creates a new HTML log entry
- Parameters:
- type: The log type
- args: The arguments to log
- Returns: void
prependStylesheet(cssText: string, order?: number): Element
- Description: Attaches a new stylesheet before all other stylesheets in the light DOM
- Parameters:
- cssText: CSS text to inject directly
- order: Optional order/priority for stylesheet placement. Lower numbers = higher priority (inserted first). Defaults to 0.
- Returns: Element
redirectConsole(): void
- Description: Capture console.xxxx and write to the div. NB: Cannot use bind here and so console output will have the wrong file/line number
- Returns: void
uibSend(evtName: string, data: string): void
- Description: Send a message to the Node-RED server via uibuilder if available. NB: These web components are NEVER dependent on Node-RED or uibuilder.
- Parameters:
- evtName: The event name to send
- data: The data to send
- Returns: void
```
--------------------------------
### Standard Package Release Workflow
Source: https://github.com/totallyinformation/web-components/blob/main/libs/RELEASE.md
A three-step process outlining the typical workflow for a standard package release. This involves updating the package version, committing the version change, and then executing the full release script.
```bash
# 1. Update version in package.json
npm version patch # or minor, major
# 2. Commit the version change
git add package.json
git commit -m "chore: bump version to 1.1.1"
# 3. Run the release script
npm run release
```
--------------------------------
### JavaScript Integration of data-list with UIBUILDER
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/experiments/edgewise-meter.md
Demonstrates how to initialize `uibuilder`, import the `data-list` web component, and programmatically populate and update a `data-list` instance. It includes an example of handling `uibuilder` messages to dynamically modify list entries.
```javascript
/** Main app script
* NOTES:
* - Any imports are relative to THIS script.
*/
// Load the uibuilder client library - to load here, you have to use the module version.
import '../uibuilder/vendor/@totallyinformation/web-components/libs/uibuilder.module.js' // Does NOT LOAD any exports
// Load the component. The component self-registers & adds the `DataList` object to the `window` global.
import '../uibuilder/vendor/@totallyinformation/web-components/components/data-list.js'
// Start uibuilder
uibuilder.start()
// Get a reference to your data-list tag
const dl1 = $('#dl1')
/** Initialise the data-list using an Object.
* Uses uibuilder's $ shortcut to reference.
* When using an object, each `` will have its id set to the key & the slot text to the value.
* If you use an array, each `` will get a numbered id.
*/
dl1.data = {
"one": "This is the first list entry",
"two": "This is the second list entry",
"three": "This is the third list entry",
}
// Change one of the entries in the list from a uibuilder msg from Node-RED
uibuilder.onTopic('update dl1', function(msg) {
console.log('>> onTopic `update dl1` >>', msg)
dl1.entry(msg.entryRef, msg.payload)
})
/* Example msg
{
"topic": "update dl1",
"entryRef": "two",
"payload": "This is the second entry amended"
}
*/
```
--------------------------------
### Basic Usage of smart-table Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/alpha/smart-table.md
Demonstrates how to embed the `smart-table` web component in HTML and populate it with data using JavaScript after the DOM content is loaded. The example shows setting an array of objects as table data.
```html
```
```js
const arrObj = [
{"COL1":"R1C1","COL2":"R1C2","COL3":"R1C3"},
{"COL1":"R2C1","COL2":"R2C2","COL3":"R2C"},
{"COL1":"R3C1","COL2":"R3C2","COL3":"R3C3"}
]
const st1 = document.getElementById('st1')
/** We need to wait for everything to be loaded before using components from JavaScript */
addEventListener("DOMContentLoaded", (event) => {
st1.data = arrObj
})
```
--------------------------------
### Basic HTML Usage for data-list Web Component
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/live/data-list.md
Demonstrates various ways to instantiate the `data-list` web component in HTML, including overriding default styles, using object/array inputs via global variables, and setting list types.
```html
Items added by JavaScript
Items added by global object variable
Items added by global array variable
```
--------------------------------
### hello-world Web Component Properties
Source: https://github.com/totallyinformation/web-components/blob/main/docs/readme/hello-world.md
Defines the configurable properties for the `hello-world` web component, including their corresponding HTML attributes and data types. These properties allow customization of the component's behavior and appearance.
```APIDOC
hello-world Component Properties:
- Property: `name`
Attribute: `name`
Type: `string | null`
Description: The name property of the component, which can be a string or null.
```
--------------------------------
### HtmlInclude: Web Component Lifecycle Methods
Source: https://github.com/totallyinformation/web-components/blob/main/docs/jsdoc/html-include.js.html
Implements standard Web Component lifecycle callbacks: the `constructor` for initial setup, `connectedCallback` which runs when an instance is added to the DOM, and `disconnectedCallback` when an instance is removed from the DOM.
```javascript
/** NB: Attributes not available here - use connectedCallback to reference */
constructor() {
super()
// Only attach the shadow dom if code and style isolation is needed - comment out if shadow dom not required
if (template && template.content) this._construct(template.content.cloneNode(true))
}
/** Runs when an instance is added to the DOM */
connectedCallback() {
this._connect() // Keep at start.
this._ready() // Keep at end. Let everyone know that a new instance of the component has been connected & is ready
}
/** Runs when an instance is removed from the DOM */
disconnectedCallback() {
this._disconnect() // Keep at end.
}
```
--------------------------------
### html-include Web Component Methods
Source: https://github.com/totallyinformation/web-components/blob/main/docs/readme/html-include.md
Outlines the public methods available on the `html-include` web component for runtime configuration, content inclusion, style management, and communication with Node-RED via uibuilder.
```APIDOC
Methods:
config(config: object|undefined): object
Description: OPTIONAL. Update runtime configuration, return complete config.
Parameters:
config: If present, partial or full set of options. If undefined, fn returns the current full option settings.
createShadowSelectors(): void
Description: Creates the $ and $$ fns that do css selections against the shadow DOM.
doInclude(url: string | URL): Promise
Description: Replaces the shadow DOM content with the imported HTML.
Parameters:
url: URL of the resource to import.
doInheritStyles(): Promise
Description: Optionally apply an external linked style sheet (called from connectedCallback).
Parameters:
url: The URL for the linked style sheet.
ensureId(): void
Description: Ensure that the component instance has a unique ID & check again if uib loaded.
prependStylesheet(cssText: string, order?: number): Element
Description: Attaches a new stylesheet before all other stylesheets in the light DOM.
Parameters:
cssText: CSS text to inject directly.
order: Optional order/priority for stylesheet placement. Lower numbers = higher priority (inserted first). Defaults to 0.
uibSend(evtName: string, data: string): void
Description: Send a message to the Node-RED server via uibuilder if available. NB: These web components are NEVER dependent on Node-RED or uibuilder.
Parameters:
evtName: The event name to send.
data: The data to send.
```
--------------------------------
### HTML Structure for data-list Web Component (With UIBUILDER)
Source: https://github.com/totallyinformation/web-components/blob/main/docs/components/experiments/edgewise-meter.md
Outlines the HTML setup for integrating `data-list` and `definition-list` web components within a UIBUILDER environment. It shows various ways to embed the components, including assigning IDs and names.
```html
Jim's Simple List
Simple List
```
--------------------------------
### Run Web Component Generator in Interactive Mode
Source: https://github.com/totallyinformation/web-components/blob/main/libs/CREATE-COMPONENT.md
Executes the web component generator script in interactive mode, prompting the user for input to create a new component. This mode is suitable for guided component creation.
```bash
npm run new-component
```