@sanity/ui 2.0.0-beta.1 → 2.0.0-beta.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.d.ts +1 -1
- package/dist/index.esm.js +92 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +92 -80
- package/dist/index.js.map +1 -1
- package/dist/theme.esm.js +15 -5
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +15 -5
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/core/__workshop__/constants.ts +3 -2
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/stack.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +14 -4
- package/src/core/primitives/avatar/avatarCounter.tsx +16 -5
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/tooltip/tooltip.tsx +1 -1
- package/src/core/types/avatar.ts +1 -1
- package/src/theme/defaults/config.ts +1 -0
- package/src/theme/defaults/fonts.ts +13 -5
package/dist/index.js
CHANGED
|
@@ -1827,14 +1827,14 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
|
|
|
1827
1827
|
arrowPosition: arrowPositionProp,
|
|
1828
1828
|
animateArrowFrom,
|
|
1829
1829
|
status = "online",
|
|
1830
|
-
size: sizeProp =
|
|
1830
|
+
size: sizeProp = 1,
|
|
1831
1831
|
...restProps
|
|
1832
1832
|
} = props;
|
|
1833
|
-
const as = ReactIs__default.default.isValidElementType(asProp) ? asProp : "div";
|
|
1834
|
-
const size = useArrayProp(sizeProp);
|
|
1835
1833
|
const {
|
|
1836
1834
|
avatar
|
|
1837
1835
|
} = useTheme_v2();
|
|
1836
|
+
const as = ReactIs__default.default.isValidElementType(asProp) ? asProp : "div";
|
|
1837
|
+
const size = useArrayProp(sizeProp);
|
|
1838
1838
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0];
|
|
1839
1839
|
const _sizeRem = avatarSize.size;
|
|
1840
1840
|
const _radius = _sizeRem / 2;
|
|
@@ -1856,7 +1856,12 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
|
|
|
1856
1856
|
onImageLoadError(new Error("Avatar: the image failed to load"));
|
|
1857
1857
|
}
|
|
1858
1858
|
}, [onImageLoadError]);
|
|
1859
|
-
const initialsSize = react.useMemo(() => size.map(s =>
|
|
1859
|
+
const initialsSize = react.useMemo(() => size.map(s => {
|
|
1860
|
+
if (s === 1) return 1;
|
|
1861
|
+
if (s === 2) return 3;
|
|
1862
|
+
if (s === 3) return 5;
|
|
1863
|
+
return 0;
|
|
1864
|
+
}), [size]);
|
|
1860
1865
|
return /* @__PURE__ */jsxRuntime.jsxs(Root$C, {
|
|
1861
1866
|
as,
|
|
1862
1867
|
"data-as": typeof as === "string" ? as : void 0,
|
|
@@ -1919,6 +1924,7 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
|
|
|
1919
1924
|
children: /* @__PURE__ */jsxRuntime.jsx(InitialsLabel, {
|
|
1920
1925
|
forwardedAs: "span",
|
|
1921
1926
|
size: initialsSize,
|
|
1927
|
+
weight: "medium",
|
|
1922
1928
|
children: initials
|
|
1923
1929
|
})
|
|
1924
1930
|
})
|
|
@@ -1930,62 +1936,7 @@ var __defProp$B = Object.defineProperty;
|
|
|
1930
1936
|
var __template$A = (cooked, raw) => __freeze$A(__defProp$B(cooked, "raw", {
|
|
1931
1937
|
value: __freeze$A(raw || cooked.slice())
|
|
1932
1938
|
}));
|
|
1933
|
-
var _a$A
|
|
1934
|
-
function textBaseStyle(props) {
|
|
1935
|
-
const {
|
|
1936
|
-
$accent,
|
|
1937
|
-
$muted
|
|
1938
|
-
} = props;
|
|
1939
|
-
const {
|
|
1940
|
-
font
|
|
1941
|
-
} = theme.getTheme_v2(props.theme);
|
|
1942
|
-
return styled.css(_c$a || (_c$a = __template$A(["\n color: var(--card-fg-color);\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n background-color: var(--card-code-bg-color);\n color: var(--card-code-fg-color);\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & strong {\n font-weight: ", ";\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n color: var(--card-icon-color);\n\n & path {\n vector-effect: non-scaling-stroke !important;\n }\n }\n "])), $accent && styled.css(_a$A || (_a$A = __template$A(["\n color: var(--card-accent-fg-color);\n "]))), $muted && styled.css(_b$l || (_b$l = __template$A(["\n color: var(--card-muted-fg-color);\n "]))), font.code.family, font.text.weights.bold);
|
|
1943
|
-
}
|
|
1944
|
-
var __freeze$z = Object.freeze;
|
|
1945
|
-
var __defProp$A = Object.defineProperty;
|
|
1946
|
-
var __template$z = (cooked, raw) => __freeze$z(__defProp$A(cooked, "raw", {
|
|
1947
|
-
value: __freeze$z(raw || cooked.slice())
|
|
1948
|
-
}));
|
|
1949
|
-
var _a$z;
|
|
1950
|
-
const Root$B = styled__default.default.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
|
|
1951
|
-
const SpanWithTextOverflow$1 = styled__default.default.span(_a$z || (_a$z = __template$z(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"])));
|
|
1952
|
-
const Text = react.forwardRef(function Text2(props, ref) {
|
|
1953
|
-
const {
|
|
1954
|
-
accent = false,
|
|
1955
|
-
align,
|
|
1956
|
-
children: childrenProp,
|
|
1957
|
-
muted = false,
|
|
1958
|
-
size = 2,
|
|
1959
|
-
textOverflow,
|
|
1960
|
-
weight,
|
|
1961
|
-
...restProps
|
|
1962
|
-
} = props;
|
|
1963
|
-
let children = childrenProp;
|
|
1964
|
-
if (textOverflow === "ellipsis") {
|
|
1965
|
-
children = /* @__PURE__ */jsxRuntime.jsx(SpanWithTextOverflow$1, {
|
|
1966
|
-
children
|
|
1967
|
-
});
|
|
1968
|
-
}
|
|
1969
|
-
return /* @__PURE__ */jsxRuntime.jsx(Root$B, {
|
|
1970
|
-
"data-ui": "Text",
|
|
1971
|
-
...restProps,
|
|
1972
|
-
$accent: accent,
|
|
1973
|
-
$align: useArrayProp(align),
|
|
1974
|
-
$muted: muted,
|
|
1975
|
-
ref,
|
|
1976
|
-
$size: useArrayProp(size),
|
|
1977
|
-
$weight: weight,
|
|
1978
|
-
children: /* @__PURE__ */jsxRuntime.jsx("span", {
|
|
1979
|
-
children
|
|
1980
|
-
})
|
|
1981
|
-
});
|
|
1982
|
-
});
|
|
1983
|
-
var __freeze$y = Object.freeze;
|
|
1984
|
-
var __defProp$z = Object.defineProperty;
|
|
1985
|
-
var __template$y = (cooked, raw) => __freeze$y(__defProp$z(cooked, "raw", {
|
|
1986
|
-
value: __freeze$y(raw || cooked.slice())
|
|
1987
|
-
}));
|
|
1988
|
-
var _a$y;
|
|
1939
|
+
var _a$A;
|
|
1989
1940
|
function _responsiveAvatarCounterSizeStyle(props) {
|
|
1990
1941
|
const {
|
|
1991
1942
|
avatar,
|
|
@@ -2005,23 +1956,28 @@ function _avatarCounterBaseStyle(props) {
|
|
|
2005
1956
|
const {
|
|
2006
1957
|
space
|
|
2007
1958
|
} = theme.getTheme_v2(props.theme);
|
|
2008
|
-
return styled.css(_a$
|
|
1959
|
+
return styled.css(_a$A || (_a$A = __template$A(["\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n user-select: none;\n color: inherit;\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n inset 0 0 0 1px var(--card-hairline-hard-color);\n padding: 0 ", ";\n\n &:not([hidden]) {\n display: flex;\n }\n "])), rem(space[2]));
|
|
2009
1960
|
}
|
|
2010
|
-
const Root$
|
|
1961
|
+
const Root$B = styled__default.default.div(_responsiveAvatarCounterSizeStyle, _avatarCounterBaseStyle);
|
|
2011
1962
|
const AvatarCounter = react.forwardRef(function AvatarCounter2(props, ref) {
|
|
2012
1963
|
const {
|
|
2013
1964
|
count,
|
|
2014
|
-
size: sizeProp =
|
|
1965
|
+
size: sizeProp = 1
|
|
2015
1966
|
} = props;
|
|
2016
1967
|
const size = useArrayProp(sizeProp);
|
|
2017
|
-
const
|
|
2018
|
-
|
|
1968
|
+
const fontSize = react.useMemo(() => size.map(s => {
|
|
1969
|
+
if (s === 1) return 1;
|
|
1970
|
+
if (s === 2) return 3;
|
|
1971
|
+
if (s === 3) return 5;
|
|
1972
|
+
return 0;
|
|
1973
|
+
}), [size]);
|
|
1974
|
+
return /* @__PURE__ */jsxRuntime.jsx(Root$B, {
|
|
2019
1975
|
$size: size,
|
|
2020
1976
|
"data-ui": "AvatarCounter",
|
|
2021
1977
|
ref,
|
|
2022
|
-
children: /* @__PURE__ */jsxRuntime.jsx(
|
|
1978
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Label, {
|
|
2023
1979
|
as: "span",
|
|
2024
|
-
size:
|
|
1980
|
+
size: fontSize,
|
|
2025
1981
|
weight: "medium",
|
|
2026
1982
|
children: count
|
|
2027
1983
|
})
|
|
@@ -2031,13 +1987,13 @@ function childrenToElementArray(children) {
|
|
|
2031
1987
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
2032
1988
|
return childrenArray.filter(node => ReactIs.isElement(node) || ReactIs.isFragment(node) || typeof node === "string");
|
|
2033
1989
|
}
|
|
2034
|
-
var __freeze$
|
|
2035
|
-
var __defProp$
|
|
2036
|
-
var __template$
|
|
2037
|
-
value: __freeze$
|
|
1990
|
+
var __freeze$z = Object.freeze;
|
|
1991
|
+
var __defProp$A = Object.defineProperty;
|
|
1992
|
+
var __template$z = (cooked, raw) => __freeze$z(__defProp$A(cooked, "raw", {
|
|
1993
|
+
value: __freeze$z(raw || cooked.slice())
|
|
2038
1994
|
}));
|
|
2039
|
-
var _a$
|
|
2040
|
-
const BASE_STYLES = styled.css(_a$
|
|
1995
|
+
var _a$z;
|
|
1996
|
+
const BASE_STYLES = styled.css(_a$z || (_a$z = __template$z(["\n white-space: nowrap;\n\n & > div {\n vertical-align: top;\n\n &:not([hidden]) {\n display: inline-block;\n }\n }\n"])));
|
|
2041
1997
|
function avatarStackStyle() {
|
|
2042
1998
|
return BASE_STYLES;
|
|
2043
1999
|
}
|
|
@@ -2056,12 +2012,12 @@ function responsiveAvatarStackSizeStyle(props) {
|
|
|
2056
2012
|
};
|
|
2057
2013
|
});
|
|
2058
2014
|
}
|
|
2059
|
-
const Root$
|
|
2015
|
+
const Root$A = styled__default.default.div(responsiveAvatarStackSizeStyle, avatarStackStyle);
|
|
2060
2016
|
const AvatarStack = react.forwardRef(function AvatarStack2(props, ref) {
|
|
2061
2017
|
const {
|
|
2062
2018
|
children: childrenProp,
|
|
2063
2019
|
maxLength: maxLengthProp = 4,
|
|
2064
|
-
size: sizeProp =
|
|
2020
|
+
size: sizeProp = 1,
|
|
2065
2021
|
...restProps
|
|
2066
2022
|
} = props;
|
|
2067
2023
|
const children = childrenToElementArray(childrenProp).filter(child => typeof child !== "string");
|
|
@@ -2071,14 +2027,15 @@ const AvatarStack = react.forwardRef(function AvatarStack2(props, ref) {
|
|
|
2071
2027
|
const visibleCount = maxLength - 1;
|
|
2072
2028
|
const extraCount = len - visibleCount;
|
|
2073
2029
|
const visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
|
|
2074
|
-
return /* @__PURE__ */jsxRuntime.jsxs(Root$
|
|
2030
|
+
return /* @__PURE__ */jsxRuntime.jsxs(Root$A, {
|
|
2075
2031
|
"data-ui": "AvatarStack",
|
|
2076
2032
|
...restProps,
|
|
2077
2033
|
ref,
|
|
2078
2034
|
$size: size,
|
|
2079
2035
|
children: [len === 0 && /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
2080
2036
|
children: /* @__PURE__ */jsxRuntime.jsx(AvatarCounter, {
|
|
2081
|
-
count: len
|
|
2037
|
+
count: len,
|
|
2038
|
+
size
|
|
2082
2039
|
})
|
|
2083
2040
|
}), len !== 0 && extraCount > 1 && /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
2084
2041
|
children: /* @__PURE__ */jsxRuntime.jsx(AvatarCounter, {
|
|
@@ -2092,7 +2049,7 @@ const AvatarStack = react.forwardRef(function AvatarStack2(props, ref) {
|
|
|
2092
2049
|
}, String(childIndex)))]
|
|
2093
2050
|
});
|
|
2094
2051
|
});
|
|
2095
|
-
const Root$
|
|
2052
|
+
const Root$z = styled__default.default.div(boxStyle, flexItemStyle, responsiveBoxStyle, responsiveGridItemStyle, responsiveMarginStyle, responsivePaddingStyle);
|
|
2096
2053
|
const Box = react.forwardRef(function Box2(props, ref) {
|
|
2097
2054
|
const {
|
|
2098
2055
|
as: asProp = "div",
|
|
@@ -2123,7 +2080,7 @@ const Box = react.forwardRef(function Box2(props, ref) {
|
|
|
2123
2080
|
sizing,
|
|
2124
2081
|
...restProps
|
|
2125
2082
|
} = props;
|
|
2126
|
-
return /* @__PURE__ */jsxRuntime.jsx(Root$
|
|
2083
|
+
return /* @__PURE__ */jsxRuntime.jsx(Root$z, {
|
|
2127
2084
|
"data-as": typeof asProp === "string" ? asProp : void 0,
|
|
2128
2085
|
"data-ui": "Box",
|
|
2129
2086
|
...restProps,
|
|
@@ -2157,6 +2114,61 @@ const Box = react.forwardRef(function Box2(props, ref) {
|
|
|
2157
2114
|
children: props.children
|
|
2158
2115
|
});
|
|
2159
2116
|
});
|
|
2117
|
+
var __freeze$y = Object.freeze;
|
|
2118
|
+
var __defProp$z = Object.defineProperty;
|
|
2119
|
+
var __template$y = (cooked, raw) => __freeze$y(__defProp$z(cooked, "raw", {
|
|
2120
|
+
value: __freeze$y(raw || cooked.slice())
|
|
2121
|
+
}));
|
|
2122
|
+
var _a$y, _b$l, _c$a;
|
|
2123
|
+
function textBaseStyle(props) {
|
|
2124
|
+
const {
|
|
2125
|
+
$accent,
|
|
2126
|
+
$muted
|
|
2127
|
+
} = props;
|
|
2128
|
+
const {
|
|
2129
|
+
font
|
|
2130
|
+
} = theme.getTheme_v2(props.theme);
|
|
2131
|
+
return styled.css(_c$a || (_c$a = __template$y(["\n color: var(--card-fg-color);\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n background-color: var(--card-code-bg-color);\n color: var(--card-code-fg-color);\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & strong {\n font-weight: ", ";\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n color: var(--card-icon-color);\n\n & path {\n vector-effect: non-scaling-stroke !important;\n }\n }\n "])), $accent && styled.css(_a$y || (_a$y = __template$y(["\n color: var(--card-accent-fg-color);\n "]))), $muted && styled.css(_b$l || (_b$l = __template$y(["\n color: var(--card-muted-fg-color);\n "]))), font.code.family, font.text.weights.bold);
|
|
2132
|
+
}
|
|
2133
|
+
var __freeze$x = Object.freeze;
|
|
2134
|
+
var __defProp$y = Object.defineProperty;
|
|
2135
|
+
var __template$x = (cooked, raw) => __freeze$x(__defProp$y(cooked, "raw", {
|
|
2136
|
+
value: __freeze$x(raw || cooked.slice())
|
|
2137
|
+
}));
|
|
2138
|
+
var _a$x;
|
|
2139
|
+
const Root$y = styled__default.default.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
|
|
2140
|
+
const SpanWithTextOverflow$1 = styled__default.default.span(_a$x || (_a$x = __template$x(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"])));
|
|
2141
|
+
const Text = react.forwardRef(function Text2(props, ref) {
|
|
2142
|
+
const {
|
|
2143
|
+
accent = false,
|
|
2144
|
+
align,
|
|
2145
|
+
children: childrenProp,
|
|
2146
|
+
muted = false,
|
|
2147
|
+
size = 2,
|
|
2148
|
+
textOverflow,
|
|
2149
|
+
weight,
|
|
2150
|
+
...restProps
|
|
2151
|
+
} = props;
|
|
2152
|
+
let children = childrenProp;
|
|
2153
|
+
if (textOverflow === "ellipsis") {
|
|
2154
|
+
children = /* @__PURE__ */jsxRuntime.jsx(SpanWithTextOverflow$1, {
|
|
2155
|
+
children
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
return /* @__PURE__ */jsxRuntime.jsx(Root$y, {
|
|
2159
|
+
"data-ui": "Text",
|
|
2160
|
+
...restProps,
|
|
2161
|
+
$accent: accent,
|
|
2162
|
+
$align: useArrayProp(align),
|
|
2163
|
+
$muted: muted,
|
|
2164
|
+
ref,
|
|
2165
|
+
$size: useArrayProp(size),
|
|
2166
|
+
$weight: weight,
|
|
2167
|
+
children: /* @__PURE__ */jsxRuntime.jsx("span", {
|
|
2168
|
+
children
|
|
2169
|
+
})
|
|
2170
|
+
});
|
|
2171
|
+
});
|
|
2160
2172
|
function badgeStyle(props) {
|
|
2161
2173
|
const {
|
|
2162
2174
|
$tone
|
|
@@ -4788,7 +4800,7 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
4788
4800
|
content,
|
|
4789
4801
|
disabled,
|
|
4790
4802
|
fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
|
|
4791
|
-
padding =
|
|
4803
|
+
padding = 2,
|
|
4792
4804
|
placement: placementProp = "bottom",
|
|
4793
4805
|
portal: portalProp,
|
|
4794
4806
|
radius = 2,
|