From 913512e0686cbb903979c18265ec9dfaaf3420bb Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Fri, 6 Oct 2023 16:55:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(react)=20add=20select=20multi=20optio?= =?UTF-8?q?ns=20custom=20render?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to be able to render the options in a customized manner. --- .../src/components/Forms/Select/index.scss | 1 + .../components/Forms/Select/multi-common.tsx | 12 +- .../src/components/Forms/Select/multi.mdx | 13 + .../components/Forms/Select/multi.spec.tsx | 234 +++++++++++++++++- .../components/Forms/Select/multi.stories.tsx | 36 ++- .../src/components/Forms/Select/multi.tsx | 7 +- 6 files changed, 295 insertions(+), 8 deletions(-) diff --git a/packages/react/src/components/Forms/Select/index.scss b/packages/react/src/components/Forms/Select/index.scss index e205f96e2..d85aa3a14 100644 --- a/packages/react/src/components/Forms/Select/index.scss +++ b/packages/react/src/components/Forms/Select/index.scss @@ -255,6 +255,7 @@ margin-bottom: 0.25rem; max-width: var(--c--components--forms-select--multi-pill-max-width); font-size: var(--c--components--forms-select--multi-pill-font-size); + vertical-align: middle; > span { min-width: 0; diff --git a/packages/react/src/components/Forms/Select/multi-common.tsx b/packages/react/src/components/Forms/Select/multi-common.tsx index 1a236ea35..3cbb0fb7d 100644 --- a/packages/react/src/components/Forms/Select/multi-common.tsx +++ b/packages/react/src/components/Forms/Select/multi-common.tsx @@ -5,12 +5,13 @@ import { Field } from ":/components/Forms/Field"; import { LabelledBox } from ":/components/Forms/LabelledBox"; import { Button } from ":/components/Button"; import { useCunningham } from ":/components/Provider"; -import { Option } from ":/components/Forms/Select/mono"; -import { SelectProps } from ":/components/Forms/Select"; +import { Option, SelectProps } from ":/components/Forms/Select"; import { getOptionsFilter, optionToValue, + renderOption, } from ":/components/Forms/Select/mono-common"; +import { SelectedOption } from ":/components/Forms/Select/utils"; /** * This method returns a comparator that can be used to filter out options for multi select. @@ -160,7 +161,10 @@ export const SelectMultiAux = ({ index, })} > - {selectedItemForRender.label} +