react-native-terra-ui 0.10.2 → 0.11.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/CHANGELOG.md +28 -0
- package/README.md +8 -4
- package/lib/module/components/badge/Badge.js +174 -0
- package/lib/module/components/badge/Badge.js.map +1 -0
- package/lib/module/components/badge/index.js +4 -0
- package/lib/module/components/badge/index.js.map +1 -0
- package/lib/module/components/badge/parts/BadgeIndicator.js +191 -0
- package/lib/module/components/badge/parts/BadgeIndicator.js.map +1 -0
- package/lib/module/components/badge/types.js +4 -0
- package/lib/module/components/badge/types.js.map +1 -0
- package/lib/module/components/badge/utils.js +25 -0
- package/lib/module/components/badge/utils.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context/ThemeProvider.js +5 -5
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/theme/define-config.js +5 -5
- package/lib/module/theme/define-config.js.map +1 -1
- package/lib/module/theme/errors.js +1 -1
- package/lib/module/theme/index.js +2 -2
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/registry.js +15 -21
- package/lib/module/theme/registry.js.map +1 -1
- package/lib/module/theme/resolve-config.js +68 -68
- package/lib/module/theme/resolve-config.js.map +1 -1
- package/lib/module/theme/runtime.js +11 -11
- package/lib/module/theme/runtime.js.map +1 -1
- package/lib/module/theme/selection-store.js +7 -7
- package/lib/module/theme/selection-store.js.map +1 -1
- package/lib/module/theme/unistyles-adapter.js +1 -1
- package/lib/module/utils/accent-utils.js +24 -24
- package/lib/module/utils/accent-utils.js.map +1 -1
- package/lib/typescript/src/components/badge/Badge.d.ts +16 -0
- package/lib/typescript/src/components/badge/Badge.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/index.d.ts +3 -0
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts +19 -0
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/types.d.ts +48 -0
- package/lib/typescript/src/components/badge/types.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/utils.d.ts +13 -0
- package/lib/typescript/src/components/badge/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/context/ThemeProvider.d.ts +7 -7
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theme/define-config.d.ts +11 -8
- package/lib/typescript/src/theme/define-config.d.ts.map +1 -1
- package/lib/typescript/src/theme/errors.d.ts +1 -1
- package/lib/typescript/src/theme/index.d.ts +3 -3
- package/lib/typescript/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/registry.d.ts +5 -5
- package/lib/typescript/src/theme/registry.d.ts.map +1 -1
- package/lib/typescript/src/theme/resolve-config.d.ts +25 -25
- package/lib/typescript/src/theme/resolve-config.d.ts.map +1 -1
- package/lib/typescript/src/theme/runtime.d.ts +5 -5
- package/lib/typescript/src/theme/runtime.d.ts.map +1 -1
- package/lib/typescript/src/theme/selection-store.d.ts +5 -5
- package/lib/typescript/src/theme/selection-store.d.ts.map +1 -1
- package/lib/typescript/src/theme/types.d.ts +20 -47
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/lib/typescript/src/theme/unistyles-adapter.d.ts +1 -1
- package/lib/typescript/src/utils/accent-utils.d.ts +6 -7
- package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/badge/Badge.tsx +111 -0
- package/src/components/badge/index.ts +2 -0
- package/src/components/badge/parts/BadgeIndicator.tsx +166 -0
- package/src/components/badge/types.ts +58 -0
- package/src/components/badge/utils.ts +24 -0
- package/src/components/index.ts +1 -0
- package/src/context/ThemeProvider.tsx +10 -10
- package/src/theme/define-config.ts +12 -7
- package/src/theme/errors.ts +1 -1
- package/src/theme/index.ts +6 -8
- package/src/theme/registry.ts +15 -23
- package/src/theme/resolve-config.ts +88 -95
- package/src/theme/runtime.ts +11 -11
- package/src/theme/selection-store.ts +9 -9
- package/src/theme/types.ts +21 -47
- package/src/theme/unistyles-adapter.ts +1 -1
- package/src/utils/accent-utils.ts +25 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { normalizeTokenOverride } from "../theme/legacy-tokens.js";
|
|
4
|
-
import {
|
|
4
|
+
import { normalizeThemeScheme } from "../theme/resolve-config.js";
|
|
5
5
|
import { defaultDarkTheme, defaultLightTheme } from "../theme/theme.js";
|
|
6
6
|
import { ACCENT_SURFACE_ROLES, generateAccentColors } from "./accent-generator.js";
|
|
7
7
|
/**
|
|
@@ -21,32 +21,33 @@ export function defaultAccentContext(scheme) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* the
|
|
26
|
-
*
|
|
24
|
+
* Generate a palette using the named theme's ordinary surface overrides. The
|
|
25
|
+
* rest of the patch passes through as authored, matching the unseeded branch —
|
|
26
|
+
* so `spacing.base` / `radius.base` stay pseudo-tokens here; only
|
|
27
|
+
* `applyThemeLayer` expands them into a scale.
|
|
27
28
|
*/
|
|
28
|
-
function seedToColorPatch(seed,
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
color: overrides
|
|
35
|
-
})?.color;
|
|
36
|
-
if (normalized) {
|
|
37
|
-
for (const [key, value] of Object.entries(normalized)) {
|
|
38
|
-
if (value !== undefined) color[key] = value;
|
|
39
|
-
}
|
|
29
|
+
function seedToColorPatch(seed, patch, scheme) {
|
|
30
|
+
const normalized = normalizeTokenOverride(patch);
|
|
31
|
+
const context = defaultAccentContext(scheme);
|
|
32
|
+
for (const role of ACCENT_SURFACE_ROLES) {
|
|
33
|
+
const value = normalized?.color?.[role];
|
|
34
|
+
if (value !== undefined) context.surfaces[role] = value;
|
|
40
35
|
}
|
|
36
|
+
context.pressedOpacity = normalized?.opacity?.pressed ?? context.pressedOpacity;
|
|
37
|
+
const generated = generateAccentColors(seed, context).colors;
|
|
41
38
|
return {
|
|
42
|
-
|
|
39
|
+
...normalized,
|
|
40
|
+
color: {
|
|
41
|
+
...generated,
|
|
42
|
+
...normalized?.color
|
|
43
|
+
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
function normalizeSchemeInput(input, scheme) {
|
|
46
|
-
const normalized =
|
|
47
|
+
const normalized = normalizeThemeScheme(input, `themes.<name>.${scheme}`);
|
|
47
48
|
if (normalized.kind === "none") return {};
|
|
48
49
|
if (normalized.kind === "seed") {
|
|
49
|
-
return seedToColorPatch(normalized.seed, normalized.
|
|
50
|
+
return seedToColorPatch(normalized.seed, normalized.patch, scheme);
|
|
50
51
|
}
|
|
51
52
|
// Preserve the compatibility helper's identity contract for full patches;
|
|
52
53
|
// the resolver itself uses the sanitized copy in `normalized.patch`.
|
|
@@ -54,11 +55,10 @@ function normalizeSchemeInput(input, scheme) {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* pass through unchanged. Pure and independent of the registry.
|
|
58
|
+
* @deprecated Prefer createTerraThemes for complete theme resolution.
|
|
59
|
+
* Generates per-scheme patches without shared config. Explicit unseeded patches
|
|
60
|
+
* pass through unchanged; seeded entries generate against their own surface and
|
|
61
|
+
* color tokens and carry the remainder of the patch through unresolved.
|
|
62
62
|
*/
|
|
63
63
|
export function normalizeAccent(accent) {
|
|
64
64
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeTokenOverride","
|
|
1
|
+
{"version":3,"names":["normalizeTokenOverride","normalizeThemeScheme","defaultDarkTheme","defaultLightTheme","ACCENT_SURFACE_ROLES","generateAccentColors","defaultAccentContext","scheme","theme","surfaces","role","color","pressedOpacity","opacity","pressed","seedToColorPatch","seed","patch","normalized","context","value","undefined","generated","colors","normalizeSchemeInput","input","kind","normalizeAccent","accent","light","dark"],"sourceRoot":"../../../src","sources":["utils/accent-utils.ts"],"mappings":";;AAAA,SAASA,sBAAsB;AAC/B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB,EAAEC,iBAAiB;AAS5C,SACEC,oBAAoB,EAGpBC,oBAAoB;AAItB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,MAAc,EAA2B;EAC5E,MAAMC,KAAK,GAAGD,MAAM,KAAK,OAAO,GAAGJ,iBAAiB,GAAGD,gBAAgB;EACvE,MAAMO,QAAQ,GAAG,CAAC,CAAsC;EACxD,KAAK,MAAMC,IAAI,IAAIN,oBAAoB,EAAEK,QAAQ,CAACC,IAAI,CAAC,GAAGF,KAAK,CAACG,KAAK,CAACD,IAAI,CAAC;EAC3E,OAAO;IAAEH,MAAM;IAAEE,QAAQ;IAAEG,cAAc,EAAEJ,KAAK,CAACK,OAAO,CAACC;EAAQ,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACvBC,IAAY,EACZC,KAAqC,EACrCV,MAAc,EACW;EACzB,MAAMW,UAAU,GAAGlB,sBAAsB,CAACiB,KAAK,CAAC;EAChD,MAAME,OAAO,GAAGb,oBAAoB,CAACC,MAAM,CAAC;EAC5C,KAAK,MAAMG,IAAI,IAAIN,oBAAoB,EAAE;IACvC,MAAMgB,KAAK,GAAGF,UAAU,EAAEP,KAAK,GAAGD,IAAI,CAAC;IACvC,IAAIU,KAAK,KAAKC,SAAS,EAAEF,OAAO,CAACV,QAAQ,CAACC,IAAI,CAAC,GAAGU,KAAK;EACzD;EACAD,OAAO,CAACP,cAAc,GAAGM,UAAU,EAAEL,OAAO,EAAEC,OAAO,IAAIK,OAAO,CAACP,cAAc;EAC/E,MAAMU,SAAS,GAAGjB,oBAAoB,CAACW,IAAI,EAAEG,OAAO,CAAC,CAACI,MAAM;EAC5D,OAAO;IAAE,GAAGL,UAAU;IAAEP,KAAK,EAAE;MAAE,GAAGW,SAAS;MAAE,GAAGJ,UAAU,EAAEP;IAAM;EAAE,CAAC;AACzE;AAEA,SAASa,oBAAoBA,CAACC,KAAmC,EAAElB,MAAc,EAA2B;EAC1G,MAAMW,UAAU,GAAGjB,oBAAoB,CAACwB,KAAK,EAAE,iBAAiBlB,MAAM,EAAE,CAAC;EACzE,IAAIW,UAAU,CAACQ,IAAI,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC;EACzC,IAAIR,UAAU,CAACQ,IAAI,KAAK,MAAM,EAAE;IAC9B,OAAOX,gBAAgB,CAACG,UAAU,CAACF,IAAI,EAAEE,UAAU,CAACD,KAAK,EAAEV,MAAM,CAAC;EACpE;EACA;EACA;EACA,OAAOkB,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAACC,MAAkB,EAAoB;EACpE,OAAO;IACLC,KAAK,EAAEL,oBAAoB,CAACI,MAAM,CAACC,KAAK,EAAE,OAAO,CAAC;IAClDC,IAAI,EAAEN,oBAAoB,CAACI,MAAM,CAACE,IAAI,EAAE,MAAM;EAChD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BadgeProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Overlays a count or status indicator on one corner of the element it wraps.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <Badge placement="top-right" color="danger" label={3}>
|
|
7
|
+
* <Toolbar.Button icon="bell" accessibilityLabel="Notifications" />
|
|
8
|
+
* </Badge>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The child renders untouched — `Badge` contributes the positioning context and
|
|
12
|
+
* the overlay, nothing else.
|
|
13
|
+
*/
|
|
14
|
+
declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<import("react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
15
|
+
export { Badge };
|
|
16
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/Badge.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAS,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,KAAK,wLA4BT,CAAC;AAEH,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BadgeColor, BadgeSize } from "../types.js";
|
|
2
|
+
export interface BadgeIndicatorProps {
|
|
3
|
+
label?: string | number;
|
|
4
|
+
color: BadgeColor;
|
|
5
|
+
size: BadgeSize;
|
|
6
|
+
accessibilityLabel?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The overlay itself: a dot, or a pill carrying the label. Owns the paint, the
|
|
10
|
+
* legibility ring, and the accessibility node — the wrapper owns only position.
|
|
11
|
+
*
|
|
12
|
+
* `useUnistyles` is called unconditionally, which is what subscribes this
|
|
13
|
+
* component to theme changes. The background below comes from a variant, which
|
|
14
|
+
* unistyles applies straight to the native node on a theme switch; without a
|
|
15
|
+
* re-render React would go on believing the node holds the previous theme's
|
|
16
|
+
* value. `Chip` documents the same hazard on its root.
|
|
17
|
+
*/
|
|
18
|
+
export declare const BadgeIndicator: ({ label, color, size, accessibilityLabel }: BadgeIndicatorProps) => import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=BadgeIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BadgeIndicator.d.ts","sourceRoot":"","sources":["../../../../../../src/components/badge/parts/BadgeIndicator.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAU,CAAC;AAqBtD,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,4CAA4C,mBAAmB,gCA0C7F,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
/** Corner of the wrapped child the indicator is anchored to. */
|
|
4
|
+
export type BadgePlacement = "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
5
|
+
/** Scale of the dot, pill, and label. */
|
|
6
|
+
export type BadgeSize = "sm" | "md";
|
|
7
|
+
/**
|
|
8
|
+
* Semantic color scheme, or a raw CSS color literal (`#fff`, `rgb(...)`, `hsl(...)`).
|
|
9
|
+
* A literal paints the indicator with that exact value and derives a readable
|
|
10
|
+
* foreground for the label.
|
|
11
|
+
*/
|
|
12
|
+
export type BadgeColor = "primary" | "secondary" | "success" | "warning" | "danger" | (string & {});
|
|
13
|
+
export interface BadgeProps extends ViewProps {
|
|
14
|
+
/** The element being badged. Rendered untouched; `Badge` only adds the overlay. */
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Corner the indicator sits on. Defaults to `'top-right'`.
|
|
18
|
+
*
|
|
19
|
+
* The indicator overhangs the child, so an ancestor that clips — a `Surface`
|
|
20
|
+
* with a radius, or a `Screen` list row — will cut it off. Pad that container
|
|
21
|
+
* by the overhang, or lift the `Badge` outside it.
|
|
22
|
+
*/
|
|
23
|
+
placement?: BadgePlacement;
|
|
24
|
+
/**
|
|
25
|
+
* Text in the indicator. Omit it (or pass an empty string) for a dot.
|
|
26
|
+
* `0` renders as a label — use `isVisible` to suppress a zero count.
|
|
27
|
+
*/
|
|
28
|
+
label?: string | number;
|
|
29
|
+
/** Semantic scheme or raw color literal. Defaults to `'danger'`. */
|
|
30
|
+
color?: BadgeColor;
|
|
31
|
+
/** Scale of the indicator. Defaults to `'md'`. */
|
|
32
|
+
size?: BadgeSize;
|
|
33
|
+
/** Renders the indicator. The child renders either way. Defaults to `true`. */
|
|
34
|
+
isVisible?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Stretches the wrapper along its parent's cross axis, so a child that
|
|
37
|
+
* stretches unwrapped keeps stretching. Defaults to `false`, which hugs the
|
|
38
|
+
* child — what an icon, avatar, or toolbar button needs. An explicit
|
|
39
|
+
* `alignSelf` in `style` beats both.
|
|
40
|
+
*/
|
|
41
|
+
fullWidth?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Announced in place of the label. Defaults to the label's own text; an
|
|
44
|
+
* unlabelled dot is hidden from assistive technology.
|
|
45
|
+
*/
|
|
46
|
+
accessibilityLabel?: string;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAC;AAEvF,yCAAyC;AACzC,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,GAER,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,mFAAmF;IACnF,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oEAAoE;IACpE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,kDAAkD;IAClD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CustomBadgeColors {
|
|
2
|
+
bg: string;
|
|
3
|
+
fg: string;
|
|
4
|
+
}
|
|
5
|
+
/** The indicator's paint for a raw literal: the literal itself, plus a readable label. */
|
|
6
|
+
export declare function getCustomBadgeColors(literal: string): CustomBadgeColors;
|
|
7
|
+
/**
|
|
8
|
+
* `true` when `label` should render as a pill. An empty string and `undefined`
|
|
9
|
+
* are a dot; `0` is a label, since a caller suppressing a zero count uses
|
|
10
|
+
* `isVisible` rather than relying on falsiness.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasLabel(label: string | number | undefined): label is string | number;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/badge/utils.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAErF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAU,CAAC;AACzB,cAAc,gBAAO,CAAC;AACtB,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,wBAAe,CAAC;AAC9B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,2BAAkB,CAAC;AACjC,cAAc,mBAAU,CAAC;AACzB,cAAc,sBAAa,CAAC;AAC5B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,oBAAW,CAAC;AAC1B,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,oBAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAU,CAAC;AACzB,cAAc,kBAAS,CAAC;AACxB,cAAc,gBAAO,CAAC;AACtB,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,wBAAe,CAAC;AAC9B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,2BAAkB,CAAC;AACjC,cAAc,mBAAU,CAAC;AACzB,cAAc,sBAAa,CAAC;AAC5B,cAAc,mBAAU,CAAC;AACzB,cAAc,iBAAQ,CAAC;AACvB,cAAc,oBAAW,CAAC;AAC1B,cAAc,oBAAW,CAAC;AAC1B,cAAc,iBAAQ,CAAC;AACvB,cAAc,kBAAS,CAAC;AACxB,cAAc,oBAAW,CAAC"}
|
|
@@ -20,13 +20,13 @@ export interface UseThemeResult {
|
|
|
20
20
|
scheme: Scheme;
|
|
21
21
|
/** Pin a scheme (stops following the system). Same as `setMode(scheme)`. */
|
|
22
22
|
setScheme: (scheme: Scheme) => void;
|
|
23
|
-
/** Applied
|
|
24
|
-
|
|
23
|
+
/** Applied theme name, or `undefined` for the base themes. */
|
|
24
|
+
themeName: string | undefined;
|
|
25
25
|
/**
|
|
26
|
-
* Apply a registered
|
|
27
|
-
* name warns in development and leaves the
|
|
26
|
+
* Apply a registered theme; `null` restores the base themes. An unknown
|
|
27
|
+
* name warns in development and leaves the theme unchanged.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
setTheme: (name: string | null) => void;
|
|
30
30
|
/**
|
|
31
31
|
* How the active scheme is chosen: `system` follows the OS appearance,
|
|
32
32
|
* `light` / `dark` pin a scheme. A system appearance change updates
|
|
@@ -37,8 +37,8 @@ export interface UseThemeResult {
|
|
|
37
37
|
setMode: (mode: ThemeMode) => void;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Access the active theme and switch scheme / mode /
|
|
41
|
-
* comes from the runtime store, so changes made imperatively (`
|
|
40
|
+
* Access the active theme and switch scheme / mode / theme. Selection state
|
|
41
|
+
* comes from the runtime store, so changes made imperatively (`setTheme`,
|
|
42
42
|
* `setThemeMode`) and through this hook are observed by every consumer.
|
|
43
43
|
*/
|
|
44
44
|
export declare function useTheme(): UseThemeResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/context/ThemeProvider.tsx"],"names":[],"mappings":"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+E;IAC/E,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CAazC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAGxD;AAED,wCAAwC;AACxC,eAAO,MAAM,eAAe,yBAAmB,CAAC"}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import type { TerraConfig } from "./types.js";
|
|
2
|
-
/** The literal
|
|
3
|
-
type
|
|
4
|
-
|
|
2
|
+
/** The literal theme names declared in `T.themes`, or `never` when none are declared. */
|
|
3
|
+
type DeclaredThemeNames<T> = T extends {
|
|
4
|
+
themes: infer A;
|
|
5
5
|
} ? A extends Record<string, unknown> ? keyof A & string : never : never;
|
|
6
6
|
/**
|
|
7
7
|
* Identity helper for authoring a {@link TerraConfig} with contextual typing.
|
|
8
|
-
* Has no side effects. With literal `
|
|
9
|
-
* them; a dynamic `Record<string,
|
|
8
|
+
* Has no side effects. With literal `themes`, `defaultTheme` must name one of
|
|
9
|
+
* them; a dynamic `Record<string, NamedTheme>` keeps `defaultTheme` as `string`
|
|
10
10
|
* and defers to runtime validation.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* const config = defineTerraConfig({
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* themes: { indigo: { light: "#4f46e5", dark: "#818cf8" } },
|
|
15
|
+
* defaultTheme: "indigo",
|
|
16
16
|
* });
|
|
17
17
|
* configureTerraUI(config);
|
|
18
18
|
*/
|
|
19
19
|
export declare function defineTerraConfig<const T extends TerraConfig>(config: T & {
|
|
20
|
-
|
|
20
|
+
defaultTheme?: DeclaredThemeNames<T>;
|
|
21
|
+
schemes?: never;
|
|
22
|
+
accents?: never;
|
|
23
|
+
defaultAccent?: never;
|
|
21
24
|
}): T;
|
|
22
25
|
export {};
|
|
23
26
|
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../../src/theme/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../../src/theme/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAE3C,yFAAyF;AACzF,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACtD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,GAAG,MAAM,GAChB,KAAK,GACP,KAAK,CAAC;AAEV;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAC3D,MAAM,EAAE,CAAC,GAAG;IACV,YAAY,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,GACA,CAAC,CAEH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Thrown for invalid pure configuration input — before any registry, selection,
|
|
3
3
|
* or native state is touched. `path` points at the offending config entry, e.g.
|
|
4
|
-
* `
|
|
4
|
+
* `themes.indigo.dark.seed` or `defaultTheme`.
|
|
5
5
|
*/
|
|
6
6
|
export declare class TerraConfigError extends Error {
|
|
7
7
|
readonly path: string;
|
|
@@ -10,14 +10,14 @@ export type { AppBreakpoints, BreakpointName } from "./breakpoints.js";
|
|
|
10
10
|
export { breakpoints, resolveBreakpointValue } from "./breakpoints.js";
|
|
11
11
|
export { defineTerraConfig } from "./define-config.js";
|
|
12
12
|
export { TerraConfigError } from "./errors.js";
|
|
13
|
-
export { configureTerraUI,
|
|
13
|
+
export { configureTerraUI, getDefaultRadius, getIcon, getImageComponent, getIsConfigured, getRequiredIcon, getSurfaceElevation, getThemeNames, resolveTheme, } from "./registry.js";
|
|
14
14
|
export { createTerraThemes } from "./resolve-config.js";
|
|
15
15
|
export type { ThemeSelection } from "./runtime.js";
|
|
16
|
-
export {
|
|
16
|
+
export { applyScheme, getCurrentTheme, getThemeMode, getThemeSelection, setTheme, setThemeMode, } from "./runtime.js";
|
|
17
17
|
export type { ResolvedScreenMargin } from "./screen-margin.js";
|
|
18
18
|
export { resolveScreenMargin } from "./screen-margin.js";
|
|
19
19
|
export type { ResolvedScreenPadding } from "./screen-padding.js";
|
|
20
20
|
export { resolveScreenPadding } from "./screen-padding.js";
|
|
21
21
|
export { defaultDarkTheme, defaultLightTheme } from "./theme.js";
|
|
22
|
-
export type {
|
|
22
|
+
export type { AccentColorToken, ActionColorToken, BackgroundColorToken, BorderColorToken, ButtonDefaults, CanonicalThemeColor, ColorToken, ComponentDefaults, ContentColorToken, CreateTerraThemesOptions, DefaultRadiusToken, ElevationKey, ElevationScale, ElevationStyle, FontWeightToken, LayoutTokens, NamedTheme, NeutralColorToken, OpacityTokens, RadiusComponent, RadiusKey, Scheme, ScreenPaddingTokens, SpacingKey, StatusColorToken, SurfaceColorToken, SurfaceDefaults, TerraColorRegistry, TerraColorRegistryCollision, TerraConfig, TerraCustomColorName, TerraIconComponent, TerraIconName, TerraIconProps, TerraImageComponent, TerraImageContentFit, TerraImageProps, TerraSemanticIconName, TerraTheme, TerraThemeInput, TerraThemeOverride, TextColorToken, TextVariant, ThemeColor, ThemeMode, ThemeRadiusOverride, ThemeSchemeInput, ThemeSeed, ThemeSpacingOverride, TypeStyle, Typography, } from "./types.js";
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAQA,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAe,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,kBAAe,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAQA,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,M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iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,SAAS,EACT,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC3B,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,UAAU,GACX,MAAM,YAAS,CAAC"}
|
|
@@ -6,8 +6,8 @@ declare module "react-native-unistyles" {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export declare const getIsConfigured: () => boolean;
|
|
9
|
-
/** Names of the registered
|
|
10
|
-
export declare const
|
|
9
|
+
/** Names of the registered themes, in declaration order. Returns a fresh array. */
|
|
10
|
+
export declare const getThemeNames: () => string[];
|
|
11
11
|
export declare const getImageComponent: () => TerraImageComponent;
|
|
12
12
|
export declare const getIcon: (name: string) => TerraIconComponent | undefined;
|
|
13
13
|
export declare const getRequiredIcon: (name: TerraSemanticIconName) => TerraIconComponent;
|
|
@@ -23,12 +23,12 @@ export declare const getDefaultRadius: (component: RadiusComponent) => DefaultRa
|
|
|
23
23
|
export declare const getSurfaceElevation: () => ElevationKey;
|
|
24
24
|
/**
|
|
25
25
|
* Resolves one scheme's theme from the installed configuration with the named
|
|
26
|
-
*
|
|
27
|
-
* not the configured `
|
|
26
|
+
* theme selected. Omitting `name` selects the base theme (defaults + shared —
|
|
27
|
+
* not the configured `defaultTheme`). An unknown name warns in development
|
|
28
28
|
* and falls back to the base theme. Pure with respect to runtime state: it
|
|
29
29
|
* never changes the applied selection.
|
|
30
30
|
*/
|
|
31
|
-
export declare function resolveTheme(scheme: Scheme,
|
|
31
|
+
export declare function resolveTheme(scheme: Scheme, name?: string): TerraTheme;
|
|
32
32
|
/**
|
|
33
33
|
* Configure Terra UI's themes. Call ONCE, as early as possible — before any
|
|
34
34
|
* component renders (e.g. top of the app entry, imported from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/theme/registry.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,MAAM,EACN,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/theme/registry.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,MAAM,EACN,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EAEX,MAAM,YAAS,CAAC;AAmBjB,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,eAAe;QAC9B,KAAK,EAAE,UAAU,CAAC;QAClB,IAAI,EAAE,UAAU,CAAC;KAClB;CACF;AA8BD,eAAO,MAAM,eAAe,QAAO,OAA0C,CAAC;AAE9E,mFAAmF;AACnF,eAAO,MAAM,aAAa,QAAO,MAAM,EAA0C,CAAC;AAElF,eAAO,MAAM,iBAAiB,QAAO,mBAA8C,CAAC;AAEpF,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,KAAG,kBAAkB,GAAG,SACS,CAAC;AAEtE,eAAO,MAAM,eAAe,GAAI,MAAM,qBAAqB,KAAG,kBAClB,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,eAAe,KAAG,kBAC3B,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,YAAyC,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAWtE;AAID;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,WAAgB,GAAG,IAAI,CAW/D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure theme resolution — normalization, layer processing, derived values and
|
|
3
|
-
* theme creation. Shared by startup configuration, runtime
|
|
3
|
+
* theme creation. Shared by startup configuration, runtime theme changes and
|
|
4
4
|
* previews so every consumer sees the same colors for the same input.
|
|
5
5
|
*
|
|
6
6
|
* Precedence, identical for both schemes:
|
|
7
7
|
*
|
|
8
|
-
* default tokens → shared →
|
|
9
|
-
*
|
|
8
|
+
* default tokens → shared → generated accent → selected theme tokens
|
|
9
|
+
* Generation uses the selected theme's resolved surfaces and pressed opacity.
|
|
10
10
|
*
|
|
11
11
|
* This module must stay free of registry, provider, Unistyles and renderer
|
|
12
12
|
* imports so `createTerraThemes` works without any native configuration.
|
|
13
13
|
*/
|
|
14
14
|
import { type ContrastDiagnostic } from "../utils/accent-generator";
|
|
15
15
|
import { type ThemeSource } from "./theme.js";
|
|
16
|
-
import type {
|
|
16
|
+
import type { CreateTerraThemesOptions, ElevationKey, Scheme, TerraTheme, TerraThemeInput, TerraThemeOverride, ThemeSchemeInput } from "./types.js";
|
|
17
17
|
/**
|
|
18
18
|
* A theme mid-resolution: its source form plus provenance for every elevation
|
|
19
19
|
* level whose `shadowColor` a layer pinned explicitly. Default shadow colors are
|
|
@@ -25,8 +25,8 @@ export interface ThemeLayerState {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Applies one override layer onto `state` and returns the next state. Every
|
|
28
|
-
* layer — shared,
|
|
29
|
-
*
|
|
28
|
+
* layer — shared, generated accent, or selected theme tokens — goes through
|
|
29
|
+
* here, so they all follow the same rules:
|
|
30
30
|
* - deprecated names are normalized within the layer (canonical wins);
|
|
31
31
|
* - `undefined`/`null` leaves are no override; arrays replace; objects merge;
|
|
32
32
|
* - `spacing.base` / `radius.base` regenerate their scale, then that layer's
|
|
@@ -36,37 +36,37 @@ export interface ThemeLayerState {
|
|
|
36
36
|
* Inputs are never mutated.
|
|
37
37
|
*/
|
|
38
38
|
export declare function applyThemeLayer(state: ThemeLayerState, override?: TerraThemeOverride): ThemeLayerState;
|
|
39
|
-
export type
|
|
39
|
+
export type NormalizedThemeScheme = {
|
|
40
40
|
readonly kind: "none";
|
|
41
41
|
} | {
|
|
42
42
|
readonly kind: "seed";
|
|
43
43
|
readonly seed: string;
|
|
44
|
-
readonly
|
|
44
|
+
readonly patch?: TerraThemeOverride;
|
|
45
45
|
} | {
|
|
46
46
|
readonly kind: "patch";
|
|
47
47
|
readonly patch: TerraThemeOverride;
|
|
48
48
|
};
|
|
49
|
-
interface
|
|
50
|
-
readonly light:
|
|
51
|
-
readonly dark:
|
|
49
|
+
interface NormalizedThemeEntry {
|
|
50
|
+
readonly light: NormalizedThemeScheme;
|
|
51
|
+
readonly dark: NormalizedThemeScheme;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* A validated, immutable theme configuration. `base` is the fully layered
|
|
55
|
-
* `defaults → shared
|
|
56
|
-
* re-resolved from it rather than from a previously resolved
|
|
55
|
+
* `defaults → shared` state per scheme; every theme selection is
|
|
56
|
+
* re-resolved from it rather than from a previously resolved theme.
|
|
57
57
|
*/
|
|
58
58
|
export interface NormalizedThemeConfig {
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
/** @internal Immutable `defaults → shared
|
|
59
|
+
readonly themeNames: readonly string[];
|
|
60
|
+
readonly defaultTheme: string | null;
|
|
61
|
+
/** @internal Immutable `defaults → shared` state per scheme. */
|
|
62
62
|
readonly base: Readonly<Record<Scheme, ThemeLayerState>>;
|
|
63
|
-
/** @internal Per-
|
|
64
|
-
readonly
|
|
63
|
+
/** @internal Per-theme, per-scheme normalized inputs. */
|
|
64
|
+
readonly themes: Readonly<Record<string, NormalizedThemeEntry>>;
|
|
65
65
|
}
|
|
66
|
-
export declare function
|
|
66
|
+
export declare function normalizeThemeScheme(input: ThemeSchemeInput | undefined, path: string): NormalizedThemeScheme;
|
|
67
67
|
/**
|
|
68
68
|
* Validates a theme input and pre-computes the immutable per-scheme base
|
|
69
|
-
* (`defaults → shared
|
|
69
|
+
* (`defaults → shared`). Throws {@link TerraConfigError} for invalid
|
|
70
70
|
* input — before any state exists to mutate. Never mutates `input` or the
|
|
71
71
|
* exported defaults.
|
|
72
72
|
*/
|
|
@@ -77,20 +77,20 @@ export interface ResolvedThemes {
|
|
|
77
77
|
diagnostics: ContrastDiagnostic[];
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* Resolves both schemes for `
|
|
80
|
+
* Resolves both schemes for `themeName` from the config's immutable base. `null`
|
|
81
81
|
* selects the base themes; an unknown name throws {@link TerraConfigError}.
|
|
82
82
|
* Returned themes are freshly built and independently owned.
|
|
83
83
|
*/
|
|
84
|
-
export declare function resolveThemes(config: NormalizedThemeConfig,
|
|
84
|
+
export declare function resolveThemes(config: NormalizedThemeConfig, themeName: string | null): ResolvedThemes;
|
|
85
85
|
/** Resolves one scheme without generating and finalizing the other. */
|
|
86
|
-
export declare function resolveThemeScheme(config: NormalizedThemeConfig, scheme: Scheme,
|
|
86
|
+
export declare function resolveThemeScheme(config: NormalizedThemeConfig, scheme: Scheme, themeName: string | null): {
|
|
87
87
|
theme: TerraTheme;
|
|
88
88
|
diagnostics: ContrastDiagnostic[];
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* Pure theme creation — no Unistyles configuration or registry involved.
|
|
92
|
-
* `options.
|
|
93
|
-
* themes. Invalid input and unknown
|
|
92
|
+
* `options.theme` omitted → the input's `defaultTheme`; `null` → the base
|
|
93
|
+
* themes. Invalid input and unknown themes throw {@link TerraConfigError}.
|
|
94
94
|
* In development, contrast diagnostics are reported once each via
|
|
95
95
|
* `console.warn`; requested colors are never altered.
|
|
96
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../../../src/theme/resolve-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAGL,KAAK,kBAAkB,EAMxB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,YAAS,CAAC;AACjB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../../../src/theme/resolve-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAGL,KAAK,kBAAkB,EAMxB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,YAAS,CAAC;AACjB,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EAEZ,MAAM,EACN,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,YAAS,CAAC;AAajB;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAC9E;AAsBD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAuCtG;AAID,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,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E,qBAAqB,EAC7B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAQ5B"}
|
|
@@ -2,16 +2,16 @@ import type { Scheme, ThemeMode } from "./types.js";
|
|
|
2
2
|
export type { ThemeSelection } from "./selection-store.js";
|
|
3
3
|
export { getThemeSelection, subscribeThemeSelection } from "./selection-store.js";
|
|
4
4
|
/**
|
|
5
|
-
* Apply a registered
|
|
5
|
+
* Apply a registered theme (`null` restores the base themes) by updating both
|
|
6
6
|
* registered themes. An unknown name warns in development and changes nothing.
|
|
7
7
|
*
|
|
8
8
|
* If the native update fails part-way (see `updateThemes` in the adapter), the
|
|
9
9
|
* error propagates and the previous selection stays published; calling
|
|
10
|
-
* `
|
|
10
|
+
* `setTheme(getCurrentTheme() ?? null)` rewrites both themes.
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
13
|
-
/** The applied
|
|
14
|
-
export declare const
|
|
12
|
+
export declare function setTheme(name: string | null): void;
|
|
13
|
+
/** The applied theme name, or `undefined` for the base themes. */
|
|
14
|
+
export declare const getCurrentTheme: () => string | undefined;
|
|
15
15
|
/**
|
|
16
16
|
* Choose how the active scheme is selected: `system` follows the OS appearance;
|
|
17
17
|
* `light` / `dark` pin a scheme until the next call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/theme/runtime.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAGjD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAmB,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/theme/runtime.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAGjD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAmB,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAalD;AAED,kEAAkE;AAClE,eAAO,MAAM,eAAe,QAAO,MAAM,GAAG,SAA0C,CAAC;AAEvF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAGlD;AAED,6EAA6E;AAC7E,eAAO,MAAM,YAAY,QAAO,SAAqC,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEhD"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* those has to import the other.
|
|
5
5
|
*
|
|
6
6
|
* Holds two things, both private to `theme/`:
|
|
7
|
-
* - the installed {@link NormalizedThemeConfig} — immutable; every
|
|
7
|
+
* - the installed {@link NormalizedThemeConfig} — immutable; every theme
|
|
8
8
|
* selection is re-resolved from it, never layered on a previous result;
|
|
9
|
-
* - the selection snapshot (`
|
|
9
|
+
* - the selection snapshot (`themeName`, `mode`) behind a `useSyncExternalStore`
|
|
10
10
|
* compatible subscribe/get pair. The snapshot object keeps its identity until
|
|
11
11
|
* a value actually changes, so subscribers only re-render on real changes.
|
|
12
12
|
*
|
|
@@ -18,10 +18,10 @@ import type { ThemeMode } from "./types.js";
|
|
|
18
18
|
export declare const getInstalledConfig: () => NormalizedThemeConfig;
|
|
19
19
|
/** @internal Replaces the installed config; only `registry.ts` should call this. */
|
|
20
20
|
export declare function setInstalledConfig(config: NormalizedThemeConfig): void;
|
|
21
|
-
/** The current runtime selection: which
|
|
21
|
+
/** The current runtime selection: which theme is applied and how the scheme is chosen. */
|
|
22
22
|
export interface ThemeSelection {
|
|
23
|
-
/** Applied
|
|
24
|
-
readonly
|
|
23
|
+
/** Applied theme name, or `undefined` for the base themes. */
|
|
24
|
+
readonly themeName: string | undefined;
|
|
25
25
|
/** `system` follows the OS appearance; `light` / `dark` pin a scheme. */
|
|
26
26
|
readonly mode: ThemeMode;
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-store.d.ts","sourceRoot":"","sources":["../../../../src/theme/selection-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,qBAAqB,EAAuB,MAAM,qBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAUzC,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,QAAO,qBAAwC,CAAC;AAE/E,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAEtE;AAID,
|
|
1
|
+
{"version":3,"file":"selection-store.d.ts","sourceRoot":"","sources":["../../../../src/theme/selection-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,qBAAqB,EAAuB,MAAM,qBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAUzC,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,QAAO,qBAAwC,CAAC;AAE/E,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAEtE;AAID,0FAA0F;AAC1F,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAMD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,cAA2B,CAAC;AAEjE,wEAAwE;AACxE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKxE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CASzE"}
|