Skip to content

Commit

Permalink
v4 alpha 2
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Mar 12, 2022
1 parent e48128e commit 1d3828a
Show file tree
Hide file tree
Showing 11 changed files with 1,862 additions and 1,784 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
## v4.0.0-alpha.2 (2022-03-12)

- Added `createLeafletContext` function to core.
- Updated React dependencies to v18 RC2.
- Changed Leaflet dependency range to v1.7.x until tested with v1.8.x.

## v4.0.0-alpha.1 (2022-02-05)

- Merge changes from v3.
- Update docs for v4 support.
- Merged changes from v3.
- Updated docs for v4 support.

## v4.0.0-alpha.0 (2022-01-05)

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"devDependencies": {
"@skypack/package-check": "^0.2.2",
"@swc/cli": "^0.1.55",
"@swc/core": "^1.2.136",
"@swc/core": "^1.2.153",
"@swc/jest": "^0.2.17",
"@testing-library/react": "^13.0.0-alpha",
"@testing-library/react-hooks": "^8.0.0-alpha",
"@types/jest": "^27.4.0",
"@types/leaflet": "^1.7.9",
"@types/leaflet": "~1.7.9",
"@types/warning": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"cross-env": "^7.0.3",
"del-cli": "^4.0.1",
"eslint": "^8.8.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -38,14 +38,14 @@
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"jest": "^27.5.0",
"leaflet": "^1.7.1",
"leaflet": "~1.7.1",
"prettier": "^2.5.1",
"prettier-eslint": "^13.0.0",
"react": "^18.0.0-rc",
"react-dom": "^18.0.0-rc",
"react-test-renderer": "^18.0.0-rc",
"react": "^18.0.0-rc.2",
"react-dom": "^18.0.0-rc.2",
"react-test-renderer": "^18.0.0-rc.2",
"ts-jest-resolver": "^2.0.0",
"turbo": "^1.1.2",
"turbo": "^1.1.6",
"typescript": "^4.5.5"
},
"jest": {
Expand Down
16 changes: 15 additions & 1 deletion packages/core/__tests__/context.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { renderHook } from '@testing-library/react-hooks'
import type { Map } from 'leaflet'
import React, { type ReactNode } from 'react'

import { LeafletProvider, useLeafletContext } from '../src'
import {
CONTEXT_VERSION,
LeafletProvider,
createLeafletContext,
useLeafletContext,
} from '../src'

export function createWrapper(context) {
return function Wrapper({ children }: { children: ReactNode }) {
Expand All @@ -10,6 +16,14 @@ export function createWrapper(context) {
}

describe('context', () => {
test('createLeafletContext() creates the context object', () => {
const map = {} as unknown as Map
expect(createLeafletContext(map)).toEqual({
__version: CONTEXT_VERSION,
map,
})
})

test('useLeafletContext() throws an error when there is no provider', () => {
expect(() => {
const { result } = renderHook(() => useLeafletContext())
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-leaflet/core",
"version": "2.0.0-alpha.0",
"version": "2.0.0-alpha.1",
"description": "React Leaflet core",
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,9 +41,9 @@
"prepublishOnly": "package-check"
},
"peerDependencies": {
"leaflet": "^1.7.1",
"react": "^18.0.0-rc",
"react-dom": "^18.0.0-rc"
"leaflet": "~1.7.1",
"react": "^18.0.0-rc.2",
"react-dom": "^18.0.0-rc.2"
},
"jest": {
"extensionsToTreatAsEsm": [
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type LeafletContextInterface = Readonly<{
pane?: string
}>

export function createLeafletContext(map: Map): LeafletContextInterface {
return Object.freeze({ __version: CONTEXT_VERSION, map })
}

export function extendContext(
source: LeafletContextInterface,
extra: Partial<LeafletContextInterface>,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
type LeafletContextInterface,
LeafletContext,
LeafletProvider,
createLeafletContext,
extendContext,
useLeafletContext,
} from './context.js'
Expand Down
12 changes: 6 additions & 6 deletions packages/react-leaflet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-leaflet",
"version": "4.0.0-alpha.1",
"version": "4.0.0-alpha.2",
"description": "React components for Leaflet maps",
"repository": {
"type": "git",
Expand Down Expand Up @@ -42,15 +42,15 @@
"prepublishOnly": "package-check"
},
"dependencies": {
"@react-leaflet/core": "^2.0.0-alpha.0"
"@react-leaflet/core": "^2.0.0-alpha.1"
},
"peerDependencies": {
"leaflet": "^1.7.1",
"react": "^18.0.0-rc",
"react-dom": "^18.0.0-rc"
"leaflet": "~1.7.1",
"react": "^18.0.0-rc.2",
"react-dom": "^18.0.0-rc.2"
},
"devDependencies": {
"@types/leaflet": "^1.7.9"
"@types/leaflet": "~1.7.9"
},
"jest": {
"extensionsToTreatAsEsm": [
Expand Down
4 changes: 2 additions & 2 deletions packages/react-leaflet/src/MapContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CONTEXT_VERSION,
LeafletProvider,
type LeafletContextInterface,
createLeafletContext,
} from '@react-leaflet/core'
import {
type FitBoundsOptions,
Expand Down Expand Up @@ -64,7 +64,7 @@ function MapContainerComponent<
if (whenReady != null) {
map.whenReady(whenReady)
}
setContext(Object.freeze({ __version: CONTEXT_VERSION, map }))
setContext(createLeafletContext(map))
}
}, [])

Expand Down
8 changes: 8 additions & 0 deletions packages/website/docs/core-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ interface PathWithChildrenProps extends PathProps, PropsWithChildren {}

`LeafletContext.Provider` component.

### createLeafletContext

**Arguments**

1. `map: Map`

**Returns** [`LeafletContextInterface`](#leafletcontextinterface)

### useLeafletContext

[React Hook](https://reactjs.org/docs/hooks-intro.html) returning the [`LeafletContext`](#leafletcontext). Calling this hook will throw an error if the context is not provided.
Expand Down
14 changes: 7 additions & 7 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"deploy": "docusaurus deploy"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-beta.15",
"@docusaurus/preset-classic": "2.0.0-beta.15",
"@docusaurus/theme-live-codeblock": "2.0.0-beta.15",
"@docusaurus/core": "2.0.0-beta.17",
"@docusaurus/preset-classic": "2.0.0-beta.17",
"@docusaurus/theme-live-codeblock": "2.0.0-beta.17",
"@react-leaflet/docusaurus-plugin": "^1.0.1",
"classnames": "^2.2.6",
"leaflet": "^1.7.1",
"react": "^18.0.0-rc",
"react-dom": "^18.0.0-rc",
"react-leaflet": "^4.0.0-alpha",
"leaflet": "~1.7.1",
"react": "^18.0.0-rc.2",
"react-dom": "^18.0.0-rc.2",
"react-leaflet": "^4.0.0-alpha.2",
"typescript": "^4.5.5"
},
"browserslist": {
Expand Down
Loading

0 comments on commit 1d3828a

Please sign in to comment.