uhuu-components 0.2.98 → 0.3.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/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 raw kit: logos and collections are read from it. */
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 fetched kit came from; its directory resolves relative font URLs when the kit has no `baseUrl`. */
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,18 +426,78 @@ 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, and loads the fonts the kit declares. Colours are hex, `rgb()`/`rgba()` or keywords:
358
- * HSL is converted, anything else is skipped as if absent.
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;
368
471
  enableDevTools?: boolean;
472
+ /** The shell's resolved interface language (`de`, `fr`, `it`, `en`, or what the template passed). */
473
+ locale: string;
474
+ }
475
+
476
+ /**
477
+ * A label as one string, or one string per language: `{ en: 'Cover', de: 'Titelseite' }`.
478
+ * Accepted wherever `templateConfig` and `pageOptions` take a `label` (pages, groups, options,
479
+ * select and colour values) and by `reorderTitle` / `reorderDescription`. Resolved in the shell's
480
+ * language, then English, then the first entry.
481
+ */
482
+ export type LocalizedText = string | Record<string, string>;
483
+
484
+ /** Editor shell words, nested as in the English catalog (docs/editor-shell-translations.md). */
485
+ export type EditorShellTranslations = { [key: string]: string | EditorShellTranslations };
486
+
487
+ export interface InteractiveModeProviderProps {
488
+ children: ReactNode;
489
+ defaultInteractive?: boolean;
490
+ enableDevTools?: boolean;
491
+ /**
492
+ * The shell's interface language. Default: the host's (uhuu-app's locale from the SDK
493
+ * handshake), then `?lang=`, `<html lang>`, the browser's languages, then `en`.
494
+ */
495
+ locale?: string;
496
+ /**
497
+ * Per-language overrides of the shell's words, or a whole catalog for a language the package
498
+ * does not ship: `{ de: { toolbar: { add: 'Neu' } }, rm: romanshCatalog }`. Pass a stable object.
499
+ */
500
+ translations?: Record<string, EditorShellTranslations>;
369
501
  }
370
502
 
371
503
  export interface BrandKitOption {
@@ -432,8 +564,8 @@ export interface PageEditorProps {
432
564
  pageId?: string;
433
565
  parent?: unknown;
434
566
  }) => ReactNode;
435
- reorderTitle?: string;
436
- reorderDescription?: string;
567
+ reorderTitle?: LocalizedText;
568
+ reorderDescription?: LocalizedText;
437
569
  stateKey?: string;
438
570
  brandKits?: BrandKitOption[];
439
571
  activeBrandKitId?: string;
@@ -467,11 +599,7 @@ export interface IntegrationAdapter {
467
599
  export const EditorShell: {
468
600
  TemplateDataProvider: ComponentType<TemplateDataProviderProps>;
469
601
  PageEditor: ComponentType<PageEditorProps>;
470
- InteractiveModeProvider: ComponentType<{
471
- children: ReactNode;
472
- defaultInteractive?: boolean;
473
- enableDevTools?: boolean;
474
- }>;
602
+ InteractiveModeProvider: ComponentType<InteractiveModeProviderProps>;
475
603
  useInteractive: () => InteractiveModeContextValue;
476
604
  useIntegrationAdapter: (config: IntegrationAdapterConfig) => IntegrationAdapter;
477
605
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.98",
2
+ "version": "0.3.1",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",
@@ -15,6 +15,15 @@
15
15
  }
16
16
  },
17
17
  "license": "https://uhuu.io/license",
18
+ "files": [
19
+ "uhuu-components.es.js",
20
+ "uhuu-components.es.js.map",
21
+ "uhuu-components.umd.cjs",
22
+ "uhuu-components.umd.cjs.map",
23
+ "index.d.ts",
24
+ "README.md",
25
+ "CHANGELOG.md"
26
+ ],
18
27
  "peerDependencies": {
19
28
  "react": "^18.0.0 || ^19.0.0",
20
29
  "react-dom": "^18.0.0 || ^19.0.0"