@sanity/ui 2.3.4-canary.0 → 2.3.4
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 +25 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -25
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +38 -0
- package/src/core/components/menu/__workshop__/index.ts +5 -0
- package/src/core/components/menu/menuButton.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +3 -2
- package/src/core/primitives/helpers.ts +11 -0
- package/src/core/primitives/inline/inline.tsx +6 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback,
|
|
4
|
-
import ReactIs, { isValidElementType } from "react-is";
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, cloneElement, isValidElement, Component, memo, useReducer, Children, Fragment as Fragment$1, startTransition } from "react";
|
|
4
|
+
import ReactIs, { isElement as isElement$1, isFragment, isValidElementType } from "react-is";
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
|
|
6
6
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
|
|
7
7
|
import Refractor from "react-refractor";
|
|
@@ -1528,7 +1528,13 @@ const Root$A = styled.div(
|
|
|
1528
1528
|
[size2]
|
|
1529
1529
|
);
|
|
1530
1530
|
return /* @__PURE__ */ jsx(Root$A, { $size: size2, "data-ui": "AvatarCounter", ref, children: /* @__PURE__ */ jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }) });
|
|
1531
|
-
})
|
|
1531
|
+
});
|
|
1532
|
+
function childrenToElementArray(children) {
|
|
1533
|
+
return (Array.isArray(children) ? children : [children]).filter(
|
|
1534
|
+
(node) => isElement$1(node) || isFragment(node) || typeof node == "string"
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
const BASE_STYLES = css`
|
|
1532
1538
|
white-space: nowrap;
|
|
1533
1539
|
|
|
1534
1540
|
& > div {
|
|
@@ -1559,7 +1565,7 @@ const Root$z = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle), Ava
|
|
|
1559
1565
|
maxLength: maxLengthProp = 4,
|
|
1560
1566
|
size: sizeProp = 1,
|
|
1561
1567
|
...restProps
|
|
1562
|
-
} = props, children =
|
|
1568
|
+
} = props, children = childrenToElementArray(childrenProp).filter(
|
|
1563
1569
|
(child) => typeof child != "string"
|
|
1564
1570
|
), maxLength = Math.max(maxLengthProp, 0), size2 = useArrayProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
|
|
1565
1571
|
return /* @__PURE__ */ jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
|
|
@@ -2634,7 +2640,7 @@ function inlineSpaceStyle(props) {
|
|
|
2634
2640
|
}
|
|
2635
2641
|
const Root$m = styled(Box)(inlineBaseStyle, inlineSpaceStyle), Inline = forwardRef(function(props, ref) {
|
|
2636
2642
|
const { as, children: childrenProp, space, ...restProps } = props, children = useMemo(
|
|
2637
|
-
() =>
|
|
2643
|
+
() => childrenToElementArray(childrenProp).filter(Boolean).map((child, idx) => /* @__PURE__ */ jsx("div", { children: child }, idx)),
|
|
2638
2644
|
[childrenProp]
|
|
2639
2645
|
);
|
|
2640
2646
|
return /* @__PURE__ */ jsx(
|
|
@@ -5605,17 +5611,20 @@ const Root$5 = styled(Box)`
|
|
|
5605
5611
|
shouldFocus
|
|
5606
5612
|
]
|
|
5607
5613
|
), menu = menuProp && cloneElement(menuProp, menuProps), ref = useRef(null), button = useMemo(
|
|
5608
|
-
() =>
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5614
|
+
() => {
|
|
5615
|
+
var _a;
|
|
5616
|
+
return buttonProp && cloneElement(buttonProp, {
|
|
5617
|
+
"data-ui": "MenuButton",
|
|
5618
|
+
id,
|
|
5619
|
+
onClick: handleButtonClick,
|
|
5620
|
+
onKeyDown: handleButtonKeyDown,
|
|
5621
|
+
onMouseDown: handleMouseDown,
|
|
5622
|
+
"aria-haspopup": !0,
|
|
5623
|
+
"aria-expanded": open,
|
|
5624
|
+
ref,
|
|
5625
|
+
selected: (_a = buttonProp.props.selected) != null ? _a : open
|
|
5626
|
+
});
|
|
5627
|
+
},
|
|
5619
5628
|
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]
|
|
5620
5629
|
);
|
|
5621
5630
|
useImperativeHandle(
|