@livo-tv/blocks 1.18.0 → 1.19.0

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/dist/index.d.cts CHANGED
@@ -750,6 +750,8 @@ interface VideoPlayerLabels {
750
750
  settings?: string;
751
751
  /** Overflow menu for speed / quality / cast / PiP on a narrow player. */
752
752
  more?: string;
753
+ /** Back control on compact More speed / quality panes. */
754
+ back?: string;
753
755
  quality?: string;
754
756
  auto?: string;
755
757
  speed?: string;
package/dist/index.d.ts CHANGED
@@ -750,6 +750,8 @@ interface VideoPlayerLabels {
750
750
  settings?: string;
751
751
  /** Overflow menu for speed / quality / cast / PiP on a narrow player. */
752
752
  more?: string;
753
+ /** Back control on compact More speed / quality panes. */
754
+ back?: string;
753
755
  quality?: string;
754
756
  auto?: string;
755
757
  speed?: string;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React9 from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
4
- import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Captions, Settings, Cast, PictureInPicture2, EllipsisVertical, Minimize, Maximize, XIcon } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Captions, Settings, Cast, PictureInPicture2, Gauge, EllipsisVertical, Minimize, Maximize, ChevronRight, ChevronLeft, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
@@ -4267,6 +4267,7 @@ var DEFAULT_LABELS3 = {
4267
4267
  cast: "Cast",
4268
4268
  settings: "Settings",
4269
4269
  more: "More",
4270
+ back: "Back",
4270
4271
  quality: "Quality",
4271
4272
  auto: "Auto",
4272
4273
  speed: "Speed",
@@ -4395,6 +4396,9 @@ function VideoPlayer({
4395
4396
  const [controlsVisible, setControlsVisible] = React9.useState(true);
4396
4397
  const [playbackRate, setPlaybackRate] = React9.useState(1);
4397
4398
  const [openMenu, setOpenMenu] = React9.useState(null);
4399
+ const [morePane, setMorePane] = React9.useState(
4400
+ "root"
4401
+ );
4398
4402
  const [compactChrome, setCompactChrome] = React9.useState(false);
4399
4403
  const [captionLocale, setCaptionLocale] = React9.useState(defaultCaptionLocale ?? "off");
4400
4404
  const [captionCues, setCaptionCues] = React9.useState([]);
@@ -4422,6 +4426,9 @@ function VideoPlayer({
4422
4426
  observer.observe(el);
4423
4427
  return () => observer.disconnect();
4424
4428
  }, [active]);
4429
+ React9.useEffect(() => {
4430
+ if (openMenu !== "more") setMorePane("root");
4431
+ }, [openMenu]);
4425
4432
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
4426
4433
  const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported || !embedded;
4427
4434
  React9.useEffect(() => {
@@ -5070,55 +5077,87 @@ function VideoPlayer({
5070
5077
  className: cn("size-5", pipActive && "text-primary")
5071
5078
  }
5072
5079
  ) }),
5073
- compactChrome && /* @__PURE__ */ jsxs(
5080
+ compactChrome && /* @__PURE__ */ jsx(
5074
5081
  MenuControl,
5075
5082
  {
5076
5083
  label: t.more,
5077
5084
  open: openMenu === "more",
5078
5085
  onOpenChange: (o) => setOpenMenu(o ? "more" : null),
5079
5086
  trigger: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-5" }),
5080
- children: [
5081
- mode === "vod" && /* @__PURE__ */ jsxs(Fragment, { children: [
5082
- /* @__PURE__ */ jsx(MenuSection, { children: t.speed }),
5083
- PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
5084
- MenuItem,
5085
- {
5086
- selected: rate === playbackRate,
5087
- onSelect: () => changeRate(rate),
5088
- children: [
5089
- rate,
5090
- "\xD7"
5091
- ]
5092
- },
5093
- rate
5094
- ))
5095
- ] }),
5096
- showQuality && /* @__PURE__ */ jsxs(Fragment, { children: [
5097
- /* @__PURE__ */ jsx(MenuSection, { children: t.quality }),
5098
- /* @__PURE__ */ jsx(
5099
- MenuItem,
5100
- {
5101
- selected: activeLevel < 0,
5102
- onSelect: () => chooseLevel(-1),
5103
- children: t.auto
5104
- }
5105
- ),
5106
- qualities.map((q) => /* @__PURE__ */ jsxs(
5107
- MenuItem,
5108
- {
5109
- selected: activeLevel === q.index,
5110
- onSelect: () => chooseLevel(q.index),
5111
- children: [
5112
- q.height,
5113
- "p"
5114
- ]
5115
- },
5116
- q.index
5117
- ))
5118
- ] }),
5087
+ children: morePane === "speed" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5088
+ /* @__PURE__ */ jsx(
5089
+ MenuBack,
5090
+ {
5091
+ label: t.back,
5092
+ title: t.speed,
5093
+ onSelect: () => setMorePane("root")
5094
+ }
5095
+ ),
5096
+ PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
5097
+ MenuItem,
5098
+ {
5099
+ selected: rate === playbackRate,
5100
+ onSelect: () => changeRate(rate),
5101
+ children: [
5102
+ rate,
5103
+ "\xD7"
5104
+ ]
5105
+ },
5106
+ rate
5107
+ ))
5108
+ ] }) : morePane === "quality" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5109
+ /* @__PURE__ */ jsx(
5110
+ MenuBack,
5111
+ {
5112
+ label: t.back,
5113
+ title: t.quality,
5114
+ onSelect: () => setMorePane("root")
5115
+ }
5116
+ ),
5117
+ /* @__PURE__ */ jsx(
5118
+ MenuItem,
5119
+ {
5120
+ selected: activeLevel < 0,
5121
+ onSelect: () => chooseLevel(-1),
5122
+ children: t.auto
5123
+ }
5124
+ ),
5125
+ qualities.map((q) => /* @__PURE__ */ jsxs(
5126
+ MenuItem,
5127
+ {
5128
+ selected: activeLevel === q.index,
5129
+ onSelect: () => chooseLevel(q.index),
5130
+ children: [
5131
+ q.height,
5132
+ "p"
5133
+ ]
5134
+ },
5135
+ q.index
5136
+ ))
5137
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5138
+ mode === "vod" && /* @__PURE__ */ jsx(
5139
+ MenuNavRow,
5140
+ {
5141
+ icon: /* @__PURE__ */ jsx(Gauge, { className: "size-4" }),
5142
+ label: t.speed,
5143
+ value: `${playbackRate}\xD7`,
5144
+ onSelect: () => setMorePane("speed")
5145
+ }
5146
+ ),
5147
+ showQuality && /* @__PURE__ */ jsx(
5148
+ MenuNavRow,
5149
+ {
5150
+ icon: /* @__PURE__ */ jsx(Settings, { className: "size-4" }),
5151
+ label: t.quality,
5152
+ value: currentLevelLabel,
5153
+ onSelect: () => setMorePane("quality")
5154
+ }
5155
+ ),
5156
+ (mode === "vod" || showQuality) && /* @__PURE__ */ jsx("div", { className: "my-1 h-px bg-white/15" }),
5119
5157
  /* @__PURE__ */ jsx(
5120
5158
  MenuAction,
5121
5159
  {
5160
+ icon: /* @__PURE__ */ jsx(Cast, { className: "size-4" }),
5122
5161
  onSelect: () => {
5123
5162
  setOpenMenu(null);
5124
5163
  void castHlsUrl(src).catch(() => void 0);
@@ -5129,6 +5168,8 @@ function VideoPlayer({
5129
5168
  pipSupported && /* @__PURE__ */ jsx(
5130
5169
  MenuAction,
5131
5170
  {
5171
+ icon: /* @__PURE__ */ jsx(PictureInPicture2, { className: "size-4" }),
5172
+ active: pipActive,
5132
5173
  onSelect: () => {
5133
5174
  setOpenMenu(null);
5134
5175
  togglePip();
@@ -5136,7 +5177,7 @@ function VideoPlayer({
5136
5177
  children: t.pictureInPicture
5137
5178
  }
5138
5179
  )
5139
- ]
5180
+ ] })
5140
5181
  }
5141
5182
  ),
5142
5183
  fullscreenSupported && /* @__PURE__ */ jsx(
@@ -5202,15 +5243,12 @@ function MenuControl({
5202
5243
  "div",
5203
5244
  {
5204
5245
  role: "menu",
5205
- className: "absolute right-0 bottom-full z-10 mb-2 min-w-24 rounded-md bg-black/90 p-1 text-sm shadow-lg backdrop-blur-sm",
5246
+ className: "absolute right-0 bottom-full z-10 mb-2 min-w-52 rounded-md bg-black/90 p-1 text-sm shadow-lg backdrop-blur-sm",
5206
5247
  children
5207
5248
  }
5208
5249
  )
5209
5250
  ] });
5210
5251
  }
5211
- function MenuSection({ children }) {
5212
- return /* @__PURE__ */ jsx("div", { className: "px-2 pt-1.5 pb-0.5 text-[10px] font-semibold tracking-wide text-white/50 uppercase", children });
5213
- }
5214
5252
  function MenuItem({
5215
5253
  selected,
5216
5254
  onSelect,
@@ -5223,7 +5261,7 @@ function MenuItem({
5223
5261
  role: "menuitemradio",
5224
5262
  "aria-checked": selected,
5225
5263
  onClick: onSelect,
5226
- className: "flex w-full items-center justify-between gap-3 rounded px-2 py-1.5 text-left text-white/90 hover:bg-white/15",
5264
+ className: "flex w-full items-center justify-between gap-3 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
5227
5265
  children: [
5228
5266
  children,
5229
5267
  selected && /* @__PURE__ */ jsx(Check, { className: "size-4" })
@@ -5231,18 +5269,69 @@ function MenuItem({
5231
5269
  }
5232
5270
  );
5233
5271
  }
5272
+ function MenuNavRow({
5273
+ icon,
5274
+ label,
5275
+ value,
5276
+ onSelect
5277
+ }) {
5278
+ return /* @__PURE__ */ jsxs(
5279
+ "button",
5280
+ {
5281
+ type: "button",
5282
+ role: "menuitem",
5283
+ "aria-label": `${label}, ${value}`,
5284
+ onClick: onSelect,
5285
+ className: "flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
5286
+ children: [
5287
+ /* @__PURE__ */ jsx("span", { className: "text-white/70", children: icon }),
5288
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: label }),
5289
+ /* @__PURE__ */ jsx("span", { className: "text-white/50", children: value }),
5290
+ /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-white/50" })
5291
+ ]
5292
+ }
5293
+ );
5294
+ }
5295
+ function MenuBack({
5296
+ label,
5297
+ title,
5298
+ onSelect
5299
+ }) {
5300
+ return /* @__PURE__ */ jsxs(
5301
+ "button",
5302
+ {
5303
+ type: "button",
5304
+ role: "menuitem",
5305
+ "aria-label": label,
5306
+ onClick: onSelect,
5307
+ className: "flex w-full items-center gap-2 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
5308
+ children: [
5309
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" }),
5310
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: title })
5311
+ ]
5312
+ }
5313
+ );
5314
+ }
5234
5315
  function MenuAction({
5235
5316
  onSelect,
5317
+ icon,
5318
+ active,
5236
5319
  children
5237
5320
  }) {
5238
- return /* @__PURE__ */ jsx(
5321
+ return /* @__PURE__ */ jsxs(
5239
5322
  "button",
5240
5323
  {
5241
5324
  type: "button",
5242
5325
  role: "menuitem",
5243
5326
  onClick: onSelect,
5244
- className: "flex w-full items-center rounded px-2 py-1.5 text-left text-white/90 hover:bg-white/15",
5245
- children
5327
+ className: cn(
5328
+ "flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
5329
+ active && "text-primary"
5330
+ ),
5331
+ children: [
5332
+ icon ? /* @__PURE__ */ jsx("span", { className: cn("text-white/70", active && "text-primary"), children: icon }) : null,
5333
+ children
5334
+ ]
5246
5335
  }
5247
5336
  );
5248
5337
  }