Skip to content

Commit b986c59

Browse files
committed
fixup for updated repo config
1 parent 7c75c61 commit b986c59

File tree

11 files changed

+87
-42
lines changed

11 files changed

+87
-42
lines changed

packages/react/document-context/src/document-context.stories.tsx renamed to apps/storybook/stories/document-context.stories.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import * as React from 'react';
2-
3-
import * as Tooltip from '@radix-ui/react-tooltip';
4-
import * as Dialog from '@radix-ui/react-dialog';
5-
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
62
import { createPortal } from 'react-dom';
7-
import * as DocumentContext from '@radix-ui/react-document-context';
8-
3+
import { DocumentContext } from 'radix-ui/internal';
4+
import { Dialog, DropdownMenu, Tooltip } from 'radix-ui';
95
import styles from './document-context.stories.module.css';
6+
107
export default { title: 'Utilities/DocumentContext' };
118

129
export const Default = () => {

apps/storybook/stories/presence.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Presence, useDocument } from 'radix-ui/internal';
2+
import { Presence, DocumentContext } from 'radix-ui/internal';
33
import styles from './presence.stories.module.css';
44

55
export default { title: 'Utilities/Presence' };
@@ -35,7 +35,7 @@ export const WithDeferredMountAnimation = () => {
3535
const timerRef = React.useRef(0);
3636
const [open, setOpen] = React.useState(false);
3737
const [animate, setAnimate] = React.useState(false);
38-
const documentWindow = useDocument()?.defaultView;
38+
const documentWindow = DocumentContext.useDocument()?.defaultView;
3939

4040
React.useEffect(() => {
4141
if (!documentWindow) return;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `react-document-context`
2+
3+
## Usage
4+
5+
This is an internal utility, not intended for public usage.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @ts-check
2+
import { configs } from '@repo/eslint-config/react-package';
3+
4+
export default configs;

packages/react/document-context/package.json

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,65 @@
11
{
22
"name": "@radix-ui/react-document-context",
3-
"version": "1.0.0",
3+
"version": "0.0.0",
44
"license": "MIT",
5-
"exports": {
6-
".": {
7-
"import": {
8-
"types": "./dist/index.d.mts",
9-
"default": "./dist/index.mjs"
10-
},
11-
"require": {
12-
"types": "./dist/index.d.ts",
13-
"default": "./dist/index.js"
5+
"source": "./src/index.ts",
6+
"main": "./src/index.ts",
7+
"module": "./src/index.ts",
8+
"publishConfig": {
9+
"main": "./dist/index.js",
10+
"module": "./dist/index.mjs",
11+
"types": "./dist/index.d.ts",
12+
"exports": {
13+
".": {
14+
"import": {
15+
"types": "./dist/index.d.mts",
16+
"default": "./dist/index.mjs"
17+
},
18+
"require": {
19+
"types": "./dist/index.d.ts",
20+
"default": "./dist/index.js"
21+
}
1422
}
1523
}
1624
},
17-
"source": "./src/index.ts",
18-
"main": "./dist/index.js",
19-
"module": "./dist/index.mjs",
20-
"types": "./dist/index.d.ts",
2125
"files": [
2226
"dist",
2327
"README.md"
2428
],
2529
"sideEffects": false,
2630
"scripts": {
31+
"lint": "eslint --max-warnings 0 src",
2732
"clean": "rm -rf dist",
28-
"version": "yarn version"
33+
"typecheck": "tsc --noEmit",
34+
"build": "radix-build"
2935
},
3036
"dependencies": {
31-
"@radix-ui/react-primitive": "workspace:*",
32-
"use-sync-external-store": "^1.4.0"
37+
"@radix-ui/react-use-is-hydrated": "workspace:*"
3338
},
3439
"devDependencies": {
40+
"@repo/builder": "workspace:*",
41+
"@repo/eslint-config": "workspace:*",
42+
"@repo/test-data": "workspace:*",
3543
"@repo/typescript-config": "workspace:*",
3644
"@types/react": "^19.0.7",
37-
"@types/use-sync-external-store": "^0.0.6",
38-
"react": "^19.0.0",
45+
"@types/react-dom": "^19.0.3",
46+
"eslint": "^9.18.0",
47+
"react": "^19.1.0",
48+
"react-dom": "^19.1.0",
3949
"typescript": "^5.7.3"
4050
},
4151
"peerDependencies": {
4252
"@types/react": "*",
43-
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0"
53+
"@types/react-dom": "*",
54+
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
55+
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4456
},
4557
"peerDependenciesMeta": {
4658
"@types/react": {
4759
"optional": true
60+
},
61+
"@types/react-dom": {
62+
"optional": true
4863
}
4964
},
5065
"homepage": "https://radix-ui.com/primitives",

packages/react/document-context/src/document-context.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import { DocumentProvider, useDocument } from './document-context';
3+
import { describe, it, expect } from 'vitest';
34

45
// Test component that uses the document context
56
function TestComponent() {
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as React from 'react';
2-
import { useSyncExternalStore } from 'use-sync-external-store/shim';
2+
import { useIsHydrated } from '@radix-ui/react-use-is-hydrated';
3+
34
// Use null as initial value to handle SSR safely
45
const DocumentContext = React.createContext<Document | null>(null);
6+
DocumentContext.displayName = 'DocumentContext';
57

68
interface DocumentProviderProps {
79
document: Document;
@@ -12,14 +14,8 @@ export function DocumentProvider({ document, children }: DocumentProviderProps)
1214
return <DocumentContext.Provider value={document}>{children}</DocumentContext.Provider>;
1315
}
1416

15-
const subscribe = () => () => {};
16-
1717
export function useDocument() {
18-
const doc = React.useContext(DocumentContext);
19-
const isHydrated = useSyncExternalStore(
20-
subscribe,
21-
() => true,
22-
() => false
23-
);
24-
return doc ?? (isHydrated ? document : null);
18+
const document = React.useContext(DocumentContext);
19+
const isHydrated = useIsHydrated();
20+
return document ?? (isHydrated ? globalThis.document : null);
2521
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@repo/typescript-config/react-library.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"types": ["@repo/typescript-config/react-library"]
6+
},
7+
"include": ["src"],
8+
"exclude": ["node_modules", "dist"]
9+
}

packages/react/radix-ui/src/internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export * as Collection from '@radix-ui/react-collection';
44
export { composeRefs, useComposedRefs } from '@radix-ui/react-compose-refs';
55
export * as Context from '@radix-ui/react-context';
66
export * as DismissableLayer from '@radix-ui/react-dismissable-layer';
7-
export { useDocument } from '@radix-ui/react-document-context';
7+
export * as DocumentContext from '@radix-ui/react-document-context';
88
export * as FocusGuards from '@radix-ui/react-focus-guards';
99
export * as FocusScope from '@radix-ui/react-focus-scope';
1010
export * as Menu from '@radix-ui/react-menu';

pnpm-lock.yaml

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)