@behindthemusictree/app-kit-ui 40.0.0 → 40.1.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.
@@ -46,6 +46,21 @@ function toTreeNodes(genrePlaylists, sizeMetric, focusUuids) {
46
46
  }));
47
47
  }
48
48
 
49
+ // src/genre-tree/playlist-tree/toGenreNodeStyles.ts
50
+ function toGenreNodeStyles(relations, genrePlaylists) {
51
+ const styles = /* @__PURE__ */ new Map();
52
+ if (!relations) return styles;
53
+ const genreUuidByPlaylistUuid = new Map(
54
+ genrePlaylists.flatMap((genrePlaylist) => genrePlaylist.criteria ? [[genrePlaylist.uuid, genrePlaylist.criteria.uuid]] : [])
55
+ );
56
+ const drawn = [relations, relations.parentNode, ...relations.childNodes, ...relations.ancestorNodes];
57
+ for (const entry of drawn) {
58
+ const genreUuid = entry && genreUuidByPlaylistUuid.get(entry.node.id);
59
+ if (entry && genreUuid) styles.set(genreUuid, { fill: entry.fill, textColor: entry.textColor });
60
+ }
61
+ return styles;
62
+ }
63
+
49
64
  // src/genre-tree/playlist-tree/TreePerRoot.tsx
50
65
  import { genrePlaylistTrackCount as genrePlaylistTrackCount2 } from "@behindthemusictree/app-kit/genre-tree";
51
66
  import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
@@ -1503,7 +1518,7 @@ function useGenreDetailContent({
1503
1518
  trailing,
1504
1519
  genrePlaylist: hostPlaylist,
1505
1520
  expanded,
1506
- treeRelations
1521
+ treeStyles
1507
1522
  }) {
1508
1523
  const { data: detail, isPending, isError } = useFetchGenreDetail(genreUuid, scope, getBackendBaseUrl);
1509
1524
  const defaultPlayback = useGenrePlaylistPlayback({ scope, genrePlaylists: [], artist: extras?.artist });
@@ -1511,19 +1526,12 @@ function useGenreDetailContent({
1511
1526
  const view = useMemo6(() => {
1512
1527
  if (!detail) return null;
1513
1528
  const rootColor = getGenreTreeColor2(detail.root.wikidataId);
1514
- const treeStyles = /* @__PURE__ */ new Map();
1515
- if (treeRelations) {
1516
- const drawn = [treeRelations, treeRelations.parentNode, ...treeRelations.childNodes, ...treeRelations.ancestorNodes];
1517
- for (const entry of drawn) {
1518
- if (entry) treeStyles.set(entry.node.id, { fill: entry.fill, textColor: entry.textColor });
1519
- }
1520
- }
1521
1529
  const relative = (genre, parentId) => ({
1522
1530
  node: toNode(genre, parentId),
1523
- ...treeStyles.get(genre.uuid) ?? { fill: tintSurface(rootColor), textColor: TEXT_COLOR }
1531
+ ...treeStyles?.get(genre.uuid) ?? { fill: tintSurface(rootColor), textColor: TEXT_COLOR }
1524
1532
  });
1525
1533
  const ancestors2 = [...detail.ascendants].sort((a, b) => b.degree - a.degree);
1526
- const own = treeStyles.get(detail.uuid) ?? { fill: rootColor, textColor: getTextColorOnFill(rootColor) };
1534
+ const own = treeStyles?.get(detail.uuid) ?? { fill: rootColor, textColor: getTextColorOnFill(rootColor) };
1527
1535
  return {
1528
1536
  node: {
1529
1537
  id: detail.uuid,
@@ -1540,7 +1548,7 @@ function useGenreDetailContent({
1540
1548
  ({ ascendant }, index) => relative(ascendant, index === 0 ? null : ancestors2[index - 1].ascendant.uuid)
1541
1549
  )
1542
1550
  };
1543
- }, [detail, scope, treeRelations]);
1551
+ }, [detail, scope, treeStyles]);
1544
1552
  if (isError) return {
1545
1553
  name: null,
1546
1554
  title: "Genre unavailable",
@@ -1910,7 +1918,6 @@ function ArtistDiscography({ albums }) {
1910
1918
  // src/genre-tree/artist/ArtistSongs.tsx
1911
1919
  import { useState as useState8 } from "react";
1912
1920
  import { keepPreviousData } from "@tanstack/react-query";
1913
- import { Play as Play3 } from "lucide-react";
1914
1921
  import { Pagination, PanelSection as PanelSection5, Skeleton as Skeleton4 } from "@behindthemusictree/ui";
1915
1922
  import { usePlayer as usePlayer9 } from "@behindthemusictree/app-kit/player";
1916
1923
  import {
@@ -2080,34 +2087,20 @@ function ArtistSongs({ artist, getBackendBaseUrl, renderArtistLink, renderSongLi
2080
2087
  void play(song.uuid);
2081
2088
  };
2082
2089
  return /* @__PURE__ */ jsx34(PanelSection5, { title: "Songs", children: isPending ? /* @__PURE__ */ jsx34(Skeleton4, { className: "h-14", "aria-busy": "true" }) : isError ? /* @__PURE__ */ jsx34("p", { className: "text-red-600", children: "Could not load songs." }) : data.results.length === 0 ? /* @__PURE__ */ jsx34("p", { className: "text-[var(--color-text-muted)]", children: "No songs yet." }) : /* @__PURE__ */ jsxs23(Fragment12, { children: [
2083
- /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap items-center justify-between gap-2 mb-2", children: [
2084
- /* @__PURE__ */ jsxs23(
2085
- "button",
2086
- {
2087
- type: "button",
2088
- onClick: () => void play(),
2089
- className: "flex w-fit items-center gap-1.5 px-3 py-1 text-caption font-medium bg-gray-900 text-white rounded-full hover:bg-gray-700",
2090
- children: [
2091
- /* @__PURE__ */ jsx34(Play3, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
2092
- "Play all"
2093
- ]
2094
- }
2095
- ),
2096
- /* @__PURE__ */ jsx34("div", { role: "group", "aria-label": "Sort songs by", className: "flex gap-1 text-caption", children: SORTS.map((sort) => /* @__PURE__ */ jsx34(
2097
- "button",
2098
- {
2099
- type: "button",
2100
- "aria-pressed": ordering === sort.ordering,
2101
- onClick: () => {
2102
- setOrdering(sort.ordering);
2103
- setPage(1);
2104
- },
2105
- className: "px-2.5 py-0.5 text-[var(--color-text)] rounded-full hover:bg-[var(--color-surface-muted)] aria-pressed:bg-gray-900 aria-pressed:text-white",
2106
- children: sort.label
2090
+ /* @__PURE__ */ jsx34("div", { className: "flex flex-wrap items-center justify-end gap-2 mb-2", children: /* @__PURE__ */ jsx34("div", { role: "group", "aria-label": "Sort songs by", className: "flex gap-1 text-caption", children: SORTS.map((sort) => /* @__PURE__ */ jsx34(
2091
+ "button",
2092
+ {
2093
+ type: "button",
2094
+ "aria-pressed": ordering === sort.ordering,
2095
+ onClick: () => {
2096
+ setOrdering(sort.ordering);
2097
+ setPage(1);
2107
2098
  },
2108
- sort.ordering
2109
- )) })
2110
- ] }),
2099
+ className: "px-2.5 py-0.5 text-[var(--color-text)] rounded-full hover:bg-[var(--color-surface-muted)] aria-pressed:bg-gray-900 aria-pressed:text-white",
2100
+ children: sort.label
2101
+ },
2102
+ sort.ordering
2103
+ )) }) }),
2111
2104
  /* @__PURE__ */ jsx34("ul", { className: "overflow-hidden mb-2 bg-zinc-950 rounded-lg", children: data.results.map((song, index) => /* @__PURE__ */ jsx34("li", { onClickCapture: (event) => handleRowClickCapture(event, song), children: /* @__PURE__ */ jsx34(
2112
2105
  TrackItem,
2113
2106
  {
@@ -2207,7 +2200,7 @@ import {
2207
2200
 
2208
2201
  // src/genre-tree/song/SongPanelContent.tsx
2209
2202
  import { useState as useState9 } from "react";
2210
- import { Pause as Pause3, Play as Play4 } from "lucide-react";
2203
+ import { Pause as Pause3, Play as Play3 } from "lucide-react";
2211
2204
  import { ActionBand as ActionBand3, ActionButton as ActionButton5, FieldList as FieldList2, PANEL_LABEL_CLASS, PanelBleed as PanelBleed3, PanelSection as PanelSection6, Skeleton as Skeleton6 } from "@behindthemusictree/ui";
2212
2205
  import { PlayStates as PlayStates3, usePlayer as usePlayer10 } from "@behindthemusictree/app-kit/player";
2213
2206
  import {
@@ -2306,7 +2299,7 @@ function SongPanelContent(props) {
2306
2299
  /* @__PURE__ */ jsx36(
2307
2300
  ActionButton5,
2308
2301
  {
2309
- icon: isPlaying ? /* @__PURE__ */ jsx36(Pause3, { "aria-hidden": "true", className: "w-5 h-5" }) : /* @__PURE__ */ jsx36(Play4, { "aria-hidden": "true", className: "w-5 h-5" }),
2302
+ icon: isPlaying ? /* @__PURE__ */ jsx36(Pause3, { "aria-hidden": "true", className: "w-5 h-5" }) : /* @__PURE__ */ jsx36(Play3, { "aria-hidden": "true", className: "w-5 h-5" }),
2310
2303
  label: isPlaying ? "Pause" : "Play",
2311
2304
  disabled: !!unplayableReason,
2312
2305
  title: unplayableReason ?? void 0,
@@ -2678,6 +2671,7 @@ function GenreTreeView({
2678
2671
  !overlayPanel && hasSelectedGenreNode ? selectedNodeId : null,
2679
2672
  resolveStyle
2680
2673
  );
2674
+ const treeStyles = useMemo8(() => toGenreNodeStyles(relations, visibleGenrePlaylists), [relations, visibleGenrePlaylists]);
2681
2675
  const [selectionHistory, setSelectionHistory] = useState10({ current: selectedGenreUuid, previous: null });
2682
2676
  if (selectionHistory.current !== selectedGenreUuid) {
2683
2677
  setSelectionHistory({ current: selectedGenreUuid, previous: selectionHistory.current ?? selectionHistory.previous });
@@ -2723,7 +2717,7 @@ function GenreTreeView({
2723
2717
  selectGenre(uuid);
2724
2718
  },
2725
2719
  expanded: isExpanded,
2726
- treeRelations: relations,
2720
+ treeStyles,
2727
2721
  playback,
2728
2722
  genrePlaylist: selectedGenrePlaylist,
2729
2723
  band: {
@@ -3263,7 +3257,7 @@ import {
3263
3257
  import { PanelEdgeTab } from "@behindthemusictree/ui";
3264
3258
 
3265
3259
  // src/genre-tree/PlayerControls.tsx
3266
- import { Pause as Pause4, Play as Play5, SkipBack, SkipForward, Volume2, VolumeX } from "lucide-react";
3260
+ import { Pause as Pause4, Play as Play4, SkipBack, SkipForward, Volume2, VolumeX } from "lucide-react";
3267
3261
  import { formatTime, useTrackList as useTrackList8 } from "@behindthemusictree/app-kit/genre-tree";
3268
3262
  import { PlayStates as PlayStates4, useCurrentTime, usePlayer as usePlayer11 } from "@behindthemusictree/app-kit/player";
3269
3263
  import { jsx as jsx41, jsxs as jsxs29 } from "react/jsx-runtime";
@@ -3332,7 +3326,7 @@ function PlayerControls() {
3332
3326
  disabled: !isReady,
3333
3327
  onClick: handlePlayPauseAction,
3334
3328
  className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white text-zinc-950 hover:bg-zinc-200 disabled:cursor-not-allowed disabled:opacity-40",
3335
- children: isPlaying ? /* @__PURE__ */ jsx41(Pause4, { "aria-hidden": "true", className: "h-4 w-4", fill: "currentColor" }) : /* @__PURE__ */ jsx41(Play5, { "aria-hidden": "true", className: "h-4 w-4", fill: "currentColor" })
3329
+ children: isPlaying ? /* @__PURE__ */ jsx41(Pause4, { "aria-hidden": "true", className: "h-4 w-4", fill: "currentColor" }) : /* @__PURE__ */ jsx41(Play4, { "aria-hidden": "true", className: "h-4 w-4", fill: "currentColor" })
3336
3330
  }
3337
3331
  ),
3338
3332
  /* @__PURE__ */ jsx41(
@@ -3607,4 +3601,4 @@ export {
3607
3601
  GenreTreeViewSkeleton2 as GenreTreeViewSkeleton,
3608
3602
  GenreTreeOutlineSkeleton
3609
3603
  };
3610
- //# sourceMappingURL=chunk-I2TEOHVG.js.map
3604
+ //# sourceMappingURL=chunk-DPYUE6WD.js.map