@jaw.id/ui 0.1.7 → 0.1.9

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/dist/index.d.ts CHANGED
@@ -13,4 +13,5 @@ export * from './icons';
13
13
  export * from './hooks';
14
14
  export * from './utils';
15
15
  export * from './react';
16
+ export * from './theme';
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,39 +1,50 @@
1
- import { h as e, C as o, j as n, k as c, m as i, D as t, E as l, n as r, o as I, F as d, G as g, L as D, O as C, p as k, P as u, q as T, R as p, S as h, r as m, T as P, U as f, t as E, W as S, u as U, v as y, w as x, x as A, y as F, z as G, A as N, I as O, J as R, K as b, M as v, N as w, Q as B } from "./index-DdcUSYhO.js";
1
+ import { h as s, j as o, C as n, k as c, m as t, n as i, D as l, o as r, p as T, E as I, q as D, r as g, F as d, t as C, G as h, L as A, O as E, u as k, P as m, v as P, R as S, S as u, w as p, T as _, U, x as L, W as R, y, z as F, A as O, I as f, J as v, K as x, M as G, N as M, Q as N, V as B, X as K, Y as b, Z as w, _ as H, $ as J, a0 as W, a1 as j, a2 as q, a3 as z, a4 as Q } from "./index-Bj8-z_bB.js";
2
2
  export {
3
- e as BadgeDollarIcon,
4
- o as CloseIcon,
5
- n as ConnectDialog,
6
- c as CopiedIcon,
3
+ s as BORDER_RADIUS_MAP,
4
+ o as BadgeDollarIcon,
5
+ n as CloseIcon,
6
+ c as ConnectDialog,
7
+ t as CopiedIcon,
7
8
  i as CopyIcon,
8
- t as DefaultDialog,
9
- l as Eip712Dialog,
10
- r as EthIcon,
11
- I as EyeIcon,
12
- d as FeeTokenSelector,
13
- g as GenericTokenIcon,
14
- D as LockIcon,
15
- C as OnboardingDialog,
9
+ l as DEFAULT_DARK_PALETTE,
10
+ r as DEFAULT_LIGHT_PALETTE,
11
+ T as DefaultDialog,
12
+ I as Eip712Dialog,
13
+ D as EthIcon,
14
+ g as EyeIcon,
15
+ d as FONT_STACK_MAP,
16
+ C as FeeTokenSelector,
17
+ h as GenericTokenIcon,
18
+ A as LockIcon,
19
+ E as OnboardingDialog,
16
20
  k as OrSeparator,
17
- u as PermissionDialog,
18
- T as PortalContainerContext,
19
- p as ReactUIHandler,
20
- h as SignatureDialog,
21
- m as SiweDialog,
22
- P as TransactionDialog,
23
- f as UsdcIcon,
24
- E as UsdtIcon,
25
- S as WalletIcon,
26
- U as clearTokenPriceCache,
27
- y as cn,
28
- x as fetchTokenBalance,
29
- A as fetchTokenPrice,
30
- F as formatAddress,
31
- G as getDisplayAddress,
21
+ m as PermissionDialog,
22
+ P as PortalContainerContext,
23
+ S as ReactUIHandler,
24
+ u as SignatureDialog,
25
+ p as SiweDialog,
26
+ _ as TransactionDialog,
27
+ U as UsdcIcon,
28
+ L as UsdtIcon,
29
+ R as WalletIcon,
30
+ y as applyThemeToContainer,
31
+ F as clearTokenPriceCache,
32
+ O as cn,
33
+ f as deriveAccentPalette,
34
+ v as fetchTokenBalance,
35
+ x as fetchTokenPrice,
36
+ G as formatAddress,
37
+ M as getDisplayAddress,
32
38
  N as getJustaNameInstance,
33
- O as isNativeToken,
34
- R as useChainIconURI,
35
- b as useDecodedCalldata,
36
- v as useFeeTokenPrice,
37
- w as useGasEstimation,
38
- B as useIsMobile
39
+ B as getSystemColorScheme,
40
+ K as hexToOklch,
41
+ b as isNativeToken,
42
+ w as oklchToString,
43
+ H as resolveTheme,
44
+ J as useChainIconURI,
45
+ W as useColorScheme,
46
+ j as useDecodedCalldata,
47
+ q as useFeeTokenPrice,
48
+ z as useGasEstimation,
49
+ Q as useIsMobile
39
50
  };
