@salesforce-ux/wes-text-input
v0.1.2
Published
A text input enable the user to interact with and input data.
Downloads
7
Readme
@salesforce-ux/wes-text-input
About
Inputs are the text boxes that allow users to input custom text entries with a keyboard.
Getting Started
Let's start by installing wes-text-input as a dependency of your project with npm.
npm i @salesforce-ux/wes-text-input
Distributable
After installation, all the distributables for the wes-text-input
are found under @salesforce-ux/wes-text-input/dist/
folder.
| File Name | Description |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| text-input.css
| The CSS file for wes-text-input
component. |
| text-input.js
| The bundled JS file for wes-text-input
component.This file is useful for Non LWC applications.(see below →) |
Integration
For the sake of understanding, we have categorized the development environment into LWC and Non LWC application. If you are using the Salesforce Experience Cloud platform, WES is supported through an Unlocked Package, see the Confluence page for the WES Unlocked Package.
This Guide covers the integration approach for these two types of application.
For Lightning Web Component(LWC)
Application
Dependency Inclusion
wes-styling-hooks
is a styling dependency for wes-text-input
. Hence, this needs to be embedded into the root of the web app in order to make the wes-text-input
render properly.
<html>
<head>
<link rel="stylesheet" href="/node_modules/@salesforce-ux/wes-styling-hooks/dist/hooks.custom-props.css">
<!-- Your application's other stylesheets go below -->
<link rel="stylesheet" href="...">
</head>
<body>
<!-- Your application -->
</body>
</html>
There are also other ways wes-styling-hooks
can be embedded. Please checkout the wes-styling-hooks
Integration Guide to learn more.
Component CSS Import
/* myComponent.css */
@import '@salesforce-ux/wes-text-input/dist/text-input.css';
HTML Decoration
After that,the HTML of your LWC component template needs to be decorated to have all the named part attributes as per the component's specification. Below is a reference to the component's structure.
<div part="input-text">
<label part="label">
<slot></slot>
</label>
<div part="input-container">
<slot name="start"></slot>
<input part="input" />
<slot name="end"></slot>
</div>
</div>
<slot name="help-text"></slot>
For Non LWC
Application
Dependency Inclusion Read the section above
Component Import
/* myComponent.js */
import WESTextInput from '@salesforce-ux/wes-text-input/dist/text-input';
Component Registration
/* myComponent.js */
customElements.define('wes-text-input', WESTextInput);
Example
Below is one approach to integrate your wes-text-input
component.
Script
/* myComponent.js */
import '@salesforce-ux/wes-styling-hooks/dist/hooks.custom-props.css';
import WESTextInput from '@salesforce-ux/wes-text-input/dist/text-input';
window.customElements.define('wes-text-input', WESTextInput);
HTML
<wes-text-input>
Label
<div slot="help-text">Help text goes here</div>
</wes-text-input>
Interactive Demo
To see more examples with interactive demo, please visit wes Subsytem
's Storybook Environment
Dependencies
This component imports the following dependencies.
Accessibility
All global
aria-*
attributes should follow all interaction requirements per the W3C.When interacting with the associated label via click, it should focus the related input.