From 3ec894a5fcfae05deea9471afae8ca6caded2362 Mon Sep 17 00:00:00 2001 From: Haider Alshamma Date: Mon, 30 Dec 2024 17:37:06 -0500 Subject: [PATCH] feat: allow the NDSOption type to be extended --- src/Select/Select.story.fixture.tsx | 18 +++++++++- src/Select/Select.story.tsx | 21 +++++++++++- src/Select/Select.tsx | 52 ++++++++++++++++++----------- src/Select/lib.ts | 2 +- 4 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/Select/Select.story.fixture.tsx b/src/Select/Select.story.fixture.tsx index 184087666..04f5fc743 100644 --- a/src/Select/Select.story.fixture.tsx +++ b/src/Select/Select.story.fixture.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { GroupBase } from "react-select"; import styled from "styled-components"; import { SelectOption, SelectOptionProps } from "./SelectOption"; import { NDSOption } from "./Select"; @@ -65,7 +66,7 @@ const Indicator = styled.span(() => ({ marginRight: "5px", })); -export const CustomOption = ({ children, ...props }: SelectOptionProps) => { +export const CustomOption = ({ children, ...props }: SelectOptionProps>) => { const newChildren = ( <> @@ -74,3 +75,18 @@ export const CustomOption = ({ children, ...props }: SelectOptionProps) => { ); return {newChildren}; }; + +export interface DescriptiveOption extends NDSOption { + description: string; +} + +export const CustomFieldsOption = ({ + ...props +}: SelectOptionProps>) => { + return ( + + {props.data.label} + {props.data.description} + + ); +}; diff --git a/src/Select/Select.story.tsx b/src/Select/Select.story.tsx index 9b0b67519..d484d53dd 100644 --- a/src/Select/Select.story.tsx +++ b/src/Select/Select.story.tsx @@ -14,6 +14,7 @@ import { wrappingOptions, PCNList, errorList, + CustomFieldsOption, } from "./Select.story.fixture"; const SelectWithManyOptions = ({ multiselect, labelText, ...props }: Partial) => { @@ -336,7 +337,7 @@ WithSmallerMaxHeight.story = { export const WithWrappingText = () => ( + ); +}; diff --git a/src/Select/Select.tsx b/src/Select/Select.tsx index 96d1a49c7..6086d7d06 100644 --- a/src/Select/Select.tsx +++ b/src/Select/Select.tsx @@ -31,37 +31,43 @@ export interface NDSOption { value: NDSOptionValue; } -interface CustomProps> extends StyledProps { - autocomplete?: Props["isSearchable"]; +interface CustomProps