@@ -1,4 +1,11 @@
1
- import { UIHandler, UIHandlerConfig, UIRequest, UIResponse } from '../../../core/src/index.ts';
1
+ import { UIHandler, UIHandlerConfig, UIRequest, UIResponse, JawTheme } from '../../../core/src/index.ts';
2
+ /**
3
+ * Options for ReactUIHandler constructor.
4
+ */
5
+ export interface ReactUIHandlerOptions {
6
+ /** Theme configuration. Takes precedence over theme provided via JAW.create(). */
7
+ readonly theme?: JawTheme;
8
+ }
2
9
  /**
3
10
  * React UI handler for app-specific mode
4
11
  *
@@ -18,15 +25,36 @@ import { UIHandler, UIHandlerConfig, UIRequest, UIResponse } from '../../../core
18
25
  * uiHandler: new ReactUIHandler(),
19
26
  * },
20
27
  * });
28
+ *
29
+ * // With theme:
30
+ * const jaw2 = JAW.create({
31
+ * apiKey: 'your-api-key',
32
+ * theme: { mode: 'dark', accentColor: '#6366f1' },
33
+ * preference: {
34
+ * mode: Mode.AppSpecific,
35
+ * uiHandler: new ReactUIHandler({
36
+ * theme: { accentColor: '#7b3fe4', borderRadius: 'lg' },
37
+ * }),
38
+ * },
39
+ * });
21
40
  * ```
22
41
  */
