@shipengine/alchemy 1.0.0-next.2 → 1.0.1

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.
package/alchemy.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const alchemy: {
2
+ createElement: <P extends object, T extends import("./components").TranslationResources<import("./components").TranslationNamespaces>>(Component: import("./components").ElementComponent<P>, fallback: import("./components").ElementFallbackComponent, options?: import("./create-element").CreateElementOptions<T> | undefined) => ({ resources, ...props }: P & {
3
+ resources?: T | undefined;
4
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ };
@@ -1,19 +1,22 @@
1
- import { BrandName, Theme } from "@packlink/brands";
1
+ import { BrandName } from "@packlink/brands";
2
+ import { Theme } from "@packlink/giger-theme";
2
3
  import { ShipEngineProps } from "@shipengine/react-api";
3
4
  export type IconIndex = {
4
5
  [key: string]: string[];
5
6
  };
7
+ export type AlchemyErrorHandler = (err: Error) => void;
6
8
  export interface AlchemyProps {
7
9
  baseURL?: string;
8
10
  brandName?: BrandName;
9
11
  cdnURL?: string;
10
12
  children: React.ReactNode;
11
13
  getToken: ShipEngineProps["getToken"];
14
+ onError?: AlchemyErrorHandler;
12
15
  scope?: string;
13
16
  }
14
17
  export type AlchemyContextValue = Required<Omit<AlchemyProps, "children">> & {
15
18
  theme: Theme;
16
19
  };
17
20
  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;
21
+ export declare const Alchemy: ({ baseURL, brandName, cdnURL, children, getToken, onError, scope, }: AlchemyProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
19
22
  export declare const useAlchemy: () => AlchemyContextValue;
@@ -1,6 +1,6 @@
1
- import { Theme } from "@packlink/brands";
1
+ import { Theme } from "@packlink/giger-theme";
2
2
  export interface UseLoadFontsProps {
3
- cdnURL: string;
3
+ cdnURL?: string;
4
4
  scope: string;
5
5
  theme?: Pick<Theme, "defaultFontFamily" | "fontFaces">;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  export interface UseLoadIconsProps {
2
2
  brandName: string;
3
- cdnURL: string;
3
+ cdnURL?: string;
4
4
  }
5
5
  export declare const useLoadIcons: ({ brandName, cdnURL }: UseLoadIconsProps) => (iconName: string) => Promise<any>;
@@ -1,6 +1,7 @@
1
- import { BrandName, Theme } from "@packlink/brands";
1
+ import { BrandName } from "@packlink/brands";
2
+ import { Theme } from "@packlink/giger-theme";
2
3
  export interface UseLoadThemeProps {
3
4
  brandName: BrandName;
4
- cdnURL: string;
5
+ cdnURL?: string;
5
6
  }
6
7
  export declare const useLoadTheme: ({ cdnURL, brandName }: UseLoadThemeProps) => Theme | undefined;
@@ -1 +1,2 @@
1
1
  export * from "./alchemy";
2
+ export * from "./hooks";
@@ -8,7 +8,8 @@ export type ElementFallbackComponentProps = {
8
8
  export type ElementFallbackComponent = React.ComponentType<ElementFallbackComponentProps>;
9
9
  export interface ElementProps {
10
10
  children: React.ReactElement<ElementComponentProps>;
11
+ className?: string;
11
12
  fallback: ElementFallbackComponent;
12
13
  resources?: TranslationResources;
13
14
  }
14
- export declare const Element: ({ children, fallback: FallbackComponent, resources }: ElementProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
15
+ export declare const Element: ({ children, className, fallback: FallbackComponent, resources, }: ElementProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
@@ -1,6 +1,6 @@
1
1
  export type TranslationNamespaces = {
2
2
  [key: string]: Record<string, any>;
3
- default: Record<string, any>;
3
+ common: Record<string, any>;
4
4
  };
5
5
  export type TranslationResources<Namespaces = TranslationNamespaces> = {
6
6
  [key: string]: Namespaces;
@@ -1 +1,3 @@
1
1
  export * from "./element";
2
+ export * from "./hooks";
3
+ export * from "./utils";
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { AlchemyErrorHandler } from "../alchemy";
2
3
  export interface ErrorProps {
3
4
  error: Error;
4
5
  }
@@ -7,6 +8,7 @@ export type ErrorBoundaryProps = {
7
8
  fallback: React.ComponentType<{
8
9
  error: Error;
9
10
  }>;
11
+ onError: AlchemyErrorHandler;
10
12
  };
11
13
  type ErrorBoundaryState = {
12
14
  error?: Error;
@@ -1,4 +1,10 @@
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 & {
1
+ import { Theme } from "@emotion/react";
2
+ import { Interpolation } from "@emotion/serialize";
3
+ import { ElementComponent, ElementFallbackComponent, TranslationResources } from "./components";
4
+ export interface CreateElementOptions<T extends TranslationResources> {
5
+ css?: Interpolation<Theme>;
6
+ resources?: T;
7
+ }
8
+ export declare const createElement: <P extends object, T extends TranslationResources<import("./components").TranslationNamespaces>>(Component: ElementComponent<P>, fallback: ElementFallbackComponent, options?: CreateElementOptions<T> | undefined) => ({ resources, ...props }: P & {
3
9
  resources?: T | undefined;
4
10
  }) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "./components";
2
- export * from "./create-element";
3
2
  export * from "@shipengine/react-api";
3
+ export { alchemy, alchemy as default } from "./alchemy";