@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.
Files changed (104) hide show
  1. package/agent-tools/skills/gamut-forms/SKILL.md +0 -16
  2. package/dist/Alert/elements.d.ts +2 -2
  3. package/dist/Anchor/index.d.ts +19 -9
  4. package/dist/Anchor/index.js +9 -6
  5. package/dist/BarChart/BarRow/elements.d.ts +47 -45
  6. package/dist/BarChart/utils/hooks.d.ts +2 -2
  7. package/dist/BarChart/utils/hooks.js +3 -1
  8. package/dist/Box/GridBox.d.ts +1 -0
  9. package/dist/Box/GridBox.js +1 -1
  10. package/dist/Box/props.d.ts +1 -1
  11. package/dist/Breadcrumbs/index.d.ts +5 -5
  12. package/dist/Breadcrumbs/index.js +2 -2
  13. package/dist/Button/CTAButton.d.ts +2 -2
  14. package/dist/Button/FillButton.d.ts +4 -4
  15. package/dist/Button/IconButton.d.ts +4 -4
  16. package/dist/Button/IconButton.js +1 -0
  17. package/dist/Button/StrokeButton.d.ts +4 -4
  18. package/dist/Button/TextButton.d.ts +4 -4
  19. package/dist/Button/shared/InlineIconButton.d.ts +2 -2
  20. package/dist/Button/shared/styles.d.ts +3 -3
  21. package/dist/Button/shared/types.d.ts +1 -1
  22. package/dist/ButtonBase/ButtonBase.d.ts +9 -4
  23. package/dist/ButtonBase/ButtonBase.js +11 -4
  24. package/dist/Card/elements.d.ts +109 -103
  25. package/dist/Card/styles.d.ts +8 -8
  26. package/dist/Coachmark/index.d.ts +1 -1
  27. package/dist/ConnectedForm/ConnectedForm.d.ts +1 -1
  28. package/dist/ConnectedForm/ConnectedFormGroup.js +3 -2
  29. package/dist/ConnectedForm/utils.d.ts +1 -1
  30. package/dist/ConnectedForm/utils.js +1 -1
  31. package/dist/DatePicker/DatePickerInput/index.d.ts +1 -1
  32. package/dist/Disclosure/elements.d.ts +18 -12
  33. package/dist/FeatureShimmer/index.js +1 -1
  34. package/dist/Form/SelectDropdown/SelectDropdown.js +101 -49
  35. package/dist/Form/SelectDropdown/elements/constants.d.ts +8 -0
  36. package/dist/Form/SelectDropdown/elements/constants.js +9 -1
  37. package/dist/Form/SelectDropdown/elements/containers.d.ts +2 -6
  38. package/dist/Form/SelectDropdown/elements/containers.js +2 -18
  39. package/dist/Form/SelectDropdown/elements/controls.d.ts +15 -1
  40. package/dist/Form/SelectDropdown/elements/controls.js +91 -2
  41. package/dist/Form/SelectDropdown/elements/index.d.ts +1 -2
  42. package/dist/Form/SelectDropdown/elements/index.js +1 -2
  43. package/dist/Form/SelectDropdown/elements/multi-value.js +2 -2
  44. package/dist/Form/SelectDropdown/elements/options.d.ts +0 -1
  45. package/dist/Form/SelectDropdown/elements/options.js +2 -5
  46. package/dist/Form/SelectDropdown/{core/styles.js → styles.js} +12 -30
  47. package/dist/Form/SelectDropdown/types/component-props.d.ts +6 -54
  48. package/dist/Form/SelectDropdown/types/internal.d.ts +4 -4
  49. package/dist/Form/SelectDropdown/types/styles.d.ts +1 -5
  50. package/dist/Form/SelectDropdown/{core/utils.d.ts → utils.d.ts} +2 -12
  51. package/dist/Form/SelectDropdown/{core/utils.js → utils.js} +2 -24
  52. package/dist/Form/elements/Form.d.ts +15 -15
  53. package/dist/Form/elements/FormGroup.d.ts +1 -1
  54. package/dist/Form/styles/Checkbox-styles.d.ts +1 -1
  55. package/dist/Form/styles/index.d.ts +1 -1
  56. package/dist/Form/styles/index.js +1 -1
  57. package/dist/GridForm/GridFormButtons/index.d.ts +4 -4
  58. package/dist/List/ListProvider.d.ts +1 -1
  59. package/dist/List/elements.d.ts +44 -42
  60. package/dist/Menu/MenuItem.d.ts +2 -0
  61. package/dist/Menu/MenuItem.js +12 -6
  62. package/dist/Menu/elements.d.ts +3 -2
  63. package/dist/Menu/elements.js +7 -5
  64. package/dist/Modals/Dialog.js +6 -2
  65. package/dist/Modals/Modal.js +5 -2
  66. package/dist/Modals/elements.d.ts +1 -1
  67. package/dist/Pagination/AnimatedPaginationButtons.d.ts +31 -29
  68. package/dist/Pagination/EllipsisButton.d.ts +2 -2
  69. package/dist/Pagination/PaginationButton.d.ts +6 -6
  70. package/dist/Pagination/utils.d.ts +31 -29
  71. package/dist/Pagination/utils.js +14 -11
  72. package/dist/Popover/Popover.js +6 -6
  73. package/dist/Popover/types.d.ts +4 -3
  74. package/dist/PopoverContainer/PopoverContainer.js +9 -9
  75. package/dist/PopoverContainer/hooks.d.ts +16 -4
  76. package/dist/PopoverContainer/hooks.js +50 -27
  77. package/dist/PopoverContainer/types.d.ts +2 -1
  78. package/dist/Tabs/TabButton.d.ts +2 -2
  79. package/dist/Tabs/TabNavLink.d.ts +2 -2
  80. package/dist/Tag/elements.d.ts +14 -8
  81. package/dist/Tip/InfoTip/InfoTipButton.d.ts +4 -4
  82. package/dist/Tip/PreviewTip/elements.d.ts +12 -6
  83. package/dist/Tip/ToolTip/index.d.ts +5 -0
  84. package/dist/Tip/__tests__/helpers.d.ts +1 -1
  85. package/dist/Tip/shared/FloatingTip.js +17 -2
  86. package/dist/Tip/shared/InlineTip.js +23 -2
  87. package/dist/Tip/shared/elements.d.ts +1 -1
  88. package/dist/Tip/shared/elements.js +16 -7
  89. package/dist/Tip/shared/types.d.ts +2 -1
  90. package/dist/Tip/shared/utils.js +1 -1
  91. package/dist/utils/nullish.d.ts +10 -0
  92. package/dist/utils/nullish.js +11 -0
  93. package/dist/utils/react.js +4 -2
  94. package/package.json +10 -10
  95. package/agent-tools/skills/gamut-select-dropdown/SKILL.md +0 -236
  96. package/dist/Form/SelectDropdown/core/accessibility.d.ts +0 -3
  97. package/dist/Form/SelectDropdown/core/accessibility.js +0 -12
  98. package/dist/Form/SelectDropdown/core/constants.d.ts +0 -13
  99. package/dist/Form/SelectDropdown/core/constants.js +0 -14
  100. package/dist/Form/SelectDropdown/hooks/useSelectHandlers.d.ts +0 -22
  101. package/dist/Form/SelectDropdown/hooks/useSelectHandlers.js +0 -62
  102. package/dist/Form/SelectDropdown/hooks/useSelectOptions.d.ts +0 -14
  103. package/dist/Form/SelectDropdown/hooks/useSelectOptions.js +0 -39
  104. /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
- };