23
42
  export declare class ReactUIHandler implements UIHandler {
24
43
  private config;
44
+ private localTheme?;
45
+ constructor(options?: ReactUIHandlerOptions);
25
46
  /**
26
47
  * Initialize the handler with SDK configuration
27
48
  * Called automatically by the SDK - do not call directly
28
49
  */
29
50
  init(config: UIHandlerConfig): void;
51
+ /**
52
+ * Update the theme without recreating the SDK or disconnecting.
53
+ * Takes effect on the next dialog that opens.
54
+ */
55
+ setTheme(theme: JawTheme): void;
56
+ /** Merged theme: local theme wins over init-provided theme */
57
+ private get effectiveTheme();
30
58
  request<T = unknown>(request: UIRequest): Promise<UIResponse<T>>;
31
59
  canHandle(request: UIRequest): boolean;
32
60
  cleanup(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactUIHandler.d.ts","sourceRoot":"","sources":["../../src/react/ReactUIHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACT,eAAe,EACf,SAAS,EACT,UAAU,EA0BX,MAAM,cAAc,CAAC;AAyHtB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C,OAAO,CAAC,MAAM,CAA0C;IAExD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAI7B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IA2FtE,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO;IAahC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,OAAO,CAAC,YAAY;CAgNrB"}
1
+ {"version":3,"file":"ReactUIHandler.d.ts","sourceRoot":"","sources":["../../src/react/ReactUIHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACT,eAAe,EACf,SAAS,EACT,UAAU,EA0BX,MAAM,cAAc,CAAC;AA2BtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA6H7C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C,OAAO,CAAC,MAAM,CAA0C;IACxD,OAAO,CAAC,UAAU,CAAC,CAAW;gBAElB,OAAO,CAAC,EAAE,qBAAqB;IAI3C;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAInC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B,8DAA8D;IAC9D,OAAO,KAAK,cAAc,GAIzB;IAEK,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAgGtE,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO;IAahC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,OAAO,CAAC,YAAY;CAgNrB"}
@@ -0,0 +1,12 @@
1
+ import { ResolvedTheme } from './resolve-theme.js';
2
+ /**
3
+ * Apply resolved theme variables to an HTML element.
4
+ *
5
+ * - Sets every `--jaw-*` variable via `style.setProperty`
6
+ * - Also sets the short backwards-compat aliases (--primary, --background, etc.)
7
+ * so Tailwind utilities like `bg-primary` resolve correctly on this container
8
+ * - Toggles the `dark` class based on `colorScheme`
9
+ * - Sets `color-scheme` CSS property for native form controls
10
+ */
11
+ export declare function applyThemeToContainer(container: HTMLElement, resolved: ResolvedTheme): void;
12
+ //# sourceMappingURL=apply-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-theme.d.ts","sourceRoot":"","sources":["../../src/theme/apply-theme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAmCnD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,aAAa,GACtB,IAAI,CAkCN"}
@@ -0,0 +1,6 @@
1
+ import { JawBorderRadius, JawFontStack } from '../../../core/src/index.ts';
2
+ export declare const DEFAULT_LIGHT_PALETTE: Readonly<Record<string, string>>;
3
+ export declare const DEFAULT_DARK_PALETTE: Readonly<Record<string, string>>;
4
+ export declare const BORDER_RADIUS_MAP: Readonly<Record<JawBorderRadius, string>>;
5
+ export declare const FONT_STACK_MAP: Readonly<Record<JawFontStack, string>>;
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/theme/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAM7D,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2B/D,CAAC;AAML,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2B9D,CAAC;AAML,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAKpE,CAAC;AAML,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAO9D,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Theme resolution engine for @jaw.id/ui.
3
+ *
4
+ * Re-exports all public APIs from the theme module.
5
+ */
6
+ export { hexToOklch, oklchToString, deriveAccentPalette } from './palette.js';
7
+ export type { Oklch } from './palette.js';
8
+ export { DEFAULT_LIGHT_PALETTE, DEFAULT_DARK_PALETTE, BORDER_RADIUS_MAP, FONT_STACK_MAP, } from './constants.js';
9
+ export { resolveTheme } from './resolve-theme.js';
10
+ export type { ResolvedTheme } from './resolve-theme.js';
11
+ export { applyThemeToContainer } from './apply-theme.js';
12
+ export { useColorScheme, getSystemColorScheme } from './use-color-scheme.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9E,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * OKLCH palette generation from hex colors.
3
+ *
4
+ * Conversion chain: Hex -> sRGB -> Linear RGB -> XYZ D65 -> OKLab -> OKLCH
5
+ */
6
+ export interface Oklch {
7
+ readonly l: number;
8
+ readonly c: number;
9
+ readonly h: number;
10
+ }
11
+ /**
12
+ * Convert a hex color string to OKLCH color space.
13
+ */
14
+ export declare function hexToOklch(hex: string): Oklch;
15
+ /**
16
+ * Format an OKLCH value as a CSS `oklch(L C H)` string.
17
+ * L and C use 3 decimal places; H uses 1 decimal place.
18
+ */
19
+ export declare function oklchToString(oklch: Oklch): string;
20
+ /**
21
+ * Derive accent palette CSS variables from a single hex accent color.
22
+ *
23
+ * Sets `--jaw-color-primary` (buttons, key actions) and related tokens.
24
+ * In dark mode, slightly lightens the accent for better visibility on dark backgrounds.
25
+ */
26
+ export declare function deriveAccentPalette(accentHex: string, effectiveMode: "light" | "dark", accentColorForeground?: string): Readonly<Record<string, string>>;
27
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/theme/palette.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAiFD;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAQ7C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAKlD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,OAAO,GAAG,MAAM,EAC/B,qBAAqB,CAAC,EAAE,MAAM,GAC7B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyClC"}
@@ -0,0 +1,17 @@
1
+ import { JawTheme } from '../../../core/src/index.ts';
2
+ export interface ResolvedTheme {
3
+ readonly variables: Readonly<Record<string, string>>;
4
+ readonly colorScheme: "light" | "dark";
5
+ }
6
+ /**
7
+ * Resolve a `JawTheme` configuration into a flat set of CSS variables.
8
+ *
9
+ * Resolution order (later wins):
10
+ * 1. Default palette (light or dark)
11
+ * 2. Accent color overrides (derived from `accentColor`)
12
+ * 3. Explicit `accentColorForeground` override
13
+ * 4. Border radius & font stack presets
14
+ * 5. Raw `cssVariables` (Layer 2 user overrides)
15
+ */
16
+ export declare function resolveTheme(theme: JawTheme, systemMode: "light" | "dark"): ResolvedTheme;
17
+ //# sourceMappingURL=resolve-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-theme.d.ts","sourceRoot":"","sources":["../../src/theme/resolve-theme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,QAAQ,EACf,UAAU,EAAE,OAAO,GAAG,MAAM,GAC3B,aAAa,CAwDf"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Color scheme detection utilities.
3
+ *
4
+ * Provides both a React hook and a plain function for detecting
5
+ * the user's system color scheme preference.
6
+ */
7
+ /**
8
+ * Get the current system color scheme (SSR-safe).
9
+ * Returns `'light'` when `window` is not available.
10
+ */
11
+ export declare function getSystemColorScheme(): 'light' | 'dark';
12
+ /**
13
+ * React hook that tracks the system color scheme preference.
14
+ *
15
+ * - SSR-safe: defaults to `'light'` during server rendering
16
+ * - Subscribes to `matchMedia` change events
17
+ * - Cleans up listener on unmount
18
+ */
19
+ export declare function useColorScheme(): 'light' | 'dark';
20
+ //# sourceMappingURL=use-color-scheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-color-scheme.d.ts","sourceRoot":"","sources":["../../src/theme/use-color-scheme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,GAAG,MAAM,CAGvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,OAAO,GAAG,MAAM,CAoBjD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jaw.id/ui",
3
3
  "description": "Pre-built React dialogs for JAW.id",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "type": "module",
6
6
  "sideEffects": [
7
7
  "**/*.css",
@@ -39,7 +39,7 @@
39
39
  "react-dom": ">=18.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@jaw.id/core": "0.2.0",
42
+ "@jaw.id/core": "0.2.2",
43
43
  "@hookform/resolvers": "^5.2.2",
44
44
  "@justaname.id/sdk": "^0.2.204",
45
45
  "@radix-ui/react-accordion": "^1.2.12",