@behindthemusictree/genre-tree-view 7.0.0 → 7.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.
- package/dist/index.cjs +185 -206
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.js +175 -201
- package/dist/index.js.map +1 -1
- package/dist/styles.css +9 -9
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -377,11 +377,92 @@ type GenreTreeViewSkeletonProps = {
|
|
|
377
377
|
};
|
|
378
378
|
declare function GenreTreeViewSkeleton({ viewMode }: GenreTreeViewSkeletonProps): react.JSX.Element;
|
|
379
379
|
|
|
380
|
+
declare const TEXT_COLOR = "#18181B";
|
|
381
|
+
declare const ACCENT_TEXT_COLOR = "#FFFFFF";
|
|
382
|
+
declare const ROOT_TINT_RATIO = 0.08;
|
|
383
|
+
/** Blends `hex` into SURFACE_FILL at `ratio` (0-1) and returns an opaque hex color — used for a
|
|
384
|
+
* node's root-color background tint. Opaque (rather than an rgba fill) so the tint reads the
|
|
385
|
+
* same regardless of what the host page renders behind the tree. */
|
|
386
|
+
declare function tintSurface(hex: string, ratio?: number): string;
|
|
380
387
|
/** Maps a root node's wikidata id to its fixed color, or FALLBACK_ROOT_COLOR when unmapped/absent. */
|
|
381
388
|
declare function getGenreTreeColor(wikidataId: string | null | undefined): string;
|
|
382
389
|
declare const DEFAULT_FRAME_WIDTH = 1200;
|
|
383
390
|
declare const DEFAULT_FRAME_HEIGHT = 750;
|
|
384
391
|
|
|
392
|
+
interface NodeToolbarProps {
|
|
393
|
+
node: GenreTreeNode;
|
|
394
|
+
playingNodeId?: string | null;
|
|
395
|
+
playState?: GenreTreePlayState;
|
|
396
|
+
onPlayPause?: (nodeId: string) => void;
|
|
397
|
+
onAddChild?: (parentId: string) => void;
|
|
398
|
+
onRenameRequest?: (node: GenreTreeNode) => void;
|
|
399
|
+
onDeleteRequest?: (node: GenreTreeNode) => void;
|
|
400
|
+
onReparentRequest?: (node: GenreTreeNode) => void;
|
|
401
|
+
additionalActions?: (node: GenreTreeNode) => GenreTreeAction[];
|
|
402
|
+
className?: string;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** A direct child of the panel's node, styled to match exactly how that child renders as its own
|
|
406
|
+
* `gtv-node-rect` out in the tree (solid vs. tinted fill, light vs. dark text) — computed by the
|
|
407
|
+
* caller, since that styling depends on renderer-specific state (e.g. `hideRoot`, pop/core sector)
|
|
408
|
+
* this component has no visibility into. */
|
|
409
|
+
interface InfoPanelChild {
|
|
410
|
+
node: GenreTreeNode;
|
|
411
|
+
fill: string;
|
|
412
|
+
textColor: string;
|
|
413
|
+
}
|
|
414
|
+
interface InfoPanelProps {
|
|
415
|
+
node: GenreTreeNode;
|
|
416
|
+
/** Fill and text color matching how `node` itself renders as its own `gtv-node-rect` out in the
|
|
417
|
+
* tree — computed by the caller for the same reason as `InfoPanelChild`'s (see above). */
|
|
418
|
+
fill: string;
|
|
419
|
+
textColor: string;
|
|
420
|
+
/** `node`'s own parent, styled the same way as `InfoPanelChild` — null for a root, which has
|
|
421
|
+
* none. */
|
|
422
|
+
parentNode: InfoPanelChild | null;
|
|
423
|
+
childNodes: InfoPanelChild[];
|
|
424
|
+
/** `node`'s ancestors root-first, including its immediate parent. Empty for a root. */
|
|
425
|
+
ancestorNodes: InfoPanelChild[];
|
|
426
|
+
side: "left" | "right";
|
|
427
|
+
onClose: () => void;
|
|
428
|
+
/** Fired when the parent chip or a child chip is clicked, with that node's id — the caller
|
|
429
|
+
* navigates the panel (and the tree's own selection/centering) to it. */
|
|
430
|
+
onSelectNode: (nodeId: string) => void;
|
|
431
|
+
/** Reselects the previously selected node; the button is hidden when omitted. */
|
|
432
|
+
onPrevious?: () => void;
|
|
433
|
+
previousLabel?: string;
|
|
434
|
+
/** See GenreTreeProps.hideInfoPanelClose. */
|
|
435
|
+
hideClose?: boolean;
|
|
436
|
+
/** See GenreTreeProps.hideInfoPanelTitle. */
|
|
437
|
+
hideTitle?: boolean;
|
|
438
|
+
/** See GenreTreeProps.itemCountLabel. */
|
|
439
|
+
itemCountLabel: string;
|
|
440
|
+
/** See GenreTreeProps.renderInfoPanelBody. */
|
|
441
|
+
renderInfoPanelBody?: (node: GenreTreeNode, sections: InfoPanelSections) => InfoPanelBody;
|
|
442
|
+
/** When set, shows a "Zoom in" action that fires it. */
|
|
443
|
+
onZoomIn?: () => void;
|
|
444
|
+
/** When set, renders the node's play/add-child/rename/reparent/delete actions below the
|
|
445
|
+
* header. Omitted when the toolbar is disabled (see GenreTreeProps.showToolbar). */
|
|
446
|
+
actions?: Omit<NodeToolbarProps, "node" | "className">;
|
|
447
|
+
/** See GenreTreeProps.readOnly. */
|
|
448
|
+
readOnly?: boolean;
|
|
449
|
+
/** See GenreTreeProps.renderDangerZone. */
|
|
450
|
+
renderDangerZone?: (node: GenreTreeNode) => ReactNode;
|
|
451
|
+
/** See GenreTreeProps.expanded. */
|
|
452
|
+
expanded?: boolean;
|
|
453
|
+
/** See GenreTreeProps.onExpandedChange. */
|
|
454
|
+
onExpandedChange?: (on: boolean) => void;
|
|
455
|
+
/** See GenreTreeProps.collapsed. */
|
|
456
|
+
collapsed?: boolean;
|
|
457
|
+
/** See GenreTreeProps.hideExpandButton. */
|
|
458
|
+
hideExpandButton?: boolean;
|
|
459
|
+
}
|
|
460
|
+
/** Displays a clicked node's own fields, its parent, and its direct children — no fetching, no
|
|
461
|
+
* mutation, purely presentational (see ARCHITECTURE.md). Anchored to `side`
|
|
462
|
+
* (see use-node-info-panel.ts/info-panel-geometry.ts for how that's decided) by the caller's own
|
|
463
|
+
* layout, not by this component. */
|
|
464
|
+
declare function InfoPanel({ node, fill, textColor, parentNode, childNodes, ancestorNodes, side, onClose, onSelectNode, onPrevious, previousLabel, renderInfoPanelBody, hideClose, hideTitle, itemCountLabel, onZoomIn, actions, readOnly, renderDangerZone, expanded, onExpandedChange, collapsed, hideExpandButton, }: InfoPanelProps): react.JSX.Element;
|
|
465
|
+
|
|
385
466
|
interface GenreTreeRootGroup {
|
|
386
467
|
root: GenreTreeNode;
|
|
387
468
|
nodes: GenreTreeNode[];
|
|
@@ -399,4 +480,4 @@ declare function groupNodesByRoot(nodes: GenreTreeNode[]): GenreTreeRootGroup[];
|
|
|
399
480
|
*/
|
|
400
481
|
declare function isZoomableNode(nodes: readonly GenreTreeNode[], id: string): boolean;
|
|
401
482
|
|
|
402
|
-
export { DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, type FocusChangeReason, GenreTree, type GenreTreeAction, type GenreTreeNode, GenreTreeOutline, type GenreTreeOutlineProps, GenreTreeOutlineSkeleton, type GenreTreeOverlayPanel, type GenreTreePlayState, type GenreTreeProps, type GenreTreeRootGroup, GenreTreeSkeleton, type GenreTreeViewMode, GenreTreeViewSkeleton, type GenreTreeViewSkeletonProps, type GenreTreeViewport, GenreTreeWheel, type GenreTreeWheelProps, GenreTreeWheelRadial, GenreTreeWheelRadialPopCore, type GenreTreeWheelRadialPopCoreProps, type GenreTreeWheelRadialProps, GenreTreeWheelRight, type GenreTreeWheelRightProps, GenreTreeWheelSkeleton, type InfoPanelBody, type InfoPanelSections, type TreeOrientation, type WheelZoomMode, type ZoomControlsVisibility, getGenreTreeColor, groupNodesByRoot, isZoomableNode };
|
|
483
|
+
export { ACCENT_TEXT_COLOR, DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, type FocusChangeReason, GenreTree, type GenreTreeAction, type GenreTreeNode, GenreTreeOutline, type GenreTreeOutlineProps, GenreTreeOutlineSkeleton, type GenreTreeOverlayPanel, type GenreTreePlayState, type GenreTreeProps, type GenreTreeRootGroup, GenreTreeSkeleton, type GenreTreeViewMode, GenreTreeViewSkeleton, type GenreTreeViewSkeletonProps, type GenreTreeViewport, GenreTreeWheel, type GenreTreeWheelProps, GenreTreeWheelRadial, GenreTreeWheelRadialPopCore, type GenreTreeWheelRadialPopCoreProps, type GenreTreeWheelRadialProps, GenreTreeWheelRight, type GenreTreeWheelRightProps, GenreTreeWheelSkeleton, InfoPanel, type InfoPanelBody, type InfoPanelChild, type InfoPanelProps, type InfoPanelSections, ROOT_TINT_RATIO, TEXT_COLOR, type TreeOrientation, type WheelZoomMode, type ZoomControlsVisibility, getGenreTreeColor, groupNodesByRoot, isZoomableNode, tintSurface };
|
package/dist/index.d.ts
CHANGED
|
@@ -377,11 +377,92 @@ type GenreTreeViewSkeletonProps = {
|
|
|
377
377
|
};
|
|
378
378
|
declare function GenreTreeViewSkeleton({ viewMode }: GenreTreeViewSkeletonProps): react.JSX.Element;
|
|
379
379
|
|
|
380
|
+
declare const TEXT_COLOR = "#18181B";
|
|
381
|
+
declare const ACCENT_TEXT_COLOR = "#FFFFFF";
|
|
382
|
+
declare const ROOT_TINT_RATIO = 0.08;
|
|
383
|
+
/** Blends `hex` into SURFACE_FILL at `ratio` (0-1) and returns an opaque hex color — used for a
|
|
384
|
+
* node's root-color background tint. Opaque (rather than an rgba fill) so the tint reads the
|
|
385
|
+
* same regardless of what the host page renders behind the tree. */
|
|
386
|
+
declare function tintSurface(hex: string, ratio?: number): string;
|
|
380
387
|
/** Maps a root node's wikidata id to its fixed color, or FALLBACK_ROOT_COLOR when unmapped/absent. */
|
|
381
388
|
declare function getGenreTreeColor(wikidataId: string | null | undefined): string;
|
|
382
389
|
declare const DEFAULT_FRAME_WIDTH = 1200;
|
|
383
390
|
declare const DEFAULT_FRAME_HEIGHT = 750;
|
|
384
391
|
|
|
392
|
+
interface NodeToolbarProps {
|
|
393
|
+
node: GenreTreeNode;
|
|
394
|
+
playingNodeId?: string | null;
|
|
395
|
+
playState?: GenreTreePlayState;
|
|
396
|
+
onPlayPause?: (nodeId: string) => void;
|
|
397
|
+
onAddChild?: (parentId: string) => void;
|
|
398
|
+
onRenameRequest?: (node: GenreTreeNode) => void;
|
|
399
|
+
onDeleteRequest?: (node: GenreTreeNode) => void;
|
|
400
|
+
onReparentRequest?: (node: GenreTreeNode) => void;
|
|
401
|
+
additionalActions?: (node: GenreTreeNode) => GenreTreeAction[];
|
|
402
|
+
className?: string;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** A direct child of the panel's node, styled to match exactly how that child renders as its own
|
|
406
|
+
* `gtv-node-rect` out in the tree (solid vs. tinted fill, light vs. dark text) — computed by the
|
|
407
|
+
* caller, since that styling depends on renderer-specific state (e.g. `hideRoot`, pop/core sector)
|
|
408
|
+
* this component has no visibility into. */
|
|
409
|
+
interface InfoPanelChild {
|
|
410
|
+
node: GenreTreeNode;
|
|
411
|
+
fill: string;
|
|
412
|
+
textColor: string;
|
|
413
|
+
}
|
|
414
|
+
interface InfoPanelProps {
|
|
415
|
+
node: GenreTreeNode;
|
|
416
|
+
/** Fill and text color matching how `node` itself renders as its own `gtv-node-rect` out in the
|
|
417
|
+
* tree — computed by the caller for the same reason as `InfoPanelChild`'s (see above). */
|
|
418
|
+
fill: string;
|
|
419
|
+
textColor: string;
|
|
420
|
+
/** `node`'s own parent, styled the same way as `InfoPanelChild` — null for a root, which has
|
|
421
|
+
* none. */
|
|
422
|
+
parentNode: InfoPanelChild | null;
|
|
423
|
+
childNodes: InfoPanelChild[];
|
|
424
|
+
/** `node`'s ancestors root-first, including its immediate parent. Empty for a root. */
|
|
425
|
+
ancestorNodes: InfoPanelChild[];
|
|
426
|
+
side: "left" | "right";
|
|
427
|
+
onClose: () => void;
|
|
428
|
+
/** Fired when the parent chip or a child chip is clicked, with that node's id — the caller
|
|
429
|
+
* navigates the panel (and the tree's own selection/centering) to it. */
|
|
430
|
+
onSelectNode: (nodeId: string) => void;
|
|
431
|
+
/** Reselects the previously selected node; the button is hidden when omitted. */
|
|
432
|
+
onPrevious?: () => void;
|
|
433
|
+
previousLabel?: string;
|
|
434
|
+
/** See GenreTreeProps.hideInfoPanelClose. */
|
|
435
|
+
hideClose?: boolean;
|
|
436
|
+
/** See GenreTreeProps.hideInfoPanelTitle. */
|
|
437
|
+
hideTitle?: boolean;
|
|
438
|
+
/** See GenreTreeProps.itemCountLabel. */
|
|
439
|
+
itemCountLabel: string;
|
|
440
|
+
/** See GenreTreeProps.renderInfoPanelBody. */
|
|
441
|
+
renderInfoPanelBody?: (node: GenreTreeNode, sections: InfoPanelSections) => InfoPanelBody;
|
|
442
|
+
/** When set, shows a "Zoom in" action that fires it. */
|
|
443
|
+
onZoomIn?: () => void;
|
|
444
|
+
/** When set, renders the node's play/add-child/rename/reparent/delete actions below the
|
|
445
|
+
* header. Omitted when the toolbar is disabled (see GenreTreeProps.showToolbar). */
|
|
446
|
+
actions?: Omit<NodeToolbarProps, "node" | "className">;
|
|
447
|
+
/** See GenreTreeProps.readOnly. */
|
|
448
|
+
readOnly?: boolean;
|
|
449
|
+
/** See GenreTreeProps.renderDangerZone. */
|
|
450
|
+
renderDangerZone?: (node: GenreTreeNode) => ReactNode;
|
|
451
|
+
/** See GenreTreeProps.expanded. */
|
|
452
|
+
expanded?: boolean;
|
|
453
|
+
/** See GenreTreeProps.onExpandedChange. */
|
|
454
|
+
onExpandedChange?: (on: boolean) => void;
|
|
455
|
+
/** See GenreTreeProps.collapsed. */
|
|
456
|
+
collapsed?: boolean;
|
|
457
|
+
/** See GenreTreeProps.hideExpandButton. */
|
|
458
|
+
hideExpandButton?: boolean;
|
|
459
|
+
}
|
|
460
|
+
/** Displays a clicked node's own fields, its parent, and its direct children — no fetching, no
|
|
461
|
+
* mutation, purely presentational (see ARCHITECTURE.md). Anchored to `side`
|
|
462
|
+
* (see use-node-info-panel.ts/info-panel-geometry.ts for how that's decided) by the caller's own
|
|
463
|
+
* layout, not by this component. */
|
|
464
|
+
declare function InfoPanel({ node, fill, textColor, parentNode, childNodes, ancestorNodes, side, onClose, onSelectNode, onPrevious, previousLabel, renderInfoPanelBody, hideClose, hideTitle, itemCountLabel, onZoomIn, actions, readOnly, renderDangerZone, expanded, onExpandedChange, collapsed, hideExpandButton, }: InfoPanelProps): react.JSX.Element;
|
|
465
|
+
|
|
385
466
|
interface GenreTreeRootGroup {
|
|
386
467
|
root: GenreTreeNode;
|
|
387
468
|
nodes: GenreTreeNode[];
|
|
@@ -399,4 +480,4 @@ declare function groupNodesByRoot(nodes: GenreTreeNode[]): GenreTreeRootGroup[];
|
|
|
399
480
|
*/
|
|
400
481
|
declare function isZoomableNode(nodes: readonly GenreTreeNode[], id: string): boolean;
|
|
401
482
|
|
|
402
|
-
export { DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, type FocusChangeReason, GenreTree, type GenreTreeAction, type GenreTreeNode, GenreTreeOutline, type GenreTreeOutlineProps, GenreTreeOutlineSkeleton, type GenreTreeOverlayPanel, type GenreTreePlayState, type GenreTreeProps, type GenreTreeRootGroup, GenreTreeSkeleton, type GenreTreeViewMode, GenreTreeViewSkeleton, type GenreTreeViewSkeletonProps, type GenreTreeViewport, GenreTreeWheel, type GenreTreeWheelProps, GenreTreeWheelRadial, GenreTreeWheelRadialPopCore, type GenreTreeWheelRadialPopCoreProps, type GenreTreeWheelRadialProps, GenreTreeWheelRight, type GenreTreeWheelRightProps, GenreTreeWheelSkeleton, type InfoPanelBody, type InfoPanelSections, type TreeOrientation, type WheelZoomMode, type ZoomControlsVisibility, getGenreTreeColor, groupNodesByRoot, isZoomableNode };
|
|
483
|
+
export { ACCENT_TEXT_COLOR, DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, type FocusChangeReason, GenreTree, type GenreTreeAction, type GenreTreeNode, GenreTreeOutline, type GenreTreeOutlineProps, GenreTreeOutlineSkeleton, type GenreTreeOverlayPanel, type GenreTreePlayState, type GenreTreeProps, type GenreTreeRootGroup, GenreTreeSkeleton, type GenreTreeViewMode, GenreTreeViewSkeleton, type GenreTreeViewSkeletonProps, type GenreTreeViewport, GenreTreeWheel, type GenreTreeWheelProps, GenreTreeWheelRadial, GenreTreeWheelRadialPopCore, type GenreTreeWheelRadialPopCoreProps, type GenreTreeWheelRadialProps, GenreTreeWheelRight, type GenreTreeWheelRightProps, GenreTreeWheelSkeleton, InfoPanel, type InfoPanelBody, type InfoPanelChild, type InfoPanelProps, type InfoPanelSections, ROOT_TINT_RATIO, TEXT_COLOR, type TreeOrientation, type WheelZoomMode, type ZoomControlsVisibility, getGenreTreeColor, groupNodesByRoot, isZoomableNode, tintSurface };
|