From 1433b3cd9a196756bbfd582041f7fa8fa2e72e6f Mon Sep 17 00:00:00 2001 From: jsherlock Date: Sun, 24 Jan 2021 23:46:56 +0000 Subject: [PATCH 1/2] Added support for user-defined keycodes --- example/index.tsx | 1 + src/index.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example/index.tsx b/example/index.tsx index 5e8b770..2b7f2d2 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -14,6 +14,7 @@ const initialSettings: ReactTagInputProps = { readOnly: false, removeOnBackspace: true, validator: undefined, + additionalKeycodes: [9, 32, 188] }; function Example() { diff --git a/src/index.tsx b/src/index.tsx index 0bf6bce..7171ff9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,6 +3,7 @@ import {Tag} from "./components/Tag"; import {classSelectors} from "./utils/selectors"; type Tags = string[]; +type Keycodes = number[]; export interface ReactTagInputProps { tags: Tags; @@ -13,6 +14,7 @@ export interface ReactTagInputProps { editable?: boolean; readOnly?: boolean; removeOnBackspace?: boolean; + additionalKeycodes?: Keycodes; } interface State { @@ -35,8 +37,8 @@ export default class ReactTagInput extends React.Component e.preventDefault(); From a9c2ebfd56e0358f0e21c52b5217df3c5b7954c8 Mon Sep 17 00:00:00 2001 From: jsherlock Date: Sun, 24 Jan 2021 23:59:33 +0000 Subject: [PATCH 2/2] Update to example --- example/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/index.tsx b/example/index.tsx index 2b7f2d2..2896697 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -8,13 +8,13 @@ const root = document.getElementById("root"); const initialSettings: ReactTagInputProps = { tags: [], onChange: (tags) => {}, - placeholder: "Types and press enter", + placeholder: "Type and press enter, tab, space or comma", maxTags: 10, editable: true, readOnly: false, removeOnBackspace: true, validator: undefined, - additionalKeycodes: [9, 32, 188] + additionalKeycodes: [9, 32, 188] // tab, space, comma }; function Example() {