@shipengine/alchemy 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { BrandName, Theme } from "@packlink/brands";
2
+ import { ShipEngineProps } from "@shipengine/react-api";
3
+ export type IconIndex = {
4
+ [key: string]: string[];
5
+ };
6
+ export interface AlchemyProps {
7
+ baseURL?: string;
8
+ brandName?: BrandName;
9
+ cdnURL?: string;
10
+ children: React.ReactNode;
11
+ getToken: ShipEngineProps["getToken"];
12
+ scope?: string;
13
+ }
14
+ export type AlchemyContextValue = Required<Omit<AlchemyProps, "children">> & {
15
+ theme: Theme;
16
+ };
17
+ export declare const AlchemyContext: import("react").Context<AlchemyContextValue | undefined>;
18
+ export declare const Alchemy: ({ baseURL, brandName, cdnURL, children, getToken, scope, }: AlchemyProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
19
+ export declare const useAlchemy: () => AlchemyContextValue;
@@ -0,0 +1,3 @@
1
+ export * from "./use-load-fonts";
2
+ export * from "./use-load-icons";
3
+ export * from "./use-load-theme";
@@ -0,0 +1,7 @@
1
+ import { Theme } from "@packlink/brands";
2
+ export interface UseLoadFontsProps {
3
+ cdnURL: string;
4
+ scope: string;
5
+ theme?: Pick<Theme, "defaultFontFamily" | "fontFaces">;
6
+ }
7
+ export declare const useLoadFonts: ({ cdnURL, scope, theme }: UseLoadFontsProps) => import("@emotion/utils").SerializedStyles;
@@ -0,0 +1,5 @@
1
+ export interface UseLoadIconsProps {
2
+ brandName: string;
3
+ cdnURL: string;
4
+ }
5
+ export declare const useLoadIcons: ({ brandName, cdnURL }: UseLoadIconsProps) => (iconName: string) => Promise<any>;
@@ -0,0 +1,6 @@
1
+ import { BrandName, Theme } from "@packlink/brands";
2
+ export interface UseLoadThemeProps {
3
+ brandName: BrandName;
4
+ cdnURL: string;
5
+ }
6
+ export declare const useLoadTheme: ({ cdnURL, brandName }: UseLoadThemeProps) => Theme | undefined;
@@ -0,0 +1 @@
1
+ export * from "./alchemy";
@@ -0,0 +1,14 @@
1
+ import { WithConditionalCSSProp } from "@emotion/react/types/jsx-namespace";
2
+ import { TranslationResources } from "./hooks";
3
+ export type ElementComponentProps = object & WithConditionalCSSProp<object>;
4
+ export type ElementComponent<P extends ElementComponentProps> = React.ComponentType<P>;
5
+ export type ElementFallbackComponentProps = {
6
+ error: Error;
7
+ };
8
+ export type ElementFallbackComponent = React.ComponentType<ElementFallbackComponentProps>;
9
+ export interface ElementProps {
10
+ children: React.ReactElement<ElementComponentProps>;
11
+ fallback: ElementFallbackComponent;
12
+ resources?: TranslationResources;
13
+ }
14
+ export declare const Element: ({ children, fallback: FallbackComponent, resources }: ElementProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./use-i18n";
@@ -0,0 +1,12 @@
1
+ export type TranslationNamespaces = {
2
+ [key: string]: Record<string, any>;
3
+ default: Record<string, any>;
4
+ };
5
+ export type TranslationResources<Namespaces = TranslationNamespaces> = {
6
+ [key: string]: Namespaces;
7
+ en: Namespaces;
8
+ };
9
+ export interface UseI18nProps {
10
+ resources?: TranslationResources;
11
+ }
12
+ export declare const useI18n: ({ resources }: UseI18nProps) => import("i18next").i18n;
@@ -0,0 +1 @@
1
+ export * from "./element";
@@ -0,0 +1 @@
1
+ export * from "./memoized-create-cache";
@@ -0,0 +1 @@
1
+ export declare const memoizedCreateCache: import("@emotion/memoize").Fn<import("@emotion/utils").EmotionCache>;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ export interface ErrorProps {
3
+ error: Error;
4
+ }
5
+ export type ErrorBoundaryProps = {
6
+ children: React.ReactNode;
7
+ fallback: React.ComponentType<{
8
+ error: Error;
9
+ }>;
10
+ };
11
+ type ErrorBoundaryState = {
12
+ error?: Error;
13
+ };
14
+ declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
15
+ constructor(props: ErrorBoundaryProps);
16
+ componentDidCatch(error: Error, context: React.ErrorInfo): void;
17
+ render(): string | number | boolean | import("@emotion/react/jsx-runtime").JSX.Element | React.ReactFragment | null | undefined;
18
+ }
19
+ export { ErrorBoundary };
@@ -0,0 +1 @@
1
+ export * from "./error-boundary";
@@ -0,0 +1,3 @@
1
+ export * from "./alchemy";
2
+ export * from "./element";
3
+ export * from "./error-boundary";
@@ -0,0 +1,4 @@
1
+ import { ElementComponent, ElementFallbackComponent } from "./components";
2
+ export declare const createElement: <P extends object, T extends TranslationResources>(Component: ElementComponent<P>, fallback: ElementFallbackComponent, defaultResources: T) => ({ resources, ...props }: P & {
3
+ resources?: T | undefined;
4
+ }) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./components";
2
+ export * from "./create-element";
3
+ export * from "@shipengine/react-api";