1.1.1 • Published 2 months ago

@equinor/fusion-wc-textinput v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

<fusion-wc-textinput> Published on npm

Storybook

Material Web Component

Installation

npm install @equinor/fusion-wc-textinput

Example Usage

<fwc-textinput label='My Label' icon="settings"></fwc-textinput>

Properties/Attributes

NameTypeDescription
valuestringThe input control's value.
typeTextInputType*A string specifying the type of control to render.
variantTextInputVariant**Input style variant to render.
labelstringSets floating label value.
placeholderstringSets disappearing input placeholder.
prefixstringPrefix text to display before the input.
suffixstringSuffix text to display after the input.
iconIconName***Leading icon to display in input. See fwc-icon.
iconTrailingIconName***Trailing icon to display in input. See fwc-icon.
disabledbooleanWhether or not the input should be disabled.
charCounterboolean | TextInputCharCounter****Note: requries maxLength to be set. Display character counter with max length.
helperstringHelper text to display below the input. Display default only when focused.
helperPersistentbooleanAlways show the helper text despite focus.
requiredbooleanDisplays error state if value is empty and input is blurred.
maxLengthnumberMaximum length to accept input.
validationMessagestringMessage to show in the error color when the textinput is invalid. (Helper text will not be visible)
patternstringHTMLInputElement.prototype.pattern (empty string will unset attribute)
minnumber|stringHTMLInputElement.prototype.min (empty string will unset attribute)
maxnumber|stringHTMLInputElement.prototype.max (empty string will unset attribute)
sizenumber|nullHTMLInputElement.prototype.size (null will unset attribute)
stepnumber|nullHTMLInputElement.prototype.step (null will unset attribute)
autoValidatebooleanReports validity on value change rather than only on blur.
validityValidityState (readonly)The ValidityState of the textinput.
willValidateboolean (readonly)HTMLInputElement.prototype.willValidate
validityTransformValidityTransform*****|nullCallback called before each validation check. See the validation section for more details.
validateOnInitialRenderbooleanRuns validation check on initial render.
namestringSets the name attribute on the internal input.***

* TextInputType is exported by fwc-textinput.

type TextInputType = 'text'|'search'|'tel'|'url'|'email'|'password'|
    'date'|'month'|'week'|'time'|'datetime-local'|'number'|'color';

** TextInputVariant is exported by fwc-textinput.

export type TextInputVariant = 'filled' | 'outlined';

*** IconName is exported by fwc-icon.

type IconName = keyof typeof edsIcons | string;

**** TextInputCharCounter is exported by fwc-textinput.

type TextInputCharCounter = 'external' | 'internal';

***** ValidityTransform is exported by fwc-textinput.

type ValidityTransform = (value: string, nativeValidity: ValidityState) => Partial<ValidityState>

****** The name property should only be used for browser autofill as webcomponent form participation does not currently consider the name attribute. See #289.

Methods

NameDescription
checkValidity() => booleanReturns true if the textinput passes validity checks. Returns false and fires an invalid event on the textinput otherwise. NOTE: When accessing any property or function that checks validity at textinput initial boot up, you may have to await <fwc-textinput>.updateComplete.
reportValidity() => booleanRuns checkValidity() method, and if it returns false, then it reports to the user that the input is invalid.
setCustomValidity(message:string) => voidSets a custom validity message (also overwrites validationMessage). If this message is not the empty string, then the element is suffering from a custom validity error and does not validate.
layout() => Promise<void>Re-calculate layout. If a textinput is styled with display:none before it is first rendered, and it has a label that is floating, then you must call layout() the first time you remove display:none, or else the notch surrounding the label will not render correctly.

Validation

<fwc-textinput> follows the basic <input> constraint validation model. It exposes:

  • required
  • maxLength
  • pattern
  • min
  • max
  • step
  • validity
  • willValidate
  • checkValidity()
  • reportValidity()
  • setCustomValidity(message)

Additionally, it implements more features such as:

  • validationMessage
  • validateOnInitialRender
  • and validityTransform

By default, <fwc-textinput> will report validation on blur.

1.1.1

2 months ago

1.0.2

7 months ago

1.1.0

5 months ago

1.0.1

7 months ago

0.5.20-next.0

8 months ago

1.0.0

7 months ago

0.5.20-next.1

7 months ago

1.0.3

6 months ago

0.5.21

7 months ago

0.5.20

7 months ago

0.5.18

1 year ago

0.5.19

11 months ago

0.5.17

1 year ago

0.5.16

1 year ago

0.5.14

1 year ago

0.5.15

1 year ago

0.5.13

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.9

2 years ago

0.5.12

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago