1.3.1 • Published 4 years ago

react-editable-title v1.3.1

Weekly downloads
63
License
MIT
Repository
github
Last release
4 years ago

react-editable-title Build Status

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} 
          editButton
          editControls
          placeholder="Type here"
          cb={handleTextUpdate}
         />
  )
}

Edit 7w063kppz6

API

AttributeTypeDescriptionRequired
textstringText to be displayedYes
textStyleCSSPropertiesCustom text stylingNo
cbfunctionInvoked when the text has been editedYes
onEditCancelfunctionInvoked when the edit has been canceledNo
onValidationFailfunctionInvoked when the text hasn't matched the regexNo
editButtonbooleanSets the visibility of the edit button. Default is falseNo
editButtonStyleCSSPropertiesCustom edit button stylingNo
editControlButtonsbooleanSets the visibility of the control buttons. Default is falseNo
saveButtonStyleCSSPropertiesCustom save button stylingNo
cancelButtonStyleCSSPropertiesCustom cancel button stylingNo
placeholderstringPlaceholder text of the input elementNo
saveOnBlurbooleanAttempts to save text input on unfocus. Default is trueNo
seamlessInputbooleanPresents text-editor alike experience. Default is falseNo
inputStyleCSSPropertiesCustom input stylingNo
isFocusedbooleanExternally sets the state of input focus. Default is falseNo
inputPatternstringRegex pattern of desired inputNo
inputErrorMessagestringInfo message about mismatch of inputNo
inputErrorMessageStyleCSSPropertiesCustom error message stylingNo
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

1.3.1

4 years ago

1.3.0

4 years ago

1.2.9

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

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago