@xhub-short/ui 0.1.0-beta.8 → 1.0.0-beta.18

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.
Files changed (75) hide show
  1. package/dist/CommentSheet.css-DuBy01rU.d.ts +219 -0
  2. package/dist/VideoSlotPlayIndicator-DPs8Xt5C.d.ts +51 -0
  3. package/dist/chunk-3OB3OVYR.js +349 -0
  4. package/dist/chunk-4RIMQOBR.js +58 -0
  5. package/dist/chunk-5MKYDI4X.js +1 -0
  6. package/dist/chunk-5Y43HNRG.js +296 -0
  7. package/dist/chunk-7WXAQHJI.js +350 -0
  8. package/dist/chunk-BADA7OLG.js +564 -0
  9. package/dist/chunk-BEJAJFV6.js +191 -0
  10. package/dist/chunk-BNI7CYRI.js +334 -0
  11. package/dist/{chunk-UPCVSGWH.js → chunk-CAWE42LH.js} +5 -2
  12. package/dist/chunk-DGKMO3AE.js +717 -0
  13. package/dist/chunk-DR7KR7OT.js +103 -0
  14. package/dist/chunk-GSNIZ6DF.js +605 -0
  15. package/dist/chunk-HXQPEZRG.js +105 -0
  16. package/dist/chunk-IC2KUU4V.js +1264 -0
  17. package/dist/chunk-IWSBYOSS.js +91 -0
  18. package/dist/chunk-MFJS65C5.js +368 -0
  19. package/dist/{chunk-CXPNPSF7.js → chunk-NJXIYSDZ.js} +12 -1
  20. package/dist/{chunk-NRQXKZO3.js → chunk-OM4L7RE5.js} +12 -2
  21. package/dist/chunk-QCRRF76W.js +75 -0
  22. package/dist/chunk-QUEJHA24.js +508 -0
  23. package/dist/chunk-UYBQTE4M.js +337 -0
  24. package/dist/chunk-VJ744W5N.js +603 -0
  25. package/dist/chunk-VXW7AOGM.js +285 -0
  26. package/dist/{chunk-OQ7P5XC7.js → chunk-YB7AXTX7.js} +1 -1
  27. package/dist/components/ActionBar/index.d.ts +7 -2
  28. package/dist/components/ActionBar/index.js +1 -1
  29. package/dist/components/AdvanceMenu/index.d.ts +80 -0
  30. package/dist/components/AdvanceMenu/index.js +1 -0
  31. package/dist/components/ArticleSlot/index.d.ts +213 -0
  32. package/dist/components/ArticleSlot/index.js +1 -0
  33. package/dist/components/AuthorInfo/index.js +1 -1
  34. package/dist/components/BottomSheet/index.d.ts +87 -0
  35. package/dist/components/BottomSheet/index.js +1 -0
  36. package/dist/components/CleanModeOverlay/index.d.ts +60 -0
  37. package/dist/components/CleanModeOverlay/index.js +1 -0
  38. package/dist/components/CommentSheet/index.d.ts +155 -3
  39. package/dist/components/CommentSheet/index.js +1 -1
  40. package/dist/components/DetailView/index.d.ts +314 -0
  41. package/dist/components/DetailView/index.js +1 -0
  42. package/dist/components/ErrorBoundary/index.js +1 -1
  43. package/dist/components/{VideoFeed → Feed}/index.d.ts +64 -45
  44. package/dist/components/Feed/index.js +1 -0
  45. package/dist/components/ImageCarousel/index.d.ts +50 -0
  46. package/dist/components/ImageCarousel/index.js +1 -0
  47. package/dist/components/Playlist/index.d.ts +117 -0
  48. package/dist/components/Playlist/index.js +1 -0
  49. package/dist/components/ProgressBar/index.js +1 -1
  50. package/dist/components/QualityPicker/index.d.ts +35 -0
  51. package/dist/components/QualityPicker/index.js +1 -0
  52. package/dist/components/ReportSheet/index.d.ts +74 -0
  53. package/dist/components/ReportSheet/index.js +1 -0
  54. package/dist/components/Skeleton/index.js +1 -1
  55. package/dist/components/SpeedPicker/index.d.ts +32 -0
  56. package/dist/components/SpeedPicker/index.js +1 -0
  57. package/dist/components/VideoInfo/index.d.ts +7 -3
  58. package/dist/components/VideoInfo/index.js +1 -1
  59. package/dist/components/VideoPlayer/index.js +1 -1
  60. package/dist/components/VideoSlot/index.d.ts +31 -68
  61. package/dist/components/VideoSlot/index.js +2 -1
  62. package/dist/components/VirtualSlider/index.js +1 -1
  63. package/dist/index.d.ts +74 -11
  64. package/dist/index.js +39 -15
  65. package/package.json +8 -4
  66. package/dist/CommentSheet.css-BD6XbpU2.d.ts +0 -207
  67. package/dist/chunk-EBAMBI3O.js +0 -571
  68. package/dist/chunk-K3CETRCY.js +0 -737
  69. package/dist/chunk-PGHLVKXS.js +0 -148
  70. package/dist/chunk-QF7O26KZ.js +0 -357
  71. package/dist/chunk-RKS7YA7Z.js +0 -562
  72. package/dist/chunk-T4RQWGRY.js +0 -1519
  73. package/dist/chunk-UXNIXHII.js +0 -2040
  74. package/dist/chunk-YWAPI7JO.js +0 -204
  75. package/dist/components/VideoFeed/index.js +0 -1
