Skip to content

Commit

Permalink
[core] Improve DX of importing Base UI components (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Oct 14, 2024
1 parent 0b5da67 commit d86a97c
Show file tree
Hide file tree
Showing 413 changed files with 565 additions and 694 deletions.
2 changes: 1 addition & 1 deletion docs/app/DocsProviders.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import * as Tooltip from '@base_ui/react/Tooltip';
import { Tooltip } from '@base_ui/react/Tooltip';
import { DemoVariantSelectorProvider } from 'docs-base/src/components/demo/DemoVariantSelectorProvider';
import { PackageManagerSnippetProvider } from 'docs-base/src/blocks/PackageManagerSnippet/PackageManagerSnippetProvider';

Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/collapsible-accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as React from 'react';
import * as Collapsible from '@base_ui/react/Collapsible';
import { Collapsible } from '@base_ui/react/Collapsible';

const TRANSITION_DURATION = '350ms';

Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/collapsible-framer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import * as React from 'react';
import { useTheme } from '@mui/system';
import * as Collapsible from '@base_ui/react/Collapsible';
import { Collapsible } from '@base_ui/react/Collapsible';
import { motion } from 'framer-motion';

export default function CollapsibleFramer() {
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/collapsible-hidden-until-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as React from 'react';
import * as Collapsible from '@base_ui/react/Collapsible';
import { Collapsible } from '@base_ui/react/Collapsible';

const DURATION = '350ms';

Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as React from 'react';
import * as Collapsible from '@base_ui/react/Collapsible';
import { Collapsible } from '@base_ui/react/Collapsible';

const DURATION = '350ms';

Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import * as React from 'react';
import clsx from 'clsx';
import * as Dialog from '@base_ui/react/Dialog';
import { Dialog } from '@base_ui/react/Dialog';
// eslint-disable-next-line no-restricted-imports
import { useTransitionStatus } from '@base_ui/react/utils/useTransitionStatus';
import { animated as springAnimated, useSpring, useSpringRef } from '@react-spring/web';
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/menu-anchor-el.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import * as Menu from '@base_ui/react/Menu';
import { Menu } from '@base_ui/react/Menu';

export default function Page() {
const [anchorEl, setAnchor] = React.useState<HTMLDivElement | null>(null);
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/menu-anchor-ref.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import * as Menu from '@base_ui/react/Menu';
import { Menu } from '@base_ui/react/Menu';

export default function Page() {
const anchor = React.useRef<HTMLDivElement>(null);
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/progress.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import * as React from 'react';
import { useTheme } from '@mui/system';
import * as Progress from '@base_ui/react/Progress';
import { Progress } from '@base_ui/react/Progress';

const VAL1 = 33;

Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/slider-change-committed-lag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/mui/material-ui/issues/41739
// to cross check whether this issue would still occur in the new API
import * as React from 'react';
import * as Slider from '@base_ui/react/Slider';
import { Slider } from '@base_ui/react/Slider';
import { Styles } from './slider';

export default function App() {
Expand Down
5 changes: 2 additions & 3 deletions docs/app/experiments/slider-marks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';
import * as React from 'react';
import * as Slider from '@base_ui/react/Slider';
import { useSliderContext } from '@base_ui/react/Slider';
import { Slider } from '@base_ui/react/Slider';

const STOPS = [
{
Expand Down Expand Up @@ -33,7 +32,7 @@ function getSliderThumbAriaValueText(value: number) {
// for "inverted track", the track/rail can be styled with CSS but a prop is needed to flip the "mark active" state
function MarkWithLabel(props: { index: number; value: number; label: string; inverted?: boolean }) {
const { index, value, label, inverted = false } = props;
const { direction, values } = useSliderContext();
const { direction, values } = Slider.useSliderContext();
const isRtl = direction === 'rtl';
const isFilled = inverted ? value >= values[0] : values[0] >= value;
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/slider-template.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as React from 'react';
import * as Slider from '@base_ui/react/Slider';
import { Slider } from '@base_ui/react/Slider';
import { Styles } from './slider';

export default function App() {
Expand Down
4 changes: 2 additions & 2 deletions docs/app/experiments/slider-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';
import * as React from 'react';
import { useTheme } from '@mui/system';
import * as Slider from '@base_ui/react/Slider';
import * as Tooltip from '@base_ui/react/Tooltip';
import { Slider } from '@base_ui/react/Slider';
import { Tooltip } from '@base_ui/react/Tooltip';

function useIsDarkMode() {
const theme = useTheme();
Expand Down
5 changes: 2 additions & 3 deletions docs/app/experiments/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use client';
import * as React from 'react';
import { useTheme } from '@mui/system';
import * as Slider from '@base_ui/react/Slider';
import { useSliderContext } from '@base_ui/react/Slider';
import { Slider } from '@base_ui/react/Slider';

export default function App() {
const [val1, setVal1] = React.useState(50);
Expand Down Expand Up @@ -233,7 +232,7 @@ function Label(props: any) {
const defaultId = React.useId();
const labelId = idProp ?? defaultId;

const { subitems } = useSliderContext();
const { subitems } = Slider.useSliderContext();

const htmlFor = Array.from(subitems.values())
.reduce((acc, item) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/no-danger */
import * as React from 'react';
import { css, styled } from '@mui/system';
import * as BaseTabs from '@base_ui/react/Tabs';
import { Tabs as BaseTabs } from '@base_ui/react/Tabs';

export default function UnstyledTabsIntroduction() {
const [v, sv] = React.useState<string | number | null>(0);
Expand Down
2 changes: 1 addition & 1 deletion docs/app/experiments/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import * as React from 'react';
import * as Tooltip from '@base_ui/react/Tooltip';
import { Tooltip } from '@base_ui/react/Tooltip';
import { styled, keyframes } from '@mui/system';
import { motion, AnimatePresence } from 'framer-motion';

Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-backdrop.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "AlertDialogBackdrop",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogBackdrop = AlertDialog.Backdrop;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogBackdrop = AlertDialog.Backdrop;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-close.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "AlertDialogClose",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogClose = AlertDialog.Close;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogClose = AlertDialog.Close;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-description.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "AlertDialogDescription",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogDescription = AlertDialog.Description;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogDescription = AlertDialog.Description;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-popup.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"name": "AlertDialogPopup",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogPopup = AlertDialog.Popup;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogPopup = AlertDialog.Popup;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"name": "AlertDialogRoot",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogRoot = AlertDialog.Root;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogRoot = AlertDialog.Root;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-title.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "AlertDialogTitle",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogTitle = AlertDialog.Title;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogTitle = AlertDialog.Title;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/alert-dialog-trigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "AlertDialogTrigger",
"imports": [
"import * as AlertDialog from '@base_ui/react/AlertDialog';\nconst AlertDialogTrigger = AlertDialog.Trigger;"
"import { AlertDialog } from '@base_ui/react/AlertDialog';\nconst AlertDialogTrigger = AlertDialog.Trigger;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/checkbox-group-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"name": "CheckboxGroupRoot",
"imports": [
"import * as CheckboxGroup from '@base_ui/react/CheckboxGroup';\nconst CheckboxGroupRoot = CheckboxGroup.Root;"
"import { CheckboxGroup } from '@base_ui/react/CheckboxGroup';\nconst CheckboxGroupRoot = CheckboxGroup.Root;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/checkbox-indicator.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "CheckboxIndicator",
"imports": [
"import * as Checkbox from '@base_ui/react/Checkbox';\nconst CheckboxIndicator = Checkbox.Indicator;"
"import { Checkbox } from '@base_ui/react/Checkbox';\nconst CheckboxIndicator = Checkbox.Indicator;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/checkbox-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"name": "CheckboxRoot",
"imports": [
"import * as Checkbox from '@base_ui/react/Checkbox';\nconst CheckboxRoot = Checkbox.Root;"
"import { Checkbox } from '@base_ui/react/Checkbox';\nconst CheckboxRoot = Checkbox.Root;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/collapsible-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"name": "CollapsibleContent",
"imports": [
"import * as Collapsible from '@base_ui/react/Collapsible';\nconst CollapsibleContent = Collapsible.Content;"
"import { Collapsible } from '@base_ui/react/Collapsible';\nconst CollapsibleContent = Collapsible.Content;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/collapsible-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"name": "CollapsibleRoot",
"imports": [
"import * as Collapsible from '@base_ui/react/Collapsible';\nconst CollapsibleRoot = Collapsible.Root;"
"import { Collapsible } from '@base_ui/react/Collapsible';\nconst CollapsibleRoot = Collapsible.Root;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/collapsible-trigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "CollapsibleTrigger",
"imports": [
"import * as Collapsible from '@base_ui/react/Collapsible';\nconst CollapsibleTrigger = Collapsible.Trigger;"
"import { Collapsible } from '@base_ui/react/Collapsible';\nconst CollapsibleTrigger = Collapsible.Trigger;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/dialog-backdrop.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "DialogBackdrop",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogBackdrop = Dialog.Backdrop;"
"import { Dialog } from '@base_ui/react/Dialog';\nconst DialogBackdrop = Dialog.Backdrop;"
],
"classes": [],
"spread": true,
Expand Down
4 changes: 1 addition & 3 deletions docs/data/api/dialog-close.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "DialogClose",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogClose = Dialog.Close;"
],
"imports": ["import { Dialog } from '@base_ui/react/Dialog';\nconst DialogClose = Dialog.Close;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/dialog-description.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "DialogDescription",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogDescription = Dialog.Description;"
"import { Dialog } from '@base_ui/react/Dialog';\nconst DialogDescription = Dialog.Description;"
],
"classes": [],
"spread": true,
Expand Down
4 changes: 1 addition & 3 deletions docs/data/api/dialog-popup.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "DialogPopup",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogPopup = Dialog.Popup;"
],
"imports": ["import { Dialog } from '@base_ui/react/Dialog';\nconst DialogPopup = Dialog.Popup;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/dialog-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"open": { "type": { "name": "bool" } }
},
"name": "DialogRoot",
"imports": ["import * as Dialog from '@base_ui/react/Dialog';\nconst DialogRoot = Dialog.Root;"],
"imports": ["import { Dialog } from '@base_ui/react/Dialog';\nconst DialogRoot = Dialog.Root;"],
"classes": [],
"spread": true,
"themeDefaultProps": null,
Expand Down
4 changes: 1 addition & 3 deletions docs/data/api/dialog-title.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "DialogTitle",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogTitle = Dialog.Title;"
],
"imports": ["import { Dialog } from '@base_ui/react/Dialog';\nconst DialogTitle = Dialog.Title;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/dialog-trigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "DialogTrigger",
"imports": [
"import * as Dialog from '@base_ui/react/Dialog';\nconst DialogTrigger = Dialog.Trigger;"
"import { Dialog } from '@base_ui/react/Dialog';\nconst DialogTrigger = Dialog.Trigger;"
],
"classes": [],
"spread": true,
Expand Down
4 changes: 1 addition & 3 deletions docs/data/api/field-control.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "FieldControl",
"imports": [
"import * as Field from '@base_ui/react/Field';\nconst FieldControl = Field.Control;"
],
"imports": ["import { Field } from '@base_ui/react/Field';\nconst FieldControl = Field.Control;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/field-description.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "FieldDescription",
"imports": [
"import * as Field from '@base_ui/react/Field';\nconst FieldDescription = Field.Description;"
"import { Field } from '@base_ui/react/Field';\nconst FieldDescription = Field.Description;"
],
"classes": [],
"spread": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/field-error.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "FieldError",
"imports": ["import * as Field from '@base_ui/react/Field';\nconst FieldError = Field.Error;"],
"imports": ["import { Field } from '@base_ui/react/Field';\nconst FieldError = Field.Error;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/field-label.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "FieldLabel",
"imports": ["import * as Field from '@base_ui/react/Field';\nconst FieldLabel = Field.Label;"],
"imports": ["import { Field } from '@base_ui/react/Field';\nconst FieldLabel = Field.Label;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/field-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
},
"name": "FieldRoot",
"imports": ["import * as Field from '@base_ui/react/Field';\nconst FieldRoot = Field.Root;"],
"imports": ["import { Field } from '@base_ui/react/Field';\nconst FieldRoot = Field.Root;"],
"classes": [],
"spread": true,
"themeDefaultProps": true,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/api/field-validity.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"props": {},
"name": "FieldValidity",
"imports": [
"import * as Field from '@base_ui/react/Field';\nconst FieldValidity = Field.Validity;"
"import { Field } from '@base_ui/react/Field';\nconst FieldValidity = Field.Validity;"
],
"classes": [],
"spread": true,
Expand Down
Loading

0 comments on commit d86a97c

Please sign in to comment.