@sanity/ui 1.7.0 → 1.7.2
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.esm.js +7 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tree/__workshop__/index.ts +6 -0
- package/src/components/tree/__workshop__/tabFromElement.tsx +83 -0
- package/src/components/tree/tree.tsx +12 -1
- package/src/components/tree/treeItem.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -8973,6 +8973,7 @@ const Tree = react.memo(react.forwardRef(function Tree2(props, ref) {
|
|
|
8973
8973
|
const {
|
|
8974
8974
|
children,
|
|
8975
8975
|
space = 1,
|
|
8976
|
+
onFocus,
|
|
8976
8977
|
...restProps
|
|
8977
8978
|
} = props;
|
|
8978
8979
|
const forwardedRef = useForwardedRef(ref);
|
|
@@ -9104,6 +9105,10 @@ const Tree = react.memo(react.forwardRef(function Tree2(props, ref) {
|
|
|
9104
9105
|
return;
|
|
9105
9106
|
}
|
|
9106
9107
|
}, [itemElements]);
|
|
9108
|
+
const handleFocus = react.useCallback(event => {
|
|
9109
|
+
setFocusedElement(event.target);
|
|
9110
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
9111
|
+
}, [onFocus]);
|
|
9107
9112
|
react.useEffect(() => {
|
|
9108
9113
|
if (!forwardedRef.current) return;
|
|
9109
9114
|
const _itemElements = Array.from(forwardedRef.current.querySelectorAll('[data-ui="TreeItem"]'));
|
|
@@ -9115,6 +9120,7 @@ const Tree = react.memo(react.forwardRef(function Tree2(props, ref) {
|
|
|
9115
9120
|
as: "ul",
|
|
9116
9121
|
"data-ui": "Tree",
|
|
9117
9122
|
...restProps,
|
|
9123
|
+
onFocus: handleFocus,
|
|
9118
9124
|
onKeyDown: handleKeyDown,
|
|
9119
9125
|
ref: forwardedRef,
|
|
9120
9126
|
role: "tree",
|
|
@@ -9223,7 +9229,7 @@ const TreeItem = react.memo(function TreeItem2(props) {
|
|
|
9223
9229
|
const handleClick = react.useCallback(event => {
|
|
9224
9230
|
if (onClick) onClick(event);
|
|
9225
9231
|
const target = event.target;
|
|
9226
|
-
if (target instanceof HTMLElement && (target.getAttribute("data-ui") === "
|
|
9232
|
+
if (target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]'))) {
|
|
9227
9233
|
event.stopPropagation();
|
|
9228
9234
|
setExpanded(itemKey, !expanded);
|
|
9229
9235
|
setFocusedElement(rootRef.current);
|