@codecademy/gamut
72.2.272.2.3-alpha.83b0a8.0
dist/Form/SelectDropdown/core/utils.d.ts+
dist/Form/SelectDropdown/core/utils.d.tsNew file+36
Index: package/dist/Form/SelectDropdown/core/utils.d.ts
===================================================================
--- package/dist/Form/SelectDropdown/core/utils.d.ts
+++ package/dist/Form/SelectDropdown/core/utils.d.ts
@@ -0,0 +1,36 @@
+import * as React from 'react';
+import { ActionMeta, Options as OptionsType } from 'react-select';
+import { SelectOptionBase } from '../../utils';
+import { BaseOnChangeProps, ExtendedOption, MultiSelectDropdownProps, OptionStrict, SelectDropdownGroup, SelectDropdownOptions, SelectDropdownProps, SingleSelectDropdownProps } from '../types';
+export declare const isMultipleSelectProps: (props: BaseOnChangeProps) => props is MultiSelectDropdownProps;
+export declare const isSingleSelectProps: (props: BaseOnChangeProps) => props is SingleSelectDropdownProps;
+/**
+ * Resolves the value for a newly created option from react-select action metadata
+ * or the onChange option payload. Returns undefined when no reliable value exists.
+ */
+export declare const getCreatedOptionValue: (optionEvent: OptionStrict | OptionsType<OptionStrict>, actionMeta: ActionMeta<OptionStrict>, multiple?: boolean) => string | undefined;
+export declare const isOptionGroup: (obj: unknown) => obj is SelectDropdownGroup;
+export declare const isOptionsGrouped: (options: SelectDropdownOptions) => options is SelectDropdownGroup[];
+/**
+ * Filters options based on the selected value(s).
+ * Handles both single values and arrays of values, and works with both
+ * flat option arrays and grouped options.
+ *
+ * @param options - The options to filter from
+ * @param value - The value or values to filter by
+ * @param optionsAreGrouped - Whether the options are grouped
+ * @returns Array of matching options
+ */
+export declare const filterValueFromOptions: (options: SelectOptionBase[] | SelectDropdownGroup[], value: SelectDropdownProps["value"], optionsAreGrouped: boolean) => ExtendedOption[] | SelectOptionBase[];
+/**
+ * Removes a value from the selected options array.
+ * Handles both single values and arrays of values to remove.
+ *
+ * @param selectedOptions - The currently selected options
+ * @param value - The value or values to remove
+ * @returns New array with the specified values removed
+ */
+export declare const resolveNoOptionsMessage: (validationMessage: SelectDropdownProps["validationMessage"]) => ((obj: {
+ inputValue: string;
+}) => React.ReactNode) | undefined;
+export declare const removeValueFromSelectedOptions: (selectedOptions: ExtendedOption[] | SelectOptionBase[], value: SelectDropdownProps["value"]) => SelectOptionBase[];