Skip to content

Commit

Permalink
fix(*): deprecate EnvironmentContext type in favor of UseEnvironmentC…
Browse files Browse the repository at this point in the history
…ontext
  • Loading branch information
cschroeter committed Nov 29, 2024
1 parent e3affbb commit 860e3c8
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 24 deletions.
5 changes: 5 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ description: All notable changes will be documented in this file.

- **ColorPicker**: Added support for `invalid` and `openAutoFocus` props.

- ### Changed

- **Environment**: Deprecated `EnvironmentContext` in favor of `UseEnvironmentContext`.

### Fixed

- **Presence, Collapsible**: Resolved a potential memory leak occurring after component unmount.
- **Environment**: Exported `EnvironmentContext`

## [4.4.4] - 2024-11-18

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentProvider } from '@ark-ui/react/environment'
import Frame from 'react-frame-component'
import { EnvironmentProvider } from '../'
import { Usage } from './usage'

export const Basic = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentProvider } from '@ark-ui/react/environment'
import Frame from 'react-frame-component'
import { EnvironmentProvider } from '../'

export const App = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EnvironmentProvider, useEnvironmentContext } from '@ark-ui/react/environment'
import { Portal } from '@ark-ui/react/portal'
import { useEffect, useState } from 'react'
import { EnvironmentProvider, useEnvironmentContext } from '../'
import { Portal } from '../../../components'
import { Basic } from '../../../components/tooltip/examples/basic'

export const ShadowRoot = () => {
const [ref, setRef] = useState<HTMLDivElement | null>(null)
Expand All @@ -28,7 +27,6 @@ const PrintEnvironment = () => {
return (
<Portal>
<pre>{JSON.stringify(getRootNode(), null, 2)}</pre>
<Basic />
</Portal>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEnvironmentContext } from '../use-environment-context'
import { useEnvironmentContext } from '@ark-ui/react/environment'

export const Usage = () => {
const { getRootNode } = useEnvironmentContext()
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/providers/environment/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export { EnvironmentProvider, type EnvironmentProviderProps } from './environment-provider'
export {
useEnvironmentContext,
type EnvironmentContext,
type UseEnvironmentContext,
/**
* @deprecated Use `UseEnvironmentContext` instead.
*/
type UseEnvironmentContext as EnvironmentContext,
type RootNode,
} from './use-environment-context'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createContext } from '../../utils/create-context'

export type RootNode = ShadowRoot | Document | Node

export interface EnvironmentContext {
export interface UseEnvironmentContext {
/**
* The root node of the application.
* This is used to determine the window and document objects.
Expand All @@ -19,7 +19,7 @@ export interface EnvironmentContext {
}

export const [EnvironmentContextProvider, useEnvironmentContext] =
createContext<EnvironmentContext>({
createContext<UseEnvironmentContext>({
name: 'EnvironmentContext',
hookName: 'useEnvironmentContext',
providerName: '<EnvironmentProvider />',
Expand Down
4 changes: 4 additions & 0 deletions packages/solid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ description: All notable changes will be documented in this file.

- **ColorPicker**: Added support for `invalid` and `openAutoFocus` props.

- ### Changed

- **Environment**: Deprecated `EnvironmentContext` in favor of `UseEnvironmentContext`.

### Fixed

- **Presence, Collapsible**: Resolved a potential memory leak occurring after component unmount.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvironmentProvider } from '../..'
import { EnvironmentProvider } from '@ark-ui/solid/environment'
import { Usage } from './usage'

export const Basic = () => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvironmentProvider } from '../..'
import { EnvironmentProvider } from '@ark-ui/solid/environment'

export const App = () => {
return (
Expand Down
6 changes: 5 additions & 1 deletion packages/solid/src/providers/environment/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export { EnvironmentProvider, type EnvironmentProviderProps } from './environment-provider'
export {
useEnvironmentContext,
type EnvironmentContext,
/**
* @deprecated Use `UseEnvironmentContext` instead.
*/
type UseEnvironmentContext as EnvironmentContext,
type RootNode,
type UseEnvironmentContext,
} from './use-environment-context'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createContext } from '../../utils/create-context'

export type RootNode = ShadowRoot | Document | Node

export interface EnvironmentContext {
export interface UseEnvironmentContext {
/**
* The root node of the application.
* This is used to determine the window and document objects.
Expand All @@ -23,7 +23,7 @@ export interface EnvironmentContext {
}

export const [EnvironmentContextProvider, useEnvironmentContext] = createContext<
Accessor<EnvironmentContext>
Accessor<UseEnvironmentContext>
>({
hookName: 'useEnvironmentContext',
providerName: '<EnvironmentProvider />',
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/lib/providers/environment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export {
} from './environment-provider.svelte'
export {
useEnvironmentContext,
type EnvironmentContext,
type UseEnvironmentContext,
type RootNode,
} from './use-environment-context'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createContext } from '$lib/utils/create-context'

export type RootNode = ShadowRoot | Document | Node

export interface EnvironmentContext {
export interface UseEnvironmentContext {
/**
* The root node of the application.
* This is used to determine the window and document objects.
Expand All @@ -22,7 +22,7 @@ export interface EnvironmentContext {
}

export const [EnvironmentContextProvider, useEnvironmentContext] =
createContext<EnvironmentContext>({
createContext<UseEnvironmentContext>({
key: 'EnvironmentContext',
defaultValue: {
getRootNode: () => document,
Expand Down
4 changes: 4 additions & 0 deletions packages/vue/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ description: All notable changes will be documented in this file.

- **ColorPicker**: Added support for `invalid` and `openAutoFocus` props.

- ### Changed

- **Environment**: Deprecated `EnvironmentContext` in favor of `UseEnvironmentContext`.

### Fixed

- **Presence, Collapsible**: Resolved a potential memory leak occurring after component unmount.
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/providers/environment/examples/basic.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { EnvironmentProvider } from '..'
import { EnvironmentProvider } from '@ark-ui/vue/environment'
import Usage from './usage.vue'
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/providers/environment/examples/setup.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { EnvironmentProvider } from '../'
import { EnvironmentProvider } from '@ark-ui/vue/environment'
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/providers/environment/examples/usage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useEnvironmentContext } from '../'
import { useEnvironmentContext } from '@ark-ui/vue/environment'
const environment = useEnvironmentContext()
</script>
Expand Down
5 changes: 4 additions & 1 deletion packages/vue/src/providers/environment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export {
} from './environment-provider.vue'
export {
useEnvironmentContext,
type EnvironmentContext,
/**
* @deprecated Use `UseEnvironmentContext` instead.
*/
type UseEnvironmentContext as EnvironmentContext,
type RootNode,
} from './use-environment-context'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createContext } from '../../utils'

export type RootNode = ShadowRoot | Document | Node

export interface EnvironmentContext {
export interface UseEnvironmentContext {
/**
* The root node of the application.
* This is used to determine the window and document objects.
Expand All @@ -20,4 +20,4 @@ export interface EnvironmentContext {
}

export const [EnvironmentContextProvider, useEnvironmentContext] =
createContext<ComputedRef<EnvironmentContext> | null>('EnvironmentContext')
createContext<ComputedRef<UseEnvironmentContext> | null>('EnvironmentContext')

0 comments on commit 860e3c8

Please sign in to comment.