Skip to content

Commit

Permalink
fix(next): Make work with next
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Nov 2, 2023
1 parent b5f16b0 commit 05f4134
Show file tree
Hide file tree
Showing 10 changed files with 555 additions and 4 deletions.
51 changes: 51 additions & 0 deletions dist/Breakpoints.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MediaBreakpointProps } from "./Media"
/**
* A union of possible breakpoint props.
*/
export type BreakpointConstraintKey = keyof MediaBreakpointProps
type ValueBreakpointPropsTuple<SizeValue, BreakpointKey> = [
SizeValue,
MediaBreakpointProps<BreakpointKey>
]
export declare enum BreakpointConstraint {
at = "at",
lessThan = "lessThan",
greaterThan = "greaterThan",
greaterThanOrEqual = "greaterThanOrEqual",
between = "between",
}
/**
* Encapsulates all breakpoint data needed by the Media component. The data is
* generated on initialization so no further runtime work is necessary.
*/
export declare class Breakpoints<BreakpointKey extends string> {
static validKeys(): BreakpointConstraint[]
private _sortedBreakpoints
private _breakpoints
private _mediaQueries
constructor(breakpoints: { [key: string]: number })
get sortedBreakpoints(): BreakpointKey[]
get dynamicResponsiveMediaQueries(): {}
get largestBreakpoint(): string
findBreakpointsForWidths: (
fromWidth: number,
throughWidth: number
) => BreakpointKey[] | undefined
findBreakpointAtWidth: (width: number) => BreakpointKey | undefined
toVisibleAtBreakpointSet(
breakpointProps: MediaBreakpointProps
): BreakpointKey[]
toRuleSets(keys?: BreakpointConstraint[]): string[]
shouldRenderMediaQuery(
breakpointProps: MediaBreakpointProps,
onlyRenderAt: string[]
): boolean
valuesWithBreakpointProps: <SizeValue>(
values: SizeValue[]
) => ValueBreakpointPropsTuple<SizeValue, BreakpointKey>[]
private _normalizeProps
private _createBreakpointQuery
private _createBreakpointQueries
private _findNextBreakpoint
}
export {}
108 changes: 108 additions & 0 deletions dist/DynamicResponsive.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* TODO: This is the deprecated runtime media-query component from Reaction.
* It can probably be simplified somewhat if we’re not going to be using
* it directly any longer.
*/
import React from "react"
/** TODO */
export type MediaQueries<M extends string = string> = { [K in M]: string }
/** TODO */
export interface MediaQueryMatchers {
[key: string]: MediaQueryList
}
/** TODO */
export type MediaQueryMatches<M extends string = string> = { [K in M]: boolean }
/** TODO */
export interface ResponsiveProviderProps<M extends string> {
mediaQueries: MediaQueries<M>
initialMatchingMediaQueries?: M[]
children: React.ReactNode
}
/** TODO */
export interface ResponsiveProviderState {
mediaQueryMatchers?: MediaQueryMatchers
mediaQueryMatches: MediaQueryMatches
}
/** TODO */
export declare function createResponsiveComponents<M extends string>(): {
Consumer: React.FunctionComponent<React.ConsumerProps<MediaQueryMatches<M>>>
Provider: {
new (props: ResponsiveProviderProps<M>): {
isSupportedEnvironment: () => boolean
/**
* Create an array of media matchers that can validate each media query
*/
setupMatchers: (mediaQueries: MediaQueries) => MediaQueryMatchers
/**
* Uses the matchers to build a map of the states of each media query
*/
checkMatchers: (
mediaQueryMatchers: MediaQueryMatchers
) => MediaQueryMatches
/**
* The function that will be called any time a media query status changes
*/
mediaQueryStatusChangedCallback: () => void
componentDidMount(): void
componentWillUnmount(): void
shouldComponentUpdate(
nextProps: Readonly<ResponsiveProviderProps<M>>,
nextState: Readonly<ResponsiveProviderState>
): boolean
render(): JSX.Element
context: unknown
setState<K extends keyof ResponsiveProviderState>(
state:
| ResponsiveProviderState
| ((
prevState: Readonly<ResponsiveProviderState>,
props: Readonly<ResponsiveProviderProps<M>>
) =>
| ResponsiveProviderState
| Pick<ResponsiveProviderState, K>
| null
)
| Pick<ResponsiveProviderState, K>
| null,
callback?: (() => void) | undefined
): void
forceUpdate(callback?: (() => void) | undefined): void
readonly props: Readonly<ResponsiveProviderProps<M>>
state: Readonly<ResponsiveProviderState>
refs: {
[key: string]: React.ReactInstance
}
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void
getSnapshotBeforeUpdate?(
prevProps: Readonly<ResponsiveProviderProps<M>>,
prevState: Readonly<ResponsiveProviderState>
): any
componentDidUpdate?(
prevProps: Readonly<ResponsiveProviderProps<M>>,
prevState: Readonly<ResponsiveProviderState>,
snapshot?: any
): void
componentWillMount?(): void
UNSAFE_componentWillMount?(): void
componentWillReceiveProps?(
nextProps: Readonly<ResponsiveProviderProps<M>>,
nextContext: any
): void
UNSAFE_componentWillReceiveProps?(
nextProps: Readonly<ResponsiveProviderProps<M>>,
nextContext: any
): void
componentWillUpdate?(
nextProps: Readonly<ResponsiveProviderProps<M>>,
nextState: Readonly<ResponsiveProviderState>,
nextContext: any
): void
UNSAFE_componentWillUpdate?(
nextProps: Readonly<ResponsiveProviderProps<M>>,
nextState: Readonly<ResponsiveProviderState>,
nextContext: any
): void
}
contextType?: React.Context<any> | undefined
}
}
16 changes: 16 additions & 0 deletions dist/Interactions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export declare enum InteractionKey {
interaction = "interaction",
}
/**
* Encapsulates all interaction data needed by the Media component. The data is
* generated on initialization so no further runtime work is necessary.
*/
export declare class Interactions {
static validKeys(): InteractionKey[]
private _interactions
constructor(interactions: { [name: string]: string })
toRuleSets(): string[]
get interactions(): string[]
get dynamicResponsiveMediaQueries(): {}
shouldRenderMediaQuery(interaction: string, onlyMatch: string[]): boolean
}
Loading

0 comments on commit 05f4134

Please sign in to comment.