1.3.1-alpha.1 • Published 5 years ago

@fes300/react-editable-text v1.3.1-alpha.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

react-editble-text

install

$> yarn add @fes300/react-editable-text

N.B.: the component exposes monadic APIs, therefore it has fp-ts as a peer dependency

description

react-editable-text is a very simple component to make your strings editable by double-clicking on them: (detailed and interactive documentation can be found at https://determined-nobel-255bb0.netlify.app/?path=/docs/editabletext--mirror)

<EditableText
  text={some('editable text')}
  onSetText={(newText: Option<string>) => {
    /* save my new text */
  }}
  RenderText={({ TextComponent }) => <TextComponent />}
  RenderInput={({ InputComponent }) => <InputComponent />}
/>

InputComponent supports many different input types:

<EditableText
  text={some('editable text')}
  onSetText={(newText: Option<string>) => {
    /* save my new text */
  }}
  RenderText={({ TextComponent }) => <TextComponent />}
  RenderInput={({ InputComponent }) => (
    <InputComponent
      type={'tel' || 'url' || 'week' || 'date' || 'color' || 'month' || 'datetime-local'}
    />
  )}
/>

props

propdescriptiontypeoptionaldefault
textthe text valueOption\<string>false-
onSetTextcallback triggered when the user save (by pressing enter) the new text(newText: Option\<string>) => voidfalse-
RenderInputfunction to render a custom InputTextEditableInputComponentfalse-
RenderTextfunction to render a custom TextTextEditableTextComponentfalse-
classNameclassName attached to the Text/Input wrapperstringtrue""
disabledif set to true the user will not be able to modify the input or double-clck on the textbooleantruefalse
initialStateif the initial UI shows the Text ot the Input componentEditStatetrue"text"
onChangeTextoptional callback triggered at every change of the input value(newText: Option\<string>) => voidtrue() => {}
onClickoptional callback triggered when the text is clicked once(newText: Option\<string>) => voidtrue() => {}
type EditState = 'edit' | 'text';

type TextEditableInputComponent = React.FC<{
  InputComponent: React.FC<{
    className?: string;
    style?: React.CSSProperties;
    type?: 'tel' | 'url' | 'week' | 'date' | 'color' | 'month' | 'datetime-local';
  }>
}>;

type TextEditableTextComponent = React.FC<{
  TextComponent: React.FC<{ TextComponent: React.FC<{
    className?: string;
    style?: React.CSSProperties;
  }>
}>;
1.3.1-alpha.1

5 years ago

1.3.1-alpha.0

5 years ago

1.2.5

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.22

5 years ago

1.1.21

5 years ago

1.1.20

5 years ago

1.1.19

5 years ago

1.1.18

5 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.9

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago