uhuu-components 0.2.98 → 0.3.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.
- package/index.d.ts +108 -5
- package/package.json +1 -1
- package/uhuu-components.es.js +4952 -4764
- package/uhuu-components.es.js.map +1 -1
- package/uhuu-components.umd.cjs +17 -16
- package/uhuu-components.umd.js +17 -16
- package/uhuu-components.umd.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -329,23 +329,95 @@ export interface BrandKitJson {
|
|
|
329
329
|
primitives?: { typography?: Record<string, unknown>; [key: string]: unknown };
|
|
330
330
|
[token: string]: unknown;
|
|
331
331
|
};
|
|
332
|
+
colorMode?: "light" | "manual" | "shade";
|
|
333
|
+
/** Template variables Brand Kit precomputed at publish. Applied as is when `version` is 2. */
|
|
334
|
+
runtime?: BrandKitRuntimeBlock;
|
|
332
335
|
[key: string]: unknown;
|
|
333
336
|
}
|
|
334
337
|
|
|
338
|
+
/**
|
|
339
|
+
* `brandkit.json.runtime` (brandkit.json "2.0"): shadcn role variables (`--primary`, `--color-primary`),
|
|
340
|
+
* `--color-kit-*` / `--font-*` / `--font-kit-*` values, ready to apply, and the fonts to load.
|
|
341
|
+
*/
|
|
342
|
+
export interface BrandKitRuntimeBlock {
|
|
343
|
+
version: 2;
|
|
344
|
+
light: Record<string, string>;
|
|
345
|
+
fontStylesheets?: string[];
|
|
346
|
+
fontFaces?: Array<{ family: string; src: string; weight?: number; style?: "normal" | "italic"; format?: string }>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface BrandKitLogo {
|
|
350
|
+
/** Absolute URL (SVG preferred, else PNG). */
|
|
351
|
+
src: string;
|
|
352
|
+
alt?: string;
|
|
353
|
+
kind: "primary" | "mark" | "wordmark";
|
|
354
|
+
background?: "light" | "dark" | "any";
|
|
355
|
+
minWidth?: { value: number; unit: "px" | "mm" };
|
|
356
|
+
clearSpace?: { value: number; unit: "px" | "mm" | "mark" };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface BrandKitCollectionItem {
|
|
360
|
+
key: string;
|
|
361
|
+
/** Absolute URL. */
|
|
362
|
+
src: string;
|
|
363
|
+
label?: string;
|
|
364
|
+
name?: string;
|
|
365
|
+
type?: string;
|
|
366
|
+
mimeType?: string;
|
|
367
|
+
tags?: string[];
|
|
368
|
+
[key: string]: unknown;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface BrandKitCollection {
|
|
372
|
+
id: string;
|
|
373
|
+
name?: string;
|
|
374
|
+
type?: string;
|
|
375
|
+
versionId?: string;
|
|
376
|
+
items: BrandKitCollectionItem[];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface BrandKitMapStyle {
|
|
380
|
+
url: string;
|
|
381
|
+
name?: string;
|
|
382
|
+
source: "config.maps" | "config.env";
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export type BrandKitLogoKind = "primary" | "logo" | "lockup" | "mark" | "icon" | "symbol" | "wordmark";
|
|
386
|
+
export type BrandKitMediaKind = "photos" | "icons" | "graphics" | "backgrounds" | "templates";
|
|
387
|
+
|
|
335
388
|
/** What `useBrandKit()` returns. */
|
|
336
389
|
export interface BrandKitRuntime {
|
|
337
|
-
/** The
|
|
390
|
+
/** The kit being rendered: the fetched one, else the `brandKit` prop. */
|
|
338
391
|
brandKit: BrandKitJson | null;
|
|
339
|
-
/** `--color-kit-*`, `--font-*` and `--font-kit-*`, as the provider's scope element carries them. */
|
|
392
|
+
/** `--<role>`, `--color-<role>`, `--color-kit-*`, `--font-*` and `--font-kit-*`, as the provider's scope element carries them. */
|
|
340
393
|
cssVars: Record<string, string>;
|
|
394
|
+
/** Where the rendered kit came from (`src` once fetched, else the `sourceUrl` prop). */
|
|
395
|
+
sourceUrl?: string;
|
|
396
|
+
/** `idle` without `src`; `loading` until it arrives; `ready`; `error` (the `brandKit` prop renders). */
|
|
397
|
+
status: "idle" | "loading" | "ready" | "error";
|
|
398
|
+
/** A logo, resolved: `logoSystem` first, then `logos`. Default `{ kind: "primary", background: "light" }`. */
|
|
399
|
+
logo(options?: { kind?: BrandKitLogoKind; background?: "light" | "dark" }): BrandKitLogo | null;
|
|
400
|
+
/** The assigned media collection's promoted version, items resolved. */
|
|
401
|
+
collection(kind: BrandKitMediaKind | string, options?: { versionId?: string }): BrandKitCollection | null;
|
|
402
|
+
mapStyle(mode: "micro" | "macro"): BrandKitMapStyle | null;
|
|
403
|
+
/** A `config.env` value; keys compare case- and punctuation-insensitively, first present wins. */
|
|
404
|
+
env(keys: string | string[]): string | undefined;
|
|
405
|
+
/** A kit-relative asset path made absolute. */
|
|
406
|
+
resolveUrl(path: unknown): string | undefined;
|
|
341
407
|
}
|
|
342
408
|
|
|
343
409
|
export interface BrandKitProviderProps {
|
|
410
|
+
/** The kit to render; with `src`, the fallback until the fetched kit arrives or when the fetch fails. */
|
|
344
411
|
brandKit?: BrandKitJson | null;
|
|
412
|
+
/** A brandkit.json URL to fetch, usually `brandKitSourceUrl(payload)`. */
|
|
413
|
+
src?: string | null;
|
|
345
414
|
/** Custom properties for whatever the kit leaves out; the kit wins. Pass a stable object. */
|
|
346
415
|
defaults?: Record<string, string>;
|
|
347
|
-
/** Where a
|
|
416
|
+
/** Where a `brandKit` passed in came from; its directory resolves relative URLs when the kit has no `baseUrl`. */
|
|
348
417
|
sourceUrl?: string;
|
|
418
|
+
onLoad?: (brandKit: BrandKitJson) => void;
|
|
419
|
+
/** Default: `console.error`. */
|
|
420
|
+
onError?: (error: unknown) => void;
|
|
349
421
|
/** For the scope element. `style` is applied last, so `{ display: "block" }` gives it a box. */
|
|
350
422
|
className?: string;
|
|
351
423
|
style?: CSSProperties;
|
|
@@ -354,14 +426,45 @@ export interface BrandKitProviderProps {
|
|
|
354
426
|
|
|
355
427
|
/**
|
|
356
428
|
* Scopes a kit's CSS variables around the pages and their overlay chrome, on a `display: contents`
|
|
357
|
-
* element
|
|
358
|
-
*
|
|
429
|
+
* element (`data-uhuu-brand-kit-status` tells a print step when a fetched kit has arrived), and
|
|
430
|
+
* loads the fonts the kit declares. Colours are hex, `rgb()`/`rgba()`, `oklch()`/`oklab()` or
|
|
431
|
+
* keywords: HSL is converted, anything else is skipped as if absent.
|
|
359
432
|
*/
|
|
360
433
|
export const BrandKitProvider: ComponentType<BrandKitProviderProps>;
|
|
361
434
|
|
|
362
435
|
/** The nearest `BrandKitProvider`'s runtime, or `null` outside one. */
|
|
363
436
|
export function useBrandKit(): BrandKitRuntime | null;
|
|
364
437
|
|
|
438
|
+
/** Brand Kit's production location for published kits. */
|
|
439
|
+
export const BRAND_KIT_PUBLIC_BASE_URL: string;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The brandkit.json URL a payload points at: `brandKitUrl` (URL or `kit-…` id), `brandKitId`, or
|
|
443
|
+
* `brandKit.storage.publicUrl`. Ids need `brandKitTeamId` (or `teamId`) and resolve under `publicBaseUrl`.
|
|
444
|
+
*/
|
|
445
|
+
export function brandKitSourceUrl(
|
|
446
|
+
payload: Record<string, unknown> | null | undefined,
|
|
447
|
+
options?: { publicBaseUrl?: string; teamId?: string | number },
|
|
448
|
+
): string | null;
|
|
449
|
+
|
|
450
|
+
/** Fetches a brandkit.json; rejects on network errors, non-2xx and non-object bodies. */
|
|
451
|
+
export function loadBrandKit(url: string, options?: { fetch?: typeof fetch; signal?: AbortSignal }): Promise<BrandKitJson>;
|
|
452
|
+
|
|
453
|
+
export function brandKitLogo(
|
|
454
|
+
brandKit: BrandKitJson | null | undefined,
|
|
455
|
+
options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; sourceUrl?: string },
|
|
456
|
+
): BrandKitLogo | null;
|
|
457
|
+
|
|
458
|
+
export function brandKitCollection(
|
|
459
|
+
brandKit: BrandKitJson | null | undefined,
|
|
460
|
+
kind: BrandKitMediaKind | string,
|
|
461
|
+
options?: { sourceUrl?: string; versionId?: string },
|
|
462
|
+
): BrandKitCollection | null;
|
|
463
|
+
|
|
464
|
+
export function brandKitMapStyle(brandKit: BrandKitJson | null | undefined, mode: "micro" | "macro"): BrandKitMapStyle | null;
|
|
465
|
+
|
|
466
|
+
export function brandKitEnv(brandKit: BrandKitJson | null | undefined, keys: string | string[]): string | undefined;
|
|
467
|
+
|
|
365
468
|
export interface InteractiveModeContextValue {
|
|
366
469
|
interactive: boolean;
|
|
367
470
|
setInteractive: (interactive: boolean) => void;
|
package/package.json
CHANGED