Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MultiInput component #693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yvmunayev
Copy link
Contributor

No description provided.

@commit-lint
Copy link

commit-lint bot commented Apr 5, 2023

Features

  • add MultiInput component (eba0521)

Contributors

yvmunayev

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

Visit the preview URL for this PR (updated for commit eba0521):

https://rainbow-modules--pr693-feat-add-multi-input-oyhkkx9u.web.app

(expires Wed, 12 Apr 2023 19:50:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a8717bcb415e206776430df4c4296748001a9951


# Overview

`MultiInput` is an component that allows you to enter many input.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's have chat GPT to help with the documentation

import { Field, UniversalForm } from '@rainbow-modules/forms';
import MultiInput from '../../src/components/MultiInput';

const GOOGLE_MAPS_APIKEY = process.env.STORYBOOK_GOOGLE_MAPS_APIKEY;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and we already have an env for this called STORYBOOK_GOOGLE_MAPS_API_KEY in circle CI then let's change it here

<Field
name="phones"
label="Phone numbers"
component={(props) => <MultiInput component={PhoneInput} {...props} />}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change the prop name component to inputComponent then we can use it like

<Field
    label="Phone numbers"
    component={MultiInput}
    inputComponent={PhoneInput}
    validate={validate}
/>

@@ -0,0 +1,101 @@
import React from 'react';
import { mount, shallow } from 'enzyme';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not use enzyme anymore, instead use react testing library

label?: ReactNode;
error?: ReactNode;
value?: T;
onChange?: (value: any) => void;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must avoid using any

? valueInProps
: [[undefined, undefined]];

const updatePhone = (index: number, newValue: any) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updatePhone?

? valueInProps
: [[undefined, undefined]];

const updatePhone = (index: number, newValue: any) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no any instead you can use unkown

: [{ label: isFirst ? 'Primary' : 'Secondary' }, { label: 'Note' }];

const rowError = !error || typeof error === 'string' ? null : (error[index] as RowError);
const phoneError = rowError && rowError.value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change var name phoneError

import { InputConfig, RowError } from './types';

interface InputProps<T> {
label?: ReactNode;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think label is always required

@LeandroTorresSicilia
Copy link
Member

Screen Shot 2023-04-07 at 11 36 19 AM

using this example causes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants