From 4b14e1189a6232bbc5fe39a3a55cf65ea064ba2f Mon Sep 17 00:00:00 2001 From: Lukas Bach Date: Thu, 18 Jan 2024 21:44:51 +0100 Subject: [PATCH] feat: expose internal render methods and hooks (#313) --- next-release-notes.md | 3 ++- packages/core/src/index.ts | 10 ++++++++++ packages/core/src/treeItem/TreeItemChildren.tsx | 4 ++-- .../src/treeItem/{TreeItem.tsx => TreeItemElement.tsx} | 2 +- packages/core/src/treeItem/useTreeItemRenderContext.ts | 1 - 5 files changed, 15 insertions(+), 5 deletions(-) rename packages/core/src/treeItem/{TreeItem.tsx => TreeItemElement.tsx} (98%) diff --git a/next-release-notes.md b/next-release-notes.md index 97fafff81..8ae0c8fc3 100644 --- a/next-release-notes.md +++ b/next-release-notes.md @@ -1,2 +1,3 @@ ### Bug Fixes and Improvements -- Maintain original item order when dropping items (#315) \ No newline at end of file +- Maintain original item order when dropping items (#315) +- Expose some hooks and internally used components in the public API that were hidden before (#313) \ No newline at end of file diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 5039f99ab..34a3feeac 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,6 +1,16 @@ +import { TreeItemElement } from './treeItem/TreeItemElement'; +import { TreeItemChildren } from './treeItem/TreeItemChildren'; + export * from './controlledEnvironment/ControlledTreeEnvironment'; export * from './tree/Tree'; export * from './uncontrolledEnvironment/UncontrolledTreeEnvironment'; export * from './uncontrolledEnvironment/StaticTreeDataProvider'; export * from './types'; export * from './renderers'; +export * from './treeItem/useTreeItemRenderContext'; +export * from './controlledEnvironment/useControlledTreeEnvironmentProps'; + +export const INTERNALS = { + TreeItemElement, + TreeItemChildren, +}; diff --git a/packages/core/src/treeItem/TreeItemChildren.tsx b/packages/core/src/treeItem/TreeItemChildren.tsx index 4491e5697..af60f4dc6 100644 --- a/packages/core/src/treeItem/TreeItemChildren.tsx +++ b/packages/core/src/treeItem/TreeItemChildren.tsx @@ -1,5 +1,5 @@ import React, { HTMLProps } from 'react'; -import { TreeItem } from './TreeItem'; +import { TreeItemElement } from './TreeItemElement'; import { TreeItemIndex } from '../types'; import { useTree } from '../tree/Tree'; @@ -14,7 +14,7 @@ export const TreeItemChildren = (props: { for (const child of props.children) { childElements.push( - + ); } diff --git a/packages/core/src/treeItem/TreeItem.tsx b/packages/core/src/treeItem/TreeItemElement.tsx similarity index 98% rename from packages/core/src/treeItem/TreeItem.tsx rename to packages/core/src/treeItem/TreeItemElement.tsx index 89cc26dfb..f006a1a4f 100644 --- a/packages/core/src/treeItem/TreeItem.tsx +++ b/packages/core/src/treeItem/TreeItemElement.tsx @@ -7,7 +7,7 @@ import { useTreeEnvironment } from '../controlledEnvironment/ControlledTreeEnvir import { useTreeItemRenderContext } from './useTreeItemRenderContext'; import { TreeItemRenamingInput } from './TreeItemRenamingInput'; -export const TreeItem = (props: { +export const TreeItemElement = (props: { itemIndex: TreeItemIndex; depth: number; }): JSX.Element => { diff --git a/packages/core/src/treeItem/useTreeItemRenderContext.ts b/packages/core/src/treeItem/useTreeItemRenderContext.ts index d863d7569..1a27692ba 100644 --- a/packages/core/src/treeItem/useTreeItemRenderContext.ts +++ b/packages/core/src/treeItem/useTreeItemRenderContext.ts @@ -202,7 +202,6 @@ export const useTreeItemRenderContext = (item?: TreeItem) => { }, 'aria-hidden': true, tabIndex: -1, - // TODO alternative interaction modes }; const viewStateFlags = !viewState