aboutsummaryrefslogtreecommitdiff
path: root/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-05-16 01:23:44 -0300
committerSebastian <sebasjm@gmail.com>2023-05-16 01:23:44 -0300
commit245ab840baf1926ef2c03a8965fce85012887d92 (patch)
tree1acec43e991100292f82db241eec70d073b6365b /packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
parent02fb71c0ff69d293911f4b0945ab964a87402d0c (diff)
one form left
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx')
-rw-r--r--packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx b/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
index 05733fe19..dd85453e5 100644
--- a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
+++ b/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
@@ -1,5 +1,5 @@
import { Fragment, VNode, h } from "preact";
-import { Choice } from "./InputChoice.js";
+import { Choice } from "./InputChoiceStacked.js";
import { LabelWithTooltipMaybeRequired, UIFormProps } from "./InputLine.js";
import { useField } from "./useField.js";
import { useState } from "preact/hooks";
@@ -8,9 +8,10 @@ export function InputSelectMultiple(
props: {
choices: Choice[];
unique?: boolean;
+ max?: number;
} & UIFormProps<Array<string>>,
): VNode {
- const { name, label, choices, placeholder, tooltip, required, unique } =
+ const { name, label, choices, placeholder, tooltip, required, unique, max } =
props;
const { value, onChange } = useField<{ [s: string]: Array<string> }>(name);
@@ -113,6 +114,9 @@ export function InputSelectMultiple(
if (unique && list.indexOf(v.value) !== -1) {
return;
}
+ if (max !== undefined && list.length >= max) {
+ return;
+ }
const newValue = [...list];
newValue.splice(0, 0, v.value);
onChange(newValue);