2.0.8 • Published 4 years ago

@42shadow42/react-editable-title v2.0.8

Weekly downloads
-
License
GPL 3.0
Repository
github
Last release
4 years ago

An editable title implementation for react.

Installation

npm install react-editable-title

Usage

import React, { useState } from 'react'
import Editable from 'react-editable-title'

const App = () => {
  const [text, setText] = useState('')

  const handleTextUpdate = (current: string) => {
    setText(current)
  }

  return (
        <Editable 
          text={text} 
          placeholder="Type here"
          cb={handleTextUpdate}
         />
  )
}

API

AttributeTypeDescriptionRequired
textstringText to be displayedYes
cbfunctionInvoked when the text has been editedYes
onEditCancelfunctionInvoked when the edit has been canceledNo
onValidationFailfunctionInvoked when the text hasn't matched the regexNo
placeholderstringPlaceholder text of the input elementNo
saveOnBlurbooleanAttempts to save text input on unfocus. Default is trueNo
seamlessInputbooleanPresents text-editor alike experience. Default is falseNo
inputPatternstringRegex pattern of desired inputNo
inputErrorMessagestringInfo message about mismatch of inputNo
inputMinLengthnumberMin length accepted as an inputNo
inputMaxLengthnumberMax length accepted as an inputNo

Features

The component can be controlled by keyboard keys. Hit Enter to save or Esc to cancel your edit. If there is no change in the text, neither Enter nor the Edit button would work.

You also can control the validity of inputs with the regex you would provide. If the regex won't match the user input then your desired error message will be shown below of the input field.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate. Thanks :raised_hands:

License

GPL

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.0

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago