The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
chore: drop deprecated Tab, TabContent, TabList, TabPanel components (#84024)
Uladzimir Havenchyk46788ea18f4c
diff --git a/frontend/src/metabase/common/components/Tab/Tab.styled.tsx b/frontend/src/metabase/common/components/Tab/Tab.styled.tsxdeleted file mode 100644index 34cd6d65ef7..00000000000--- a/frontend/src/metabase/common/components/Tab/Tab.styled.tsx+++ /dev/null@@ -1,47 +0,0 @@-// eslint-disable-next-line eslint-js/no-restricted-imports-import styled from "@emotion/styled";--import { focusOutlineStyle } from "metabase/common/style/focus-outline";-import { Icon } from "metabase/ui";-import { alpha } from "metabase/ui/colors";-import { color } from "metabase/ui/utils/colors";--interface TabProps {- isSelected?: boolean;-}--export const TabRoot = styled.button<TabProps>`- display: flex;- align-items: end;- width: 100%;- flex: 1;- text-align: left;- color: ${(props) =>- props.isSelected ? color("core-brand") : color("text-primary")};- background-color: ${(props) =>- props.isSelected ? alpha("core-brand", 0.1) : "transparent"};- cursor: pointer;- margin-bottom: 0.75rem;- padding: 0.75rem 1rem;- margin-right: var(--mantine-spacing-sm);- border-radius: var(--mantine-spacing-xxs);-- &:hover {- color: var(--mb-color-core-brand);- }-- ${focusOutlineStyle("core-brand")};-`;--export const TabIcon = styled(Icon)`- width: 1rem;- height: 1rem;- margin-right: 0.5rem;-`;--export const TabLabel = styled.div`- width: 100%;- font-weight: bold;- overflow: hidden;- text-overflow: ellipsis;-`;diff --git a/frontend/src/metabase/common/components/Tab/Tab.tsx b/frontend/src/metabase/common/components/Tab/Tab.tsxdeleted file mode 100644index bd7c2d47421..00000000000--- a/frontend/src/metabase/common/components/Tab/Tab.tsx+++ /dev/null@@ -1,49 +0,0 @@-import type { HTMLAttributes, MouseEvent, ReactNode, Ref } from "react";-import { forwardRef, useCallback, useContext } from "react";--import type { IconName } from "metabase-types/api";--import { TabIcon, TabLabel, TabRoot } from "./Tab.styled";-import { TabContext } from "./TabContext";-import { getTabId, getTabPanelId } from "./utils";--export interface TabProps<T> extends HTMLAttributes<HTMLButtonElement> {- value?: T;- icon?: IconName;- children?: ReactNode;- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;-}--export const Tab = forwardRef(function Tab<T>(- { value, icon, children, onClick, ...props }: TabProps<T>,- ref: Ref<HTMLButtonElement>,-) {- const { value: selectedValue, idPrefix, onChange } = useContext(TabContext);- const tabId = getTabId(idPrefix, value);- const panelId = getTabPanelId(idPrefix, value);- const isSelected = value === selectedValue;-- const handleClick = useCallback(- (event: MouseEvent<HTMLButtonElement>) => {- onClick?.(event);- onChange?.(value);- },- [value, onClick, onChange],- );-- return (- <TabRoot- {...props}- ref={ref}- id={tabId}- role="tab"- isSelected={isSelected}- aria-selected={isSelected}- aria-controls={panelId}- onClick={handleClick}- >- {icon && <TabIcon name={icon} />}- <TabLabel>{children}</TabLabel>- </TabRoot>- );-});diff --git a/frontend/src/metabase/common/components/Tab/index.ts b/frontend/src/metabase/common/components/Tab/index.tsindex eea36252f8e..698b5b03f23 100644--- a/frontend/src/metabase/common/components/Tab/index.ts+++ b/frontend/src/metabase/common/components/Tab/index.ts@@ -1,3 +1,2 @@-export { Tab } from "./Tab";export * from "./TabContext";export * from "./utils";diff --git a/frontend/src/metabase/common/components/TabContent/TabContent.stories.tsx b/frontend/src/metabase/common/components/TabContent/TabContent.stories.tsxdeleted file mode 100644index 120ce1677ca..00000000000--- a/frontend/src/metabase/common/components/TabContent/TabContent.stories.tsx+++ /dev/null@@ -1,36 +0,0 @@-import { useArgs } from "@storybook/preview-api";-import type { StoryFn } from "@storybook/react";--import { Tab } from "../Tab";-import { TabList } from "../TabList";-import { TabPanel } from "../TabPanel";--import { TabContent } from "./TabContent";--export default {- title: "Deprecated/Components/TabContent",- component: TabContent,-};-const Template: StoryFn<typeof TabContent> = (args) => {- const [{ value }, updateArgs] = useArgs();- const handleChange = (value: unknown) => updateArgs({ value });-- return (- <TabContent {...args} value={value} onChange={handleChange}>- <TabList>- <Tab value={1}>Tab 1</Tab>- <Tab value={2}>Tab 2</Tab>- </TabList>- <TabPanel value={1}>Panel 1</TabPanel>- <TabPanel value={2}>Panel 2</TabPanel>- </TabContent>- );-};--export const Default = {- render: Template,-- args: {- value: 1,- },-};diff --git a/frontend/src/metabase/common/components/TabContent/TabContent.tsx b/frontend/src/metabase/common/components/TabContent/TabContent.tsxdeleted file mode 100644index 033497c328c..00000000000--- a/frontend/src/metabase/common/components/TabContent/TabContent.tsx+++ /dev/null@@ -1,31 +0,0 @@-import type { ReactNode } from "react";-import { useMemo } from "react";--import { useUniqueId } from "metabase/common/hooks/use-unique-id";--import type { TabContextType } from "../Tab";-import { TabContext } from "../Tab";--export interface TabContentProps<T> {- value?: T;- children?: ReactNode;- onChange?: (value: T) => void;-}--export const TabContent = function TabContent<T>({- value,- children,- onChange,-}: TabContentProps<T>) {- const idPrefix = useUniqueId();- const context = useMemo(() => {- return { value, idPrefix, onChange };- }, [value, idPrefix, onChange]);-- // Unjustified type cast. FIXME- return (- <TabContext.Provider value={context as TabContextType}>- {children}- </TabContext.Provider>- );-};diff --git a/frontend/src/metabase/common/components/TabContent/TabContent.unit.spec.tsx b/frontend/src/metabase/common/components/TabContent/TabContent.unit.spec.tsxdeleted file mode 100644index 9b1e5fbc873..00000000000--- a/frontend/src/metabase/common/components/TabContent/TabContent.unit.spec.tsx+++ /dev/null@@ -1,37 +0,0 @@-import userEvent from "@testing-library/user-event";-import { useState } from "react";--import { render, screen } from "__support__/ui";--import { Tab } from "../Tab";-import { TabList } from "../TabList";-import { TabPanel } from "../TabPanel";--import { TabContent } from "./TabContent";--const TestTabContent = () => {- const [value, setValue] = useState(1);-- return (- <TabContent value={value} onChange={setValue}>- <TabList>- <Tab value={1}>Tab 1</Tab>- <Tab value={2}>Tab 2</Tab>- </TabList>- <TabPanel value={1}>Panel 1</TabPanel>- <TabPanel value={2}>Panel 2</TabPanel>- </TabContent>- );-};--describe("TabContent", () => {- it("should navigate between tabs", async () => {- render(<TestTabContent />);- expect(screen.getByText("Panel 1")).toBeInTheDocument();- expect(screen.queryByText("Panel 2")).not.toBeInTheDocument();-- await userEvent.click(screen.getByRole("tab", { name: "Tab 2" }));- expect(screen.queryByText("Panel 1")).not.toBeInTheDocument();- expect(screen.getByText("Panel 2")).toBeInTheDocument();- });-});diff --git a/frontend/src/metabase/common/components/TabContent/index.ts b/frontend/src/metabase/common/components/TabContent/index.tsdeleted file mode 100644index 9559fd5308f..00000000000--- a/frontend/src/metabase/common/components/TabContent/index.ts+++ /dev/null@@ -1 +0,0 @@-export { TabContent } from "./TabContent";diff --git a/frontend/src/metabase/common/components/TabList/TabList.stories.tsx b/frontend/src/metabase/common/components/TabList/TabList.stories.tsxdeleted file mode 100644index 66a3858ba31..00000000000--- a/frontend/src/metabase/common/components/TabList/TabList.stories.tsx+++ /dev/null@@ -1,52 +0,0 @@-import { useArgs } from "@storybook/preview-api";-import type { StoryFn } from "@storybook/react";--import { Tab } from "../Tab";--import { TabList } from "./TabList";--export default {- title: "Deprecated/Components/TabList",- component: TabList,-};--const sampleStyle = {- maxWidth: "200px",- padding: "10px",- border: "1px solid #ccc",-};--const Template: StoryFn<typeof TabList> = (args) => {- const [{ value }, updateArgs] = useArgs();- const handleChange = (value: unknown) => updateArgs({ value });-- return (- <div style={sampleStyle}>- <TabList {...args} value={value} onChange={handleChange}>- <Tab value={1}>Tab 1</Tab>- <Tab value={2}>Tab 2</Tab>- <Tab value={3}>Tab3_supercal_ifragilisticexpia_lidocious</Tab>- <Tab value={4}>- Tab 4 With a Very Long Name that may cause this component to wrap- </Tab>- <Tab value={5}>- Tab 5 With a Very Long Name that may cause this component to wrap- </Tab>- <Tab value={6}>- Tab 6 With a Very Long Name that may cause this component to wrap- </Tab>- <Tab value={7}>- Tab 7 With a Very Long Name that may cause this component to wrap- </Tab>- </TabList>- </div>- );-};--export const Default = {- render: Template,-- args: {- value: 1,- },-};diff --git a/frontend/src/metabase/common/components/TabList/TabList.unit.spec.tsx b/frontend/src/metabase/common/components/TabList/TabList.unit.spec.tsxdeleted file mode 100644index 9d0fa3f9a0a..00000000000--- a/frontend/src/metabase/common/components/TabList/TabList.unit.spec.tsx+++ /dev/null@@ -1,34 +0,0 @@-import userEvent from "@testing-library/user-event";-import { useState } from "react";--import { render, screen } from "__support__/ui";--import { Tab } from "../Tab";--import { TabList } from "./TabList";--const TestTabList = () => {- const [value, setValue] = useState(1);-- return (- <TabList value={value} onChange={setValue}>- <Tab value={1}>Tab 1</Tab>- <Tab value={2}>Tab 2</Tab>- </TabList>- );-};--describe("TabList", () => {- it("should navigate between tabs", async () => {- render(<TestTabList />);-- const option1 = screen.getByRole("tab", { name: "Tab 1" });- const option2 = screen.getByRole("tab", { name: "Tab 2" });- expect(option1).toHaveAttribute("aria-selected", "true");- expect(option2).toHaveAttribute("aria-selected", "false");-- await userEvent.click(option2);- expect(option1).toHaveAttribute("aria-selected", "false");- expect(option2).toHaveAttribute("aria-selected", "true");- });-});diff --git a/frontend/src/metabase/common/components/TabPanel/TabPanel.tsx b/frontend/src/metabase/common/components/TabPanel/TabPanel.tsxdeleted file mode 100644index 0604c01a9be..00000000000--- a/frontend/src/metabase/common/components/TabPanel/TabPanel.tsx+++ /dev/null@@ -1,32 +0,0 @@-import type { HTMLAttributes, ReactNode, Ref } from "react";-import { forwardRef, useContext } from "react";--import { TabContext, getTabId, getTabPanelId } from "../Tab";--export interface TabPanelProps<T> extends HTMLAttributes<HTMLDivElement> {- value?: T;- children?: ReactNode;-}--export const TabPanel = forwardRef(function TabPanel<T>(- { value, children, ...props }: TabPanelProps<T>,- ref: Ref<HTMLDivElement>,-) {- const { value: selectedValue, idPrefix } = useContext(TabContext);- const tabId = getTabId(idPrefix, value);- const panelId = getTabPanelId(idPrefix, value);- const isSelected = value === selectedValue;-- return (- <div- {...props}- ref={ref}- id={panelId}- role="tabpanel"- hidden={!isSelected}- aria-labelledby={tabId}- >- {isSelected && children}- </div>- );-});diff --git a/frontend/src/metabase/common/components/TabPanel/index.ts b/frontend/src/metabase/common/components/TabPanel/index.tsdeleted file mode 100644index 91a829b6d89..00000000000--- a/frontend/src/metabase/common/components/TabPanel/index.ts+++ /dev/null@@ -1 +0,0 @@-export { TabPanel } from "./TabPanel";