1.15.0-beta.1 • Published 21 days ago

@squiz/xaccel-assisted-input v1.15.0-beta.1

Weekly downloads
-
License
ISC
Repository
-
Last release
21 days ago

Assisted Input

Description

The AssistedInput component enhances user input by providing suggestions or results based on what the user types. It's meant to be flexible and integrate with various types of content that might need autocomplete functionality, such as search bars or data entry fields.

The component consists of a few subcomponents, including a results container and a label, which allows for complex interaction and presentation of data.

Components properties

Property NameProperty DescriptionProperty TypeIsRequired
nameUnique identifier for the input, used in form submissions.stringx
showClearDetermines if a clear button should be displayed.bool
clearIconCustom icon to be used for the clear button.node
preloadValueFromNameParamPreloads the input with a value from URL parameters, if available.bool
classNameOverwrite ClassNameclassNameOverride
autofocusAutomatically focus the input upon component mount.bool
onChangeValueCallback function called with the current input value.func

For more information about className please visit packages/utility/functions/src/generateClasses.js

Subcomponents and Context

  1. AssistedInputContainer - wraps the AssistedInput and other related components, managing their shared state and interactions. It provides a context for communication between the input field and the results list, handling focus, input changes, and keyboard navigation.

  2. AssistedInputContext - enables the sharing of state and interactions among AssistedInput and its subcomponents. It contains: input value, active descendant, and fetching state.

  3. AssistedInputLabel - optional label component for the AssistedInput, indicating the purpose of the input field.

  4. AssistedInputResultsContainer - a container for the results or suggestions displayed as the user types. It listens to the context for changes in the input field.

Conditional component presentation

The appearance and behavior of the AssistedInput component can be customized through props - for example, setting showClear to true adds a clear button, allowing users to clear their input.

The preloadValueFromNameParam can automatically fill the input based on URL parameters, preloading expected values.

Props Example:

<AssistedInput
  name="search"
  showClear={true}
  clearIcon={<ClearIcon />}
  preloadValueFromNameParam={true}
  className="customClass"
  autofocus={true}
  onChangeValue={(value) => console.log(value)}
/>

Usage

Install the package by running: npm i @squiz/xaccel-assisted-input

import { AssistedInputContainer, AssistedInput, AssistedInputResultsContainer, AssistedInputLabel } from '@squiz/xaccel-assisted-input';

function SomeReactComponent({ id }) {
    return (
        <form>
            <AssistedInputContainer id={id} onSubmit={() => console.log('Submit')}>
                <AssistedInputLabel>Search</AssistedInputLabel>
                <AssistedInput showClear />
                <AssistedInputResultsContainer>
                    Enter something to see results
                </AssistedInputResultsContainer>
            </AssistedInputContainer>
        </form>
    );
}

export default SomeReactComponent;
1.14.0-alpha.1

21 days ago

1.15.0-beta.1

21 days ago

1.15.0-beta.0

2 months ago

1.14.0-alpha.0

2 months ago

1.13.0-alpha.7

3 months ago

1.13.1

3 months ago

1.12.2

4 months ago

1.12.1

4 months ago

1.12.1-beta.3

4 months ago

1.12.1-beta.2

4 months ago

1.13.0-beta.1

4 months ago

1.9.1-alpha.0

4 months ago

1.12.1-alpha.0

4 months ago

1.9.1-beta.0

4 months ago

1.9.0

4 months ago

1.9.0-beta.38

4 months ago

1.9.0-beta.36

4 months ago

1.9.0-beta.32

4 months ago

1.11.0-alpha.8

5 months ago

1.11.0-alpha.7

5 months ago

1.9.0-beta.24

6 months ago

1.10.0-alpha.15

6 months ago

1.10.0-alpha.13

6 months ago

1.10.0-alpha.12

6 months ago

1.10.0-alpha.5

7 months ago

1.9.0-beta.13

7 months ago

1.9.0-alpha.13

7 months ago

1.9.0-beta.8

7 months ago

1.9.0-alpha.9

7 months ago

1.9.0-alpha.8

7 months ago

1.9.0-beta.3

7 months ago

1.9.0-alpha.4

7 months ago

1.9.0-alpha.3

7 months ago

1.9.0-beta.2

7 months ago

1.9.0-beta.0

7 months ago

1.6.0-beta.0

7 months ago

1.5.1-beta.4

7 months ago

1.6.0-alpha.5

7 months ago

1.6.0-alpha.4

7 months ago

1.5.1-beta.3

7 months ago

1.5.1-beta.0

7 months ago

1.5.0-beta.1

7 months ago

1.5.1-alpha.2

7 months ago

1.5.1-alpha.1

7 months ago

1.5.0-beta.0

7 months ago

1.4.2-beta.0

7 months ago

1.4.2-alpha.0

7 months ago

1.4.0

8 months ago

1.3.0

8 months ago

1.2.2

8 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.0

9 months ago