uhuu-components 0.4.4 → 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
@@ -161,7 +161,24 @@ export interface StaticFlowColumn {
161
161
 
162
162
  export type StaticFlowLayoutNode =
163
163
  | { kind: "item"; index: number }
164
- | { kind: "columns"; id: string; columns: StaticFlowColumn[] };
164
+ | { kind: "columns"; id: string; columns: StaticFlowColumn[] }
165
+ /**
166
+ * One text set in `columns` columns, read as a newspaper: `indexes` (reading order) fill the first
167
+ * column, then the next, then the first column of the next sheet. Items move whole. Columns get
168
+ * ids `column-1` … `column-<n>` (`getColumnProps`, `data-uhuu-flow-column`) and equal widths.
169
+ */
170
+ | {
171
+ kind: "flowingColumns";
172
+ id: string;
173
+ indexes: number[];
174
+ /** How many columns, 1 or more. */
175
+ columns: number;
176
+ /**
177
+ * The group's last sheet: "balance" (default) evens its columns out, "auto" fills them in
178
+ * order, as CSS `column-fill`.
179
+ */
180
+ columnFill?: "balance" | "auto";
181
+ };
165
182
 
166
183
  export interface StaticFlowColumnFragment {
167
184
  id: string;
@@ -704,6 +721,50 @@ export interface FrameBlockProps extends FrameDeclaration, Omit<ImageBlockProps,
704
721
  */
705
722
  export const FrameBlock: ComponentType<FrameBlockProps>;
706
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
+
707
768
  // --- Brand-kit runtime (src/uhuu/brand-kit/). See docs/brand-kit-runtime.md. ---
708
769
 
709
770
  export interface BrandKitFontFile {
@@ -764,7 +825,16 @@ export interface BrandKitRuntimeBlock {
764
825
  version: 2;
765
826
  light: Record<string, string>;
766
827
  fontStylesheets?: string[];
767
- 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
+ }>;
768
838
  }
769
839
 
770
840
  export interface BrandKitLogo {
@@ -773,6 +843,8 @@ export interface BrandKitLogo {
773
843
  alt?: string;
774
844
  kind: "primary" | "mark" | "wordmark";
775
845
  background?: "light" | "dark" | "any";
846
+ /** The language a named or language version is for. */
847
+ locale?: string;
776
848
  minWidth?: { value: number; unit: "px" | "mm" };
777
849
  clearSpace?: { value: number; unit: "px" | "mm" | "mark" };
778
850
  }
@@ -814,10 +886,19 @@ export interface BrandKitRuntime {
814
886
  cssVars: Record<string, string>;
815
887
  /** Where the rendered kit came from (`src` once fetched, else the `sourceUrl` prop). */
816
888
  sourceUrl?: string;
817
- /** `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`. */
818
890
  status: "idle" | "loading" | "ready" | "error";
819
- /** A logo, resolved: `logoSystem` first, then `logos`. Default `{ kind: "primary", background: "light" }`. */
820
- 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 };
821
902
  /** The assigned media collection's promoted version, items resolved. */
822
903
  collection(kind: BrandKitMediaKind | string, options?: { versionId?: string }): BrandKitCollection | null;
823
904
  mapStyle(mode: "micro" | "macro"): BrandKitMapStyle | null;
@@ -830,8 +911,16 @@ export interface BrandKitRuntime {
830
911
  export interface BrandKitProviderProps {
831
912
  /** The kit to render; with `src`, the fallback until the fetched kit arrives or when the fetch fails. */
832
913
  brandKit?: BrandKitJson | null;
833
- /** A brandkit.json URL to fetch, usually `brandKitSourceUrl(payload)`. */
914
+ /** A brandkit.json URL to fetch, usually `brandKitSelection(payload, { snapshot }).src`. */
834
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 };
835
924
  /** Custom properties for whatever the kit leaves out; the kit wins. Pass a stable object. */
836
925
  defaults?: Record<string, string>;
837
926
  /** Where a `brandKit` passed in came from; its directory resolves relative URLs when the kit has no `baseUrl`. */
@@ -862,18 +951,89 @@ export const BRAND_KIT_PUBLIC_BASE_URL: string;
862
951
  /**
863
952
  * The brandkit.json URL a payload points at: `brandKitUrl` (URL or `kit-…` id), `brandKitId`, or
864
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.
865
955
  */
866
956
  export function brandKitSourceUrl(
867
957
  payload: Record<string, unknown> | null | undefined,
868
958
  options?: { publicBaseUrl?: string; teamId?: string | number },
869
959
  ): string | null;
870
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
+
871
1031
  /** Fetches a brandkit.json; rejects on network errors, non-2xx and non-object bodies. */
872
1032
  export function loadBrandKit(url: string, options?: { fetch?: typeof fetch; signal?: AbortSignal }): Promise<BrandKitJson>;
873
1033
 
874
1034
  export function brandKitLogo(
875
1035
  brandKit: BrandKitJson | null | undefined,
876
- options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; sourceUrl?: string },
1036
+ options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; name?: string; locale?: string; sourceUrl?: string },
877
1037
  ): BrandKitLogo | null;
878
1038
 
879
1039
  export function brandKitCollection(
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.4",
2
+ "version": "0.4.6",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",