@0xsquid/ui 0.27.6 → 0.27.7-beta.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.
Files changed (46) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/index.js +513 -241
  3. package/dist/cjs/types/components/buttons/AssetsButton.d.ts +2 -2
  4. package/dist/cjs/types/components/buttons/Button.d.ts +5 -3
  5. package/dist/cjs/types/components/controls/Input.d.ts +3 -3
  6. package/dist/cjs/types/components/controls/NumericInput.d.ts +2 -2
  7. package/dist/cjs/types/components/icons/Generic.d.ts +28 -0
  8. package/dist/cjs/types/components/icons/Weather.d.ts +8 -0
  9. package/dist/cjs/types/components/typography/BodyText.d.ts +2 -2
  10. package/dist/cjs/types/components/typography/HeadingText.d.ts +2 -2
  11. package/dist/cjs/types/core/design-system.d.ts +9 -0
  12. package/dist/cjs/types/core/index.d.ts +1 -1
  13. package/dist/cjs/types/core/themes.d.ts +13 -8
  14. package/dist/cjs/types/core/utils.d.ts +11 -2
  15. package/dist/cjs/types/hooks/index.d.ts +1 -0
  16. package/dist/cjs/types/hooks/useUserTheme.d.ts +13 -0
  17. package/dist/cjs/types/providers/ThemeProvider.d.ts +11 -0
  18. package/dist/cjs/types/providers/index.d.ts +1 -1
  19. package/dist/cjs/types/services/internal/colorService.d.ts +9 -4
  20. package/dist/cjs/types/types/config.d.ts +28 -29
  21. package/dist/cjs/types/types/index.d.ts +2 -2
  22. package/dist/esm/index.js +502 -241
  23. package/dist/esm/types/components/buttons/AssetsButton.d.ts +2 -2
  24. package/dist/esm/types/components/buttons/Button.d.ts +5 -3
  25. package/dist/esm/types/components/controls/Input.d.ts +3 -3
  26. package/dist/esm/types/components/controls/NumericInput.d.ts +2 -2
  27. package/dist/esm/types/components/icons/Generic.d.ts +28 -0
  28. package/dist/esm/types/components/icons/Weather.d.ts +8 -0
  29. package/dist/esm/types/components/typography/BodyText.d.ts +2 -2
  30. package/dist/esm/types/components/typography/HeadingText.d.ts +2 -2
  31. package/dist/esm/types/core/design-system.d.ts +9 -0
  32. package/dist/esm/types/core/index.d.ts +1 -1
  33. package/dist/esm/types/core/themes.d.ts +13 -8
  34. package/dist/esm/types/core/utils.d.ts +11 -2
  35. package/dist/esm/types/hooks/index.d.ts +1 -0
  36. package/dist/esm/types/hooks/useUserTheme.d.ts +13 -0
  37. package/dist/esm/types/providers/ThemeProvider.d.ts +11 -0
  38. package/dist/esm/types/providers/index.d.ts +1 -1
  39. package/dist/esm/types/services/internal/colorService.d.ts +9 -4
  40. package/dist/esm/types/types/config.d.ts +28 -29
  41. package/dist/esm/types/types/index.d.ts +2 -2
  42. package/dist/index.css +1 -1
  43. package/dist/index.d.ts +82 -28
  44. package/package.json +2 -1
  45. package/dist/cjs/types/providers/SquidConfigProvider.d.ts +0 -9
  46. package/dist/esm/types/providers/SquidConfigProvider.d.ts +0 -9
