@codecademy/gamut 72.2.3-alpha.f0a032.0 → 72.2.3-alpha.f43044.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-tools/skills/gamut-forms/SKILL.md +0 -16
- package/dist/Alert/elements.d.ts +2 -2
- package/dist/Anchor/index.d.ts +19 -9
- package/dist/Anchor/index.js +9 -6
- package/dist/BarChart/BarRow/elements.d.ts +47 -45
- package/dist/BarChart/utils/hooks.d.ts +2 -2
- package/dist/BarChart/utils/hooks.js +3 -1
- package/dist/Box/GridBox.d.ts +1 -0
- package/dist/Box/GridBox.js +1 -1
- package/dist/Box/props.d.ts +1 -1
- package/dist/Breadcrumbs/index.d.ts +5 -5
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/Button/CTAButton.d.ts +2 -2
- package/dist/Button/FillButton.d.ts +4 -4
- package/dist/Button/IconButton.d.ts +4 -4
- package/dist/Button/IconButton.js +1 -0
- package/dist/Button/StrokeButton.d.ts +4 -4
- package/dist/Button/TextButton.d.ts +4 -4
- package/dist/Button/shared/InlineIconButton.d.ts +2 -2
- package/dist/Button/shared/styles.d.ts +3 -3
- package/dist/Button/shared/types.d.ts +1 -1
- package/dist/ButtonBase/ButtonBase.d.ts +9 -4
- package/dist/ButtonBase/ButtonBase.js +11 -4
- package/dist/Card/elements.d.ts +109 -103
- package/dist/Card/styles.d.ts +8 -8
- package/dist/Coachmark/index.d.ts +1 -1
- package/dist/ConnectedForm/ConnectedForm.d.ts +1 -1
- package/dist/ConnectedForm/ConnectedFormGroup.js +3 -2
- package/dist/ConnectedForm/utils.d.ts +1 -1
- package/dist/ConnectedForm/utils.js +1 -1
- package/dist/DatePicker/DatePickerInput/index.d.ts +1 -1
- package/dist/Disclosure/elements.d.ts +18 -12
- package/dist/FeatureShimmer/index.js +1 -1
- package/dist/Form/SelectDropdown/SelectDropdown.js +101 -49
- package/dist/Form/SelectDropdown/elements/constants.d.ts +8 -0
- package/dist/Form/SelectDropdown/elements/constants.js +9 -1
- package/dist/Form/SelectDropdown/elements/containers.d.ts +2 -6
- package/dist/Form/SelectDropdown/elements/containers.js +2 -18
- package/dist/Form/SelectDropdown/elements/controls.d.ts +15 -1
- package/dist/Form/SelectDropdown/elements/controls.js +91 -2
- package/dist/Form/SelectDropdown/elements/index.d.ts +1 -2
- package/dist/Form/SelectDropdown/elements/index.js +1 -2
- package/dist/Form/SelectDropdown/elements/multi-value.js +2 -2
- package/dist/Form/SelectDropdown/elements/options.d.ts +0 -1
- package/dist/Form/SelectDropdown/elements/options.js +2 -5
- package/dist/Form/SelectDropdown/{core/styles.js → styles.js} +12 -30
- package/dist/Form/SelectDropdown/types/component-props.d.ts +6 -54
- package/dist/Form/SelectDropdown/types/internal.d.ts +4 -4
- package/dist/Form/SelectDropdown/types/styles.d.ts +1 -5
- package/dist/Form/SelectDropdown/{core/utils.d.ts → utils.d.ts} +2 -12
- package/dist/Form/SelectDropdown/{core/utils.js → utils.js} +2 -24
- package/dist/Form/elements/Form.d.ts +15 -15
- package/dist/Form/elements/FormGroup.d.ts +1 -1
- package/dist/Form/styles/Checkbox-styles.d.ts +1 -1
- package/dist/Form/styles/index.d.ts +1 -1
- package/dist/Form/styles/index.js +1 -1
- package/dist/GridForm/GridFormButtons/index.d.ts +4 -4
- package/dist/List/ListProvider.d.ts +1 -1
- package/dist/List/elements.d.ts +44 -42
- package/dist/Menu/MenuItem.d.ts +2 -0
- package/dist/Menu/MenuItem.js +12 -6
- package/dist/Menu/elements.d.ts +3 -2
- package/dist/Menu/elements.js +7 -5
- package/dist/Modals/Dialog.js +6 -2
- package/dist/Modals/Modal.js +5 -2
- package/dist/Modals/elements.d.ts +1 -1
- package/dist/Pagination/AnimatedPaginationButtons.d.ts +31 -29
- package/dist/Pagination/EllipsisButton.d.ts +2 -2
- package/dist/Pagination/PaginationButton.d.ts +6 -6
- package/dist/Pagination/utils.d.ts +31 -29
- package/dist/Pagination/utils.js +14 -11
- package/dist/Popover/Popover.js +6 -6
- package/dist/Popover/types.d.ts +4 -3
- package/dist/PopoverContainer/PopoverContainer.js +9 -9
- package/dist/PopoverContainer/hooks.d.ts +16 -4
- package/dist/PopoverContainer/hooks.js +50 -27
- package/dist/PopoverContainer/types.d.ts +2 -1
- package/dist/Tabs/TabButton.d.ts +2 -2
- package/dist/Tabs/TabNavLink.d.ts +2 -2
- package/dist/Tag/elements.d.ts +14 -8
- package/dist/Tip/InfoTip/InfoTipButton.d.ts +4 -4
- package/dist/Tip/PreviewTip/elements.d.ts +12 -6
- package/dist/Tip/ToolTip/index.d.ts +5 -0
- package/dist/Tip/__tests__/helpers.d.ts +1 -1
- package/dist/Tip/shared/FloatingTip.js +17 -2
- package/dist/Tip/shared/InlineTip.js +23 -2
- package/dist/Tip/shared/elements.d.ts +1 -1
- package/dist/Tip/shared/elements.js +16 -7
- package/dist/Tip/shared/types.d.ts +2 -1
- package/dist/Tip/shared/utils.js +1 -1
- package/dist/utils/nullish.d.ts +10 -0
- package/dist/utils/nullish.js +11 -0
- package/dist/utils/react.js +4 -2
- package/package.json +10 -10
- package/agent-tools/skills/gamut-select-dropdown/SKILL.md +0 -236
- package/dist/Form/SelectDropdown/core/accessibility.d.ts +0 -3
- package/dist/Form/SelectDropdown/core/accessibility.js +0 -12
- package/dist/Form/SelectDropdown/core/constants.d.ts +0 -13
- package/dist/Form/SelectDropdown/core/constants.js +0 -14
- package/dist/Form/SelectDropdown/hooks/useSelectHandlers.d.ts +0 -22
- package/dist/Form/SelectDropdown/hooks/useSelectHandlers.js +0 -62
- package/dist/Form/SelectDropdown/hooks/useSelectOptions.d.ts +0 -14
- package/dist/Form/SelectDropdown/hooks/useSelectOptions.js +0 -39
- /package/dist/Form/SelectDropdown/{core/styles.d.ts → styles.d.ts} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AbbreviatedSingleValue, CustomContainer, CustomInput, CustomValueContainer, DropdownButton, IconOption, MultiValueRemoveButton, MultiValueWithColorMode, RemoveAllButton } from '../elements';
|
|
2
|
-
export const defaultComponents = {
|
|
3
|
-
DropdownIndicator: DropdownButton,
|
|
4
|
-
IndicatorSeparator: () => null,
|
|
5
|
-
ClearIndicator: RemoveAllButton,
|
|
6
|
-
SelectContainer: CustomContainer,
|
|
7
|
-
ValueContainer: CustomValueContainer,
|
|
8
|
-
MultiValue: MultiValueWithColorMode,
|
|
9
|
-
MultiValueRemove: MultiValueRemoveButton,
|
|
10
|
-
Option: IconOption,
|
|
11
|
-
SingleValue: AbbreviatedSingleValue,
|
|
12
|
-
Input: CustomInput
|
|
13
|
-
};
|
|
14
|
-
export const ON_CHANGE_ACTION = 'select-option';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { KeyboardEvent } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ActionMeta, Options as OptionsType } from 'react-select';
|
|
4
|
-
import { SelectOptionBase } from '../../utils';
|
|
5
|
-
import { MultiSelectDropdownProps, OptionStrict, SelectDropdownGroup, SelectDropdownProps, SingleSelectDropdownProps } from '../types';
|
|
6
|
-
interface UseSelectHandlersArgs {
|
|
7
|
-
onChange?: SingleSelectDropdownProps['onChange'] | MultiSelectDropdownProps['onChange'];
|
|
8
|
-
multiple?: boolean;
|
|
9
|
-
onCreateOption?: (inputValue: string) => void;
|
|
10
|
-
selectOptions: SelectOptionBase[] | SelectDropdownGroup[];
|
|
11
|
-
value?: SelectDropdownProps['value'];
|
|
12
|
-
currentFocusedValue: unknown;
|
|
13
|
-
removeAllButtonRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
14
|
-
}
|
|
15
|
-
interface UseSelectHandlersReturn {
|
|
16
|
-
activated: boolean;
|
|
17
|
-
multiValues: OptionStrict[] | false;
|
|
18
|
-
changeHandler: (optionEvent: OptionStrict | OptionsType<OptionStrict>, actionMeta: ActionMeta<OptionStrict>) => void;
|
|
19
|
-
keyPressHandler: (e: KeyboardEvent<HTMLDivElement>) => void;
|
|
20
|
-
}
|
|
21
|
-
export declare const useSelectHandlers: ({ onChange, multiple, onCreateOption, selectOptions, value, currentFocusedValue, removeAllButtonRef, }: UseSelectHandlersArgs) => UseSelectHandlersReturn;
|
|
22
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { ON_CHANGE_ACTION } from '../core/constants';
|
|
3
|
-
import { filterValueFromOptions, getCreatedOptionValue, isMultipleSelectProps, isOptionsGrouped, isSingleSelectProps, removeValueFromSelectedOptions } from '../core/utils';
|
|
4
|
-
export const useSelectHandlers = ({
|
|
5
|
-
onChange,
|
|
6
|
-
multiple,
|
|
7
|
-
onCreateOption,
|
|
8
|
-
selectOptions,
|
|
9
|
-
value,
|
|
10
|
-
currentFocusedValue,
|
|
11
|
-
removeAllButtonRef
|
|
12
|
-
}) => {
|
|
13
|
-
const [activated, setActivated] = useState(false);
|
|
14
|
-
const [multiValues, setMultiValues] = useState(multiple ? filterValueFromOptions(selectOptions, value, isOptionsGrouped(selectOptions)) : false);
|
|
15
|
-
|
|
16
|
-
// Sync multi-select value from props when controlled (`value` is a string[]).
|
|
17
|
-
// Uncontrolled multi (`value` undefined or '') keeps selection in local state.
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!multiple || !Array.isArray(value)) return;
|
|
20
|
-
const newMultiValues = filterValueFromOptions(selectOptions, value, isOptionsGrouped(selectOptions));
|
|
21
|
-
if (newMultiValues !== multiValues) setMultiValues(newMultiValues);
|
|
22
|
-
|
|
23
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
-
}, [selectOptions, value, multiple]);
|
|
25
|
-
const changeHandler = useCallback((optionEvent, actionMeta) => {
|
|
26
|
-
setActivated(true);
|
|
27
|
-
if (actionMeta.action === 'create-option') {
|
|
28
|
-
const createdValue = getCreatedOptionValue(optionEvent, actionMeta, multiple);
|
|
29
|
-
if (createdValue) onCreateOption?.(createdValue);
|
|
30
|
-
}
|
|
31
|
-
const onChangeProps = {
|
|
32
|
-
onChange,
|
|
33
|
-
multiple
|
|
34
|
-
};
|
|
35
|
-
const forwardedMeta = actionMeta.action === 'create-option' ? actionMeta : {
|
|
36
|
-
action: ON_CHANGE_ACTION,
|
|
37
|
-
option: isMultipleSelectProps(onChangeProps) ? undefined : optionEvent
|
|
38
|
-
};
|
|
39
|
-
if (isSingleSelectProps(onChangeProps)) {
|
|
40
|
-
onChangeProps.onChange?.(optionEvent, forwardedMeta);
|
|
41
|
-
}
|
|
42
|
-
if (isMultipleSelectProps(onChangeProps)) {
|
|
43
|
-
setMultiValues(optionEvent);
|
|
44
|
-
onChangeProps.onChange?.(optionEvent, forwardedMeta);
|
|
45
|
-
}
|
|
46
|
-
}, [onChange, multiple, onCreateOption]);
|
|
47
|
-
const keyPressHandler = e => {
|
|
48
|
-
if (multiple && e.key === 'Enter' && currentFocusedValue && multiValues) {
|
|
49
|
-
const newMultiValues = removeValueFromSelectedOptions(multiValues, currentFocusedValue);
|
|
50
|
-
if (newMultiValues !== multiValues) setMultiValues(newMultiValues);
|
|
51
|
-
}
|
|
52
|
-
if (removeAllButtonRef.current !== null && e.key === 'ArrowRight' && multiValues && currentFocusedValue === multiValues[multiValues.length - 1].value) {
|
|
53
|
-
removeAllButtonRef.current.focus();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return {
|
|
57
|
-
activated,
|
|
58
|
-
multiValues,
|
|
59
|
-
changeHandler,
|
|
60
|
-
keyPressHandler
|
|
61
|
-
};
|
|
62
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SelectOptionBase } from '../../utils';
|
|
2
|
-
import { SelectDropdownGroup, SelectDropdownOptions, SelectDropdownSizes } from '../types';
|
|
3
|
-
interface UseSelectOptionsArgs {
|
|
4
|
-
options?: SelectDropdownOptions | SelectDropdownGroup[];
|
|
5
|
-
id?: string;
|
|
6
|
-
size?: SelectDropdownSizes['size'];
|
|
7
|
-
value?: string | string[];
|
|
8
|
-
}
|
|
9
|
-
interface UseSelectOptionsReturn {
|
|
10
|
-
selectOptions: SelectOptionBase[] | SelectDropdownGroup[];
|
|
11
|
-
parsedValue: SelectOptionBase | undefined;
|
|
12
|
-
}
|
|
13
|
-
export declare const useSelectOptions: ({ options, id, size, value, }: UseSelectOptionsArgs) => UseSelectOptionsReturn;
|
|
14
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { parseOptions } from '../../utils';
|
|
3
|
-
import { isOptionsGrouped } from '../core/utils';
|
|
4
|
-
export const useSelectOptions = ({
|
|
5
|
-
options,
|
|
6
|
-
id,
|
|
7
|
-
size,
|
|
8
|
-
value
|
|
9
|
-
}) => {
|
|
10
|
-
const selectOptions = useMemo(() => {
|
|
11
|
-
if (!options || Array.isArray(options) && !options.length || typeof options === 'object' && !Array.isArray(options) && Object.keys(options).length === 0) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
if (isOptionsGrouped(options)) {
|
|
15
|
-
return options;
|
|
16
|
-
}
|
|
17
|
-
return parseOptions({
|
|
18
|
-
options,
|
|
19
|
-
id,
|
|
20
|
-
size
|
|
21
|
-
});
|
|
22
|
-
}, [options, id, size]);
|
|
23
|
-
const parsedValue = useMemo(() => {
|
|
24
|
-
if (isOptionsGrouped(selectOptions)) {
|
|
25
|
-
for (const group of selectOptions) {
|
|
26
|
-
if (group.options) {
|
|
27
|
-
const foundOption = group.options.find(option => option.value === value);
|
|
28
|
-
if (foundOption) return foundOption;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
return selectOptions.find(option => option.value === value);
|
|
34
|
-
}, [selectOptions, value]);
|
|
35
|
-
return {
|
|
36
|
-
selectOptions,
|
|
37
|
-
parsedValue
|
|
38
|
-
};
|
|
39
|
-
};
|
|
File without changes
|