@sanity/ui 1.6.0 → 1.7.1
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.d.ts +4 -0
- package/dist/index.esm.js +8 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -0
- 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 +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -2714,6 +2714,10 @@ export declare interface TreeItemProps {
|
|
|
2714
2714
|
expanded?: boolean
|
|
2715
2715
|
fontSize?: number | number[]
|
|
2716
2716
|
icon?: React.ElementType
|
|
2717
|
+
/**
|
|
2718
|
+
* Allows passing a custom element type to the link component
|
|
2719
|
+
*/
|
|
2720
|
+
linkAs?: BoxProps['as']
|
|
2717
2721
|
padding?: number | number[]
|
|
2718
2722
|
space?: number | number[]
|
|
2719
2723
|
text?: React.ReactNode
|
package/dist/index.esm.js
CHANGED
|
@@ -8960,6 +8960,7 @@ const Tree = memo(forwardRef(function Tree2(props, ref) {
|
|
|
8960
8960
|
const {
|
|
8961
8961
|
children,
|
|
8962
8962
|
space = 1,
|
|
8963
|
+
onFocus,
|
|
8963
8964
|
...restProps
|
|
8964
8965
|
} = props;
|
|
8965
8966
|
const forwardedRef = useForwardedRef(ref);
|
|
@@ -9091,6 +9092,10 @@ const Tree = memo(forwardRef(function Tree2(props, ref) {
|
|
|
9091
9092
|
return;
|
|
9092
9093
|
}
|
|
9093
9094
|
}, [itemElements]);
|
|
9095
|
+
const handleFocus = useCallback(event => {
|
|
9096
|
+
setFocusedElement(event.target);
|
|
9097
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
9098
|
+
}, [onFocus]);
|
|
9094
9099
|
useEffect(() => {
|
|
9095
9100
|
if (!forwardedRef.current) return;
|
|
9096
9101
|
const _itemElements = Array.from(forwardedRef.current.querySelectorAll('[data-ui="TreeItem"]'));
|
|
@@ -9102,6 +9107,7 @@ const Tree = memo(forwardRef(function Tree2(props, ref) {
|
|
|
9102
9107
|
as: "ul",
|
|
9103
9108
|
"data-ui": "Tree",
|
|
9104
9109
|
...restProps,
|
|
9110
|
+
onFocus: handleFocus,
|
|
9105
9111
|
onKeyDown: handleKeyDown,
|
|
9106
9112
|
ref: forwardedRef,
|
|
9107
9113
|
role: "tree",
|
|
@@ -9175,6 +9181,7 @@ const TreeItem = memo(function TreeItem2(props) {
|
|
|
9175
9181
|
href,
|
|
9176
9182
|
icon,
|
|
9177
9183
|
id: idProp,
|
|
9184
|
+
linkAs,
|
|
9178
9185
|
muted,
|
|
9179
9186
|
onClick,
|
|
9180
9187
|
padding = 3,
|
|
@@ -9272,6 +9279,7 @@ const TreeItem = memo(function TreeItem2(props) {
|
|
|
9272
9279
|
children: [/* @__PURE__ */jsx(TreeItemBox, {
|
|
9273
9280
|
$level: tree.level,
|
|
9274
9281
|
"aria-expanded": expanded,
|
|
9282
|
+
as: linkAs,
|
|
9275
9283
|
"data-ui": "TreeItem__box",
|
|
9276
9284
|
href,
|
|
9277
9285
|
ref: treeitemRef,
|