@@ -1,5 +1,5 @@
1
- import { AssetsButtonVariant } from "../../types/components";
2
- import { TooltipProps } from "../controls";
1
+ import { type AssetsButtonVariant } from "../../types/components";
2
+ import { type TooltipProps } from "../controls";
3
3
  interface AssetsButtonProps {
4
4
  token?: {
5
5
  iconUrl: string;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { ButtonSize, ButtonVariant } from "../../types/components";
3
- import { ChipProps } from "./Chip";
2
+ import { type ButtonSize, type ButtonVariant } from "../../types/components";
3
+ import { type ChipProps } from "./Chip";
4
4
  interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
5
5
  label?: string;
6
6
  icon?: React.ReactNode;
@@ -11,6 +11,8 @@ interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
11
11
  isLoading?: boolean;
12
12
  chip?: ChipProps;
13
13
  containerClassName?: string;
14
+ buttonRef?: React.Ref<HTMLButtonElement>;
15
+ anchorRef?: React.Ref<HTMLAnchorElement>;
14
16
  }
15
- export declare function Button({ label, disabled, size, variant, icon, link, isLoading, chip, containerClassName, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function Button({ label, disabled, size, variant, icon, link, isLoading, chip, containerClassName, anchorRef, buttonRef, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
16
18
  export {};
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ButtonVariant } from "../../types/components";
2
+ import { type ButtonVariant } from "../../types/components";
3
3
  interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
4
  placeholder?: string;
5
5
  showIcon?: boolean;
@@ -12,9 +12,9 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
12
12
  inputRef?: React.RefObject<HTMLInputElement>;
13
13
  }
14
14
  export declare function Input({ placeholder, showIcon, className, icon, isError, isWarning, containerClassName, actionButtonProps, autoFocusTimeout, inputRef: inputRefProp, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
15
- type InputActionButtonProps = {
15
+ interface InputActionButtonProps {
16
16
  onClick?: () => void;
17
17
  variant?: ButtonVariant;
18
18
  label?: string;
19
- };
19
+ }
20
20
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { SwapDirection } from "../../types/components";
3
- import { TooltipProps } from "./Tooltip";
2
+ import { type SwapDirection } from "../../types/components";
3
+ import { type TooltipProps } from "./Tooltip";
4
4
  interface Token {
5
5
  price: number;
6
6
  symbol: string;
@@ -54,3 +54,31 @@ export declare function CoinsOutlinedIcon({ className, size, }: {
54
54
  className?: string;
55
55
  size?: string;
56
56
  }): import("react/jsx-runtime").JSX.Element;
57
+ export declare function PhoneIcon({ size, className, }: {
58
+ size?: string;
59
+ className?: string;
60
+ }): import("react/jsx-runtime").JSX.Element;
61
+ export declare function LaptopIcon({ size, className, }: {
62
+ size?: string;
63
+ className?: string;
64
+ }): import("react/jsx-runtime").JSX.Element;
65
+ export declare function CopyIcon({ size, className, }: {
66
+ size?: string;
67
+ className?: string;
68
+ }): import("react/jsx-runtime").JSX.Element;
69
+ export declare function FileDownloadIcon({ size, className, }: {
70
+ size?: string;
71
+ className?: string;
72
+ }): import("react/jsx-runtime").JSX.Element;
73
+ export declare function CodeSolidSquareIcon({ size, className, }: {
74
+ size?: string;
75
+ className?: string;
76
+ }): import("react/jsx-runtime").JSX.Element;
77
+ export declare function CodeBracketsIcon({ size, className, }: {
78
+ size?: string;
79
+ className?: string;
80
+ }): import("react/jsx-runtime").JSX.Element;
81
+ export declare function CommandIcon({ size, className, }: {
82
+ size?: string;
83
+ className?: string;
84
+ }): import("react/jsx-runtime").JSX.Element;
@@ -10,3 +10,11 @@ export declare function MoonIcon({ size, className, }: {
10
10
  size?: string;
11
11
  className?: string;
12
12
  }): import("react/jsx-runtime").JSX.Element;
13
+ export declare function SunOutlinedIcon({ size, className, }: {
14
+ size?: string;
15
+ className?: string;
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ export declare function CrossedOutSunSolidIcon({ size, className, }: {
18
+ size?: string;
19
+ className?: string;
20
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from "react";
2
- import { TextSize } from "../../types/components";
1
+ import { type ReactNode } from "react";
2
+ import { type TextSize } from "../../types/components";
3
3
  interface BodyTextProps extends React.HTMLAttributes<HTMLSpanElement> {
4
4
  children: ReactNode;
5
5
  size: TextSize;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from "react";
2
- import { TextSize } from "../../types/components";
1
+ import { type ReactNode } from "react";
2
+ import { type TextSize } from "../../types/components";
3
3
  interface HeadingTextProps {
4
4
  children?: ReactNode;
5
5
  size: TextSize;
@@ -1,2 +1,11 @@
1
1
  import type { Config } from "tailwindcss";
2
+ export declare const spacing: {
3
+ "squid-xxs": string;
4
+ "squid-xs": string;
5
+ "squid-s": string;
6
+ "squid-m": string;
7
+ "squid-l": string;
8
+ "squid-xl": string;
9
+ "squid-xxl": string;
10
+ };
2
11
  export declare const baseTailwindConfig: Config;
@@ -1,4 +1,4 @@
1
1
  export { MEDIA_QUERIES, CSS_VARS } from "./constants";
2
- export { darkTheme, lightTheme } from "./themes";
2
+ export { darkTheme, lightTheme, defaultTheme } from "./themes";
3
3
  export { baseTailwindConfig } from "./design-system";
4
4
  export { cn } from "./utils";
@@ -1,12 +1,17 @@
1
- import { ThemeType } from "../types/components";
2
- import { SquidTheme } from "../types/config";
3
- export type Theme = {
1
+ import { type ThemeType } from "../types/components";
2
+ import { type Theme } from "../types/config";
3
+ export interface ThemeConfig {
4
4
  name: string;
5
5
  themeImgPath: string;
6
6
  websiteBackgroundColor: string;
7
- theme: SquidTheme;
7
+ theme: Theme;
8
8
  type: ThemeType;
9
- };
10
- export declare const lightTheme: SquidTheme;
11
- export declare const darkTheme: SquidTheme;
12
- export declare const themes: Theme[];
9
+ }
10
+ export declare const defaultFontSize: Theme["fontSize"];
11
+ export declare const defaultFontWeight: Theme["fontWeight"];
12
+ export declare const defaultFontFamily: Theme["fontFamily"];
13
+ export declare const defaultBorderRadius: Theme["borderRadius"];
14
+ export declare const lightTheme: Theme;
15
+ export declare const darkTheme: Theme;
16
+ export declare const defaultTheme: Required<Theme>;
17
+ export declare const themes: ThemeConfig[];
@@ -1,5 +1,5 @@
1
- import { ClassValue } from "clsx";
2
- import { ComponentProps, ElementType } from "react";
1
+ import { type ClassValue } from "clsx";
2
+ import { type ComponentProps, type ElementType } from "react";
3
3
  /**
4
4
  * Combines multiple class names into a single string
5
5
  *
@@ -35,4 +35,13 @@ export declare const calcLerp: (a: string, b: string, t: string | number) => str
35
35
  * @returns The filtered array
36
36
  */
37
37
  export declare const getFirstUniques: <T>(array: T[], key: keyof T, count: number) => T[];
38
+ interface FlattenOptions {
39
+ prefix?: string;
40
+ }
41
+ export declare function flatten<T extends Record<string, any>>(obj: T, options?: FlattenOptions): Record<string, string>;
42
+ interface ReplaceKeysOptions {
43
+ keysToReplace: Array<[string, string]>;
44
+ }
45
+ export declare function replaceKeys(obj: Record<string, any>, options: ReplaceKeysOptions): Record<string, any>;
46
+ export declare function mapToCssVariables<T extends Record<string, any>>(obj: T): Record<keyof T & string, string>;
38
47
  export {};
@@ -4,3 +4,4 @@ export * from "./useCollapsibleMenu";
4
4
  export * from "./useRect";
5
5
  export * from "./useVersion";
6
6
  export * from "./useTimer";
7
+ export * from "./useUserTheme";
@@ -0,0 +1,13 @@
1
+ import { type ThemeType } from "../types";
2
+ export declare enum ThemePreference {
3
+ LIGHT = "light",
4
+ DARK = "dark",
5
+ SYSTEM = "system"
6
+ }
7
+ export declare function useUserTheme(): {
8
+ themePreference: ThemePreference;
9
+ themeType: ThemeType;
10
+ theme: import("../types").Theme;
11
+ setThemeManually: (theme: ThemePreference) => void;
12
+ isDarkMode: boolean;
13
+ };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import "../styles/compiled-tailwind.css";
3
+ import { type Theme } from "../types";
4
+ import { type ThemeType } from "../types/components";
5
+ interface ThemeProviderProps extends React.ComponentProps<"div"> {
6
+ theme?: Theme;
7
+ children?: React.ReactNode;
8
+ themeType?: ThemeType;
9
+ }
10
+ export declare function ThemeProvider({ theme, children, themeType, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -1 +1 @@
1
- export * from "./SquidConfigProvider";
1
+ export * from "./ThemeProvider";
@@ -1,4 +1,4 @@
1
- import { SquidTheme } from "../../types/config";
1
+ import { type Theme } from "../../types/config";
2
2
  /**
3
3
  * Parses the user readable config to css variables
4
4
  * Also maps the public theme variables to the internal theme variables
@@ -18,9 +18,7 @@ import { SquidTheme } from "../../types/config";
18
18
  * }
19
19
  * @param style
20
20
  */
21
- export declare const parseSquidTheme: (userTheme?: SquidTheme) => {
22
- [key: string]: string | undefined;
23
- } | undefined;
21
+ export declare const parseSquidTheme: (userTheme?: Theme) => Record<string, string | undefined> | undefined;
24
22
  export declare function getContrastColor({ r, g, b, }: {
25
23
  r: number;
26
24
  g: number;
@@ -36,4 +34,11 @@ export declare function getContrastColor({ r, g, b, }: {
36
34
  * @returns {string} The hexadecimal color with opacity.
37
35
  */
38
36
  export declare function getHexColorFromOpacityPercentage(color: string, opacity: number): string;
37
+ export declare function hexToRgb(hex: string): {
38
+ r: number;
39
+ g: number;
40
+ b: number;
41
+ a: number;
42
+ } | null;
43
+ export declare function rgbToHex(r: number, g: number, b: number): string;
39
44
  export declare function blendColors(foreground: string, background: string): string | null;
@@ -1,33 +1,32 @@
1
- /**
2
- * The color format must be of type #FFFFFF
3
- */
4
- export type ColorType = `#${string}${string}${string}${string}${string}${string}`;
5
- declare const INTERNAL_SQUID_THEME_KEYS: readonly ["grey-100", "grey-200", "grey-300", "grey-400", "grey-500", "grey-600", "grey-700", "grey-800", "grey-900", "royal-300", "royal-400", "royal-500", "royal-700", "status-positive", "status-negative", "status-partial", "material-light-thin", "material-light-average", "material-light-thick", "material-dark-thin", "material-dark-average", "material-dark-thick", "grey-100-005", "material-light-blend-grey-900", "material-light-blend-grey-800", "volt-700"];
6
- export type InternalSquidTheme = Record<(typeof INTERNAL_SQUID_THEME_KEYS)[number], string>;
7
- export type SquidTheme = {
8
- "content-100": string;
9
- "content-200": string;
10
- "content-300": string;
11
- "content-400": string;
12
- "content-500": string;
13
- "content-600": string;
14
- "content-700": string;
15
- "content-800": string;
16
- "content-900": string;
17
- "accent-300": string;
18
- "accent-400": string;
19
- "accent-500": string;
20
- "accent-700": string;
21
- "status-positive": string;
22
- "status-negative": string;
23
- "status-warning": string;
24
- "highlight-700": string;
1
+ declare const THEME_COLOR_KEYS: readonly ["grey-100", "grey-200", "grey-300", "grey-400", "grey-500", "grey-600", "grey-700", "grey-800", "grey-900", "royal-300", "royal-400", "royal-500", "royal-700", "status-positive", "status-negative", "status-partial", "material-light-thin", "material-light-average", "material-light-thick", "material-dark-thin", "material-dark-average", "material-dark-thick", "highlight-700", "grey-100-005", "material-light-blend-grey-900", "material-light-blend-grey-800"];
2
+ declare const THEME_BORDER_RADIUS_KEYS: readonly ["button-large", "button-medium"];
3
+ declare const THEME_FONT_SIZE_KEYS: readonly ["caption", "body-large", "body-medium", "body-small", "heading-small", "heading-medium", "heading-large"];
4
+ declare const THEME_FONT_WEIGHT_KEYS: readonly ["caption", "body-small", "body-medium", "body-large", "heading-small", "heading-medium", "heading-large"];
5
+ declare const THEME_FONT_FAMILY_KEYS: readonly ["squid-main"];
6
+ type ThemeColors = Record<(typeof THEME_COLOR_KEYS)[number], string>;
7
+ type ThemeFontSize = Record<(typeof THEME_FONT_SIZE_KEYS)[number], string>;
8
+ type ThemeFontWeight = Record<(typeof THEME_FONT_WEIGHT_KEYS)[number], string>;
9
+ type ThemeBorderRadius = Record<(typeof THEME_BORDER_RADIUS_KEYS)[number], string>;
10
+ type ThemeFontFamily = Record<(typeof THEME_FONT_FAMILY_KEYS)[number], string>;
11
+ export interface InternalTheme {
12
+ color: ThemeColors;
13
+ fontSize: ThemeFontSize;
14
+ fontWeight: ThemeFontWeight;
15
+ borderRadius: ThemeBorderRadius;
16
+ fontFamily: ThemeFontFamily;
17
+ }
18
+ export interface Theme extends Omit<InternalTheme, "color"> {
19
+ color: Omit<ThemeColors, "material-light-thin" | "material-light-average" | "material-light-thick" | "material-dark-thin" | "material-dark-average" | "material-dark-thick" | "grey-100-005" | "material-light-blend-grey-900" | "material-light-blend-grey-800">;
20
+ }
21
+ interface CssVariable {
22
+ cssVariable: string;
23
+ }
24
+ type ThemeCssVariables = {
25
+ [K in keyof InternalTheme]: Record<keyof InternalTheme[K], CssVariable>;
25
26
  };
26
- export declare const SQUID_THEME_CSS_VARIABLE_PREFIX = "--squid-theme-";
27
27
  /**
28
- * Mapping between readable variables name and css variables used TailwindCSS config
28
+ * 'st' = Squid Theme
29
29
  */
30
- export declare const themeTypesKeys: Record<keyof InternalSquidTheme, {
31
- cssVariable: string;
32
- }>;
30
+ export declare const THEME_CSS_VARIABLE_PREFIX = "--st-";
31
+ export declare const themeKeysToCssVariables: ThemeCssVariables;
33
32
  export {};
@@ -1,3 +1,3 @@
1
- export type { SquidTheme } from "./config";
1
+ export type { Theme } from "./config";
2
2
  export * from "./utils";
3
- export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant, DescriptionBlock, } from "./components";
3
+ export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant, ButtonVariant, ButtonSize, DescriptionBlock, } from "./components";