@livo-tv/blocks 0.0.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/README.md +64 -0
- package/dist/avatar.cjs +88 -0
- package/dist/avatar.cjs.map +1 -0
- package/dist/avatar.d.cts +18 -0
- package/dist/avatar.d.ts +18 -0
- package/dist/avatar.js +84 -0
- package/dist/avatar.js.map +1 -0
- package/dist/index.cjs +3685 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +690 -0
- package/dist/index.d.ts +690 -0
- package/dist/index.js +3621 -0
- package/dist/index.js.map +1 -0
- package/package.json +146 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormEvent, KeyboardEvent, RefObject, CSSProperties, ReactNode, ComponentProps, ImgHTMLAttributes, SyntheticEvent } from 'react';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
import { HlsConfig, RetryConfig, LoaderResponse } from 'hls.js';
|
|
6
|
+
import { ClassValue } from 'clsx';
|
|
7
|
+
export { AvatarColors, avatarFallbackStyle, getAvatarColors, getInitials } from './avatar.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Blocks Context Interfaces
|
|
11
|
+
*
|
|
12
|
+
* These interfaces define the contract that consuming apps must implement
|
|
13
|
+
* to provide context to blocks components. Components will automatically
|
|
14
|
+
* consume these contexts when available, falling back to props otherwise.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Language definition for the language switcher.
|
|
18
|
+
*/
|
|
19
|
+
interface BlocksLanguage {
|
|
20
|
+
code: string;
|
|
21
|
+
name: string;
|
|
22
|
+
flag?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Language context value interface.
|
|
26
|
+
* Consuming apps implement this interface to provide language state
|
|
27
|
+
* and actions to blocks components.
|
|
28
|
+
*/
|
|
29
|
+
interface LanguageContextValue {
|
|
30
|
+
/** Current language code (e.g., "en", "es") */
|
|
31
|
+
language: string;
|
|
32
|
+
/** Function to change the language */
|
|
33
|
+
setLanguage: (lang: string) => void;
|
|
34
|
+
/** Available languages (optional, components have defaults) */
|
|
35
|
+
languages?: BlocksLanguage[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* React context for language.
|
|
39
|
+
* Blocks components will consume this context when available.
|
|
40
|
+
*/
|
|
41
|
+
declare const LanguageContext: React.Context<LanguageContextValue | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Hook to consume the language context.
|
|
44
|
+
* Returns null if no provider is present (components should fall back to props).
|
|
45
|
+
*/
|
|
46
|
+
declare function useLanguageContext(): LanguageContextValue | null;
|
|
47
|
+
|
|
48
|
+
declare function LoadingState({ label, className, }: {
|
|
49
|
+
label?: string;
|
|
50
|
+
className?: string;
|
|
51
|
+
}): React.JSX.Element;
|
|
52
|
+
declare function ErrorState({ title, description, action, className, }: {
|
|
53
|
+
title?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
action?: React.ReactNode;
|
|
56
|
+
className?: string;
|
|
57
|
+
}): React.JSX.Element;
|
|
58
|
+
/** Accept any icon component with a className prop — avoids LucideIcon
|
|
59
|
+
* version skew between blocks peers and consuming apps. */
|
|
60
|
+
type EmptyStateIcon = React.ComponentType<{
|
|
61
|
+
className?: string;
|
|
62
|
+
"aria-hidden"?: boolean | "true" | "false";
|
|
63
|
+
}>;
|
|
64
|
+
type EmptyStateProps = {
|
|
65
|
+
title: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
action?: React.ReactNode;
|
|
68
|
+
icon?: EmptyStateIcon;
|
|
69
|
+
variant?: "default" | "compact";
|
|
70
|
+
className?: string;
|
|
71
|
+
};
|
|
72
|
+
declare function EmptyState({ title, description, action, icon: Icon, variant, className, }: EmptyStateProps): React.JSX.Element;
|
|
73
|
+
|
|
74
|
+
declare function Empty({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
75
|
+
declare function EmptyHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
76
|
+
declare const emptyMediaVariants: (props?: ({
|
|
77
|
+
variant?: "default" | "icon" | null | undefined;
|
|
78
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
79
|
+
declare function EmptyMedia({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>): React.JSX.Element;
|
|
80
|
+
declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
81
|
+
declare function EmptyDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
82
|
+
declare function EmptyContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
83
|
+
|
|
84
|
+
type ConfirmDestructiveDialogProps = {
|
|
85
|
+
open: boolean;
|
|
86
|
+
onOpenChange: (open: boolean) => void;
|
|
87
|
+
title: string;
|
|
88
|
+
description: string;
|
|
89
|
+
confirmLabel?: string;
|
|
90
|
+
cancelLabel?: string;
|
|
91
|
+
onConfirm: () => void;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Shared confirm step for destructive actions (delete, mute, etc.).
|
|
95
|
+
* Prefer this over window.confirm so focus stays in the app and copy is clear.
|
|
96
|
+
*/
|
|
97
|
+
declare function ConfirmDestructiveDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, onConfirm, }: ConfirmDestructiveDialogProps): React.JSX.Element;
|
|
98
|
+
|
|
99
|
+
type EditableSectionMode = "reading" | "editing" | "saving";
|
|
100
|
+
type EditableSectionLabels = {
|
|
101
|
+
/** Visible Edit button label. Default: "Edit" */
|
|
102
|
+
edit?: string;
|
|
103
|
+
/** Visible Save button label. Default: "Save" */
|
|
104
|
+
save?: string;
|
|
105
|
+
/** Visible Save button label while pending. Default: "Saving…" */
|
|
106
|
+
saving?: string;
|
|
107
|
+
/** Visible Cancel button label. Default: "Cancel" */
|
|
108
|
+
cancel?: string;
|
|
109
|
+
/** Polite live-region message after a successful save. Default: "Saved" */
|
|
110
|
+
saved?: string;
|
|
111
|
+
/** ConfirmDestructiveDialog title when discarding dirty edits. */
|
|
112
|
+
discardTitle?: string;
|
|
113
|
+
/** ConfirmDestructiveDialog description when discarding dirty edits. */
|
|
114
|
+
discardDescription?: string;
|
|
115
|
+
/** ConfirmDestructiveDialog confirm label. Default: "Discard" */
|
|
116
|
+
discardConfirm?: string;
|
|
117
|
+
/** ConfirmDestructiveDialog cancel label. Default: "Keep editing" */
|
|
118
|
+
discardCancel?: string;
|
|
119
|
+
};
|
|
120
|
+
declare const DEFAULT_EDITABLE_SECTION_LABELS: {
|
|
121
|
+
readonly edit: "Edit";
|
|
122
|
+
readonly save: "Save";
|
|
123
|
+
readonly saving: "Saving…";
|
|
124
|
+
readonly cancel: "Cancel";
|
|
125
|
+
readonly saved: "Saved";
|
|
126
|
+
readonly discardTitle: "Discard changes?";
|
|
127
|
+
readonly discardDescription: "If you leave now, unsaved changes will be lost.";
|
|
128
|
+
readonly discardConfirm: "Discard";
|
|
129
|
+
readonly discardCancel: "Keep editing";
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type UseEditableSectionOptions = {
|
|
133
|
+
onSave: () => Promise<void> | void;
|
|
134
|
+
/** Called when edit mode exits without saving (Cancel / Escape / discard confirm). */
|
|
135
|
+
onDiscard?: () => void;
|
|
136
|
+
/** Whether the in-progress edit has unsaved changes. Defaults to false. */
|
|
137
|
+
isDirty?: boolean;
|
|
138
|
+
/** Id of an existing heading that names this section (preferred). */
|
|
139
|
+
labelledBy?: string;
|
|
140
|
+
/** Fallback accessible name when there is no visible heading. */
|
|
141
|
+
title?: string;
|
|
142
|
+
labels?: EditableSectionLabels;
|
|
143
|
+
/**
|
|
144
|
+
* After the first edit entry, keep `min-height` at the tallest measured
|
|
145
|
+
* content height so later toggles do not shift. First toggle may still shift.
|
|
146
|
+
*/
|
|
147
|
+
stableHeight?: boolean;
|
|
148
|
+
};
|
|
149
|
+
type UseEditableSectionResult = {
|
|
150
|
+
mode: EditableSectionMode;
|
|
151
|
+
isEditing: boolean;
|
|
152
|
+
isSaving: boolean;
|
|
153
|
+
startEdit: () => void;
|
|
154
|
+
requestCancel: () => void;
|
|
155
|
+
formProps: {
|
|
156
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
157
|
+
onKeyDown: (event: KeyboardEvent<HTMLFormElement>) => void;
|
|
158
|
+
noValidate: true;
|
|
159
|
+
};
|
|
160
|
+
contentRef: RefObject<HTMLElement | null>;
|
|
161
|
+
editButtonRef: RefObject<HTMLButtonElement | null>;
|
|
162
|
+
/** Form id for associating external submit buttons via the HTML `form` attribute. */
|
|
163
|
+
contentFormId: string;
|
|
164
|
+
editButtonProps: {
|
|
165
|
+
type: "button";
|
|
166
|
+
id: string;
|
|
167
|
+
onClick: () => void;
|
|
168
|
+
ref: RefObject<HTMLButtonElement | null>;
|
|
169
|
+
"aria-labelledby"?: string;
|
|
170
|
+
"aria-label"?: string;
|
|
171
|
+
};
|
|
172
|
+
saveButtonProps: {
|
|
173
|
+
type: "submit";
|
|
174
|
+
disabled: boolean;
|
|
175
|
+
};
|
|
176
|
+
cancelButtonProps: {
|
|
177
|
+
type: "button";
|
|
178
|
+
onClick: () => void;
|
|
179
|
+
disabled: boolean;
|
|
180
|
+
};
|
|
181
|
+
status: string | null;
|
|
182
|
+
statusProps: {
|
|
183
|
+
role: "status";
|
|
184
|
+
"aria-live": "polite";
|
|
185
|
+
className: string;
|
|
186
|
+
};
|
|
187
|
+
confirmDiscard: {
|
|
188
|
+
open: boolean;
|
|
189
|
+
onOpenChange: (open: boolean) => void;
|
|
190
|
+
title: string;
|
|
191
|
+
description: string;
|
|
192
|
+
confirmLabel: string;
|
|
193
|
+
cancelLabel: string;
|
|
194
|
+
onConfirm: () => void;
|
|
195
|
+
};
|
|
196
|
+
resolvedLabels: Required<EditableSectionLabels>;
|
|
197
|
+
contentStyle: CSSProperties | undefined;
|
|
198
|
+
actionsClassName: string;
|
|
199
|
+
};
|
|
200
|
+
declare function useEditableSection({ onSave, onDiscard, isDirty, labelledBy, title, labels, stableHeight, }: UseEditableSectionOptions): UseEditableSectionResult;
|
|
201
|
+
|
|
202
|
+
type EditableSectionSlots = {
|
|
203
|
+
actions: ReactNode;
|
|
204
|
+
content: ReactNode;
|
|
205
|
+
status: ReactNode;
|
|
206
|
+
mode: UseEditableSectionResult["mode"];
|
|
207
|
+
isSaving: boolean;
|
|
208
|
+
isEditing: boolean;
|
|
209
|
+
};
|
|
210
|
+
type EditableSectionProps = UseEditableSectionOptions & {
|
|
211
|
+
readView: () => ReactNode;
|
|
212
|
+
editView: () => ReactNode;
|
|
213
|
+
className?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Compose chrome yourself (Card, dialog, page header, …). Receives the
|
|
216
|
+
* stable actions node, the read/edit content, and the live status region.
|
|
217
|
+
* When omitted, actions render above content with no surrounding chrome.
|
|
218
|
+
*/
|
|
219
|
+
children?: (slots: EditableSectionSlots) => ReactNode;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Chrome-free read-first section: semantic text by default, real `<form>` on
|
|
223
|
+
* Edit, pending Save until `onSave` resolves, and ConfirmDestructiveDialog
|
|
224
|
+
* when Cancel/Escape would discard dirty edits.
|
|
225
|
+
*
|
|
226
|
+
* Does not render a Card — place `actions` wherever your layout needs them.
|
|
227
|
+
*/
|
|
228
|
+
declare function EditableSection({ readView, editView, children, className, ...options }: EditableSectionProps): React.JSX.Element;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Read-mode description list. Column grid and label placement match the
|
|
232
|
+
* typical edit-form field stack (`flex flex-col gap-1.5` + `text-sm` label)
|
|
233
|
+
* so labels and values keep the same x-position across modes.
|
|
234
|
+
*/
|
|
235
|
+
type DataListProps = ComponentProps<"dl">;
|
|
236
|
+
declare function DataList({ className, ...props }: DataListProps): React.JSX.Element;
|
|
237
|
+
type DataListItemProps = {
|
|
238
|
+
label: ReactNode;
|
|
239
|
+
children?: ReactNode;
|
|
240
|
+
/** Shown when `children` is nullish or an empty string. Default: "—" */
|
|
241
|
+
empty?: ReactNode;
|
|
242
|
+
className?: string;
|
|
243
|
+
labelClassName?: string;
|
|
244
|
+
valueClassName?: string;
|
|
245
|
+
};
|
|
246
|
+
declare function DataListItem({ label, children, empty, className, labelClassName, valueClassName, }: DataListItemProps): React.JSX.Element;
|
|
247
|
+
|
|
248
|
+
type FieldMessageProps = Omit<ComponentProps<"p">, "children"> & {
|
|
249
|
+
children?: ReactNode;
|
|
250
|
+
/**
|
|
251
|
+
* Id referenced by the field's `aria-describedby`. Required when the
|
|
252
|
+
* message is shown so assistive tech can associate it with the control.
|
|
253
|
+
*/
|
|
254
|
+
id?: string;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Reserved slot for field-level validation copy. Always occupies `min-h-5`
|
|
258
|
+
* so async errors do not shift fields under the pointer (CLS outside the
|
|
259
|
+
* 500ms input exclusion window).
|
|
260
|
+
*/
|
|
261
|
+
declare function FieldMessage({ id, children, className, ...props }: FieldMessageProps): React.JSX.Element;
|
|
262
|
+
|
|
263
|
+
type SafeImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "onError"> & {
|
|
264
|
+
src?: string | null;
|
|
265
|
+
/** Rendered when `src` is missing/empty or the image fails to load. */
|
|
266
|
+
fallback: ReactNode;
|
|
267
|
+
onError?: (event: SyntheticEvent<HTMLImageElement>) => void;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* `<img>` that swaps to `fallback` when the source is missing or fails to load,
|
|
271
|
+
* so the browser never shows its default broken-image glyph.
|
|
272
|
+
*/
|
|
273
|
+
declare function SafeImage({ src, fallback, alt, onError, ...imgProps }: SafeImageProps): React.JSX.Element;
|
|
274
|
+
|
|
275
|
+
type ThemeSwitcherLabels = {
|
|
276
|
+
/** Tooltip label for the theme switcher */
|
|
277
|
+
theme?: string;
|
|
278
|
+
/** Label for "System" option */
|
|
279
|
+
system?: string;
|
|
280
|
+
/** Label for "Light" option */
|
|
281
|
+
light?: string;
|
|
282
|
+
/** Label for "Dark" option */
|
|
283
|
+
dark?: string;
|
|
284
|
+
};
|
|
285
|
+
type ThemeSwitcherProps = {
|
|
286
|
+
className?: string;
|
|
287
|
+
/** Size of the switcher */
|
|
288
|
+
size?: "sm" | "md" | "lg";
|
|
289
|
+
/** Shape of the button */
|
|
290
|
+
shape?: "rounded" | "pill";
|
|
291
|
+
/** Mini variant shows only current theme icon as dropdown */
|
|
292
|
+
variant?: "default" | "mini";
|
|
293
|
+
/** Dropdown alignment (for mini variant) */
|
|
294
|
+
align?: "start" | "center" | "end";
|
|
295
|
+
/** Dropdown side (for mini variant) */
|
|
296
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
297
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
298
|
+
tooltipSide?: "top" | "right" | "bottom" | "left";
|
|
299
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
300
|
+
tooltipAlign?: "start" | "center" | "end";
|
|
301
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
302
|
+
tooltipSideOffset?: number;
|
|
303
|
+
/** Translation labels - consumers can pass their own t() values */
|
|
304
|
+
labels?: ThemeSwitcherLabels;
|
|
305
|
+
};
|
|
306
|
+
declare function ThemeSwitcher({ className, size, shape, variant, align, side, labels: userLabels, }: ThemeSwitcherProps): React.JSX.Element;
|
|
307
|
+
|
|
308
|
+
type Language = {
|
|
309
|
+
/** Language key/code (e.g., "en", "es") */
|
|
310
|
+
key: string;
|
|
311
|
+
/** Short label for segmented control (e.g., "EN", "ES") */
|
|
312
|
+
label: string;
|
|
313
|
+
/** Full native name for dropdown (e.g., "English", "Español") */
|
|
314
|
+
nativeName: string;
|
|
315
|
+
};
|
|
316
|
+
type LanguageSwitcherLabels = {
|
|
317
|
+
/** Tooltip label for the language switcher */
|
|
318
|
+
language?: string;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Default languages when none are provided via props or context.
|
|
322
|
+
*/
|
|
323
|
+
declare const defaultLanguages: Language[];
|
|
324
|
+
type LanguageSwitcherProps = {
|
|
325
|
+
/**
|
|
326
|
+
* Available languages. Optional if using LanguageContext.
|
|
327
|
+
* When context is available, context.languages is used; props override context.
|
|
328
|
+
* Falls back to defaultLanguages if neither provided.
|
|
329
|
+
*/
|
|
330
|
+
languages?: Language[];
|
|
331
|
+
/**
|
|
332
|
+
* Current selected language key. Optional if using LanguageContext.
|
|
333
|
+
* When context is available, context.language is used; props override context.
|
|
334
|
+
*/
|
|
335
|
+
currentLanguage?: string;
|
|
336
|
+
/**
|
|
337
|
+
* Callback when language changes. Optional if using LanguageContext.
|
|
338
|
+
* When context is available, context.setLanguage is used; props override context.
|
|
339
|
+
*/
|
|
340
|
+
onLanguageChange?: (languageKey: string) => void;
|
|
341
|
+
/** Labels for accessibility/tooltips */
|
|
342
|
+
labels?: LanguageSwitcherLabels;
|
|
343
|
+
className?: string;
|
|
344
|
+
/** Size of the switcher */
|
|
345
|
+
size?: "sm" | "md" | "lg";
|
|
346
|
+
/** Shape of the button */
|
|
347
|
+
shape?: "rounded" | "squared" | "pill";
|
|
348
|
+
/** Mini variant shows only an icon */
|
|
349
|
+
variant?: "default" | "mini";
|
|
350
|
+
/** Show language icon in default variant */
|
|
351
|
+
showIcon?: boolean;
|
|
352
|
+
/** Dropdown alignment */
|
|
353
|
+
align?: "start" | "center" | "end";
|
|
354
|
+
/** Dropdown side */
|
|
355
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
356
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
357
|
+
tooltipSide?: "top" | "right" | "bottom" | "left";
|
|
358
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
359
|
+
tooltipAlign?: "start" | "center" | "end";
|
|
360
|
+
/** @deprecated No longer used; mini variant no longer renders a tooltip. */
|
|
361
|
+
tooltipSideOffset?: number;
|
|
362
|
+
};
|
|
363
|
+
declare function LanguageSwitcher({ languages: propLanguages, currentLanguage: propCurrentLanguage, onLanguageChange: propOnLanguageChange, labels, className, size, shape, variant, showIcon, align, side, }: LanguageSwitcherProps): React.JSX.Element;
|
|
364
|
+
|
|
365
|
+
type AvatarEditorLabels = {
|
|
366
|
+
uploadAria?: string;
|
|
367
|
+
uploadHint?: string;
|
|
368
|
+
uploadFormats?: string;
|
|
369
|
+
dragging?: string;
|
|
370
|
+
zoomOut?: string;
|
|
371
|
+
zoomIn?: string;
|
|
372
|
+
zoomLevel?: string;
|
|
373
|
+
rotateLeft?: string;
|
|
374
|
+
rotateRight?: string;
|
|
375
|
+
toggleGrid?: string;
|
|
376
|
+
reset?: string;
|
|
377
|
+
replace?: string;
|
|
378
|
+
discard?: string;
|
|
379
|
+
};
|
|
380
|
+
interface AvatarEditorProps {
|
|
381
|
+
/** Current cropped image as data URL (controlled) */
|
|
382
|
+
value?: string | null;
|
|
383
|
+
/** Callback when the cropped image changes */
|
|
384
|
+
onChange?: (dataUrl: string | null) => void;
|
|
385
|
+
/** Size of the editor container in pixels */
|
|
386
|
+
size?: number;
|
|
387
|
+
/** Whether to show grid overlay by default */
|
|
388
|
+
showGrid?: boolean;
|
|
389
|
+
/** Square output image size in pixels (width === height) */
|
|
390
|
+
outputSize?: number;
|
|
391
|
+
/** Output format */
|
|
392
|
+
outputFormat?: "png" | "jpeg" | "webp";
|
|
393
|
+
/** Output quality for jpeg/webp (0-1) */
|
|
394
|
+
outputQuality?: number;
|
|
395
|
+
/** Additional class names */
|
|
396
|
+
className?: string;
|
|
397
|
+
/** Control size variant - 'default' for desktop, 'large' for mobile/touch devices */
|
|
398
|
+
controlSize?: "default" | "large";
|
|
399
|
+
/** Override English chrome strings */
|
|
400
|
+
labels?: AvatarEditorLabels;
|
|
401
|
+
}
|
|
402
|
+
declare function AvatarEditor({ value: _value, onChange, size, showGrid: initialShowGrid, outputSize, outputFormat, outputQuality, className, controlSize, labels, }: AvatarEditorProps): React.JSX.Element;
|
|
403
|
+
|
|
404
|
+
interface AvatarEditorDialogProps {
|
|
405
|
+
/** Current avatar URL or data URL */
|
|
406
|
+
value?: string | null;
|
|
407
|
+
/** Callback when avatar changes (after accepting) */
|
|
408
|
+
onChange?: (dataUrl: string | null) => void;
|
|
409
|
+
/** Async callback for saving/uploading - return true for success, false for failure */
|
|
410
|
+
onSave?: (dataUrl: string) => Promise<boolean> | boolean;
|
|
411
|
+
/** Size of the displayed avatar in pixels */
|
|
412
|
+
displaySize?: number;
|
|
413
|
+
/** Size of the editor in the dialog */
|
|
414
|
+
editorSize?: number;
|
|
415
|
+
/** Output image size */
|
|
416
|
+
outputSize?: number;
|
|
417
|
+
/** Placeholder text when no avatar */
|
|
418
|
+
placeholder?: string;
|
|
419
|
+
/** Edit button label for accessibility */
|
|
420
|
+
editLabel?: string;
|
|
421
|
+
/** Dialog title */
|
|
422
|
+
dialogTitle?: string;
|
|
423
|
+
/** Accept button text */
|
|
424
|
+
acceptText?: string;
|
|
425
|
+
/** Cancel button text */
|
|
426
|
+
cancelText?: string;
|
|
427
|
+
/** Saving button text while upload is in progress */
|
|
428
|
+
savingText?: string;
|
|
429
|
+
/** Saved button text after a successful save */
|
|
430
|
+
savedText?: string;
|
|
431
|
+
/** Success message */
|
|
432
|
+
successMessage?: string;
|
|
433
|
+
/** Error message */
|
|
434
|
+
errorMessage?: string;
|
|
435
|
+
/** Additional class names */
|
|
436
|
+
className?: string;
|
|
437
|
+
/** Override AvatarEditor chrome strings */
|
|
438
|
+
editorLabels?: AvatarEditorLabels;
|
|
439
|
+
}
|
|
440
|
+
declare function AvatarEditorDialog({ value, onChange, onSave, displaySize, editorSize, outputSize, placeholder, editLabel, dialogTitle, acceptText, cancelText, savingText, savedText, successMessage, errorMessage, className, editorLabels, }: AvatarEditorDialogProps): React.JSX.Element;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Playback error description, ported from the app's HLS player but stripped of
|
|
444
|
+
* Sentry. `@livo/blocks` must stay reporting-agnostic: the player surfaces
|
|
445
|
+
* a {@link DescribedPlaybackError} through an optional `onError` prop so each
|
|
446
|
+
* app can wire its own reporting (Sentry, Datadog, console, …).
|
|
447
|
+
*
|
|
448
|
+
* User-facing messages are intentionally NOT baked in here — they come from the
|
|
449
|
+
* player's `labels` prop so they stay translatable. This module only classifies
|
|
450
|
+
* the error and produces a machine-readable summary + detail for logging.
|
|
451
|
+
*/
|
|
452
|
+
type HlsPlayerMode = "live" | "vod";
|
|
453
|
+
/** Coarse category the player uses to pick the right localized message. */
|
|
454
|
+
type PlaybackErrorKind = "unavailable" | "network" | "media" | "unsupported" | "resync" | "generic";
|
|
455
|
+
type PlaybackErrorContext = {
|
|
456
|
+
mode: HlsPlayerMode;
|
|
457
|
+
src: string;
|
|
458
|
+
manifestParsed: boolean;
|
|
459
|
+
retryCount?: number;
|
|
460
|
+
source: "hls" | "native" | "unsupported";
|
|
461
|
+
};
|
|
462
|
+
type PlaybackErrorDetail = {
|
|
463
|
+
source: PlaybackErrorContext["source"];
|
|
464
|
+
kind: PlaybackErrorKind;
|
|
465
|
+
type?: string;
|
|
466
|
+
details?: string;
|
|
467
|
+
fatal?: boolean;
|
|
468
|
+
httpStatus?: number;
|
|
469
|
+
url?: string;
|
|
470
|
+
reason?: string;
|
|
471
|
+
errorMessage?: string;
|
|
472
|
+
mediaErrorCode?: number;
|
|
473
|
+
mediaErrorName?: string;
|
|
474
|
+
context: PlaybackErrorContext;
|
|
475
|
+
};
|
|
476
|
+
type DescribePlaybackErrorInput = {
|
|
477
|
+
source: "hls";
|
|
478
|
+
type?: string;
|
|
479
|
+
details?: string;
|
|
480
|
+
fatal: boolean;
|
|
481
|
+
url?: string;
|
|
482
|
+
response?: {
|
|
483
|
+
code?: number;
|
|
484
|
+
text?: string;
|
|
485
|
+
};
|
|
486
|
+
reason?: string;
|
|
487
|
+
error?: unknown;
|
|
488
|
+
context: PlaybackErrorContext;
|
|
489
|
+
} | {
|
|
490
|
+
source: "native";
|
|
491
|
+
mediaError?: MediaError | null;
|
|
492
|
+
context: PlaybackErrorContext;
|
|
493
|
+
} | {
|
|
494
|
+
source: "unsupported";
|
|
495
|
+
context: PlaybackErrorContext;
|
|
496
|
+
};
|
|
497
|
+
type DescribedPlaybackError = {
|
|
498
|
+
/** Machine-readable one-line summary for logs. */
|
|
499
|
+
summary: string;
|
|
500
|
+
/** Coarse category for choosing a localized message. */
|
|
501
|
+
kind: PlaybackErrorKind;
|
|
502
|
+
detail: PlaybackErrorDetail;
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Soft (non-fatal) report for an automatic A/V resync. Apps should treat this
|
|
506
|
+
* like other non-fatal playback events (breadcrumb / warn), never as a hard
|
|
507
|
+
* error UI — the player recovers in place.
|
|
508
|
+
*/
|
|
509
|
+
declare function describeAvResync(input: {
|
|
510
|
+
lagSeconds: number;
|
|
511
|
+
context: PlaybackErrorContext;
|
|
512
|
+
}): DescribedPlaybackError;
|
|
513
|
+
declare function describePlaybackError(input: DescribePlaybackErrorInput): DescribedPlaybackError;
|
|
514
|
+
|
|
515
|
+
interface PlaybackStats {
|
|
516
|
+
/** Concurrent live viewers (meaningful in live mode). */
|
|
517
|
+
viewers?: number;
|
|
518
|
+
/** Cumulative VOD reproductions. */
|
|
519
|
+
views?: number;
|
|
520
|
+
}
|
|
521
|
+
interface UsePlaybackStatsOptions {
|
|
522
|
+
/** Poll interval in ms. Default 15000. */
|
|
523
|
+
intervalMs?: number;
|
|
524
|
+
/** When false, polling is paused. Default true. */
|
|
525
|
+
enabled?: boolean;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Polls a playback-stats endpoint (media-svc `GET /playback/:mediaId/stats`)
|
|
529
|
+
* and returns `{ viewers, views }`. Plain `fetch`, zero dependencies, so wiring
|
|
530
|
+
* it into an app is a one-liner. Fails silently (stats are non-critical); the
|
|
531
|
+
* last successful value is retained across transient errors.
|
|
532
|
+
*/
|
|
533
|
+
declare function usePlaybackStats(statsUrl: string | null | undefined, { intervalMs, enabled }?: UsePlaybackStatsOptions): PlaybackStats;
|
|
534
|
+
|
|
535
|
+
interface VideoPlayerLabels {
|
|
536
|
+
play?: string;
|
|
537
|
+
pause?: string;
|
|
538
|
+
mute?: string;
|
|
539
|
+
unmute?: string;
|
|
540
|
+
enterFullscreen?: string;
|
|
541
|
+
exitFullscreen?: string;
|
|
542
|
+
pictureInPicture?: string;
|
|
543
|
+
settings?: string;
|
|
544
|
+
quality?: string;
|
|
545
|
+
auto?: string;
|
|
546
|
+
speed?: string;
|
|
547
|
+
live?: string;
|
|
548
|
+
goLive?: string;
|
|
549
|
+
tapToUnmute?: string;
|
|
550
|
+
loading?: string;
|
|
551
|
+
waiting?: string;
|
|
552
|
+
retry?: string;
|
|
553
|
+
/** Messages by error kind; a generic fallback covers the rest. */
|
|
554
|
+
errorUnavailable?: string;
|
|
555
|
+
errorNetwork?: string;
|
|
556
|
+
errorMedia?: string;
|
|
557
|
+
errorUnsupported?: string;
|
|
558
|
+
errorGeneric?: string;
|
|
559
|
+
/** `(n) => "N watching"`. */
|
|
560
|
+
formatViewers?: (n: number) => string;
|
|
561
|
+
/** `(n) => "N views"`. */
|
|
562
|
+
formatViews?: (n: number) => string;
|
|
563
|
+
}
|
|
564
|
+
interface VideoPlayerProps {
|
|
565
|
+
src: string;
|
|
566
|
+
mode: "live" | "vod";
|
|
567
|
+
/** Cover image; renders a click-to-play state before attaching HLS. */
|
|
568
|
+
poster?: string;
|
|
569
|
+
autoPlay?: boolean;
|
|
570
|
+
muted?: boolean;
|
|
571
|
+
/** Presentational stats (see `usePlaybackStats`). */
|
|
572
|
+
stats?: PlaybackStats;
|
|
573
|
+
labels?: VideoPlayerLabels;
|
|
574
|
+
/** Show the resolution picker when multiple levels exist. Default true. */
|
|
575
|
+
showQualitySelector?: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* When true, force-pauses the media element. Clearing it does not
|
|
578
|
+
* auto-resume — the user must press play again.
|
|
579
|
+
*/
|
|
580
|
+
paused?: boolean;
|
|
581
|
+
onPlayingChange?: (playing: boolean) => void;
|
|
582
|
+
/** Fires once, the first time playback actually starts — wire your view
|
|
583
|
+
* beacon here. */
|
|
584
|
+
onFirstPlay?: () => void;
|
|
585
|
+
onError?: (error: DescribedPlaybackError) => void;
|
|
586
|
+
/**
|
|
587
|
+
* Default `aspect-video` for feed cards. Use `contain` in fullscreen
|
|
588
|
+
* viewers so portrait sources fill the pane with object-fit and controls
|
|
589
|
+
* stay at the bottom of the pane.
|
|
590
|
+
*/
|
|
591
|
+
fit?: "aspect-video" | "contain";
|
|
592
|
+
className?: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Standardized HLS video player with a fully custom control bar (no native
|
|
596
|
+
* `controls`): click-to-play poster, play/pause, mute + volume, resolution
|
|
597
|
+
* picker, playback speed (VOD), Picture-in-Picture, fullscreen, a VOD seekbar
|
|
598
|
+
* with buffered ranges, and a live badge (no seekbar) with a "go live"
|
|
599
|
+
* affordance. `stats` renders live viewer / VOD reproduction counts.
|
|
600
|
+
*
|
|
601
|
+
* hls.js is a peer dependency loaded on demand; see {@link useHlsPlayback}.
|
|
602
|
+
*/
|
|
603
|
+
declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, fit, className, }: VideoPlayerProps): React.JSX.Element;
|
|
604
|
+
|
|
605
|
+
interface FeedVideoPlayerProps extends VideoPlayerProps {
|
|
606
|
+
/** Stable id for exclusive playback (typically the feed post id). */
|
|
607
|
+
playbackId: string;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Feed-scoped {@link VideoPlayer}: only one feed video plays at a time, and
|
|
611
|
+
* playback autopauses when the card leaves the viewport or the tab is hidden.
|
|
612
|
+
*/
|
|
613
|
+
declare function FeedVideoPlayer({ playbackId, onPlayingChange, paused: pausedProp, fit, className, ...playerProps }: FeedVideoPlayerProps): React.JSX.Element;
|
|
614
|
+
|
|
615
|
+
interface UseFeedExclusivePlaybackResult {
|
|
616
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
617
|
+
paused: boolean;
|
|
618
|
+
onPlayingChange: (playing: boolean) => void;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Coordinates exclusive feed playback: claims the global slot on play,
|
|
622
|
+
* force-pauses when another feed video plays, when the player leaves the
|
|
623
|
+
* viewport, or when the tab is hidden. Picture-in-Picture is exempt from
|
|
624
|
+
* scroll/visibility autopause.
|
|
625
|
+
*/
|
|
626
|
+
declare function useFeedExclusivePlayback(playbackId: string): UseFeedExclusivePlaybackResult;
|
|
627
|
+
|
|
628
|
+
type PlaybackState = "idle" | "loading" | "ready" | "waiting" | "error";
|
|
629
|
+
/** Autoplay overlay state once the manifest is parsed. */
|
|
630
|
+
type AutoplayState = "none" | "playing" | "muted" | "blocked";
|
|
631
|
+
interface QualityLevel {
|
|
632
|
+
/** hls.js level index. */
|
|
633
|
+
index: number;
|
|
634
|
+
/** Vertical resolution, e.g. 720. */
|
|
635
|
+
height: number;
|
|
636
|
+
}
|
|
637
|
+
interface UseHlsPlaybackOptions {
|
|
638
|
+
src: string;
|
|
639
|
+
mode: HlsPlayerMode;
|
|
640
|
+
/** When false, nothing is attached/loaded (poster gating). */
|
|
641
|
+
active: boolean;
|
|
642
|
+
/** Attempt autoplay once the manifest is ready. Live always autoplays. */
|
|
643
|
+
autoPlay?: boolean;
|
|
644
|
+
/** Start muted (independent of the autoplay cascade). */
|
|
645
|
+
muted?: boolean;
|
|
646
|
+
onError?: (error: DescribedPlaybackError) => void;
|
|
647
|
+
onPlayingChange?: (playing: boolean) => void;
|
|
648
|
+
}
|
|
649
|
+
interface UseHlsPlaybackResult {
|
|
650
|
+
videoRef: React.RefObject<HTMLVideoElement | null>;
|
|
651
|
+
state: PlaybackState;
|
|
652
|
+
/** Available quality levels (empty for native HLS / single-level). */
|
|
653
|
+
qualities: QualityLevel[];
|
|
654
|
+
/** Selected level index, or -1 for automatic. */
|
|
655
|
+
activeLevel: number;
|
|
656
|
+
setLevel: (index: number) => void;
|
|
657
|
+
autoplayState: AutoplayState;
|
|
658
|
+
/** The classified error, when `state === "error"`. */
|
|
659
|
+
error: DescribedPlaybackError | null;
|
|
660
|
+
retry: () => void;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Attaches hls.js (loaded on demand via dynamic import) or native HLS to a
|
|
664
|
+
* `<video>` element and exposes the state a custom control bar needs. Ported
|
|
665
|
+
* from the app's production `HlsPlayer` effect, minus the built-in UI and
|
|
666
|
+
* Sentry: errors are classified and handed to `onError`.
|
|
667
|
+
*/
|
|
668
|
+
declare function useHlsPlayback({ src, mode, active, autoPlay, muted, onError, onPlayingChange, }: UseHlsPlaybackOptions): UseHlsPlaybackResult;
|
|
669
|
+
|
|
670
|
+
/** Retry transient live-edge 404s; hls.js skips all 4xx by default. */
|
|
671
|
+
declare function shouldRetryLiveEdge404(retryConfig: RetryConfig | null | undefined, retryCount: number, _isTimeout: boolean, loaderResponse: LoaderResponse | undefined, defaultRetry: boolean): boolean;
|
|
672
|
+
/**
|
|
673
|
+
* HLS.js options tuned for live playback through a Cloudflare R2 custom domain.
|
|
674
|
+
* Ported from the app's production player: stays 4 segments (~8s) behind the
|
|
675
|
+
* live edge so transient upload lag never reaches the playhead, and retries the
|
|
676
|
+
* 404s that appear while a new segment is still being written.
|
|
677
|
+
*/
|
|
678
|
+
declare function createLiveHlsConfig(): Partial<HlsConfig>;
|
|
679
|
+
/**
|
|
680
|
+
* HLS.js options for on-demand (VOD) playback. No live-edge cushion; enables
|
|
681
|
+
* the worker and lets hls.js manage the buffer with its defaults, which are
|
|
682
|
+
* well suited to seekable recordings.
|
|
683
|
+
*/
|
|
684
|
+
declare function createVodHlsConfig(): Partial<HlsConfig>;
|
|
685
|
+
|
|
686
|
+
declare function useMediaQuery(query: string): boolean;
|
|
687
|
+
|
|
688
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
689
|
+
|
|
690
|
+
export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
|