From c680f5aa71b08e978444df07f93c381f9d47ab82 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 5 Jun 2023 10:04:09 -0300 Subject: rename aml --- .../src/handlers/InputSelectMultiple.tsx | 151 --------------------- 1 file changed, 151 deletions(-) delete mode 100644 packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx (limited to 'packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx') diff --git a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx b/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx deleted file mode 100644 index 837744827..000000000 --- a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import { Fragment, VNode, h } from "preact"; -import { Choice } from "./InputChoiceStacked.js"; -import { LabelWithTooltipMaybeRequired, UIFormProps } from "./InputLine.js"; -import { useField } from "./useField.js"; -import { useState } from "preact/hooks"; - -export function InputSelectMultiple( - props: { - choices: Choice[]; - unique?: boolean; - max?: number; - } & UIFormProps, -): VNode { - const { name, label, choices, placeholder, tooltip, required, unique, max } = - props; - const { value, onChange } = useField(name); - - const [filter, setFilter] = useState(undefined); - const regex = new RegExp(`.*${filter}.*`, "i"); - const choiceMap = choices.reduce((prev, curr) => { - return { ...prev, [curr.value as string]: curr.label }; - }, {} as Record); - - const list = (value ?? []) as string[]; - const filteredChoices = - filter === undefined - ? undefined - : choices.filter((v) => { - return regex.test(v.label); - }); - return ( -
- - {list.map((v, idx) => { - return ( - - {choiceMap[v]} - - - ); - })} - -
- { - setFilter(e.currentTarget.value); - }} - placeholder={placeholder} - class="w-full rounded-md border-0 bg-white py-1.5 pl-3 pr-12 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" - role="combobox" - aria-controls="options" - aria-expanded="false" - /> - - - {filteredChoices !== undefined && ( -
    - {filteredChoices.map((v, idx) => { - return ( -
  • { - setFilter(undefined); - if (unique && list.indexOf(v.value as string) !== -1) { - return; - } - if (max !== undefined && list.length >= max) { - return; - } - const newValue = [...list]; - newValue.splice(0, 0, v.value as string); - onChange(newValue as T[K]); - }} - - // tabindex="-1" - > - {/* */} - {v.label} - - {/* */} -
  • - ); - })} - - {/* */} - - {/* */} -
- )} -
-
- ); -} -- cgit v1.2.3