uhuu-components 0.4.5 → 0.4.6

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
@@ -721,6 +721,50 @@ export interface FrameBlockProps extends FrameDeclaration, Omit<ImageBlockProps,
721
721
  */
722
722
  export const FrameBlock: ComponentType<FrameBlockProps>;
723
723
 
724
+ /**
725
+ * A neutral, brand-free empty image (outline and icon in Text mixed into Paper) for `ImageBlock`'s
726
+ * `placeholder`, so templates never borrow placeholder photos from a client folder.
727
+ */
728
+ export const ImagePlaceholder: ComponentType<{ label?: string; className?: string; style?: CSSProperties }>;
729
+
730
+ /** A position on the sheet in mm: `left` or `right`, and `top` or `bottom`. */
731
+ export interface FurniturePosition { left?: number; right?: number; top?: number; bottom?: number }
732
+
733
+ /**
734
+ * The printed page number of sheet `pageNo` (1-based, deck order), or `null` when it is not numbered.
735
+ * Counting starts at the first numbered sheet and skips unnumbered sheets after it; `offset` is subtracted.
736
+ */
737
+ export function folioNumber(input: {
738
+ pageNo: number;
739
+ sheetKeys: readonly string[];
740
+ numbered: readonly string[] | ((key: string) => boolean);
741
+ offset?: number;
742
+ }): number | null;
743
+
744
+ /** The page number in the brand's body font and muted colour, at the verso (even) or recto (odd) position. */
745
+ export const PageFolio: ComponentType<{
746
+ number: number | null | undefined;
747
+ pageNo: number;
748
+ verso: FurniturePosition;
749
+ recto: FurniturePosition;
750
+ /** pt, default 9. */
751
+ size?: number;
752
+ className?: string;
753
+ style?: CSSProperties;
754
+ }>;
755
+
756
+ /** A running header: title, the brand's logo (default the mark on Paper) and a `border` or `accent` rule. */
757
+ export const RunningHeader: ComponentType<{
758
+ position: FurniturePosition;
759
+ children?: ReactNode;
760
+ logo?: false | { kind?: "primary" | "mark" | "wordmark"; background?: "light" | "dark"; name?: string; locale?: string };
761
+ /** mm, default 6. */
762
+ logoHeight?: number;
763
+ rule?: "border" | "accent" | false;
764
+ className?: string;
765
+ style?: CSSProperties;
766
+ }>;
767
+
724
768
  // --- Brand-kit runtime (src/uhuu/brand-kit/). See docs/brand-kit-runtime.md. ---
725
769
 
