0.6.1 • Published 5 months ago

@equinor/fusion-react-textarea v0.6.1

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

@equinor/fusion-react-textarea

Published on npm

Storybook

Fusion Web Component

Installation

npm install @equinor/fusion-react-textarea

Example Usage

<TextArea label='My Label' rows='3' cols='4'>Hello world!</TextArea>

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.
rowsnumberSets number of visible text lines.
colsnumberSets the visible width of the textarea.
placeholderstringSets disappearing input placeholder.
prefixstringPrefix text to display before the input.
suffixstringSuffix text to display after the input.
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 textarea 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 textarea.
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 TextArea.

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

** TextInputVariant is exported by TextArea.

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

*** TextInputCharCounter is exported by TextArea.

type TextInputCharCounter = 'external' | 'internal';

**** ValidityTransform is exported by TextArea.

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 textarea passes validity checks. Returns false and fires an invalid event on the textarea otherwise. NOTE: When accessing any property or function that checks validity at textarea initial boot up, you may have to await <TextArea>.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 textarea 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

<TextArea> 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, <TextArea> will report validation on blur.

0.5.16

8 months ago

0.6.1

5 months ago

0.6.0

7 months ago

0.5.15

1 year ago

0.5.14

2 years ago

0.5.12

2 years ago

0.5.14-313.0

2 years ago

0.5.13

2 years ago

0.5.11

2 years ago

0.5.10

2 years ago

0.5.9

2 years ago

0.5.9-248.0

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.6

2 years ago

0.5.4

3 years ago

0.5.5

2 years ago

0.5.2-filter.4

3 years ago

0.5.2-filter.5

3 years ago

0.5.2-filter.6

3 years ago

0.5.2-filter.7

3 years ago

0.5.2-filter.0

3 years ago

0.5.2-filter.1

3 years ago

0.5.2-filter.2

3 years ago

0.5.2-filter.3

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.2

3 years ago

0.3.0

3 years ago

0.3.1

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