Skip to content

Commit

Permalink
Merge branch 'main' into LG-3439-cell-max-height-2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp authored Jan 25, 2024
2 parents 3030063 + e0b4080 commit 4ed0ab6
Show file tree
Hide file tree
Showing 56 changed files with 464 additions and 301 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-turkeys-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/date-picker': patch
---

Modify `DatePickerMenu.stories.tsx` to exclude the current date, as it caused daily chromatic changes.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-rabbits-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/date-picker': patch
---

Applies a CSS transition duration of 100ms to enhance the hover and focus styles on calendar cells.
5 changes: 0 additions & 5 deletions .changeset/popular-hats-travel.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/stale-dryers-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/date-picker': minor
---

Extends [Popover props](https://www.mongodb.design/component/popover/documentation/) but omits the following props: `usePortal`, `refEl`, `children`, `className`, `onClick`, and `active`. [LG-3930](https://jira.mongodb.org/browse/LG-3930)
5 changes: 5 additions & 0 deletions .changeset/strange-pumpkins-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/marketing-modal': patch
---

Sets the default `closeIconColor` to correctly be 'default' (`CloseIconColor.Default`)
5 changes: 5 additions & 0 deletions .changeset/tricky-games-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/modal': patch
---

Sets the `CloseIconColor` enum to be readonly (`as const`). Improves TypeScript Intellisense/autocomplete
6 changes: 6 additions & 0 deletions .changeset/yellow-items-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/combobox': minor
---

Exports `ComboboxOptionProps` & `ComboboxGroupProps`.
Internal refactor of `type` file organization.
2 changes: 1 addition & 1 deletion packages/combobox/src/Combobox.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SearchState,
State,
TruncationLocation,
} from './Combobox.types';
} from './types';
import { Combobox, ComboboxOption, ComboboxProps } from '.';