726
770
  export interface BrandKitFontFile {
@@ -781,7 +825,16 @@ export interface BrandKitRuntimeBlock {
781
825
  version: 2;
782
826
  light: Record<string, string>;
783
827
  fontStylesheets?: string[];
784
- fontFaces?: Array<{ family: string; src: string; weight?: number; style?: "normal" | "italic"; format?: string }>;
828
+ fontFaces?: Array<{
829
+ family: string;
830
+ src: string;
831
+ weight?: number;
832
+ style?: "normal" | "italic";
833
+ format?: string;
834
+ ascentOverride?: number;
835
+ descentOverride?: number;
836
+ lineGapOverride?: number;
837
+ }>;
785
838
  }
786
839
 
787
840
  export interface BrandKitLogo {
@@ -790,6 +843,8 @@ export interface BrandKitLogo {
790
843
  alt?: string;
791
844
  kind: "primary" | "mark" | "wordmark";
792
845
  background?: "light" | "dark" | "any";
846
+ /** The language a named or language version is for. */
847
+ locale?: string;
793
848
  minWidth?: { value: number; unit: "px" | "mm" };
794
849
  clearSpace?: { value: number; unit: "px" | "mm" | "mark" };
795
850
  }
@@ -831,10 +886,19 @@ export interface BrandKitRuntime {
831
886
  cssVars: Record<string, string>;
832
887
  /** Where the rendered kit came from (`src` once fetched, else the `sourceUrl` prop). */
833
888
  sourceUrl?: string;
834
- /** `idle` without `src`; `loading` until it arrives; `ready`; `error` (the `brandKit` prop renders). */
889
+ /** `idle` without `src` (a snapshot or the `brandKit` prop renders); `loading` until it arrives; `ready`; `error`. */
835
890
  status: "idle" | "loading" | "ready" | "error";
836
- /** A logo, resolved: `logoSystem` first, then `logos`. Default `{ kind: "primary", background: "light" }`. */
837
- logo(options?: { kind?: BrandKitLogoKind; background?: "light" | "dark" }): BrandKitLogo | null;
891
+ /** The snapshot the rendered kit came from, when no fetched kit replaced it. */
892
+ snapshot: BrandKitSnapshotInfo | null;
893
+ /**
894
+ * A logo, resolved: `logoSystem` first, then `logos`. Default `{ kind: "primary", background: "light" }`.
895
+ * `name` and `locale` pick a named or language version, falling back to the standard logo.
896
+ */
897
+ logo(options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; name?: string; locale?: string }): BrandKitLogo | null;
898
+ /** The brand's chart colors as hex when it set them, else `fallback` (the template's). */
899
+ chartPalette(options?: { fallback?: string[]; count?: number }): BrandChartPalette;
900
+ /** The brand's default locale and currency (`extensions.locale`); `payload.locale` wins over it. */
901
+ locale: { locale?: string; currency?: string };
838
902
  /** The assigned media collection's promoted version, items resolved. */
839
903
  collection(kind: BrandKitMediaKind | string, options?: { versionId?: string }): BrandKitCollection | null;
840
904
  mapStyle(mode: "micro" | "macro"): BrandKitMapStyle | null;
@@ -847,8 +911,16 @@ export interface BrandKitRuntime {
847
911
  export interface BrandKitProviderProps {
848
912
  /** The kit to render; with `src`, the fallback until the fetched kit arrives or when the fetch fails. */
849
913
  brandKit?: BrandKitJson | null;
850
- /** A brandkit.json URL to fetch, usually `brandKitSourceUrl(payload)`. */
914
+ /** A brandkit.json URL to fetch, usually `brandKitSelection(payload, { snapshot }).src`. */
851
915
  src?: string | null;
916
+ /**
917
+ * The template's locked brand (`src/brand/`, from `brandkit pull`): renders with no request for
918
+ * the brand, logos and fonts from the template's copies. Wins over `brandKit`; a fetched `src`
919
+ * replaces it. Pass a stable object.
920
+ */
921
+ snapshot?: BrandKitSnapshot | null;
922
+ /** Brand values the template opts into beyond colours and fonts: `{ radius: true }` adds `--radius*`. Stable object. */
923
+ adopt?: { radius?: boolean };
852
924
  /** Custom properties for whatever the kit leaves out; the kit wins. Pass a stable object. */
853
925
  defaults?: Record<string, string>;
854
926
  /** Where a `brandKit` passed in came from; its directory resolves relative URLs when the kit has no `baseUrl`. */
@@ -879,18 +951,89 @@ export const BRAND_KIT_PUBLIC_BASE_URL: string;
879
951
  /**
880
952
  * The brandkit.json URL a payload points at: `brandKitUrl` (URL or `kit-…` id), `brandKitId`, or
881
953
  * `brandKit.storage.publicUrl`. Ids need `brandKitTeamId` (or `teamId`) and resolve under `publicBaseUrl`.
954
+ * @deprecated Use `brandKitSelection(payload, { snapshot })`: a pinned `payload.brand`, then the template's snapshot.
882
955
  */
883
956
  export function brandKitSourceUrl(
884
957
  payload: Record<string, unknown> | null | undefined,
885
958
  options?: { publicBaseUrl?: string; teamId?: string | number },
886
959
  ): string | null;
887
960
 
961
+ /**
962
+ * Which brand a document renders: a pinned `payload.brand` (unpinned warns), then the deprecated
963
+ * `brandKitUrl` / `brandKitId` (warns), then the template's snapshot, then none.
964
+ */
965
+ export function brandKitSelection(
966
+ payload: Record<string, unknown> | null | undefined,
967
+ options?: { snapshot?: BrandKitSnapshot | null; publicBaseUrl?: string; teamId?: string | number },
968
+ ): { source: "payload" | "payload-legacy" | "snapshot" | "none"; src: string | null; pinned: boolean; presetId?: string };
969
+
970
+ /** A template's locked brand: the published document, its `brand.lock.json`, and where the copies are served. */
971
+ export interface BrandKitSnapshot {
972
+ brandKit: BrandKitJson;
973
+ /** `brand.lock.json` (`uhuu.brand-lock.v1`). */
974
+ lock: Record<string, unknown>;
975
+ /** The folder the snapshot is served from (`/brand`, an absolute URL). */
976
+ baseUrl?: string;
977
+ /** Snapshot paths to bundled URLs (`import.meta.glob('./brand/assets/**', { query: '?url', import: 'default', eager: true })`, keyed by `assets/…`). */
978
+ assets?: Record<string, string>;
979
+ }
980
+
981
+ export interface BrandKitSnapshotInfo {
982
+ kind: "team" | "template";
983
+ kitId?: string;
984
+ version?: string;
985
+ digest?: string;
986
+ }
987
+
988
+ export const BRAND_LOCK_SCHEMA: "uhuu.brand-lock.v1";
989
+
990
+ /** The kit a snapshot renders: copied files point at the template's copies, the rest at absolute published URLs. */
991
+ export function brandKitFromSnapshot(snapshot: BrandKitSnapshot): { brandKit: BrandKitJson; lock: Record<string, unknown>; info: BrandKitSnapshotInfo } | null;
992
+
993
+ export interface BrandChartPalette {
994
+ colors: string[];
995
+ source: "brand" | "template";
996
+ }
997
+
998
+ /** Chart colors as `#rrggbb`: the brand's when it set them (Brand Kit publishes them only then), else `fallback`. */
999
+ export function brandChartPalette(brandKit: BrandKitJson | null | undefined, options?: { fallback?: string[]; count?: number }): BrandChartPalette;
1000
+
1001
+ /**
1002
+ * The chart dialog's `config.brand` (`ChartDialogBrand`): the series palette from `brandChartPalette`
1003
+ * and ink, line, muted and surface, all `#rrggbb`. Missing roles are left for the dialog's defaults.
1004
+ */
1005
+ export function brandChartDialogBrand(
1006
+ brandKit: BrandKitJson | null | undefined,
1007
+ options?: { fallback?: string[]; count?: number },
1008
+ ): { palette?: string[]; ink?: string; line?: string; muted?: string; surface?: string };
1009
+
1010
+ /** `#rrggbb` for hex, `rgb()`, HSL, `oklch()` or `oklab()`; `undefined` otherwise. */
1011
+ export function colorToHex(value: unknown): string | undefined;
1012
+
1013
+ /** The brand's default locale and currency (`extensions.locale.strings`). */
1014
+ export function brandKitLocale(brandKit: BrandKitJson | null | undefined): { locale?: string; currency?: string };
1015
+
1016
+ /** A number in the locale (`payload.locale`, else the brand's); Swiss locales group with `'`. */
1017
+ export function formatNumber(
1018
+ value: number,
1019
+ options?: { locale?: string; brandKit?: BrandKitJson | null; apostrophe?: "straight" | "typographic" } & Intl.NumberFormatOptions,
1020
+ ): string;
1021
+
1022
+ /** Money; Swiss locales print `CHF 3'600'000.–` (whole) and `CHF 1'250.50`. Currency: option, brand, `CHF`. */
1023
+ export function formatMoney(
1024
+ value: number,
1025
+ options?: { locale?: string; currency?: string; brandKit?: BrandKitJson | null; wholeDash?: boolean; apostrophe?: "straight" | "typographic" },
1026
+ ): string;
1027
+
1028
+ /** A date in the locale; `dateStyle: "long"` unless date fields are given. */
1029
+ export function formatDate(value: Date | string | number, options?: { locale?: string; brandKit?: BrandKitJson | null } & Intl.DateTimeFormatOptions): string;
1030
+
888
1031
  /** Fetches a brandkit.json; rejects on network errors, non-2xx and non-object bodies. */
889
1032
  export function loadBrandKit(url: string, options?: { fetch?: typeof fetch; signal?: AbortSignal }): Promise<BrandKitJson>;
890
1033
 
891
1034
  export function brandKitLogo(
892
1035
  brandKit: BrandKitJson | null | undefined,
893
- options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; sourceUrl?: string },
1036
+ options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; name?: string; locale?: string; sourceUrl?: string },
894
1037
  ): BrandKitLogo | null;
895
1038
 
896
1039
  export function brandKitCollection(
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.5",
2
+ "version": "0.4.6",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",