hc-oss / react-tag-input-component

lightweight react component for tag(s) input
https://codesandbox.io/s/react-tag-input-component-rgf97
MIT License
80 stars 36 forks source link

add onkeyup event and className for style the tags and input field #22

Closed moinakmalkhan closed 1 year ago

moinakmalkhan commented 1 year ago

Please test it out before merging it. I need these changes for adding some style to input and tags and also need the onKeyUp event to do some logic related to project

harshzalavadiya commented 1 year ago

@moinakmalkhan on key up seems okay but will it be possible for you to manage using overriding styles w/ css like target built in class rti--tag etc.

moinakmalkhan commented 1 year ago

@harshzalavadiya Yeh, you are right but what if the user wanna add a pre-existing CSS class to tags or input such as form-control?

harshzalavadiya commented 1 year ago

@moinakmalkhan

makes sense is it possible to have common property that we can use for both for example...

classNames={{tag: "clsnm-tag", input: "clasnm-input"}}

Then in components we can use

<Tag key={tag} className={classNames?.tag} {...rest} />

<input className={cc("rti--input", RTIInput, classNames?.input)} />

also https://github.com/hc-oss/react-tag-input-component/blob/master/src/classnames.tsx#L9 can be modified to look like below to handle empty conditions

return obj.filter(c => c).join(" ");

also in docs onChange is copied twice can we rename one to classNames

moinakmalkhan commented 1 year ago

@harshzalavadiya Sure.

moinakmalkhan commented 1 year ago

@harshzalavadiya I pushed the new changes. Please tested it out before merging it

harshzalavadiya commented 1 year ago

@moinakmalkhan LGTM, i'll do small cleanup and then merge this with master