Skip to content

Commit 4827952

Browse files
committed
refactor(shared): consolidate inert helper into @clerk/shared/inert
Replace the duplicated per-package inert.ts utilities in @clerk/ui and @clerk/headless with a single canonical helper at @clerk/shared/inert. Adds @clerk/shared as @clerk/headless's first internal dependency and externalizes it in the headless vite build.
1 parent 55cb047 commit 4827952

11 files changed

Lines changed: 77 additions & 99 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/shared": patch
3+
---
4+
5+
Add an `inertProps` helper (`@clerk/shared/inert`) that resolves the correct `inert` attribute value for the consumer's React major (React 19 dropped the `inert` attribute for falsy string values).

packages/headless/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"test": "vitest run"
5858
},
5959
"dependencies": {
60+
"@clerk/shared": "workspace:^",
6061
"@floating-ui/react": "catalog:repo"
6162
},
6263
"devDependencies": {

packages/headless/src/primitives/tabs/tabs-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use client';
22

3+
import { inertProps } from '@clerk/shared/inert';
34
import { useMergeRefs } from '@floating-ui/react';
45
import React, { useRef } from 'react';
56

67
import { useTransition } from '../../hooks/use-transition';
7-
import { inertProps } from '../../utils/inert';
88
import { type ComponentProps, mergeProps, renderElement } from '../../utils/render-element';
99
import { useTabsContext } from './tabs-context';
1010

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { cssVars } from './css-vars';
2-
export { inertProps } from './inert';
32
export { type ComponentProps, mergeProps, type RenderProp, renderElement } from './render-element';

packages/headless/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineConfig({
3131
formats: ['es'],
3232
},
3333
rollupOptions: {
34-
external: ['react', 'react-dom', 'react/jsx-runtime', '@floating-ui/react'],
34+
external: ['react', 'react-dom', 'react/jsx-runtime', '@floating-ui/react', /^@clerk\/shared(\/.*)?$/],
3535
// Preserve module-level directives such as `'use client'`. Rollup otherwise
3636
// strips them when bundling (emitting a warning), which would drop the
3737
// client boundary for React Server Component consumers of the primitives.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const major = parseInt(version, 10);
1212
const isModernReact = major >= 19 || major === 0;
1313

1414
/**
15-
* Props to spread onto an element to apply (or omit) the `inert` attribute correctly
16-
* across React 18 and 19.
15+
* Returns props to spread onto an element to apply (or omit) the `inert` attribute
16+
* correctly across React 18 and 19.
1717
*
18-
* Returned as `Record<string, unknown>` on purpose: React 18's types reject `inert` and
18+
* Typed as `Record<string, unknown>` on purpose: React 18's types reject `inert` and
1919
* React 19's type it as `boolean`, so an untyped spread sidesteps both type-level shapes
2020
* regardless of which `@types/react` a consumer compiles against.
2121
*

packages/ui/src/components/PricingTable/PricingTableMatrix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { inertProps } from '@clerk/shared/inert';
12
import type { BillingPlanResource, BillingSubscriptionPlanPeriod } from '@clerk/shared/types';
23
import * as React from 'react';
34

45
import { Avatar } from '@/ui/elements/Avatar';
56
import { SegmentedControl } from '@/ui/elements/SegmentedControl';
67
import { colors } from '@/ui/utils/colors';
7-
import { inertProps } from '@/ui/utils/inert';
88

99
import { usePlansContext } from '../../contexts';
1010
import {

packages/ui/src/components/devPrompts/KeylessPrompt/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { inertProps } from '@clerk/shared/inert';
12
import { useUser } from '@clerk/shared/react';
23
// eslint-disable-next-line no-restricted-imports
34
import { css } from '@emotion/react';
45
import { type ReactNode, useId, useMemo, useState } from 'react';
56

67
import { InternalThemeProvider } from '../../../styledSystem';
7-
import { inertProps } from '../../../utils/inert';
88
import { handleDashboardUrlParsing } from '../shared';
99
import { useDragToCorner } from './use-drag-to-corner';
1010
import { useRevalidateEnvironment } from './use-revalidate-environment';

packages/ui/src/elements/Collapsible.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { inertProps } from '@clerk/shared/inert';
12
import { type PropsWithChildren, useEffect, useState } from 'react';
23

34
import { Box, descriptors, useAppearance } from '../customizables';
45
import { usePrefersReducedMotion } from '../hooks';
56
import type { ThemableCssProp } from '../styledSystem';
6-
import { inertProps } from '../utils/inert';
77

88
type CollapsibleProps = PropsWithChildren<{
99
open: boolean;

packages/ui/src/utils/inert.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)