Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: restructure the utils folder #1246

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import {
ButtonProps,
} from '@lumx/react';
import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiInformation } from '@lumx/icons';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useId } from '@lumx/react/hooks/useId';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
import type { ComponentClassName } from '@lumx/react/utils/type';

export interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
/** Message variant. */
Expand Down Expand Up @@ -61,7 +62,7 @@ const COMPONENT_NAME = 'AlertDialog';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-alert-dialog';

/**
* Component default props.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import classNames from 'classnames';
import { Dropdown, DropdownProps, IconButtonProps, Offset, Placement, TextField, TextFieldProps } from '@lumx/react';

import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName } from '@lumx/react/utils/className';
import { useFocus } from '@lumx/react/hooks/useFocus';
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
import type { ComponentClassName } from '@lumx/react/utils/type';

/**
* Defines the props of the component.
Expand Down Expand Up @@ -181,7 +181,7 @@ const COMPONENT_NAME = 'Autocomplete';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-autocomplete';

/**
* Component default props.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import classNames from 'classnames';
import { mdiClose } from '@lumx/icons';

import { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';
import { getRootClassName } from '@lumx/react/utils/className';
import type { ComponentClassName } from '@lumx/react/utils/type';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';

Expand Down Expand Up @@ -34,7 +34,7 @@ const COMPONENT_NAME = 'AutocompleteMultiple';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-autocomplete-multiple';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import classNames from 'classnames';

import { AspectRatio, Size, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';

import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand Down Expand Up @@ -51,7 +51,7 @@ const COMPONENT_NAME = 'Avatar';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-avatar';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React, { ReactNode } from 'react';
import classNames from 'classnames';

import { ColorPalette } from '@lumx/react';
import { GenericProps } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

/**
Expand All @@ -25,7 +25,7 @@ const COMPONENT_NAME = 'Badge';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-badge';

/**
* Component default props.
Expand Down
5 changes: 2 additions & 3 deletions packages/lumx-react/src/components/badge/BadgeWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import React, { ReactElement, ReactNode } from 'react';

import classNames from 'classnames';

import { getRootClassName } from '@lumx/react/utils/className';
import { DEFAULT_PROPS } from '@lumx/react/components/select/WithSelectContext';
import { GenericProps } from '@lumx/react/utils/type';
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

export interface BadgeWrapperProps extends GenericProps {
Expand All @@ -22,7 +21,7 @@ const COMPONENT_NAME = 'BadgeWrapper';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-badge-wrapper';

export const BadgeWrapper = forwardRef<BadgeWrapperProps, HTMLDivElement>((props, ref) => {
const { badge, children, className, ...forwardedProps } = props;
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import classNames from 'classnames';
import isEmpty from 'lodash/isEmpty';

import { Emphasis, Icon, Size, Theme, Text } from '@lumx/react';
import { isComponent } from '@lumx/react/utils/type';
import { getBasicClass, getRootClassName } from '@lumx/react/utils/className';
import { isComponent, type ComponentClassName } from '@lumx/react/utils/type';
import { getBasicClass } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand Down Expand Up @@ -39,7 +39,7 @@ const COMPONENT_NAME = 'Button';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-button';

/**
* Component default props.
Expand Down
5 changes: 2 additions & 3 deletions packages/lumx-react/src/components/button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';

import classNames from 'classnames';

import { GenericProps } from '@lumx/react/utils/type';
import { getRootClassName } from '@lumx/react/utils/className';
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

/**
Expand All @@ -24,7 +23,7 @@ const COMPONENT_NAME = 'ButtonGroup';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-button-group';

/**
* Component default props.
Expand Down
4 changes: 2 additions & 2 deletions packages/lumx-react/src/components/button/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

import { Emphasis, Icon, Size, Theme, Tooltip, TooltipProps } from '@lumx/react';
import { BaseButtonProps, ButtonRoot } from '@lumx/react/components/button/ButtonRoot';
import { getRootClassName } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
import type { ComponentClassName } from '@lumx/react/utils/type';

export interface IconButtonProps extends BaseButtonProps {
/**
Expand Down Expand Up @@ -39,7 +39,7 @@ const COMPONENT_NAME = 'IconButton';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-icon-button';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import classNames from 'classnames';
import { mdiCheck, mdiMinus } from '@lumx/icons';

import { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useId } from '@lumx/react/hooks/useId';
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
Expand Down Expand Up @@ -51,7 +51,7 @@ const COMPONENT_NAME = 'Checkbox';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-checkbox';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import isFunction from 'lodash/isFunction';
import { ColorPalette, Size, Theme } from '@lumx/react';
import { useStopPropagation } from '@lumx/react/hooks/useStopPropagation';

import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { onEnterPressed } from '@lumx/react/utils/browser/event';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
Expand Down Expand Up @@ -53,7 +53,7 @@ const COMPONENT_NAME = 'Chip';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-chip';

/**
* Component default props.
Expand Down
5 changes: 2 additions & 3 deletions packages/lumx-react/src/components/chip/ChipGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import React, { ReactNode } from 'react';
import classNames from 'classnames';

import { HorizontalAlignment } from '@lumx/react/components';
import { GenericProps } from '@lumx/react/utils/type';
import { getRootClassName } from '@lumx/react/utils/className';
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

import { useChipGroupNavigation } from '@lumx/react/hooks/useChipGroupNavigation';
Expand Down Expand Up @@ -35,7 +34,7 @@ const COMPONENT_NAME = 'ChipGroup';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-chip-group';

/**
* ChipGroup component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React, { Children, ReactNode } from 'react';
import classNames from 'classnames';

import { Avatar, Size, Theme, Tooltip } from '@lumx/react';
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ValueOf, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
Expand Down Expand Up @@ -72,7 +72,7 @@ const COMPONENT_NAME = 'CommentBlock';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-comment-block';

/**
* Component default props.
Expand Down
4 changes: 2 additions & 2 deletions packages/lumx-react/src/components/date-picker/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRootClassName } from '@lumx/react/utils/className';
import type { ComponentClassName } from '@lumx/react/utils/type';

/**
* Component display name.
Expand All @@ -8,4 +8,4 @@ export const COMPONENT_NAME = 'DatePicker';
/**
* Component default class name and class prefix.
*/
export const CLASSNAME = getRootClassName(COMPONENT_NAME);
export const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-date-picker';
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
import { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';

import { GenericProps, isComponent } from '@lumx/react/utils/type';
import { type GenericProps, isComponent, type ComponentClassName } from '@lumx/react/utils/type';
import { partitionMulti } from '@lumx/react/utils/partitionMulti';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
Expand Down Expand Up @@ -78,7 +78,7 @@ const COMPONENT_NAME = 'Dialog';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-dialog';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/divider/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import classNames from 'classnames';

import { Theme } from '@lumx/react';
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand All @@ -21,7 +21,7 @@ const COMPONENT_NAME = 'Divider';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-divider';

/**
* Component default props.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import classNames from 'classnames';

import { mdiDragVertical } from '@lumx/icons';
import { ColorPalette, Icon, Size, Theme } from '@lumx/react';
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand All @@ -22,7 +22,7 @@ const COMPONENT_NAME = 'DragHandle';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-drag-handle';

/**
* DragHandle component.
Expand Down
5 changes: 2 additions & 3 deletions packages/lumx-react/src/components/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import classNames from 'classnames';
import { List, ListProps } from '@lumx/react/components/list/List';
import { Popover, PopoverProps } from '@lumx/react/components/popover/Popover';
import { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';
import { GenericProps, isComponent } from '@lumx/react/utils/type';
import { getRootClassName } from '@lumx/react/utils/className';
import { type GenericProps, isComponent, type ComponentClassName } from '@lumx/react/utils/type';
import { Offset, Placement } from '@lumx/react/components/popover/constants';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand Down Expand Up @@ -91,7 +90,7 @@ const COMPONENT_NAME = 'Dropdown';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-dropdown';

/**
* Component default props.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import isEmpty from 'lodash/isEmpty';
import isFunction from 'lodash/isFunction';

import { ColorPalette, DragHandle, Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
import { GenericProps, HasTheme, isComponent } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import { type GenericProps, type HasTheme, type ComponentClassName, isComponent } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { partitionMulti } from '@lumx/react/utils/partitionMulti';
import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
import { EXPANSION_PANEL_TRANSITION_DURATION } from '@lumx/core/js/constants';
Expand Down Expand Up @@ -50,7 +50,7 @@ const COMPONENT_NAME = 'ExpansionPanel';
/**
* Component default class name and class prefix.
*/
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-expansion-panel';

/**
* Component default props.
Expand Down
6 changes: 3 additions & 3 deletions packages/lumx-react/src/components/flag/Flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import classNames from 'classnames';

import { ColorPalette, Icon, Size, Theme, Text } from '@lumx/react';
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
import { handleBasicClasses } from '@lumx/react/utils/className';
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
import { forwardRef } from '@lumx/react/utils/react/forwardRef';

Expand All @@ -20,7 +20,7 @@ export interface FlagProps extends GenericProps, HasTheme {
}

const COMPONENT_NAME = 'Flag';
const CLASSNAME = getRootClassName(COMPONENT_NAME);
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-flag';
const DEFAULT_PROPS: Partial<FlagProps> = {};

/**
Expand Down
Loading