uhuu-components 0.2.97 → 0.2.98

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
@@ -4,6 +4,7 @@ import type {
4
4
  CSSProperties,
5
5
  ImgHTMLAttributes,
6
6
  Key,
7
+ MouseEventHandler,
7
8
  ReactElement,
8
9
  ReactEventHandler,
9
10
  ReactNode,
@@ -222,8 +223,145 @@ export interface EditableProps {
222
223
  children?: ReactNode;
223
224
  }
224
225
 
226
+ /**
227
+ * Wraps its children in a `div` bound to `dialog`. The element is rendered even when the
228
+ * children are empty (null, false, whitespace): it is the click target. A bound, empty
229
+ * Editable carries `uhuu-text-empty`, which gets a one-line box in the editor.
230
+ * Template CSS controls print layout. Only text/textarea/markdown dialogs get the marker.
231
+ * Pass `null`, not a renderer element around an empty string.
232
+ */
225
233
  export const Editable: ComponentType<EditableProps>;
226
234
 
235
+ /** What `getDialogProps` returns. Spread it onto the element that renders the field. */
236
+ export interface DialogBindingProps {
237
+ /** Marks the element for the editor: `""`, or the serialised dialog under legacy dynamic pagination. */
238
+ "data-uhuu"?: string;
239
+ /** `dialog.type`, so CSS can tell an empty text binding from an empty image. */
240
+ "data-uhuu-type"?: string;
241
+ /** Opens the dialog in the interactive editor. Never set in renderer mode (`window.$uhuu_renderer`). */
242
+ onClick?: MouseEventHandler<HTMLElement>;
243
+ }
244
+
245
+ /**
246
+ * The props `Editable` and `ImageBlock` attach, for a template that binds its own element:
247
+ * `<p {...getDialogProps({ dialog: { path, type: "textarea", value } })}>`. Renderer mode gets
248
+ * the markers without a click handler. No dialog returns `{}`. Never returns `className`.
249
+ */
250
+ export function getDialogProps(props: { dialog?: object | null } | null | undefined): DialogBindingProps;
251
+
252
+ // --- Image URLs (src/uhuu/image/image-url.js). See docs/image-url.md. ---
253
+
254
+ /** An image as payloads store it: an ImageObject, the dialogs' legacy `{ url }`, a URL, or nothing. */
255
+ export type ImageSource =
256
+ | string
257
+ | {
258
+ contentUrl?: string;
259
+ url?: string;
260
+ src?: string;
261
+ encodingFormat?: string;
262
+ mimeType?: string;
263
+ [key: string]: unknown;
264
+ }
265
+ | null
266
+ | undefined;
267
+
268
+ export interface ImageUrlOptions {
269
+ /** Print-product sizing. Default: the host's `$uhuu.is.printProduct()` (false without a host). */
270
+ print?: boolean;
271
+ /** Screen size as `WxH`. Default `2000x2000`. */
272
+ size?: string;
273
+ /** Print size as `WxH`. Default `4000x4000`. */
274
+ printSize?: string;
275
+ /** Thumbnail output format, e.g. `image/jpeg`. Default: the source's own (keeps transparency). */
276
+ format?: string;
277
+ }
278
+
279
+ /**
280
+ * The thumbnailer URL to render an image at: print-aware size, encoded source URL, SVG/`data:`/
281
+ * relative sources passed through, already-thumbnailed URLs rebuilt rather than nested.
282
+ * No image returns `undefined`, which renders no `src` attribute.
283
+ */
284
+ export function imageUrl(src: ImageSource, options?: ImageUrlOptions): string | undefined;
285
+
286
+ // --- Brand-kit runtime (src/uhuu/brand-kit/). See docs/brand-kit-runtime.md. ---
287
+
288
+ export interface BrandKitFontFile {
289
+ src: string;
290
+ weight?: number | string;
291
+ style?: "normal" | "italic";
292
+ format?: string;
293
+ }
294
+
295
+ export interface BrandKitFont {
296
+ id?: string;
297
+ family?: string;
298
+ /** Role-keyed fonts (`fonts.body`, `fonts.heading`): the stack after `family`. */
299
+ fallback?: string;
300
+ source?: string;
301
+ provider?: string;
302
+ cssUrl?: string;
303
+ weights?: number[];
304
+ styles?: Array<"normal" | "italic">;
305
+ files?: BrandKitFontFile[];
306
+ faces?: Array<{
307
+ weight?: number;
308
+ style?: "normal" | "italic";
309
+ cssUrl?: string;
310
+ files?: BrandKitFontFile[] | Record<string, string>;
311
+ [key: string]: unknown;
312
+ }>;
313
+ [key: string]: unknown;
314
+ }
315
+
316
+ /** A brandkit.json document. Only the parts the runtime reads are typed. */
317
+ export interface BrandKitJson {
318
+ version?: string | number;
319
+ id?: string;
320
+ name?: string;
321
+ baseUrl?: string;
322
+ assignments?: Record<string, string>;
323
+ fonts?: Record<string, BrandKitFont> | BrandKitFont[];
324
+ tokens?: {
325
+ light?: {
326
+ semantic?: Record<string, string | undefined>;
327
+ aliases?: Record<string, string | Record<string, string | undefined> | undefined>;
328
+ };
329
+ primitives?: { typography?: Record<string, unknown>; [key: string]: unknown };
330
+ [token: string]: unknown;
331
+ };
332
+ [key: string]: unknown;
333
+ }
334
+
335
+ /** What `useBrandKit()` returns. */
336
+ export interface BrandKitRuntime {
337
+ /** The raw kit: logos and collections are read from it. */
338
+ brandKit: BrandKitJson | null;
339
+ /** `--color-kit-*`, `--font-*` and `--font-kit-*`, as the provider's scope element carries them. */
340
+ cssVars: Record<string, string>;
341
+ }
342
+
343
+ export interface BrandKitProviderProps {
344
+ brandKit?: BrandKitJson | null;
345
+ /** Custom properties for whatever the kit leaves out; the kit wins. Pass a stable object. */
346
+ defaults?: Record<string, string>;
347
+ /** Where a fetched kit came from; its directory resolves relative font URLs when the kit has no `baseUrl`. */
348
+ sourceUrl?: string;
349
+ /** For the scope element. `style` is applied last, so `{ display: "block" }` gives it a box. */
350
+ className?: string;
351
+ style?: CSSProperties;
352
+ children?: ReactNode;
353
+ }
354
+
355
+ /**
356
+ * 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.
359
+ */
360
+ export const BrandKitProvider: ComponentType<BrandKitProviderProps>;
361
+
362
+ /** The nearest `BrandKitProvider`'s runtime, or `null` outside one. */
363
+ export function useBrandKit(): BrandKitRuntime | null;
364
+
227
365
  export interface InteractiveModeContextValue {
228
366
  interactive: boolean;
229
367
  setInteractive: (interactive: boolean) => void;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.97",
2
+ "version": "0.2.98",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",