From 3ffab27099ab01a0c8fa46ca3d5dbb0419911003 Mon Sep 17 00:00:00 2001 From: mimshins Date: Sun, 26 May 2024 20:49:25 +0330 Subject: [PATCH 1/4] Remove get options utility usage --- lib/Select/Select.tsx | 41 ++++------------- lib/Select/components/Group.tsx | 47 +++++++++++-------- lib/Select/context.ts | 5 -- lib/Select/utils.ts | 81 --------------------------------- 4 files changed, 36 insertions(+), 138 deletions(-) diff --git a/lib/Select/Select.tsx b/lib/Select/Select.tsx index c0fd75e..96fb63d 100644 --- a/lib/Select/Select.tsx +++ b/lib/Select/Select.tsx @@ -18,12 +18,7 @@ import { } from "../utils"; import { SelectContext, type SelectContextValue } from "./context"; import { Root as RootSlot } from "./slots"; -import { - getOptions as getOptionsUtil, - noValueSelected, - normalizeValues, - useElementsRegistry, -} from "./utils"; +import { noValueSelected, normalizeValues, useElementsRegistry } from "./utils"; export type RenderProps = { /** @@ -415,8 +410,6 @@ const SelectBase = (props: Props, ref: React.Ref) => { closeList(); } - const getOptions = () => getOptionsUtil(React.Children.toArray(children)); - const context: SelectContextValue = { readOnly, disabled, @@ -433,7 +426,6 @@ const SelectBase = (props: Props, ref: React.Ref) => { closeListAndMaintainFocus, setFilteredEntities, setActiveDescendant, - getOptions, openList, closeList, toggleList, @@ -491,29 +483,14 @@ const SelectBase = (props: Props, ref: React.Ref) => { if (selectedValues.length === 0) return null; const renderOptions = () => { - const disabledOptions = getOptions().filter(o => o.disabled); - - const isOptionDisabled = (optionValue: string) => - disabledOptions.some(o => o.value === optionValue); - - if (!multiple) { - const optionValue = selectedValues as string; - - if (isOptionDisabled(optionValue)) return null; - - return