From 530da6159115e55afd6d335f8b272ee26e551863 Mon Sep 17 00:00:00 2001 From: reece-white Date: Wed, 5 Feb 2025 12:28:16 +0000 Subject: [PATCH 1/4] chore(deps): update react to 19 --- examples/demo/package.json | 4 +- examples/demo/src/App.tsx | 2 +- package.json | 8 +-- packages/docsearch-react/package.json | 6 +- packages/docsearch-react/src/AlgoliaLogo.tsx | 2 +- packages/docsearch-react/src/DocSearch.tsx | 2 +- .../docsearch-react/src/DocSearchButton.tsx | 2 +- .../docsearch-react/src/DocSearchModal.tsx | 2 +- packages/docsearch-react/src/ErrorScreen.tsx | 2 +- packages/docsearch-react/src/Footer.tsx | 2 +- packages/docsearch-react/src/Hit.tsx | 2 +- .../docsearch-react/src/NoResultsScreen.tsx | 2 +- packages/docsearch-react/src/Results.tsx | 2 +- .../docsearch-react/src/ResultsScreen.tsx | 2 +- packages/docsearch-react/src/SearchBox.tsx | 5 +- packages/docsearch-react/src/Snippet.tsx | 2 +- packages/docsearch-react/src/StartScreen.tsx | 2 +- .../src/__tests__/api.test.tsx | 2 +- .../src/icons/ControlKeyIcon.tsx | 2 +- .../docsearch-react/src/icons/ErrorIcon.tsx | 2 +- .../src/icons/GoToExternalIcon.tsx | 2 +- .../docsearch-react/src/icons/LoadingIcon.tsx | 2 +- .../src/icons/NoResultsIcon.tsx | 2 +- .../docsearch-react/src/icons/RecentIcon.tsx | 2 +- .../docsearch-react/src/icons/ResetIcon.tsx | 2 +- .../docsearch-react/src/icons/SearchIcon.tsx | 2 +- .../docsearch-react/src/icons/SelectIcon.tsx | 2 +- .../docsearch-react/src/icons/SourceIcon.tsx | 2 +- .../docsearch-react/src/icons/StarIcon.tsx | 2 +- .../src/useDocSearchKeyboardEvents.ts | 2 +- yarn.lock | 69 ++++++++++++------- 31 files changed, 80 insertions(+), 64 deletions(-) diff --git a/examples/demo/package.json b/examples/demo/package.json index 2533e34d7..513dbf22e 100644 --- a/examples/demo/package.json +++ b/examples/demo/package.json @@ -13,8 +13,8 @@ "dependencies": { "@docsearch/css": "3.8.3", "@docsearch/react": "3.8.3", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^19.0.0", + "react-dom": "^19.0.0" }, "devDependencies": { "@vitejs/plugin-react": "^4.3.4", diff --git a/examples/demo/src/App.tsx b/examples/demo/src/App.tsx index 9402c2ecc..24ec11ce8 100644 --- a/examples/demo/src/App.tsx +++ b/examples/demo/src/App.tsx @@ -1,5 +1,5 @@ import { DocSearch } from '@docsearch/react'; - +import type { JSX } from 'react'; import './App.css'; import '@docsearch/css/dist/style.css'; diff --git a/package.json b/package.json index 9bc0bba25..fdddf0070 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "@rollup/plugin-terser": "0.4.4", "@stylistic/eslint-plugin": "2.13.0", "@testing-library/dom": "10.4.0", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@types/react": "^19.0.0", + "@types/react-dom": "^19.0.0", "@typescript-eslint/eslint-plugin": "8.20.0", "@typescript-eslint/parser": "8.20.0", "babel-plugin-module-resolver": "5.0.2", @@ -66,8 +66,8 @@ "lerna": "8.1.9", "postcss": "8.5.1", "prettier": "3.4.2", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", "rollup": "4.31.0", "rollup-plugin-dts": "6.1.1", "rollup-plugin-filesize": "10.0.0", diff --git a/packages/docsearch-react/package.json b/packages/docsearch-react/package.json index 239ec65ee..f8b7a1bf6 100644 --- a/packages/docsearch-react/package.json +++ b/packages/docsearch-react/package.json @@ -48,9 +48,9 @@ "vitest": "3.0.2" }, "peerDependencies": { - "@types/react": ">= 16.8.0 < 19.0.0", - "react": ">= 16.8.0 < 19.0.0", - "react-dom": ">= 16.8.0 < 19.0.0", + "@types/react": ">= 16.8.0 < 20.0.0", + "react": ">= 16.8.0 < 20.0.0", + "react-dom": ">= 16.8.0 < 20.0.0", "search-insights": ">= 1 < 3" }, "peerDependenciesMeta": { diff --git a/packages/docsearch-react/src/AlgoliaLogo.tsx b/packages/docsearch-react/src/AlgoliaLogo.tsx index cf2040fae..c81b45795 100644 --- a/packages/docsearch-react/src/AlgoliaLogo.tsx +++ b/packages/docsearch-react/src/AlgoliaLogo.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; type AlgoliaLogoTranslations = Partial<{ searchByText: string; diff --git a/packages/docsearch-react/src/DocSearch.tsx b/packages/docsearch-react/src/DocSearch.tsx index a7e1e6559..4bf5a9f46 100644 --- a/packages/docsearch-react/src/DocSearch.tsx +++ b/packages/docsearch-react/src/DocSearch.tsx @@ -1,6 +1,6 @@ import type { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core'; import type { LiteClient, SearchParamsObject } from 'algoliasearch/lite'; -import React from 'react'; +import React, { type JSX } from 'react'; import { createPortal } from 'react-dom'; import { DocSearchButton } from './DocSearchButton'; diff --git a/packages/docsearch-react/src/DocSearchButton.tsx b/packages/docsearch-react/src/DocSearchButton.tsx index 9aca83897..d222678fe 100644 --- a/packages/docsearch-react/src/DocSearchButton.tsx +++ b/packages/docsearch-react/src/DocSearchButton.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { type JSX, useEffect, useState } from 'react'; import { ControlKeyIcon } from './icons/ControlKeyIcon'; import { SearchIcon } from './icons/SearchIcon'; diff --git a/packages/docsearch-react/src/DocSearchModal.tsx b/packages/docsearch-react/src/DocSearchModal.tsx index 4f10caa64..6fc99d529 100644 --- a/packages/docsearch-react/src/DocSearchModal.tsx +++ b/packages/docsearch-react/src/DocSearchModal.tsx @@ -1,6 +1,6 @@ import { type AlgoliaInsightsHit, createAutocomplete } from '@algolia/autocomplete-core'; import type { SearchResponse } from 'algoliasearch/lite'; -import React from 'react'; +import React, { type JSX } from 'react'; import { MAX_QUERY_SIZE } from './constants'; import type { DocSearchProps } from './DocSearch'; diff --git a/packages/docsearch-react/src/ErrorScreen.tsx b/packages/docsearch-react/src/ErrorScreen.tsx index c47f8e175..d2f52bd0f 100644 --- a/packages/docsearch-react/src/ErrorScreen.tsx +++ b/packages/docsearch-react/src/ErrorScreen.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import { ErrorIcon } from './icons'; diff --git a/packages/docsearch-react/src/Footer.tsx b/packages/docsearch-react/src/Footer.tsx index 012b37ff0..92c1d28bf 100644 --- a/packages/docsearch-react/src/Footer.tsx +++ b/packages/docsearch-react/src/Footer.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import { AlgoliaLogo } from './AlgoliaLogo'; diff --git a/packages/docsearch-react/src/Hit.tsx b/packages/docsearch-react/src/Hit.tsx index ff121c973..15e3222eb 100644 --- a/packages/docsearch-react/src/Hit.tsx +++ b/packages/docsearch-react/src/Hit.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import type { InternalDocSearchHit, StoredDocSearchHit } from './types'; diff --git a/packages/docsearch-react/src/NoResultsScreen.tsx b/packages/docsearch-react/src/NoResultsScreen.tsx index 78f5a8ab5..ea27de37f 100644 --- a/packages/docsearch-react/src/NoResultsScreen.tsx +++ b/packages/docsearch-react/src/NoResultsScreen.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import { NoResultsIcon } from './icons'; import type { ScreenStateProps } from './ScreenState'; diff --git a/packages/docsearch-react/src/Results.tsx b/packages/docsearch-react/src/Results.tsx index 1a46e8892..bfc84af73 100644 --- a/packages/docsearch-react/src/Results.tsx +++ b/packages/docsearch-react/src/Results.tsx @@ -1,5 +1,5 @@ import type { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core'; -import React from 'react'; +import React, { type JSX } from 'react'; import type { DocSearchProps } from './DocSearch'; import { Snippet } from './Snippet'; diff --git a/packages/docsearch-react/src/ResultsScreen.tsx b/packages/docsearch-react/src/ResultsScreen.tsx index a90f8a479..a0e5d6aa0 100644 --- a/packages/docsearch-react/src/ResultsScreen.tsx +++ b/packages/docsearch-react/src/ResultsScreen.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import { SelectIcon, SourceIcon } from './icons'; import { Results } from './Results'; diff --git a/packages/docsearch-react/src/SearchBox.tsx b/packages/docsearch-react/src/SearchBox.tsx index 95dbbe5f2..8ff3e7761 100644 --- a/packages/docsearch-react/src/SearchBox.tsx +++ b/packages/docsearch-react/src/SearchBox.tsx @@ -1,6 +1,5 @@ import type { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core'; -import type { MutableRefObject } from 'react'; -import React from 'react'; +import React, { type JSX, type RefObject } from 'react'; import { MAX_QUERY_SIZE } from './constants'; import { LoadingIcon } from './icons/LoadingIcon'; @@ -20,7 +19,7 @@ interface SearchBoxProps extends AutocompleteApi { state: AutocompleteState; autoFocus: boolean; - inputRef: MutableRefObject; + inputRef: RefObject; onClose: () => void; isFromSelection: boolean; translations?: SearchBoxTranslations; diff --git a/packages/docsearch-react/src/Snippet.tsx b/packages/docsearch-react/src/Snippet.tsx index 0bfdf93d6..db4eca5f6 100644 --- a/packages/docsearch-react/src/Snippet.tsx +++ b/packages/docsearch-react/src/Snippet.tsx @@ -1,4 +1,4 @@ -import { createElement } from 'react'; +import { type JSX, createElement } from 'react'; import type { StoredDocSearchHit } from './types'; diff --git a/packages/docsearch-react/src/StartScreen.tsx b/packages/docsearch-react/src/StartScreen.tsx index 4e16b88ad..a43d71340 100644 --- a/packages/docsearch-react/src/StartScreen.tsx +++ b/packages/docsearch-react/src/StartScreen.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; import { RecentIcon, ResetIcon, StarIcon } from './icons'; import { Results } from './Results'; diff --git a/packages/docsearch-react/src/__tests__/api.test.tsx b/packages/docsearch-react/src/__tests__/api.test.tsx index 8650cc649..a2ea317b5 100644 --- a/packages/docsearch-react/src/__tests__/api.test.tsx +++ b/packages/docsearch-react/src/__tests__/api.test.tsx @@ -1,5 +1,5 @@ import { render, act, fireEvent, screen, cleanup } from '@testing-library/react'; -import React from 'react'; +import React, { type JSX } from 'react'; import { describe, it, expect, afterEach } from 'vitest'; import '@testing-library/jest-dom/vitest'; diff --git a/packages/docsearch-react/src/icons/ControlKeyIcon.tsx b/packages/docsearch-react/src/icons/ControlKeyIcon.tsx index c099d2d11..a988daa27 100644 --- a/packages/docsearch-react/src/icons/ControlKeyIcon.tsx +++ b/packages/docsearch-react/src/icons/ControlKeyIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function ControlKeyIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/ErrorIcon.tsx b/packages/docsearch-react/src/icons/ErrorIcon.tsx index 39b6d53c3..e4c20260b 100644 --- a/packages/docsearch-react/src/icons/ErrorIcon.tsx +++ b/packages/docsearch-react/src/icons/ErrorIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function ErrorIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/GoToExternalIcon.tsx b/packages/docsearch-react/src/icons/GoToExternalIcon.tsx index f0fddaca3..0668e89c7 100644 --- a/packages/docsearch-react/src/icons/GoToExternalIcon.tsx +++ b/packages/docsearch-react/src/icons/GoToExternalIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function GoToExternal(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/LoadingIcon.tsx b/packages/docsearch-react/src/icons/LoadingIcon.tsx index dc2f43b00..88eed612e 100644 --- a/packages/docsearch-react/src/icons/LoadingIcon.tsx +++ b/packages/docsearch-react/src/icons/LoadingIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function LoadingIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/NoResultsIcon.tsx b/packages/docsearch-react/src/icons/NoResultsIcon.tsx index 569608cdb..2da34d62e 100644 --- a/packages/docsearch-react/src/icons/NoResultsIcon.tsx +++ b/packages/docsearch-react/src/icons/NoResultsIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function NoResultsIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/RecentIcon.tsx b/packages/docsearch-react/src/icons/RecentIcon.tsx index 5eb84ea06..cdb9af9c4 100644 --- a/packages/docsearch-react/src/icons/RecentIcon.tsx +++ b/packages/docsearch-react/src/icons/RecentIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function RecentIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/ResetIcon.tsx b/packages/docsearch-react/src/icons/ResetIcon.tsx index 2863a4b5c..7f0beb0d0 100644 --- a/packages/docsearch-react/src/icons/ResetIcon.tsx +++ b/packages/docsearch-react/src/icons/ResetIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function ResetIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/SearchIcon.tsx b/packages/docsearch-react/src/icons/SearchIcon.tsx index d53605c4c..0572031d0 100644 --- a/packages/docsearch-react/src/icons/SearchIcon.tsx +++ b/packages/docsearch-react/src/icons/SearchIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function SearchIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/SelectIcon.tsx b/packages/docsearch-react/src/icons/SelectIcon.tsx index 6ddb78cd1..53a732e15 100644 --- a/packages/docsearch-react/src/icons/SelectIcon.tsx +++ b/packages/docsearch-react/src/icons/SelectIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function SelectIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/icons/SourceIcon.tsx b/packages/docsearch-react/src/icons/SourceIcon.tsx index 533bb9576..8a30f47b7 100644 --- a/packages/docsearch-react/src/icons/SourceIcon.tsx +++ b/packages/docsearch-react/src/icons/SourceIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; const LvlIcon: React.FC = () => { return ( diff --git a/packages/docsearch-react/src/icons/StarIcon.tsx b/packages/docsearch-react/src/icons/StarIcon.tsx index 586cd0a3b..93351feed 100644 --- a/packages/docsearch-react/src/icons/StarIcon.tsx +++ b/packages/docsearch-react/src/icons/StarIcon.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type JSX } from 'react'; export function StarIcon(): JSX.Element { return ( diff --git a/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts index 6e41221f2..eb172da48 100644 --- a/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts +++ b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts @@ -5,7 +5,7 @@ export interface UseDocSearchKeyboardEventsProps { onOpen: () => void; onClose: () => void; onInput?: (event: KeyboardEvent) => void; - searchButtonRef?: React.RefObject; + searchButtonRef: React.RefObject; } function isEditingContent(event: KeyboardEvent): boolean { diff --git a/yarn.lock b/yarn.lock index d644a42fd..8cb9619ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2130,8 +2130,8 @@ __metadata: "@rollup/plugin-terser": "npm:0.4.4" "@stylistic/eslint-plugin": "npm:2.13.0" "@testing-library/dom": "npm:10.4.0" - "@types/react": "npm:^18.0.0" - "@types/react-dom": "npm:^18.0.0" + "@types/react": "npm:^19.0.0" + "@types/react-dom": "npm:^19.0.0" "@typescript-eslint/eslint-plugin": "npm:8.20.0" "@typescript-eslint/parser": "npm:8.20.0" babel-plugin-module-resolver: "npm:5.0.2" @@ -2153,8 +2153,8 @@ __metadata: lerna: "npm:8.1.9" postcss: "npm:8.5.1" prettier: "npm:3.4.2" - react: "npm:^18.0.0" - react-dom: "npm:^18.0.0" + react: "npm:^19.0.0" + react-dom: "npm:^19.0.0" rollup: "npm:4.31.0" rollup-plugin-dts: "npm:6.1.1" rollup-plugin-filesize: "npm:10.0.0" @@ -2180,8 +2180,8 @@ __metadata: "@docsearch/css": "npm:3.8.3" "@docsearch/react": "npm:3.8.3" "@vitejs/plugin-react": "npm:^4.3.4" - react: "npm:^18.0.0" - react-dom: "npm:^18.0.0" + react: "npm:^19.0.0" + react-dom: "npm:^19.0.0" vite: "npm:^6.0.7" languageName: unknown linkType: soft @@ -2199,9 +2199,9 @@ __metadata: algoliasearch: "npm:^5.14.2" vitest: "npm:3.0.2" peerDependencies: - "@types/react": ">= 16.8.0 < 19.0.0" - react: ">= 16.8.0 < 19.0.0" - react-dom: ">= 16.8.0 < 19.0.0" + "@types/react": ">= 16.8.0 < 20.0.0" + react: ">= 16.8.0 < 20.0.0" + react-dom: ">= 16.8.0 < 20.0.0" search-insights: ">= 1 < 3" peerDependenciesMeta: "@types/react": @@ -5340,13 +5340,6 @@ __metadata: languageName: node linkType: hard -"@types/prop-types@npm:*": - version: 15.7.14 - resolution: "@types/prop-types@npm:15.7.14" - checksum: 10c0/1ec775160bfab90b67a782d735952158c7e702ca4502968aa82565bd8e452c2de8601c8dfe349733073c31179116cf7340710160d3836aa8a1ef76d1532893b1 - languageName: node - linkType: hard - "@types/qs@npm:*": version: 6.9.18 resolution: "@types/qs@npm:6.9.18" @@ -5361,12 +5354,12 @@ __metadata: languageName: node linkType: hard -"@types/react-dom@npm:^18.0.0": - version: 18.3.5 - resolution: "@types/react-dom@npm:18.3.5" +"@types/react-dom@npm:^19.0.0": + version: 19.0.3 + resolution: "@types/react-dom@npm:19.0.3" peerDependencies: - "@types/react": ^18.0.0 - checksum: 10c0/b163d35a6b32a79f5782574a7aeb12a31a647e248792bf437e6d596e2676961c394c5e3c6e91d1ce44ae90441dbaf93158efb4f051c0d61e2612f1cb04ce4faa + "@types/react": ^19.0.0 + checksum: 10c0/3867427b333cbe8cbba496d7cc20ec9676d32c25ae44f4d1263a4129d42e57cf4adf0039ad263432f1215b88075c27d326e7eb4ed646128235d01a76e661d48f languageName: node linkType: hard @@ -5411,13 +5404,12 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^18.0.0": - version: 18.3.18 - resolution: "@types/react@npm:18.3.18" +"@types/react@npm:^19.0.0": + version: 19.0.8 + resolution: "@types/react@npm:19.0.8" dependencies: - "@types/prop-types": "npm:*" csstype: "npm:^3.0.2" - checksum: 10c0/8fb2b00672072135d0858dc9db07873ea107cc238b6228aaa2a9afd1ef7a64a7074078250db38afbeb19064be8ea6af5eac32d404efdd5f45e093cc4829d87f8 + checksum: 10c0/5fa7236356b1476de03519c66ef65d4fd904826956105619e2ad60cb0b55ae7b251dd5fff02234076225b5e15333d0d936bf9dbe1d461406f8a2ba01c197ddcd languageName: node linkType: hard @@ -19090,6 +19082,17 @@ __metadata: languageName: node linkType: hard +"react-dom@npm:^19.0.0": + version: 19.0.0 + resolution: "react-dom@npm:19.0.0" + dependencies: + scheduler: "npm:^0.25.0" + peerDependencies: + react: ^19.0.0 + checksum: 10c0/a36ce7ab507b237ae2759c984cdaad4af4096d8199fb65b3815c16825e5cfeb7293da790a3fc2184b52bfba7ba3ff31c058c01947aff6fd1a3701632aabaa6a9 + languageName: node + linkType: hard + "react-error-overlay@npm:^6.0.11": version: 6.0.11 resolution: "react-error-overlay@npm:6.0.11" @@ -19258,6 +19261,13 @@ __metadata: languageName: node linkType: hard +"react@npm:^19.0.0": + version: 19.0.0 + resolution: "react@npm:19.0.0" + checksum: 10c0/9cad8f103e8e3a16d15cb18a0d8115d8bd9f9e1ce3420310aea381eb42aa0a4f812cf047bb5441349257a05fba8a291515691e3cb51267279b2d2c3253f38471 + languageName: node + linkType: hard + "read-cache@npm:^1.0.0": version: 1.0.0 resolution: "read-cache@npm:1.0.0" @@ -20223,6 +20233,13 @@ __metadata: languageName: node linkType: hard +"scheduler@npm:^0.25.0": + version: 0.25.0 + resolution: "scheduler@npm:0.25.0" + checksum: 10c0/a4bb1da406b613ce72c1299db43759526058fdcc413999c3c3e0db8956df7633acf395cb20eb2303b6a65d658d66b6585d344460abaee8080b4aa931f10eaafe + languageName: node + linkType: hard + "schema-utils@npm:2.7.0": version: 2.7.0 resolution: "schema-utils@npm:2.7.0" From c0b50de6f20d5da0361cfdc027347a089acbc705 Mon Sep 17 00:00:00 2001 From: Dylan Tientcheu Date: Thu, 6 Feb 2025 10:49:47 +0100 Subject: [PATCH 2/4] fix: examples to show backwards compatibility with react 18 --- examples/demo-react-18/index.html | 16 +++++++++++ examples/demo-react-18/package.json | 23 ++++++++++++++++ examples/demo-react-18/public/favicon.ico | Bin 0 -> 5558 bytes examples/demo-react-18/src/App.css | 4 +++ examples/demo-react-18/src/App.tsx | 15 +++++++++++ examples/demo-react-18/src/main.tsx | 10 +++++++ examples/demo-react-18/src/vite-env.d.ts | 1 + examples/demo-react-18/tsconfig.json | 31 ++++++++++++++++++++++ examples/demo-react-18/vite.config.ts | 7 +++++ yarn.lock | 17 ++++++++++-- 10 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 examples/demo-react-18/index.html create mode 100644 examples/demo-react-18/package.json create mode 100644 examples/demo-react-18/public/favicon.ico create mode 100644 examples/demo-react-18/src/App.css create mode 100644 examples/demo-react-18/src/App.tsx create mode 100644 examples/demo-react-18/src/main.tsx create mode 100644 examples/demo-react-18/src/vite-env.d.ts create mode 100644 examples/demo-react-18/tsconfig.json create mode 100644 examples/demo-react-18/vite.config.ts diff --git a/examples/demo-react-18/index.html b/examples/demo-react-18/index.html new file mode 100644 index 000000000..59d9baf45 --- /dev/null +++ b/examples/demo-react-18/index.html @@ -0,0 +1,16 @@ + + + + + + + + DocSearch v3 - React + + + +
+ + + + diff --git a/examples/demo-react-18/package.json b/examples/demo-react-18/package.json new file mode 100644 index 000000000..b82d40640 --- /dev/null +++ b/examples/demo-react-18/package.json @@ -0,0 +1,23 @@ +{ + "name": "@docsearch/react-18-example", + "description": "DocSearch v3 React 18 example", + "version": "3.8.3", + "private": true, + "license": "MIT", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "preview": "vite preview" + }, + "dependencies": { + "@docsearch/css": "workspace:*", + "@docsearch/react": "workspace:*", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@vitejs/plugin-react": "^4.3.4", + "vite": "^6.0.7" + } +} diff --git a/examples/demo-react-18/public/favicon.ico b/examples/demo-react-18/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c481de75b6d7efef27e9f5b9aaf39f01da1afed9 GIT binary patch literal 5558 zcmd^D`%_g_6h1Zmn%U1yh0{#qztE^?Sz1<3nU6~CVN(N^IE`szPMT?rHHIjPPLT)# zmp2!<2qJKK`+$o)5)>R!M7W5^Q;^sF`qn*g;czdPb42>3HS=*f`>eg!+WV}%_P4g8 zJfS?P`1mON^-<u{Rm{#$i8~7^_2suFfW&qSbydU^w zJFwFa*b@Lm{R!N>uGbGb{uspJ0J=JWic6fwA>g|&fD;D+`yE|_x3$_~Nr*>!VuDu` zTXS*0y?y#I#cpU2u)#Wy< zU-mjSu2`-cAHT5_`*&=|z<|y@mwN`-@ueE49=$N$I5IM#zmw=5*a^gix%GL_+l#uI z8r0VsLml-65BvMw#`M@wW#gV;EOg%2ysj)O#cJP$So_*y!&v3J07cxFx@2gGIch7A ze^#SDJUoovo*u|L7=`p3)Efh0H8uBHzwi~TUcAUKRxMh9&)$6-?QLzY@x1$ca%_BSIpcVRF}$+^ z8{S-olKec)cvC(|jO^P6oJ-ZHbdXaNWoM%(H^&%qvPmy;(B0Lg8E?vmx+^LlXltEP zWmaFvx`!QgGa+#&+(-D0UihzDgFp7}(SQD4Eacoj0q(ZA*_YgFHbo&N#-tm`QIWV( zQQbhGqJieaQMwzedw}=q1&hTie{%S3DeeI7Q1HSQ!-CF|?a`1OZzSSky z7;oQ`^Zb1n@RFaKZrwuYp+Kqy;pCCS2n#;KFbT$~V}heN6><#W$3u`7ABV<<22R8C zJX}6?b3Y`W1_H?W%+cWC=z2A4|48lCz`7?Pf^+_gHPH?*nNDktSu+X!4^&=Y3I&WJ z{1|JneZcN5D!-I^%yu43$kW=ULO$!y=P)!_2P^rhjCK0BF$kYLYX*edk;fa58`OPa ztOn)^oG{RLrmCDIUi5Y+@PBzH_awYJao&)4yC>m#%|S=I#mO7m$sHy`>Tl06$H2lf zL^`f*H|Bp@Tr97u#vyacN=@<5 zpLtsHFZ-+hm#O|2as4Mi{Fk%T&3{=t=}(dM%eJIJ)+&YmPDDaPxbu5ze3yr6=A_~r zXY*9+pUN}en(5(Omij36B+%XI?C;5ci64n6`{er=IqM{r|GDh!JN74oYZMz9iFo=i zNQ&cmHZgwXoRa&JgmB(vktb^<74?kA!Yq(1jzel$xm(CeQSW)O$SvFK+MYl*tF5Qe b+8oV73m$QgoN!>$_g6=W<n_O~ literal 0 HcmV?d00001 diff --git a/examples/demo-react-18/src/App.css b/examples/demo-react-18/src/App.css new file mode 100644 index 000000000..d1a94a917 --- /dev/null +++ b/examples/demo-react-18/src/App.css @@ -0,0 +1,4 @@ +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, + Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; +} diff --git a/examples/demo-react-18/src/App.tsx b/examples/demo-react-18/src/App.tsx new file mode 100644 index 000000000..fa5b45d94 --- /dev/null +++ b/examples/demo-react-18/src/App.tsx @@ -0,0 +1,15 @@ +import { DocSearch } from '@docsearch/react'; +import type { JSX } from 'react'; +import './App.css'; +import '@docsearch/css/dist/style.css'; + +function App(): JSX.Element { + return ( +
+

DocSearch v3 - React - 18

+ +
+ ); +} + +export default App; diff --git a/examples/demo-react-18/src/main.tsx b/examples/demo-react-18/src/main.tsx new file mode 100644 index 000000000..9ac8961f7 --- /dev/null +++ b/examples/demo-react-18/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; + +import App from './App.tsx'; + +createRoot(document.getElementById('root')!).render( + + + , +); diff --git a/examples/demo-react-18/src/vite-env.d.ts b/examples/demo-react-18/src/vite-env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/examples/demo-react-18/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/demo-react-18/tsconfig.json b/examples/demo-react-18/tsconfig.json new file mode 100644 index 000000000..697e14a91 --- /dev/null +++ b/examples/demo-react-18/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "module": "ESNext", + "skipLibCheck": true, + /* Bundler mode */ + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": [ + "src", + "vite.config.ts" + ], +} diff --git a/examples/demo-react-18/vite.config.ts b/examples/demo-react-18/vite.config.ts new file mode 100644 index 000000000..a74ec848a --- /dev/null +++ b/examples/demo-react-18/vite.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/yarn.lock b/yarn.lock index 8cb9619ad..851051857 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2089,7 +2089,7 @@ __metadata: languageName: node linkType: hard -"@docsearch/css@npm:3.8.3, @docsearch/css@workspace:packages/docsearch-css": +"@docsearch/css@npm:3.8.3, @docsearch/css@workspace:*, @docsearch/css@workspace:packages/docsearch-css": version: 0.0.0-use.local resolution: "@docsearch/css@workspace:packages/docsearch-css" languageName: unknown @@ -2173,6 +2173,19 @@ __metadata: languageName: unknown linkType: soft +"@docsearch/react-18-example@workspace:examples/demo-react-18": + version: 0.0.0-use.local + resolution: "@docsearch/react-18-example@workspace:examples/demo-react-18" + dependencies: + "@docsearch/css": "workspace:*" + "@docsearch/react": "workspace:*" + "@vitejs/plugin-react": "npm:^4.3.4" + react: "npm:^18.0.0" + react-dom: "npm:^18.0.0" + vite: "npm:^6.0.7" + languageName: unknown + linkType: soft + "@docsearch/react-example@workspace:examples/demo": version: 0.0.0-use.local resolution: "@docsearch/react-example@workspace:examples/demo" @@ -2186,7 +2199,7 @@ __metadata: languageName: unknown linkType: soft -"@docsearch/react@npm:3.8.3, @docsearch/react@npm:^3.8.1, @docsearch/react@workspace:packages/docsearch-react": +"@docsearch/react@npm:3.8.3, @docsearch/react@npm:^3.8.1, @docsearch/react@workspace:*, @docsearch/react@workspace:packages/docsearch-react": version: 0.0.0-use.local resolution: "@docsearch/react@workspace:packages/docsearch-react" dependencies: From 57397a7474329dce275249aca2830aec39e4137e Mon Sep 17 00:00:00 2001 From: Dylan Tientcheu Date: Thu, 6 Feb 2025 11:54:29 +0100 Subject: [PATCH 3/4] fix: types --- examples/demo-react-18/src/App.tsx | 4 ++-- examples/demo-react-18/src/main.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/demo-react-18/src/App.tsx b/examples/demo-react-18/src/App.tsx index fa5b45d94..31830ec30 100644 --- a/examples/demo-react-18/src/App.tsx +++ b/examples/demo-react-18/src/App.tsx @@ -1,9 +1,9 @@ import { DocSearch } from '@docsearch/react'; -import type { JSX } from 'react'; +import React from 'react'; import './App.css'; import '@docsearch/css/dist/style.css'; -function App(): JSX.Element { +function App(): React.JSX.Element { return (

DocSearch v3 - React - 18

diff --git a/examples/demo-react-18/src/main.tsx b/examples/demo-react-18/src/main.tsx index 9ac8961f7..ec6476a27 100644 --- a/examples/demo-react-18/src/main.tsx +++ b/examples/demo-react-18/src/main.tsx @@ -1,4 +1,4 @@ -import { StrictMode } from 'react'; +import React, { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import App from './App.tsx'; From cbc0a1352f7c2597630071db77fe61af7f84be71 Mon Sep 17 00:00:00 2001 From: Dylan Tientcheu Date: Thu, 6 Feb 2025 12:12:22 +0100 Subject: [PATCH 4/4] fix: eslint --- examples/demo-react-18/src/main.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/demo-react-18/src/main.tsx b/examples/demo-react-18/src/main.tsx index ec6476a27..1744314d1 100644 --- a/examples/demo-react-18/src/main.tsx +++ b/examples/demo-react-18/src/main.tsx @@ -1,4 +1,5 @@ -import React, { StrictMode } from 'react'; +/* eslint-disable react/react-in-jsx-scope */ +import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import App from './App.tsx';