@@ -0,0 +1,296 @@
1
+ import { injectComponentCSS } from './chunk-CAWE42LH.js';
2
+ import { BottomSheetHeadless } from './chunk-UYBQTE4M.js';
3
+ import { clsx } from 'clsx';
4
+ import { memo, useRef, useEffect, useState } from 'react';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+ import { isVideoItem, isImagePost } from '@xhub-short/contracts';
7
+
8
+ // src/components/Playlist/PlaylistBar.css.ts
9
+ var PLAYLIST_BAR_CSS = `.sv-playlist-bar-container{display:flex;align-items:center;justify-content:space-between;position:fixed;bottom:0;left:12px;right:12px;z-index:60;padding:var(--sv-spacing-sm,8px)var(--sv-spacing-md,12px);background-color:var(--sv-playlist-bar-bg,rgba(255,255,255,.15));backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border-radius:var(--sv-radius-md,10px);color:var(--sv-text-primary,#fff);font-family:var(--sv-font-family,system-ui,sans-serif);font-size:var(--sv-text-sm,13px);cursor:pointer;user-select:none;overflow:hidden;transition:background-color .2s,opacity .3s cubic-bezier(.4,0,.2,1),transform .3s ease;border:1px solid rgba(255,255,255,.1);box-sizing:border-box;box-shadow:0 4px 12px rgba(0,0,0,.2)}.sv-playlist-bar-container--hidden{opacity:0 !important;pointer-events:none !important}.sv-playlist-bar-container:active{background-color:var(--sv-playlist-bar-bg-active,rgba(255,255,255,.2))}.sv-playlist-bar-content{display:flex;align-items:center;flex:1;min-width:0;gap:var(--sv-spacing-xs,4px)}.sv-playlist-bar-icon{display:flex;align-items:center;justify-content:center;flex-shrink:0;width:16px;height:16px;margin-right:4px;opacity:.9}.sv-playlist-bar-text{display:flex;align-items:center;overflow:hidden;white-space:nowrap;flex:1}.sv-playlist-bar-title{font-weight:500;overflow:hidden;text-overflow:ellipsis;margin-right:4px;transition:opacity .3s ease,transform .3s ease;display:block}.sv-playlist-bar-title--entering{opacity:0;transform:translateY(5px)}.sv-playlist-bar-title--active{opacity:1;transform:translateY(0)}.sv-playlist-bar-title--exiting{opacity:0;transform:translateY(-5px)}.sv-playlist-bar-label{opacity:.7;font-weight:normal}.sv-playlist-bar-separator{opacity:.4;margin:0 4px}.sv-playlist-bar-counter{font-variant-numeric:tabular-nums;opacity:.7;font-size:.9em;white-space:nowrap}.sv-playlist-bar-arrow{display:flex;align-items:center;justify-content:center;flex-shrink:0;margin-left:8px;opacity:.6}`;
10
+ injectComponentCSS("sv-playlist-bar", PLAYLIST_BAR_CSS);
11
+ function PlaylistBarHeadless({
12
+ title,
13
+ currentIndex,
14
+ totalItems,
15
+ onClick,
16
+ className,
17
+ style,
18
+ icon,
19
+ arrowIcon,
20
+ onNext,
21
+ label,
22
+ isVisible = true
23
+ }) {
24
+ const [displayTitle, setDisplayTitle] = useState(title);
25
+ const [animState, setAnimState] = useState("active");
26
+ useEffect(() => {
27
+ let timer;
28
+ if (title !== displayTitle) {
29
+ setAnimState("exiting");
30
+ timer = setTimeout(() => {
31
+ setDisplayTitle(title);
32
+ setAnimState("entering");
33
+ requestAnimationFrame(() => {
34
+ requestAnimationFrame(() => {
35
+ setAnimState("active");
36
+ });
37
+ });
38
+ }, 300);
39
+ }
40
+ return () => {
41
+ if (timer) clearTimeout(timer);
42
+ };
43
+ }, [title, displayTitle]);
44
+ return /* @__PURE__ */ jsxs(
45
+ "div",
46
+ {
47
+ className: clsx(
48
+ "sv-playlist-bar-container",
49
+ !isVisible && "sv-playlist-bar-container--hidden",
50
+ className
51
+ ),
52
+ style,
53
+ onClick,
54
+ "aria-label": `Playlist: ${title}, item ${currentIndex} of ${totalItems}`,
55
+ onKeyDown: (e) => {
56
+ if (e.key === "Enter" || e.key === " ") {
57
+ onClick?.();
58
+ }
59
+ },
60
+ children: [
61
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-bar-content", children: [
62
+ icon && /* @__PURE__ */ jsx("span", { className: "sv-playlist-bar-icon", children: icon }),
63
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-bar-text", children: [
64
+ label && /* @__PURE__ */ jsxs(Fragment, { children: [
65
+ /* @__PURE__ */ jsx("span", { className: "sv-playlist-bar-label", children: label }),
66
+ /* @__PURE__ */ jsx("span", { className: "sv-playlist-bar-separator", children: "\u2022" })
67
+ ] }),
68
+ /* @__PURE__ */ jsx("span", { className: clsx("sv-playlist-bar-title", `sv-playlist-bar-title--${animState}`), children: displayTitle })
69
+ ] }),
70
+ /* @__PURE__ */ jsx("span", { className: "sv-playlist-bar-separator", children: "|" }),
71
+ /* @__PURE__ */ jsxs("span", { className: "sv-playlist-bar-counter", children: [
72
+ currentIndex,
73
+ "/",
74
+ totalItems
75
+ ] })
76
+ ] }),
77
+ arrowIcon && /* @__PURE__ */ jsx(
78
+ "button",
79
+ {
80
+ type: "button",
81
+ className: "sv-playlist-bar-next-btn",
82
+ onClick: (e) => {
83
+ e.stopPropagation();
84
+ onNext?.();
85
+ },
86
+ "aria-label": "Next video",
87
+ style: {
88
+ background: "none",
89
+ border: "none",
90
+ padding: 0,
91
+ display: "flex",
92
+ alignItems: "center",
93
+ cursor: "pointer",
94
+ color: "inherit"
95
+ },
96
+ children: /* @__PURE__ */ jsx("span", { className: "sv-playlist-bar-arrow", children: arrowIcon })
97
+ }
98
+ )
99
+ ]
100
+ }
101
+ );
102
+ }
103
+
104
+ // src/components/Playlist/PlaylistSheet.css.ts
105
+ var PLAYLIST_SHEET_CSS = `:root{--sv-playlist-sheet-bg:#1a1a1a;--sv-playlist-sheet-text:#fff;--sv-playlist-sheet-item-bg-active:rgba(255,255,255,.1);--sv-playlist-sheet-divider:rgba(255,255,255,.1);--sv-playlist-sheet-thumb-width:80px;--sv-playlist-sheet-thumb-height:106px}.sv-playlist-sheet{--sv-sheet-bg:var(--sv-playlist-sheet-bg);--sv-sheet-handle-bg:rgba(255,255,255,.2);background:var(--sv-sheet-bg);color:var(--sv-playlist-sheet-text);z-index:51}.sv-playlist-sheet-backdrop{z-index:50}.sv-playlist-sheet__header{padding:16px 20px;border-bottom:1px solid var(--sv-playlist-sheet-divider);display:flex;align-items:center;justify-content:space-between}.sv-playlist-sheet__title{font-size:16px;font-weight:600;margin:0}.sv-playlist-sheet__list{padding:8px 0;max-height:55vh;overflow-y:auto}.sv-playlist-sheet__item{display:flex;padding:12px 20px;gap:12px;cursor:pointer;transition:background-color .2s ease;outline:none}.sv-playlist-sheet__item:hover,.sv-playlist-sheet__item:focus{background-color:rgba(255,255,255,.05)}.sv-playlist-sheet__item--active{background-color:var(--sv-playlist-sheet-item-bg-active)}.sv-playlist-sheet__thumb-container{width:var(--sv-playlist-sheet-thumb-width);height:var(--sv-playlist-sheet-thumb-height);flex-shrink:0;background:#000;border-radius:8px;overflow:hidden;position:relative}.sv-playlist-sheet__thumb{width:100%;height:100%;object-fit:cover}.sv-playlist-sheet__duration{position:absolute;bottom:4px;right:4px;background:rgba(0,0,0,.6);color:#fff;font-size:10px;padding:2px 4px;border-radius:4px}.sv-playlist-sheet__info{flex:1;display:flex;flex-direction:column;justify-content:center;min-width:0}.sv-playlist-sheet__item-title{font-size:14px;line-height:1.4;margin-bottom:4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.sv-playlist-sheet__item-meta{font-size:12px;color:rgba(255,255,255,.6)}.sv-playlist-sheet__empty{padding:60px 20px;text-align:center;color:rgba(255,255,255,.4);font-size:14px}`;
106
+ injectComponentCSS("sv-playlist-sheet", PLAYLIST_SHEET_CSS);
107
+ function PlaylistSheetHeadlessComponent({
108
+ isOpen,
109
+ onClose,
110
+ items,
111
+ currentIndex,
112
+ activeId,
113
+ onItemSelect,
114
+ className,
115
+ translations,
116
+ headerAccessory,
117
+ onGestureLock
118
+ }) {
119
+ const listRef = useRef(null);
120
+ const activeItemRef = useRef(null);
121
+ useEffect(() => {
122
+ if (isOpen && activeItemRef.current) {
123
+ const timer = setTimeout(() => {
124
+ activeItemRef.current?.scrollIntoView({
125
+ behavior: "smooth",
126
+ block: "center"
127
+ });
128
+ }, 100);
129
+ return () => clearTimeout(timer);
130
+ }
131
+ return;
132
+ }, [isOpen]);
133
+ const renderThumbnail = (item) => {
134
+ if (isVideoItem(item)) {
135
+ return /* @__PURE__ */ jsxs("div", { className: "sv-playlist-sheet__thumb-container", children: [
136
+ item.poster && /* @__PURE__ */ jsx("img", { src: item.poster, alt: "", className: "sv-playlist-sheet__thumb", loading: "lazy" }),
137
+ item.duration > 0 && /* @__PURE__ */ jsx("span", { className: "sv-playlist-sheet__duration", children: formatDuration(item.duration) })
138
+ ] });
139
+ }
140
+ if (isImagePost(item)) {
141
+ return /* @__PURE__ */ jsxs("div", { className: "sv-playlist-sheet__thumb-container", children: [
142
+ item.images[0] && /* @__PURE__ */ jsx("img", { src: item.images[0], alt: "", className: "sv-playlist-sheet__thumb", loading: "lazy" }),
143
+ /* @__PURE__ */ jsx("span", { className: "sv-playlist-sheet__duration", children: item.images.length })
144
+ ] });
145
+ }
146
+ return /* @__PURE__ */ jsx("div", { className: "sv-playlist-sheet__thumb-container" });
147
+ };
148
+ return /* @__PURE__ */ jsxs(
149
+ BottomSheetHeadless,
150
+ {
151
+ isOpen,
152
+ onClose,
153
+ className: clsx("sv-playlist-sheet", className),
154
+ backdropClassName: "sv-playlist-sheet-backdrop",
155
+ contentClassName: "sv-playlist-sheet__content",
156
+ height: "80vh",
157
+ ariaLabel: translations.title,
158
+ dragHandleSelector: ".sv-playlist-sheet__header",
159
+ scrollContainerSelector: ".sv-playlist-sheet__list",
160
+ onGestureLock,
161
+ children: [
162
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-sheet__header", children: [
163
+ /* @__PURE__ */ jsxs("h3", { className: "sv-playlist-sheet__title", children: [
164
+ translations.title,
165
+ " (",
166
+ items.length,
167
+ ")"
168
+ ] }),
169
+ headerAccessory
170
+ ] }),
171
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-sheet__list", ref: listRef, children: items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "sv-playlist-sheet__empty", children: translations.emptyState }) : items.map((item, index) => {
172
+ const isActive = item.id === activeId || index === currentIndex;
173
+ return /* @__PURE__ */ jsxs(
174
+ "div",
175
+ {
176
+ ref: isActive ? activeItemRef : null,
177
+ className: clsx("sv-playlist-sheet__item", {
178
+ "sv-playlist-sheet__item--active": isActive
179
+ }),
180
+ onClick: () => onItemSelect(index),
181
+ onKeyDown: (e) => {
182
+ if (e.key === "Enter" || e.key === " ") {
183
+ onItemSelect(index);
184
+ }
185
+ },
186
+ "aria-pressed": isActive,
187
+ children: [
188
+ renderThumbnail(item),
189
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-sheet__info", children: [
190
+ /* @__PURE__ */ jsx("span", { className: "sv-playlist-sheet__item-title", children: isVideoItem(item) ? item.title : item.caption }),
191
+ /* @__PURE__ */ jsxs("span", { className: "sv-playlist-sheet__item-meta", children: [
192
+ item.author.name,
193
+ isActive && translations.nowPlaying && ` \u2022 ${translations.nowPlaying}`
194
+ ] })
195
+ ] })
196
+ ]
197
+ },
198
+ item.id
199
+ );
200
+ }) })
201
+ ]
202
+ }
203
+ );
204
+ }
205
+ function formatDuration(seconds) {
206
+ const mins = Math.floor(seconds / 60);
207
+ const secs = Math.floor(seconds % 60);
208
+ return `${mins}:${secs.toString().padStart(2, "0")}`;
209
+ }
210
+ var PlaylistSheetHeadless = memo(PlaylistSheetHeadlessComponent);
211
+ PlaylistSheetHeadless.displayName = "PlaylistSheetHeadless";
212
+
213
+ // src/components/Playlist/PlaylistCollection.css.ts
214
+ var PLAYLIST_COLLECTION_CSS = `.sv-playlist-collection{height:100%;width:100%;padding:16px;box-sizing:border-box;color:#fff;overflow-y:auto}.sv-playlist-collection__title{font-size:20px;font-weight:bold;margin-bottom:16px;line-height:1.2}.sv-playlist-collection__grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}@media(min-width:768px){.sv-playlist-collection__grid{grid-template-columns:repeat(3,1fr)}}@media(min-width:1024px){.sv-playlist-collection__grid{grid-template-columns:repeat(4,1fr)}}.sv-playlist-collection__list{display:flex;flex-direction:column;gap:12px}.sv-playlist-collection__item{display:flex;flex-direction:column;position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform 150ms cubic-bezier(.2,0,0,1.0)}.sv-playlist-collection__item:active{transform:scale(.98)}.sv-playlist-collection__list .sv-playlist-collection__item{flex-direction:row;align-items:center;gap:12px}.sv-playlist-collection__thumb-wrapper{position:relative;width:100%;aspect-ratio:9 / 16;border-radius:8px;overflow:hidden;background-color:#1a1a1a}.sv-playlist-collection__list .sv-playlist-collection__thumb-wrapper{width:80px;flex-shrink:0}.sv-playlist-collection__thumb{width:100%;height:100%;object-fit:cover}.sv-playlist-collection__item-count{position:absolute;bottom:8px;right:8px;background:rgba(0,0,0,.7);color:#fff;padding:2px 6px;border-radius:4px;font-size:10px;font-weight:600}.sv-playlist-collection__info{margin-top:8px;display:flex;flex-direction:column;gap:2px}.sv-playlist-collection__list .sv-playlist-collection__info{margin-top:0;flex:1}.sv-playlist-collection__item-title{font-size:14px;font-weight:600;line-height:1.4;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.sv-playlist-collection__item-meta{font-size:12px;color:rgba(255,255,255,.6)}.sv-playlist-collection__skeleton{background:linear-gradient(90deg,#1a1a1a 25%,#262626 50%,#1a1a1a 75%);background-size:200% 100%;animation:sv-skeleton-pulse 1.5s infinite ease-in-out}@keyframes sv-skeleton-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}.sv-playlist-collection__skeleton-info{margin-top:8px;display:flex;flex-direction:column;gap:8px}.sv-playlist-collection__skeleton-line{height:12px;border-radius:4px;width:100%}.sv-playlist-collection__skeleton-line--short{width:60%}.sv-playlist-collection__empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 24px;text-align:center;gap:16px}.sv-playlist-collection__empty-title{font-size:18px;font-weight:600;color:#fff}.sv-playlist-collection__empty-desc{font-size:14px;color:rgba(255,255,255,.6);max-width:240px}.sv-playlist-collection__empty-button{margin-top:8px}`;
215
+ injectComponentCSS("sv-playlist-collection", PLAYLIST_COLLECTION_CSS);
216
+ function PlaylistCollectionHeadlessComponent({
217
+ playlists,
218
+ viewType = "grid",
219
+ isLoading = false,
220
+ onSelect,
221
+ className,
222
+ translations,
223
+ renderEmptyButton
224
+ }) {
225
+ if (isLoading) {
226
+ return /* @__PURE__ */ jsxs("div", { className: clsx("sv-playlist-collection", className), children: [
227
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__title", children: translations.title }),
228
+ /* @__PURE__ */ jsx("div", { className: clsx(`sv-playlist-collection__${viewType}`), children: [0, 1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__item", children: [
229
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__thumb-wrapper sv-playlist-collection__skeleton" }),
230
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__skeleton-info", children: [
231
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__skeleton-line sv-playlist-collection__skeleton" }),
232
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__skeleton-line sv-playlist-collection__skeleton-line--short sv-playlist-collection__skeleton" })
233
+ ] })
234
+ ] }, `skeleton-${i}`)) })
235
+ ] });
236
+ }
237
+ if (playlists.length === 0) {
238
+ return /* @__PURE__ */ jsx("div", { className: clsx("sv-playlist-collection", className), children: /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__empty", children: [
239
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__empty-title", children: translations.emptyTitle }),
240
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__empty-desc", children: translations.emptyDesc }),
241
+ renderEmptyButton ? /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__empty-button", children: renderEmptyButton() }) : /* @__PURE__ */ jsx(
242
+ "button",
243
+ {
244
+ type: "button",
245
+ className: "sv-playlist-collection__empty-button",
246
+ onClick: () => window.location.reload(),
247
+ children: translations.retryButton
248
+ }
249
+ )
250
+ ] }) });
251
+ }
252
+ return /* @__PURE__ */ jsxs("div", { className: clsx("sv-playlist-collection", className), children: [
253
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__title", children: translations.title }),
254
+ /* @__PURE__ */ jsx("div", { className: clsx(`sv-playlist-collection__${viewType}`), children: playlists.map((playlist) => /* @__PURE__ */ jsxs(
255
+ "button",
256
+ {
257
+ type: "button",
258
+ className: "sv-playlist-collection__item",
259
+ onClick: () => onSelect(playlist.id),
260
+ onKeyDown: (e) => {
261
+ if (e.key === "Enter" || e.key === " ") {
262
+ onSelect(playlist.id);
263
+ }
264
+ },
265
+ "aria-label": playlist.title,
266
+ children: [
267
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__thumb-wrapper", children: [
268
+ playlist.thumbnail && /* @__PURE__ */ jsx(
269
+ "img",
270
+ {
271
+ src: playlist.thumbnail,
272
+ alt: "",
273
+ className: "sv-playlist-collection__thumb",
274
+ loading: "lazy"
275
+ }
276
+ ),
277
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__item-count", children: translations.itemsCount(playlist.itemCount) })
278
+ ] }),
279
+ /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__info", children: [
280
+ /* @__PURE__ */ jsx("div", { className: "sv-playlist-collection__item-title", children: playlist.title }),
281
+ playlist.authorName && /* @__PURE__ */ jsxs("div", { className: "sv-playlist-collection__item-meta", children: [
282
+ playlist.authorName,
283
+ " ",
284
+ playlist.updatedAt ? `\u2022 ${playlist.updatedAt}` : ""
285
+ ] })
286
+ ] })
287
+ ]
288
+ },
289
+ playlist.id
290
+ )) })
291
+ ] });
292
+ }
293
+ var PlaylistCollectionHeadless = memo(PlaylistCollectionHeadlessComponent);
294
+ PlaylistCollectionHeadless.displayName = "PlaylistCollectionHeadless";
295
+
296
+ export { PlaylistBarHeadless, PlaylistCollectionHeadless, PlaylistSheetHeadless };
@@ -0,0 +1,350 @@
1
+ import { injectComponentCSS } from './chunk-CAWE42LH.js';
2
+ import { clsx } from 'clsx';
3
+ import { createContext, useInsertionEffect, useMemo, useState, useContext } from 'react';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+
6
+ var VideoInfoContext = createContext(void 0);
7
+ function useVideoInfoContext() {
8
+ const context = useContext(VideoInfoContext);
9
+ if (context === void 0) {
10
+ throw new Error("useVideoInfoContext must be used within a VideoInfoHeadless component");
11
+ }
12
+ return context;
13
+ }
14
+ function useOptionalVideoInfoContext() {
15
+ return useContext(VideoInfoContext);
16
+ }
17
+ function DefaultVerifiedIcon() {
18
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "10", height: "10", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z" }) });
19
+ }
20
+ function VideoAuthorName({
21
+ name,
22
+ showAtPrefix = true,
23
+ showVerified = true,
24
+ isVerified,
25
+ verifiedIcon,
26
+ onClick,
27
+ className,
28
+ children
29
+ }) {
30
+ const context = useOptionalVideoInfoContext();
31
+ const authorName = name ?? context?.state.authorName;
32
+ const verified = isVerified ?? context?.state.isVerified ?? false;
33
+ const handleClick = onClick ?? context?.actions.openProfile;
34
+ if (!authorName) {
35
+ return null;
36
+ }
37
+ const handleKeyDown = (e) => {
38
+ if ((e.key === "Enter" || e.key === " ") && handleClick) {
39
+ e.preventDefault();
40
+ e.stopPropagation();
41
+ handleClick();
42
+ }
43
+ };
44
+ return /* @__PURE__ */ jsx(
45
+ "div",
46
+ {
47
+ className: clsx("sv-video-info__author", className),
48
+ onClick: (e) => {
49
+ e.stopPropagation();
50
+ handleClick?.();
51
+ },
52
+ onKeyDown: handleKeyDown,
53
+ role: handleClick ? "button" : void 0,
54
+ tabIndex: handleClick ? 0 : void 0,
55
+ "aria-label": handleClick ? `View ${authorName}'s profile` : void 0,
56
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsxs("span", { className: "sv-video-info__author-name", children: [
58
+ showAtPrefix && /* @__PURE__ */ jsx("span", { className: "sv-video-info__author-prefix", children: "@" }),
59
+ authorName
60
+ ] }),
61
+ showVerified && verified && /* @__PURE__ */ jsx("span", { className: "sv-video-info__verified-badge", "aria-label": "Verified", children: verifiedIcon ?? /* @__PURE__ */ jsx(DefaultVerifiedIcon, {}) })
62
+ ] })
63
+ }
64
+ );
65
+ }
66
+ function VideoCaption({
67
+ caption,
68
+ maxLines = 2,
69
+ expandable = false,
70
+ moreText = "more",
71
+ lessText = "less",
72
+ onClick,
73
+ className,
74
+ children
75
+ }) {
76
+ const context = useOptionalVideoInfoContext();
77
+ const [isExpanded, setIsExpanded] = useState(false);
78
+ const captionText = caption ?? context?.state.caption;
79
+ if (!captionText) {
80
+ return null;
81
+ }
82
+ const lineClampClass = isExpanded ? "sv-video-info__caption--expanded" : `sv-video-info__caption--lines-${maxLines}`;
83
+ const handleToggleExpand = (e) => {
84
+ e.stopPropagation();
85
+ setIsExpanded(!isExpanded);
86
+ };
87
+ const handleClick = (e) => {
88
+ e.stopPropagation();
89
+ onClick?.();
90
+ };
91
+ const isClickable = onClick && !expandable;
92
+ return /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ className: clsx(
96
+ "sv-video-info__caption",
97
+ lineClampClass,
98
+ isClickable && "sv-video-info__caption--clickable",
99
+ className
100
+ ),
101
+ onClick: isClickable ? handleClick : void 0,
102
+ onKeyDown: isClickable ? (e) => {
103
+ if (e.key === "Enter" || e.key === " ") {
104
+ e.stopPropagation();
105
+ onClick?.();
106
+ }
107
+ } : void 0,
108
+ role: isClickable ? "button" : void 0,
109
+ tabIndex: isClickable ? 0 : void 0,
110
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
111
+ captionText,
112
+ expandable && /* @__PURE__ */ jsx(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ className: "sv-video-info__caption-more",
117
+ onClick: handleToggleExpand,
118
+ children: isExpanded ? lessText : moreText
119
+ }
120
+ )
121
+ ] })
122
+ }
123
+ );
124
+ }
125
+ function VideoHashtags({
126
+ hashtags,
127
+ clickable = true,
128
+ onHashtagClick,
129
+ display = "block",
130
+ className,
131
+ children
132
+ }) {
133
+ const context = useOptionalVideoInfoContext();
134
+ const hashtagsArray = hashtags ?? context?.state.hashtags ?? [];
135
+ const handleClick = onHashtagClick ?? context?.actions.onHashtagClick;
136
+ if (hashtagsArray.length === 0) {
137
+ return null;
138
+ }
139
+ const handleHashtagClick = (tag) => (e) => {
140
+ e.stopPropagation();
141
+ if (clickable && handleClick) {
142
+ handleClick(tag);
143
+ }
144
+ };
145
+ const handleKeyDown = (tag) => (e) => {
146
+ if ((e.key === "Enter" || e.key === " ") && clickable && handleClick) {
147
+ e.preventDefault();
148
+ handleClick(tag);
149
+ }
150
+ };
151
+ const formatTag = (tag) => tag.startsWith("#") ? tag : `#${tag}`;
152
+ if (children) {
153
+ return /* @__PURE__ */ jsx(Fragment, { children });
154
+ }
155
+ return /* @__PURE__ */ jsx(
156
+ "div",
157
+ {
158
+ className: clsx(
159
+ "sv-video-info__hashtags",
160
+ display === "inline" && "sv-video-info__hashtags--inline",
161
+ className
162
+ ),
163
+ children: hashtagsArray.map((tag) => /* @__PURE__ */ jsx(
164
+ "button",
165
+ {
166
+ type: "button",
167
+ className: clsx(
168
+ "sv-video-info__hashtag",
169
+ !clickable && "sv-video-info__hashtag--not-clickable"
170
+ ),
171
+ onClick: handleHashtagClick(tag),
172
+ onKeyDown: handleKeyDown(tag),
173
+ tabIndex: clickable ? 0 : -1,
174
+ "aria-label": clickable ? `View hashtag ${tag}` : void 0,
175
+ children: formatTag(tag)
176
+ },
177
+ tag
178
+ ))
179
+ }
180
+ );
181
+ }
182
+
183
+ // src/components/VideoInfo/VideoInfo.css.ts
184
+ var VIDEO_INFO_CSS = `.sv-video-info{display:flex;flex-direction:column;gap:var(--sv-video-info-gap,6px);color:var(--sv-video-info-color,#fff);font-family:var(--sv-font-family,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif);text-shadow:var(--sv-video-info-text-shadow,0 1px 2px rgba(0,0,0,.5));max-width:100%;overflow:hidden;transition:opacity .3s cubic-bezier(.4,0,.2,1)}.sv-video-info--hidden{opacity:0;pointer-events:none}.sv-video-info--overlay{pointer-events:none}.sv-video-info--overlay>*{pointer-events:auto}.sv-video-info__author{display:flex;align-items:center;gap:var(--sv-video-info-author-gap,6px);cursor:pointer;transition:opacity .15s ease}.sv-video-info__author:hover{opacity:.85}.sv-video-info__author:active{opacity:.7}.sv-video-info__author-name{font-size:var(--sv-video-info-author-font-size,16px);font-weight:var(--sv-video-info-author-font-weight,700);line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.sv-video-info__author-prefix{opacity:.95}.sv-video-info__verified-badge{display:inline-flex;align-items:center;justify-content:center;width:var(--sv-video-info-verified-size,14px);height:var(--sv-video-info-verified-size,14px);background:var(--sv-video-info-verified-bg,#20d5ec);border-radius:50%;flex-shrink:0}.sv-video-info__verified-badge svg,.sv-video-info__verified-badge span{font-size:10px;color:#fff;font-weight:bold}.sv-video-info__caption{font-size:var(--sv-video-info-caption-font-size,14px);line-height:var(--sv-video-info-caption-line-height,1.4);color:var(--sv-video-info-caption-color,#fff);display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.sv-video-info__caption--lines-1{-webkit-line-clamp:1}.sv-video-info__caption--lines-2{-webkit-line-clamp:2}.sv-video-info__caption--lines-3{-webkit-line-clamp:3}.sv-video-info__caption--expanded{-webkit-line-clamp:unset}.sv-video-info__caption--clickable{cursor:pointer;transition:opacity .15s ease}.sv-video-info__caption--clickable:hover{opacity:.85}.sv-video-info__caption--clickable:active{opacity:.7}.sv-video-info__caption-more{background:0 0;border:0;color:var(--sv-video-info-caption-more-color,rgba(255,255,255,.7));font-size:var(--sv-video-info-caption-font-size,14px);padding:0;margin-left:4px;cursor:pointer}.sv-video-info__caption-more:hover{color:var(--sv-video-info-caption-color,#fff)}.sv-video-info__hashtags{display:inline-flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:var(--sv-video-info-hashtag-gap,6px);font-size:var(--sv-video-info-hashtag-font-size,14px)}.sv-video-info__hashtags--inline{gap:var(--sv-video-info-hashtag-gap-inline,4px)}.sv-video-info__hashtag{display:inline-flex;color:var(--sv-video-info-hashtag-color,#fff);font-weight:var(--sv-video-info-hashtag-font-weight,500);background:0 0;border:0;padding:0;cursor:pointer;transition:opacity .15s ease;white-space:nowrap}.sv-video-info__hashtag:hover{opacity:.8;text-decoration:underline}.sv-video-info__hashtag--not-clickable{cursor:default}.sv-video-info__hashtag--not-clickable:hover{opacity:1;text-decoration:none}.sv-video-info__caption .sv-video-info__hashtag{display:inline}.sv-video-info__location{display:flex;align-items:center;gap:var(--sv-video-info-location-gap,4px);font-size:var(--sv-video-info-location-font-size,13px);color:var(--sv-video-info-location-color,rgba(255,255,255,.9));cursor:pointer;transition:opacity .15s ease}.sv-video-info__location:hover{opacity:.8}.sv-video-info__location-icon{font-size:14px;flex-shrink:0}.sv-video-info__location-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sv-video-info__music{display:flex;align-items:center;gap:var(--sv-video-info-music-gap,8px);font-size:var(--sv-video-info-music-font-size,13px);color:var(--sv-video-info-music-color,#fff);cursor:pointer;transition:opacity .15s ease;overflow:hidden}.sv-video-info__music:hover{opacity:.8}.sv-video-info__music-icon{font-size:14px;flex-shrink:0}.sv-video-info__music-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sv-video-info__music-text--marquee{animation:sv-video-info-marquee 8s linear infinite}@keyframes sv-video-info-marquee{0%{transform:translateX(0)}100%{transform:translateX(-50%)}}`;
185
+ function DefaultLocationIcon() {
186
+ return /* @__PURE__ */ jsx("span", { className: "sv-video-info__location-icon", children: "\u{1F4CD}" });
187
+ }
188
+ function VideoLocation({
189
+ location,
190
+ icon,
191
+ onClick,
192
+ className,
193
+ children
194
+ }) {
195
+ const context = useOptionalVideoInfoContext();
196
+ const locationText = location ?? context?.state.location;
197
+ const handleClick = onClick ?? context?.actions.onLocationClick;
198
+ if (!locationText) {
199
+ return null;
200
+ }
201
+ const handleKeyDown = (e) => {
202
+ if ((e.key === "Enter" || e.key === " ") && handleClick) {
203
+ e.preventDefault();
204
+ e.stopPropagation();
205
+ handleClick();
206
+ }
207
+ };
208
+ return /* @__PURE__ */ jsx(
209
+ "div",
210
+ {
211
+ className: clsx("sv-video-info__location", className),
212
+ onClick: (e) => {
213
+ e.stopPropagation();
214
+ handleClick?.();
215
+ },
216
+ onKeyDown: handleKeyDown,
217
+ role: handleClick ? "button" : void 0,
218
+ tabIndex: handleClick ? 0 : void 0,
219
+ "aria-label": handleClick ? `View location: ${locationText}` : void 0,
220
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
221
+ icon ?? /* @__PURE__ */ jsx(DefaultLocationIcon, {}),
222
+ /* @__PURE__ */ jsx("span", { className: "sv-video-info__location-text", children: locationText })
223
+ ] })
224
+ }
225
+ );
226
+ }
227
+ function DefaultMusicIcon() {
228
+ return /* @__PURE__ */ jsx("span", { className: "sv-video-info__music-icon", children: "\u{1F3B5}" });
229
+ }
230
+ function VideoMusic({
231
+ title,
232
+ artist,
233
+ icon,
234
+ marquee = false,
235
+ onClick,
236
+ className,
237
+ children
238
+ }) {
239
+ const context = useOptionalVideoInfoContext();
240
+ const musicTitle = title ?? context?.state.music?.title;
241
+ const musicArtist = artist ?? context?.state.music?.artist;
242
+ const handleClick = onClick ?? context?.actions.onMusicClick;
243
+ if (!musicTitle && !musicArtist) {
244
+ return null;
245
+ }
246
+ const displayText = musicArtist ? `${musicTitle} - ${musicArtist}` : musicTitle;
247
+ const handleKeyDown = (e) => {
248
+ if ((e.key === "Enter" || e.key === " ") && handleClick) {
249
+ e.preventDefault();
250
+ e.stopPropagation();
251
+ handleClick();
252
+ }
253
+ };
254
+ return /* @__PURE__ */ jsx(
255
+ "div",
256
+ {
257
+ className: clsx("sv-video-info__music", className),
258
+ onClick: (e) => {
259
+ e.stopPropagation();
260
+ handleClick?.();
261
+ },
262
+ onKeyDown: handleKeyDown,
263
+ role: handleClick ? "button" : void 0,
264
+ tabIndex: handleClick ? 0 : void 0,
265
+ "aria-label": handleClick ? `View sound: ${displayText}` : void 0,
266
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
267
+ icon ?? /* @__PURE__ */ jsx(DefaultMusicIcon, {}),
268
+ /* @__PURE__ */ jsx(
269
+ "span",
270
+ {
271
+ className: clsx(
272
+ "sv-video-info__music-text",
273
+ marquee && "sv-video-info__music-text--marquee"
274
+ ),
275
+ children: displayText
276
+ }
277
+ )
278
+ ] })
279
+ }
280
+ );
281
+ }
282
+ function VideoInfoHeadlessRoot({
283
+ videoInfoState,
284
+ videoInfoActions,
285
+ overlay = false,
286
+ isVisible = true,
287
+ className,
288
+ children,
289
+ testId
290
+ }) {
291
+ useInsertionEffect(() => {
292
+ return injectComponentCSS("video-info", VIDEO_INFO_CSS);
293
+ }, []);
294
+ const contextValue = useMemo(
295
+ () => ({
296
+ state: videoInfoState,
297
+ actions: videoInfoActions
298
+ }),
299
+ [videoInfoState, videoInfoActions]
300
+ );
301
+ const stopPropagation = (e) => {
302
+ e.stopPropagation();
303
+ };
304
+ return /* @__PURE__ */ jsx(VideoInfoContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
305
+ "div",
306
+ {
307
+ className: clsx(
308
+ "sv-video-info",
309
+ overlay && "sv-video-info--overlay",
310
+ !isVisible && "sv-video-info--hidden",
311
+ className
312
+ ),
313
+ onClick: stopPropagation,
314
+ onKeyDown: stopPropagation,
315
+ onPointerDown: stopPropagation,
316
+ onPointerUp: stopPropagation,
317
+ onTouchStart: stopPropagation,
318
+ onTouchEnd: stopPropagation,
319
+ "data-testid": testId,
320
+ children: children ?? // Default layout
321
+ /* @__PURE__ */ jsxs(Fragment, { children: [
322
+ /* @__PURE__ */ jsx(VideoAuthorName, { showAtPrefix: true, showVerified: true }),
323
+ /* @__PURE__ */ jsx(VideoCaption, { maxLines: 2 }),
324
+ /* @__PURE__ */ jsx(VideoHashtags, { clickable: true })
325
+ ] })
326
+ }
327
+ ) });
328
+ }
329
+ function VideoInfoContent({
330
+ children,
331
+ className
332
+ }) {
333
+ return /* @__PURE__ */ jsx("div", { className: clsx("sv-video-info__content", className), children });
334
+ }
335
+ var VideoInfoHeadless = Object.assign(VideoInfoHeadlessRoot, {
336
+ /** Author name with @ prefix and verified badge */
337
+ AuthorName: VideoAuthorName,
338
+ /** Video caption/title with line clamping */
339
+ Caption: VideoCaption,
340
+ /** Hashtags (inline or block) */
341
+ Hashtags: VideoHashtags,
342
+ /** Location info */
343
+ Location: VideoLocation,
344
+ /** Music/sound info */
345
+ Music: VideoMusic,
346
+ /** Content wrapper */
347
+ Content: VideoInfoContent
348
+ });
349
+
350
+ export { VIDEO_INFO_CSS, VideoAuthorName, VideoCaption, VideoHashtags, VideoInfoContext, VideoInfoHeadless, VideoLocation, VideoMusic, useOptionalVideoInfoContext, useVideoInfoContext };