Skip to content

Commit

Permalink
Merge pull request #346 from artsy/damassi/fix/next
Browse files Browse the repository at this point in the history
fix(next): Make work with next via suppressHydrationWarning
  • Loading branch information
damassi committed Nov 2, 2023
2 parents b5f16b0 + f40af37 commit 72e5424
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 12 deletions.
43 changes: 43 additions & 0 deletions dist/Breakpoints.d.ts
@@ -0,0 +1,43 @@
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 {};
72 changes: 72 additions & 0 deletions dist/DynamicResponsive.d.ts
@@ -0,0 +1,72 @@
/**
* 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;
};
};
18 changes: 18 additions & 0 deletions dist/Interactions.d.ts
@@ -0,0 +1,18 @@
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;
}

0 comments on commit 72e5424

Please sign in to comment.