Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions examples/demo-react-18/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DocSearch v3 - React</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
23 changes: 23 additions & 0 deletions examples/demo-react-18/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Binary file added examples/demo-react-18/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/demo-react-18/src/App.css
Original file line number Diff line number Diff line change
@@ -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';
}
15 changes: 15 additions & 0 deletions examples/demo-react-18/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DocSearch } from '@docsearch/react';
import React from 'react';
import './App.css';
import '@docsearch/css/dist/style.css';

function App(): React.JSX.Element {
return (
<div>
<h1>DocSearch v3 - React - 18</h1>
<DocSearch indexName="vuejs" appId="ML0LEBN7FQ" apiKey="21cf9df0734770a2448a9da64a700c22" insights={true} />
</div>
);
}

export default App;
11 changes: 11 additions & 0 deletions examples/demo-react-18/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable react/react-in-jsx-scope */
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App.tsx';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
);
1 change: 1 addition & 0 deletions examples/demo-react-18/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
31 changes: 31 additions & 0 deletions examples/demo-react-18/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
],
}
7 changes: 7 additions & 0 deletions examples/demo-react-18/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
});
4 changes: 2 additions & 2 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocSearch } from '@docsearch/react';

import type { JSX } from 'react';
import './App.css';
import '@docsearch/css/dist/style.css';

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/docsearch-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/AlgoliaLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

type AlgoliaLogoTranslations = Partial<{
searchByText: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/DocSearch.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/DocSearchButton.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/DocSearchModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/ErrorScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import { ErrorIcon } from './icons';

Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import { AlgoliaLogo } from './AlgoliaLogo';

Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/Hit.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import type { InternalDocSearchHit, StoredDocSearchHit } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/NoResultsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import { NoResultsIcon } from './icons';
import type { ScreenStateProps } from './ScreenState';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/Results.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/ResultsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import { SelectIcon, SourceIcon } from './icons';
import { Results } from './Results';
Expand Down
5 changes: 2 additions & 3 deletions packages/docsearch-react/src/SearchBox.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +19,7 @@ interface SearchBoxProps
extends AutocompleteApi<InternalDocSearchHit, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
state: AutocompleteState<InternalDocSearchHit>;
autoFocus: boolean;
inputRef: MutableRefObject<HTMLInputElement | null>;
inputRef: RefObject<HTMLInputElement | null>;
onClose: () => void;
isFromSelection: boolean;
translations?: SearchBoxTranslations;
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/Snippet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement } from 'react';
import { type JSX, createElement } from 'react';

import type { StoredDocSearchHit } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/StartScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

import { RecentIcon, ResetIcon, StarIcon } from './icons';
import { Results } from './Results';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/__tests__/api.test.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/ControlKeyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function ControlKeyIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/ErrorIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function ErrorIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/GoToExternalIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function GoToExternal(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/LoadingIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function LoadingIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/NoResultsIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function NoResultsIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/RecentIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function RecentIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/ResetIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function ResetIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/SearchIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function SearchIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/SelectIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function SelectIcon(): JSX.Element {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/SourceIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

const LvlIcon: React.FC = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docsearch-react/src/icons/StarIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';

export function StarIcon(): JSX.Element {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface UseDocSearchKeyboardEventsProps {
onOpen: () => void;
onClose: () => void;
onInput?: (event: KeyboardEvent) => void;
searchButtonRef?: React.RefObject<HTMLButtonElement>;
searchButtonRef: React.RefObject<HTMLButtonElement | null>;
}

function isEditingContent(event: KeyboardEvent): boolean {
Expand Down
Loading