const wrapperStyle = css`
Expand Down
2 changes: 1 addition & 1 deletion packages/combobox/src/Combobox/Combobox.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import isUndefined from 'lodash/isUndefined';
import Button from '@leafygreen-ui/button';
import { keyMap } from '@leafygreen-ui/lib';

import { OptionObject } from '../Combobox.types';
import { OptionObject } from '../ComboboxOption/ComboboxOption.types';
import {
defaultOptions,
getComboboxJSX,
Expand Down
2 changes: 1 addition & 1 deletion packages/combobox/src/Combobox/Combobox.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
typeScales,
} from '@leafygreen-ui/tokens';

import { ComboboxSize as Size, Overflow } from '../Combobox.types';
import {
chipClassName,
chipWrapperPaddingY,
fontSize,
lineHeight,
} from '../ComboboxChip/ComboboxChip.styles';
import { ComboboxSize as Size, Overflow } from '../types';

/**
* Util to get the chip height
Expand Down
16 changes: 8 additions & 8 deletions packages/combobox/src/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,23 @@ import LeafyGreenProvider, {
import { consoleOnce, isComponentType, keyMap } from '@leafygreen-ui/lib';
import { Description, Label } from '@leafygreen-ui/typography';

import { ComboboxChip } from '../ComboboxChip';
import { ComboboxContext } from '../ComboboxContext';
import { InternalComboboxGroup } from '../ComboboxGroup';
import { ComboboxMenu } from '../ComboboxMenu';
import { OptionObject } from '../ComboboxOption';
import { InternalComboboxOption } from '../ComboboxOption';
import {
ComboboxElement,
ComboboxProps,
ComboboxSize,
getNullSelection,
onChangeType,
OptionObject,
Overflow,
SearchState,
SelectValueType,
State,
TruncationLocation,
} from '../Combobox.types';
import { ComboboxChip } from '../ComboboxChip';
import { ComboboxContext } from '../ComboboxContext';
import { InternalComboboxGroup } from '../ComboboxGroup';
import { ComboboxMenu } from '../ComboboxMenu';
import { InternalComboboxOption } from '../ComboboxOption';
} from '../types';
import {
checkScrollPosition,
flattenChildren,
Expand Down Expand Up @@ -91,6 +90,7 @@ import {
labelDescriptionLargeStyles,
multiselectInputElementStyle,
} from './Combobox.styles';
import { ComboboxProps } from './Combobox.types';

/**
* Combobox is a combination of a Select and TextInput,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,17 @@
import { ComponentPropsWithoutRef, ReactElement, ReactNode } from 'react';
import { ReactNode } from 'react';

import { type ChipProps, TruncationLocation } from '@leafygreen-ui/chip';
import { type ChipProps } from '@leafygreen-ui/chip';
import { Either, HTMLElementProps } from '@leafygreen-ui/lib';
import { PortalControlProps } from '@leafygreen-ui/popover';

export { TruncationLocation };

/**
* Prop Enums & Types
*/

export const ComboboxElement = {
Input: 'Input',
ClearButton: 'ClearButton',
FirstChip: 'FirstChip',
LastChip: 'LastChip',
MiddleChip: 'MiddleChip',
Combobox: 'Combobox',
Menu: 'Menu',
} as const;
export type ComboboxElement =
(typeof ComboboxElement)[keyof typeof ComboboxElement];

/**
* Prop types
*/

export const ComboboxSize = {
XSmall: 'xsmall',
Small: 'small',
Default: 'default',
Large: 'large',
} as const;
export type ComboboxSize = (typeof ComboboxSize)[keyof typeof ComboboxSize];

export const Overflow = {
/**
* Combobox will be set to a fixed width, and will expand its height based on the number of Chips selected
*/
expandY: 'expand-y',
/**
* Combobox will be set to a fixed height and width (default 100% of container). Chips will be scrollable left-right
*/
scrollX: 'scroll-x',
/**
* @deprecated
*/
expandX: 'expand-x',
} as const;
export type Overflow = (typeof Overflow)[keyof typeof Overflow];

export const State = {
none: 'none',
error: 'error',
} as const;
export type State = (typeof State)[keyof typeof State];

export const SearchState = {
unset: 'unset',
error: 'error',
loading: 'loading',
} as const;
export type SearchState = (typeof SearchState)[keyof typeof SearchState];

/**
* Generic Typing
*/

export type SelectValueType<M extends boolean> = M extends true
? Array<string>
: string | null;

export type onChangeType<M extends boolean> = M extends true
? (value: SelectValueType<true>) => void
: (value: SelectValueType<false>) => void;

// Returns the correct empty state for multiselcect / single select
export function getNullSelection<M extends boolean>(
multiselect: M,
): SelectValueType<M> {
if (multiselect) {
return [] as Array<string> as SelectValueType<M>;
} else {
return null as SelectValueType<M>;
}
}
import {
ComboboxSize,
onChangeType,
Overflow,
SearchState,
SelectValueType,
State,
} from '../types';

/**
* Combobox Props
Expand Down Expand Up @@ -234,112 +161,3 @@ export type ComboboxProps<M extends boolean> = Either<
BaseComboboxProps & ComboboxMultiselectProps<M>,
'label' | 'aria-label'
>;

/**
* Combobox Option Props
*/

type ListItemProps = Omit<ComponentPropsWithoutRef<'li'>, 'onClick' | 'value'>;

interface SharedComboboxOptionProps {
/**
* The internal value of the option. Used as the identifier in Combobox `initialValue`, value and filteredOptions.
* When undefined, this is set to `_.kebabCase(displayName)`
*/
value?: string;

/**
* The display value of the option. Used as the rendered string within the menu and chips.
* When undefined, this is set to `value`
*/
displayName?: string;

/**
* The icon to display to the left of the option in the menu.
*/
glyph?: ReactElement;

/**
* Defines whether the option is disabled.
* Node: disabled options are still rendered in the menu, but not selectable.
*/
disabled?: boolean;

/**
* Styling Prop
*/
className?: string;

/**
* Optional descriptive text under the displayName.
*/
description?: string;

/**
* Callback fired when an option is clicked.
*/
onClick?: (
event: React.SyntheticEvent<HTMLLIElement, Event>,
value: string,
) => void;
}

type RequiredComboboxOptionProps = Required<
Pick<SharedComboboxOptionProps, 'value' | 'displayName'>
>;

type BaseComboboxOptionProps = ListItemProps & SharedComboboxOptionProps;

export type ComboboxOptionProps = Either<
BaseComboboxOptionProps,
'value' | 'displayName'
>;

export interface OptionObject
extends Pick<SharedComboboxOptionProps, 'description' | 'onClick'>,
RequiredComboboxOptionProps {
isDisabled: boolean;
hasGlyph?: boolean;
}

export interface InternalComboboxOptionProps
extends ListItemProps,
Omit<SharedComboboxOptionProps, 'value' | 'displayName'>,
RequiredComboboxOptionProps {
isSelected: boolean;
isFocused: boolean;
setSelected: () => void;
index: number;
}

/**
* Combobox Group Props
*/

export interface ComboboxGroupProps {
/**
* Label for the group of options
*/
label: string;

/**
* Options in the group. Must be one or more `ComboboxOption` components
*/
children: React.ReactNode;

/**
* Styling prop
*/
className?: string;
}

/**
* Combobox Chip
*/

export interface ComboboxChipProps {
displayName: string;
isFocused: boolean;
onRemove: () => void;
onFocus: () => void;
}
5 changes: 5 additions & 0 deletions packages/combobox/src/Combobox/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export { Combobox } from './Combobox';
export {
type BaseComboboxProps,
type ComboboxMultiselectProps,
type ComboboxProps,
} from './Combobox.types';
2 changes: 1 addition & 1 deletion packages/combobox/src/ComboboxChip/ComboboxChip.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from '@leafygreen-ui/emotion';
import { createUniqueClassName } from '@leafygreen-ui/lib';
import { typeScales } from '@leafygreen-ui/tokens';

import { ComboboxSize } from '../Combobox.types';
import { ComboboxSize } from '../types';

export const chipClassName = createUniqueClassName('combobox-chip');

Expand Down
7 changes: 2 additions & 5 deletions packages/combobox/src/ComboboxChip/ComboboxChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import { cx } from '@leafygreen-ui/emotion';
import { useForwardedRef } from '@leafygreen-ui/hooks';
import { keyMap } from '@leafygreen-ui/lib';

import {
ComboboxChipProps,
Overflow,
TruncationLocation,
} from '../Combobox.types';
import { ComboboxContext } from '../ComboboxContext';
import { Overflow, TruncationLocation } from '../types';

import { chipClassName, chipSizeStyles } from './ComboboxChip.styles';
import { ComboboxChipProps } from './ComboboxChip.types';

export const ComboboxChip = React.forwardRef<
HTMLSpanElement,
Expand Down
6 changes: 6 additions & 0 deletions packages/combobox/src/ComboboxChip/ComboboxChip.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ComboboxChipProps {
displayName: string;
isFocused: boolean;
onRemove: () => void;
onFocus: () => void;
}
2 changes: 1 addition & 1 deletion packages/combobox/src/ComboboxContext/ComboboxContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SearchState,
State,
TruncationLocation,
} from '../Combobox.types';
} from '../types';

export interface ComboboxData {
multiselect: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/combobox/src/ComboboxContext/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { ComboboxContext } from './ComboboxContext';
export { ComboboxContext, defaultContext } from './ComboboxContext';
3 changes: 1 addition & 2 deletions packages/combobox/src/ComboboxGroup/ComboboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { cx } from '@leafygreen-ui/emotion';
import { useIdAllocator } from '@leafygreen-ui/hooks';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';

import { ComboboxGroupProps } from '../Combobox.types';

import {
comboboxGroupLabel,
comboboxGroupLabelThemeStyle,
comboboxGroupStyle,
} from './ComboboxGroup.styles';
import { ComboboxGroupProps } from './ComboboxGroup.types';

/**
* @internal
Expand Down
Loading

0 comments on commit 4ed0ab6

Please sign in to comment.