@chakra-ui/react#InputProps TypeScript Examples

The following examples show how to use @chakra-ui/react#InputProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegexInputWidget.tsx    From ke with MIT License 5 votes vote down vote up
RegexInputWidget = forwardRef<HTMLInputElement, RegexInputWidgetProps>(
  (props: RegexInputWidgetProps, ref): JSX.Element => {
    const {
      name,
      helpText,
      targetPayload,
      style,
      submitChange,
      setInitialValue,
      containerStore,
      height,
      debounce = 1000,
      notifier,
      copyValue,
      useClipboard,
      isDisabled,
      mainDetailObject,
      containerProps,
      labelContainerProps,
      regexp,
    } = props
    const context = containerStore.getState()

    const { targetUrl, content, isRequired, widgetDescription } = useWidgetInitialization({ ...props, context })

    setInitialValue({ [name]: content })

    const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
      const inputPayload = getPayload(e.target.value, name, targetPayload)
      submitChange({ url: targetUrl, payload: inputPayload })
    }

    const handleCopyValue = getCopyHandler(content, copyValue)

    const Element = useMemo(() => (localProps: InputProps) => <RegexInput {...localProps} regexp={regexp} />, [regexp])

    const { getDataTestId } = useCreateTestId()
    return (
      <WidgetWrapper
        name={name}
        style={style}
        helpText={helpText}
        description={widgetDescription}
        required={isRequired}
        notifier={notifier}
        useClipboard={useClipboard}
        copyValue={handleCopyValue}
        containerProps={containerProps}
        labelContainerProps={labelContainerProps}
        {...getDataTestId(props)}
      >
        <DebounceInput
          value={content as string}
          height={height}
          debounceTimeout={debounce}
          element={Element}
          onChange={handleChange}
          inputRef={ref}
          disabled={getAccessor(isDisabled, mainDetailObject, context)}
        />
      </WidgetWrapper>
    )
  }
)