diff --git a/.changeset/free-singers-cross.md b/.changeset/free-singers-cross.md new file mode 100644 index 000000000..dfe69d0bd --- /dev/null +++ b/.changeset/free-singers-cross.md @@ -0,0 +1,13 @@ +--- +'@clickhouse/click-ui': patch +--- + +Restore changes lost in PR 841-845 merge conflict resolution. + +**What changed:** + +- Removed the `Common/` barrel-export directory that was causing circular dependency issues +- Split shared components into their own directories: `CrossButton`, `EmptyButton`, `GridCenter`, `FormContainer` +- Updated imports across components to use direct paths instead of `@/components/Common` + +This is an internal refactoring with no public API changes. diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index ae85617a2..79b230cfe 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -4,7 +4,7 @@ import { Icon } from '@/components/Icon'; import * as RadixCheckbox from '@radix-ui/react-checkbox'; import { useId } from 'react'; import { styled } from 'styled-components'; -import { FormRoot } from '@/components/Common'; +import { FormRoot } from '@/components/FormContainer'; import { CheckboxProps, CheckboxVariants } from './Checkbox.types'; const Wrapper = styled(FormRoot)` diff --git a/src/components/CodeBlock/CodeBlock.tsx b/src/components/CodeBlock/CodeBlock.tsx index 51fb962ba..d38edfa59 100644 --- a/src/components/CodeBlock/CodeBlock.tsx +++ b/src/components/CodeBlock/CodeBlock.tsx @@ -1,7 +1,7 @@ import React, { HTMLAttributes, useState } from 'react'; import { Light as SyntaxHighlighter, createElement } from 'react-syntax-highlighter'; -import { EmptyButton } from '@/components/Common'; +import { EmptyButton } from '@/components/EmptyButton'; import { IconButton } from '@/components/IconButton'; import { styled } from 'styled-components'; diff --git a/src/components/Collapsible/Collapsible.tsx b/src/components/Collapsible/Collapsible.tsx index a5cc2e50b..38561de65 100644 --- a/src/components/Collapsible/Collapsible.tsx +++ b/src/components/Collapsible/Collapsible.tsx @@ -10,7 +10,7 @@ import { styled } from 'styled-components'; import { Icon, type IconName } from '@/components/Icon'; import type { HorizontalDirection } from '@/types'; -import { EmptyButton } from '@/components/Common'; +import { EmptyButton } from '@/components/EmptyButton'; import { IconWrapper } from './IconWrapper'; import { CollapsibleProps } from './Collapsible.types'; diff --git a/src/components/Common/BaseButton.tsx b/src/components/Common/BaseButton.tsx deleted file mode 100644 index 73510d0d8..000000000 --- a/src/components/Common/BaseButton.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { styled } from 'styled-components'; - -export const BaseButton = styled.button` - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - cursor: pointer; - ${({ theme }) => ` - padding: ${theme.click.button.basic.space.y} ${theme.click.button.basic.space.x}; - border-radius: ${theme.click.button.radii.all}; - gap: ${theme.click.button.basic.space.gap}; - font: ${theme.click.button.basic.typography.label.default}; - &:hover { - font: ${theme.click.button.basic.typography.label.hover}; - } - - &:active, - &:focus { - outline: none; - font: ${theme.click.button.basic.typography.label.active}; - } - - &:disabled, - &:disabled:hover, - &:disabled:active { - font: ${theme.click.button.basic.typography.label.disabled}; - cursor: not-allowed; - } - `} -`; diff --git a/src/components/Common/EllipsisContainer.tsx b/src/components/Common/EllipsisContainer.tsx deleted file mode 100644 index f5134d42d..000000000 --- a/src/components/Common/EllipsisContainer.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { styled } from 'styled-components'; - -export const EllipsisContainer = styled.span` - display: flex; - white-space: nowrap; - overflow: hidden; - justify-content: flex-end; - gap: inherit; - & > *:not(button) { - overflow: hidden; - text-overflow: ellipsis; - } -`; diff --git a/src/components/Common/Error.tsx b/src/components/Common/Error.tsx deleted file mode 100644 index ad19e40c0..000000000 --- a/src/components/Common/Error.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { styled } from 'styled-components'; - -export const Error = styled.div` - ${({ theme }) => ` - font: ${theme.click.field.typography.label.error}; - color: ${theme.click.field.color.label.error}; -`}; -`; diff --git a/src/components/Common/FormElementContainer.tsx b/src/components/Common/FormElementContainer.tsx deleted file mode 100644 index 4883a3f1d..000000000 --- a/src/components/Common/FormElementContainer.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { styled } from 'styled-components'; - -export const FormElementContainer = styled.div` - display: flex; - flex-direction: column; - align-items: flex-start; - width: 100%; - width: -webkit-fill-available; - width: fill-available; - width: stretch; - gap: ${({ theme }) => theme.click.field.space.gap}; -`; diff --git a/src/components/Common/FormRoot.tsx b/src/components/Common/FormRoot.tsx deleted file mode 100644 index b8236ca69..000000000 --- a/src/components/Common/FormRoot.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { styled } from 'styled-components'; - -export const FormRoot = styled.div<{ - $orientation?: 'horizontal' | 'vertical'; - $dir?: 'start' | 'end'; - $addLabelPadding?: boolean; -}>` - display: flex; - width: 100%; - gap: ${({ theme }) => theme.click.field.space.gap}; - ${({ theme, $orientation = 'vertical', $dir = 'start', $addLabelPadding = false }) => ` - flex-direction: ${ - $orientation === 'horizontal' - ? $dir === 'start' - ? 'row-reverse' - : 'row' - : $dir === 'start' - ? 'column-reverse' - : 'column' - }; - align-items: flex-start; - ${ - $addLabelPadding && $orientation === 'horizontal' - ? ` - label { - padding-top: calc(${theme.click.field.space.y} + 1px); - line-height: 1lh; - } - ` - : '' - } - `} - * { - box-shadow: none; - outline: none; - } -`; diff --git a/src/components/Common/index.ts b/src/components/Common/index.ts deleted file mode 100644 index 1fedbb1ea..000000000 --- a/src/components/Common/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export { FormRoot } from './FormRoot'; -export { Error } from './Error'; -export { EmptyButton } from './EmptyButton'; -export { CrossButton } from './CrossButton'; -export { GridCenter } from './GridCenter'; -export { BaseButton } from './BaseButton'; -export { FormElementContainer } from './FormElementContainer'; -export { EllipsisContainer } from './EllipsisContainer'; -export type { TextSize, TextWeight } from '@/components/Typography'; -export type { CursorOptions } from '@/components/Panel/Panel.types'; diff --git a/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx b/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx index 9073f6225..5fe9a545b 100644 --- a/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx +++ b/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx @@ -1,5 +1,5 @@ import { Meta, StoryObj } from '@storybook/react-vite'; -import { GridCenter } from '@/components/Common'; +import { GridCenter } from '@/components/GridCenter'; import { ConfirmationDialog, ConfirmationDialogProps, diff --git a/src/components/Common/CrossButton.tsx b/src/components/CrossButton/CrossButton.tsx similarity index 90% rename from src/components/Common/CrossButton.tsx rename to src/components/CrossButton/CrossButton.tsx index 2cc5992a6..8ddc6b554 100644 --- a/src/components/Common/CrossButton.tsx +++ b/src/components/CrossButton/CrossButton.tsx @@ -1,5 +1,5 @@ import { styled } from 'styled-components'; -import { EmptyButton } from './EmptyButton'; +import { EmptyButton } from '@/components/EmptyButton'; export const CrossButton = styled(EmptyButton)` padding: ${({ theme }) => theme.click.button.iconButton.sm.space.y} diff --git a/src/components/CrossButton/index.ts b/src/components/CrossButton/index.ts new file mode 100644 index 000000000..90f0a2de2 --- /dev/null +++ b/src/components/CrossButton/index.ts @@ -0,0 +1 @@ +export { CrossButton } from './CrossButton'; diff --git a/src/components/Dialog/Dialog.stories.tsx b/src/components/Dialog/Dialog.stories.tsx index 7213c4f83..443dbf1a7 100644 --- a/src/components/Dialog/Dialog.stories.tsx +++ b/src/components/Dialog/Dialog.stories.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { Meta, StoryObj } from '@storybook/react-vite'; -import { GridCenter } from '@/components/Common'; +import { GridCenter } from '@/components/GridCenter'; import { Text } from '@/components/Typography'; import { Dialog } from '@/components/Dialog'; import { Separator } from '@/components/Separator'; diff --git a/src/components/Dialog/Dialog.tsx b/src/components/Dialog/Dialog.tsx index f1fb00d68..d5c7f3a76 100644 --- a/src/components/Dialog/Dialog.tsx +++ b/src/components/Dialog/Dialog.tsx @@ -3,7 +3,7 @@ import { keyframes, styled } from 'styled-components'; import { Button, ButtonProps } from '@/components/Button'; import { Icon } from '@/components/Icon'; import { Spacer } from '@/components/Spacer'; -import { CrossButton } from '@/components/Common'; +import { CrossButton } from '@/components/CrossButton'; import { DialogContentProps, DialogProps, DialogTriggerProps } from './Dialog.types'; export const Dialog = ({ children, ...props }: DialogProps) => { diff --git a/src/components/Dropdown/Dropdown.stories.tsx b/src/components/Dropdown/Dropdown.stories.tsx index 60cf5db0c..a21d32f8f 100644 --- a/src/components/Dropdown/Dropdown.stories.tsx +++ b/src/components/Dropdown/Dropdown.stories.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Meta, StoryObj } from '@storybook/react-vite'; import { DropdownMenuProps } from '@radix-ui/react-dropdown-menu'; import { Dropdown } from '@/components/Dropdown'; -import { GridCenter } from '@/components/Common'; +import { GridCenter } from '@/components/GridCenter'; import { Button } from '@/components/Button'; import { Key } from 'react'; diff --git a/src/components/Common/EmptyButton.tsx b/src/components/EmptyButton/EmptyButton.tsx similarity index 100% rename from src/components/Common/EmptyButton.tsx rename to src/components/EmptyButton/EmptyButton.tsx diff --git a/src/components/EmptyButton/index.ts b/src/components/EmptyButton/index.ts new file mode 100644 index 000000000..6bb9c37a6 --- /dev/null +++ b/src/components/EmptyButton/index.ts @@ -0,0 +1 @@ +export { EmptyButton } from './EmptyButton'; diff --git a/src/components/Flyout/Flyout.tsx b/src/components/Flyout/Flyout.tsx index bc02370c5..2b894d1ba 100644 --- a/src/components/Flyout/Flyout.tsx +++ b/src/components/Flyout/Flyout.tsx @@ -18,7 +18,7 @@ import { Icon } from '@/components/Icon'; import { Separator } from '@/components/Separator'; import { Spacer } from '@/components/Spacer'; import { styled } from 'styled-components'; -import { CrossButton } from '@/components/Common'; +import { CrossButton } from '@/components/CrossButton'; import { keyframes } from 'styled-components'; import type { FlyoutProps, diff --git a/src/components/FormContainer/FormContainer.tsx b/src/components/FormContainer/FormContainer.tsx index adb7fea53..c2612f654 100644 --- a/src/components/FormContainer/FormContainer.tsx +++ b/src/components/FormContainer/FormContainer.tsx @@ -1,4 +1,6 @@ -import { Error, FormElementContainer, FormRoot } from '@/components/Common'; +import { Error } from './Error'; +import { FormElementContainer } from './FormElementContainer'; +import { FormRoot } from './FormRoot'; import { Label } from '@/components/Label'; import { FormContainerProps } from './FormContainer.types'; diff --git a/src/components/FormContainer/index.ts b/src/components/FormContainer/index.ts index 9888a63a2..d73ab74c6 100644 --- a/src/components/FormContainer/index.ts +++ b/src/components/FormContainer/index.ts @@ -1,2 +1,6 @@ export { FormContainer } from './FormContainer'; export type { FormContainerProps } from './FormContainer.types'; + +export { FormRoot } from './FormRoot'; +export { Error } from './Error'; +export { FormElementContainer } from './FormElementContainer'; diff --git a/src/components/Common/GridCenter.tsx b/src/components/GridCenter/GridCenter.tsx similarity index 100% rename from src/components/Common/GridCenter.tsx rename to src/components/GridCenter/GridCenter.tsx diff --git a/src/components/GridCenter/index.ts b/src/components/GridCenter/index.ts new file mode 100644 index 000000000..3ac03aa49 --- /dev/null +++ b/src/components/GridCenter/index.ts @@ -0,0 +1 @@ +export { GridCenter } from './GridCenter'; diff --git a/src/components/Input/InputWrapper.tsx b/src/components/Input/InputWrapper.tsx index 14eb03685..fff94e7b9 100644 --- a/src/components/Input/InputWrapper.tsx +++ b/src/components/Input/InputWrapper.tsx @@ -1,4 +1,4 @@ -import { Error, FormElementContainer, FormRoot } from '@/components/Common'; +import { Error, FormElementContainer, FormRoot } from '@/components/FormContainer'; import { Label } from '@/components/Label'; import { styled } from 'styled-components'; import { ReactNode } from 'react'; diff --git a/src/components/Popover/Popover.stories.tsx b/src/components/Popover/Popover.stories.tsx index a08080e6a..a05129c6a 100644 --- a/src/components/Popover/Popover.stories.tsx +++ b/src/components/Popover/Popover.stories.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Meta, StoryObj } from '@storybook/react-vite'; import { Button } from '@/components/Button'; import { Checkbox } from '@/components/Checkbox'; -import { GridCenter } from '@/components/Common'; +import { GridCenter } from '@/components/GridCenter'; import { Text, Title } from '@/components/Typography'; import { Popover } from '@/components/Popover'; diff --git a/src/components/Popover/Popover.tsx b/src/components/Popover/Popover.tsx index caa1b39c6..51cc22c68 100644 --- a/src/components/Popover/Popover.tsx +++ b/src/components/Popover/Popover.tsx @@ -3,7 +3,7 @@ import { Arrow, GenericMenuPanel } from '@/components/GenericMenu'; import { styled } from 'styled-components'; import { ReactNode } from 'react'; import { Icon } from '@/components/Icon'; -import { EmptyButton } from '@/components/Common'; +import { EmptyButton } from '@/components/EmptyButton'; import Popover_Arrow from '@/components/Assets/Icons/Popover-Arrow'; export const Popover = ({ children, ...props }: RadixPopover.PopoverProps) => { diff --git a/src/components/RadioGroup/RadioGroup.tsx b/src/components/RadioGroup/RadioGroup.tsx index 7c0fa8202..d6f8e69b3 100644 --- a/src/components/RadioGroup/RadioGroup.tsx +++ b/src/components/RadioGroup/RadioGroup.tsx @@ -3,7 +3,7 @@ import { HTMLAttributes, ReactNode, useId } from 'react'; import { styled } from 'styled-components'; import { GenericLabel } from '@/components/GenericLabel'; import { Label } from '@/components/Label'; -import { Error, FormElementContainer, FormRoot } from '@/components/Common'; +import { Error, FormElementContainer, FormRoot } from '@/components/FormContainer'; export interface RadioGroupProps extends Omit { /** Whether to display radio items inline (horizontally) */ diff --git a/src/components/Select/common/InternalSelect.tsx b/src/components/Select/common/InternalSelect.tsx index 7682f2f18..4cb3b217f 100644 --- a/src/components/Select/common/InternalSelect.tsx +++ b/src/components/Select/common/InternalSelect.tsx @@ -22,7 +22,7 @@ import { SelectItemProps, SelectOptionListItem, } from './types'; -import { Error, FormElementContainer, FormRoot } from '@/components/Common'; +import { Error, FormElementContainer, FormRoot } from '@/components/FormContainer'; import { Portal } from '@radix-ui/react-popover'; import { Checkbox } from '@/components/Checkbox'; import type { CheckboxVariants } from '@/components/Checkbox'; diff --git a/src/components/SplitButton/SplitButton.tsx b/src/components/SplitButton/SplitButton.tsx index 73c231a62..8516ff6a1 100644 --- a/src/components/SplitButton/SplitButton.tsx +++ b/src/components/SplitButton/SplitButton.tsx @@ -1,7 +1,7 @@ import { useEffect, useRef, useState } from 'react'; import { styled } from 'styled-components'; import { Dropdown } from '@/components/Dropdown'; -import { BaseButton } from '@/components/Common'; +import { BaseButton } from '@/components/Button/BaseButton'; import { IconWrapper } from '@/components/IconWrapper'; import { Icon } from '@/components/Icon'; import { SplitButtonProps, Menu, ButtonType } from './SplitButton.types'; diff --git a/src/components/Switch/Switch.tsx b/src/components/Switch/Switch.tsx index 3fcf4014e..01c2133a7 100644 --- a/src/components/Switch/Switch.tsx +++ b/src/components/Switch/Switch.tsx @@ -1,7 +1,7 @@ import * as RadixSwitch from '@radix-ui/react-switch'; import { forwardRef, useId } from 'react'; import { styled } from 'styled-components'; -import { FormRoot } from '@/components/Common'; +import { FormRoot } from '@/components/FormContainer'; import { GenericLabel } from '@/components/GenericLabel'; import { SwitchProps } from './Switch.types'; import type { Theme } from '@/theme/theme.types';