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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@placekit/autocomplete-react",
"version": "2.2.2",
"version": "2.3.0",
"author": "PlaceKit <support@placekit.io>",
"description": "PlaceKit Autocomplete React library",
"keywords": [
Expand Down Expand Up @@ -67,7 +67,7 @@
"prop-types": "^15.8.1"
},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
"react-dom": "^16 || ^17 || ^18"
"react": "^16 || ^17 || ^18 || ^19",
"react-dom": "^16 || ^17 || ^18 || ^19"
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy';

import pkg from './package.json' assert { type: 'json' };
import pkg from './package.json' with { type: 'json' };
const banner = [
`/*! ${pkg.name} v${pkg.version}`,
'© placekit.io',
Expand Down
17 changes: 12 additions & 5 deletions src/PlaceKit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import React, { forwardRef, useCallback, useEffect } from 'react';

import { usePlaceKit } from './usePlaceKit';

// default props as parameter defaults (React 19 ignores `defaultProps` on function components)
// `options` default is a module-level constant to keep a stable reference across renders
const DEFAULT_OPTIONS = {};
const DEFAULT_PLACEHOLDER = 'Search places...';

const PlaceKit = forwardRef(
(
{
apiKey,
className,
geolocation,
options,
geolocation = true,
options = DEFAULT_OPTIONS,
placeholder = DEFAULT_PLACEHOLDER,
onClient,
onOpen,
onClose,
Expand Down Expand Up @@ -108,16 +114,17 @@ const PlaceKit = forwardRef(
>
<span className="pka-sr-only">Clear value</span>
</button>
<input {...inputProps} type="search" ref={target} />
<input {...inputProps} placeholder={placeholder} type="search" ref={target} />
</div>
);
},
);

// kept for backward compatibility on React 16 to 18 (apps reading or mutating `PlaceKit.defaultProps`)
PlaceKit.defaultProps = {
geolocation: true,
options: {},
placeholder: 'Search places...',
options: DEFAULT_OPTIONS,
placeholder: DEFAULT_PLACEHOLDER,
};

PlaceKit.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export type PlaceKitHooks = {
state: PKAState;
};

declare function PlaceKit(props: PlaceKitProps): JSX.Element;
declare function PlaceKit(props: PlaceKitProps): React.ReactElement;

declare function usePlaceKit(apiKey: string, options?: PlaceKitOptions): PlaceKitHooks;
Loading