@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.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1815,14 +1815,14 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
1815
1815
|
arrowPosition: arrowPositionProp,
|
|
1816
1816
|
animateArrowFrom,
|
|
1817
1817
|
status = "online",
|
|
1818
|
-
size: sizeProp =
|
|
1818
|
+
size: sizeProp = 1,
|
|
1819
1819
|
...restProps
|
|
1820
1820
|
} = props;
|
|
1821
|
-
const as = ReactIs.isValidElementType(asProp) ? asProp : "div";
|
|
1822
|
-
const size = useArrayProp(sizeProp);
|
|
1823
1821
|
const {
|
|
1824
1822
|
avatar
|
|
1825
1823
|
} = useTheme_v2();
|
|
1824
|
+
const as = ReactIs.isValidElementType(asProp) ? asProp : "div";
|
|
1825
|
+
const size = useArrayProp(sizeProp);
|
|
1826
1826
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0];
|
|
1827
1827
|
const _sizeRem = avatarSize.size;
|
|
1828
1828
|
const _radius = _sizeRem / 2;
|
|
@@ -1844,7 +1844,12 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
1844
1844
|
onImageLoadError(new Error("Avatar: the image failed to load"));
|
|
1845
1845
|
}
|
|
1846
1846
|
}, [onImageLoadError]);
|
|
1847
|
-
const initialsSize = useMemo(() => size.map(s =>
|
|
1847
|
+
const initialsSize = useMemo(() => size.map(s => {
|
|
1848
|
+
if (s === 1) return 1;
|
|
1849
|
+
if (s === 2) return 3;
|
|
1850
|
+
if (s === 3) return 5;
|
|
1851
|
+
return 0;
|
|
1852
|
+
}), [size]);
|
|
1848
1853
|
return /* @__PURE__ */jsxs(Root$C, {
|
|
1849
1854
|
as,
|
|
1850
1855
|
"data-as": typeof as === "string" ? as : void 0,
|
|
@@ -1907,6 +1912,7 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
1907
1912
|
children: /* @__PURE__ */jsx(InitialsLabel, {
|
|
1908
1913
|
forwardedAs: "span",
|
|
1909
1914
|
size: initialsSize,
|
|
1915
|
+
weight: "medium",
|
|
1910
1916
|
children: initials
|
|
1911
1917
|
})
|
|
1912
1918
|
})
|
|
@@ -1918,62 +1924,7 @@ var __defProp$B = Object.defineProperty;
|
|
|
1918
1924
|
var __template$A = (cooked, raw) => __freeze$A(__defProp$B(cooked, "raw", {
|
|
1919
1925
|
value: __freeze$A(raw || cooked.slice())
|
|
1920
1926
|
}));
|
|
1921
|
-
var _a$A
|
|
1922
|
-
function textBaseStyle(props) {
|
|
1923
|
-
const {
|
|
1924
|
-
$accent,
|
|
1925
|
-
$muted
|
|
1926
|
-
} = props;
|
|
1927
|
-
const {
|
|
1928
|
-
font
|
|
1929
|
-
} = getTheme_v2(props.theme);
|
|
1930
|
-
return 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 && css(_a$A || (_a$A = __template$A(["\n color: var(--card-accent-fg-color);\n "]))), $muted && css(_b$l || (_b$l = __template$A(["\n color: var(--card-muted-fg-color);\n "]))), font.code.family, font.text.weights.bold);
|
|
1931
|
-
}
|
|
1932
|
-
var __freeze$z = Object.freeze;
|
|
1933
|
-
var __defProp$A = Object.defineProperty;
|
|
1934
|
-
var __template$z = (cooked, raw) => __freeze$z(__defProp$A(cooked, "raw", {
|
|
1935
|
-
value: __freeze$z(raw || cooked.slice())
|
|
1936
|
-
}));
|
|
1937
|
-
var _a$z;
|
|
1938
|
-
const Root$B = styled.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
|
|
1939
|
-
const SpanWithTextOverflow$1 = styled.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"])));
|
|
1940
|
-
const Text = forwardRef(function Text2(props, ref) {
|
|
1941
|
-
const {
|
|
1942
|
-
accent = false,
|
|
1943
|
-
align,
|
|
1944
|
-
children: childrenProp,
|
|
1945
|
-
muted = false,
|
|
1946
|
-
size = 2,
|
|
1947
|
-
textOverflow,
|
|
1948
|
-
weight,
|
|
1949
|
-
...restProps
|
|
1950
|
-
} = props;
|
|
1951
|
-
let children = childrenProp;
|
|
1952
|
-
if (textOverflow === "ellipsis") {
|
|
1953
|
-
children = /* @__PURE__ */jsx(SpanWithTextOverflow$1, {
|
|
1954
|
-
children
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
return /* @__PURE__ */jsx(Root$B, {
|
|
1958
|
-
"data-ui": "Text",
|
|
1959
|
-
...restProps,
|
|
1960
|
-
$accent: accent,
|
|
1961
|
-
$align: useArrayProp(align),
|
|
1962
|
-
$muted: muted,
|
|
1963
|
-
ref,
|
|
1964
|
-
$size: useArrayProp(size),
|
|
1965
|
-
$weight: weight,
|
|
1966
|
-
children: /* @__PURE__ */jsx("span", {
|
|
1967
|
-
children
|
|
1968
|
-
})
|
|
1969
|
-
});
|
|
1970
|
-
});
|
|
1971
|
-
var __freeze$y = Object.freeze;
|
|
1972
|
-
var __defProp$z = Object.defineProperty;
|
|
1973
|
-
var __template$y = (cooked, raw) => __freeze$y(__defProp$z(cooked, "raw", {
|
|
1974
|
-
value: __freeze$y(raw || cooked.slice())
|
|
1975
|
-
}));
|
|
1976
|
-
var _a$y;
|
|
1927
|
+
var _a$A;
|
|
1977
1928
|
function _responsiveAvatarCounterSizeStyle(props) {
|
|
1978
1929
|
const {
|
|
1979
1930
|
avatar,
|
|
@@ -1993,23 +1944,28 @@ function _avatarCounterBaseStyle(props) {
|
|
|
1993
1944
|
const {
|
|
1994
1945
|
space
|
|
1995
1946
|
} = getTheme_v2(props.theme);
|
|
1996
|
-
return css(_a$
|
|
1947
|
+
return 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]));
|
|
1997
1948
|
}
|
|
1998
|
-
const Root$
|
|
1949
|
+
const Root$B = styled.div(_responsiveAvatarCounterSizeStyle, _avatarCounterBaseStyle);
|
|
1999
1950
|
const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
|
|
2000
1951
|
const {
|
|
2001
1952
|
count,
|
|
2002
|
-
size: sizeProp =
|
|
1953
|
+
size: sizeProp = 1
|
|
2003
1954
|
} = props;
|
|
2004
1955
|
const size = useArrayProp(sizeProp);
|
|
2005
|
-
const
|
|
2006
|
-
|
|
1956
|
+
const fontSize = useMemo(() => size.map(s => {
|
|
1957
|
+
if (s === 1) return 1;
|
|
1958
|
+
if (s === 2) return 3;
|
|
1959
|
+
if (s === 3) return 5;
|
|
1960
|
+
return 0;
|
|
1961
|
+
}), [size]);
|
|
1962
|
+
return /* @__PURE__ */jsx(Root$B, {
|
|
2007
1963
|
$size: size,
|
|
2008
1964
|
"data-ui": "AvatarCounter",
|
|
2009
1965
|
ref,
|
|
2010
|
-
children: /* @__PURE__ */jsx(
|
|
1966
|
+
children: /* @__PURE__ */jsx(Label, {
|
|
2011
1967
|
as: "span",
|
|
2012
|
-
size:
|
|
1968
|
+
size: fontSize,
|
|
2013
1969
|
weight: "medium",
|
|
2014
1970
|
children: count
|
|
2015
1971
|
})
|
|
@@ -2019,13 +1975,13 @@ function childrenToElementArray(children) {
|
|
|
2019
1975
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
2020
1976
|
return childrenArray.filter(node => isElement$1(node) || isFragment(node) || typeof node === "string");
|
|
2021
1977
|
}
|
|
2022
|
-
var __freeze$
|
|
2023
|
-
var __defProp$
|
|
2024
|
-
var __template$
|
|
2025
|
-
value: __freeze$
|
|
1978
|
+
var __freeze$z = Object.freeze;
|
|
1979
|
+
var __defProp$A = Object.defineProperty;
|
|
1980
|
+
var __template$z = (cooked, raw) => __freeze$z(__defProp$A(cooked, "raw", {
|
|
1981
|
+
value: __freeze$z(raw || cooked.slice())
|
|
2026
1982
|
}));
|
|
2027
|
-
var _a$
|
|
2028
|
-
const BASE_STYLES = css(_a$
|
|
1983
|
+
var _a$z;
|
|
1984
|
+
const BASE_STYLES = 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"])));
|
|
2029
1985
|
function avatarStackStyle() {
|
|
2030
1986
|
return BASE_STYLES;
|
|
2031
1987
|
}
|
|
@@ -2044,12 +2000,12 @@ function responsiveAvatarStackSizeStyle(props) {
|
|
|
2044
2000
|
};
|
|
2045
2001
|
});
|
|
2046
2002
|
}
|
|
2047
|
-
const Root$
|
|
2003
|
+
const Root$A = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle);
|
|
2048
2004
|
const AvatarStack = forwardRef(function AvatarStack2(props, ref) {
|
|
2049
2005
|
const {
|
|
2050
2006
|
children: childrenProp,
|
|
2051
2007
|
maxLength: maxLengthProp = 4,
|
|
2052
|
-
size: sizeProp =
|
|
2008
|
+
size: sizeProp = 1,
|
|
2053
2009
|
...restProps
|
|
2054
2010
|
} = props;
|
|
2055
2011
|
const children = childrenToElementArray(childrenProp).filter(child => typeof child !== "string");
|
|
@@ -2059,14 +2015,15 @@ const AvatarStack = forwardRef(function AvatarStack2(props, ref) {
|
|
|
2059
2015
|
const visibleCount = maxLength - 1;
|
|
2060
2016
|
const extraCount = len - visibleCount;
|
|
2061
2017
|
const visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
|
|
2062
|
-
return /* @__PURE__ */jsxs(Root$
|
|
2018
|
+
return /* @__PURE__ */jsxs(Root$A, {
|
|
2063
2019
|
"data-ui": "AvatarStack",
|
|
2064
2020
|
...restProps,
|
|
2065
2021
|
ref,
|
|
2066
2022
|
$size: size,
|
|
2067
2023
|
children: [len === 0 && /* @__PURE__ */jsx("div", {
|
|
2068
2024
|
children: /* @__PURE__ */jsx(AvatarCounter, {
|
|
2069
|
-
count: len
|
|
2025
|
+
count: len,
|
|
2026
|
+
size
|
|
2070
2027
|
})
|
|
2071
2028
|
}), len !== 0 && extraCount > 1 && /* @__PURE__ */jsx("div", {
|
|
2072
2029
|
children: /* @__PURE__ */jsx(AvatarCounter, {
|
|
@@ -2080,7 +2037,7 @@ const AvatarStack = forwardRef(function AvatarStack2(props, ref) {
|
|
|
2080
2037
|
}, String(childIndex)))]
|
|
2081
2038
|
});
|
|
2082
2039
|
});
|
|
2083
|
-
const Root$
|
|
2040
|
+
const Root$z = styled.div(boxStyle, flexItemStyle, responsiveBoxStyle, responsiveGridItemStyle, responsiveMarginStyle, responsivePaddingStyle);
|
|
2084
2041
|
const Box = forwardRef(function Box2(props, ref) {
|
|
2085
2042
|
const {
|
|
2086
2043
|
as: asProp = "div",
|
|
@@ -2111,7 +2068,7 @@ const Box = forwardRef(function Box2(props, ref) {
|
|
|
2111
2068
|
sizing,
|
|
2112
2069
|
...restProps
|
|
2113
2070
|
} = props;
|
|
2114
|
-
return /* @__PURE__ */jsx(Root$
|
|
2071
|
+
return /* @__PURE__ */jsx(Root$z, {
|
|
2115
2072
|
"data-as": typeof asProp === "string" ? asProp : void 0,
|
|
2116
2073
|
"data-ui": "Box",
|
|
2117
2074
|
...restProps,
|
|
@@ -2145,6 +2102,61 @@ const Box = forwardRef(function Box2(props, ref) {
|
|
|
2145
2102
|
children: props.children
|
|
2146
2103
|
});
|
|
2147
2104
|
});
|
|
2105
|
+
var __freeze$y = Object.freeze;
|
|
2106
|
+
var __defProp$z = Object.defineProperty;
|
|
2107
|
+
var __template$y = (cooked, raw) => __freeze$y(__defProp$z(cooked, "raw", {
|
|
2108
|
+
value: __freeze$y(raw || cooked.slice())
|
|
2109
|
+
}));
|
|
2110
|
+
var _a$y, _b$l, _c$a;
|
|
2111
|
+
function textBaseStyle(props) {
|
|
2112
|
+
const {
|
|
2113
|
+
$accent,
|
|
2114
|
+
$muted
|
|
2115
|
+
} = props;
|
|
2116
|
+
const {
|
|
2117
|
+
font
|
|
2118
|
+
} = getTheme_v2(props.theme);
|
|
2119
|
+
return 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 && css(_a$y || (_a$y = __template$y(["\n color: var(--card-accent-fg-color);\n "]))), $muted && css(_b$l || (_b$l = __template$y(["\n color: var(--card-muted-fg-color);\n "]))), font.code.family, font.text.weights.bold);
|
|
2120
|
+
}
|
|
2121
|
+
var __freeze$x = Object.freeze;
|
|
2122
|
+
var __defProp$y = Object.defineProperty;
|
|
2123
|
+
var __template$x = (cooked, raw) => __freeze$x(__defProp$y(cooked, "raw", {
|
|
2124
|
+
value: __freeze$x(raw || cooked.slice())
|
|
2125
|
+
}));
|
|
2126
|
+
var _a$x;
|
|
2127
|
+
const Root$y = styled.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
|
|
2128
|
+
const SpanWithTextOverflow$1 = styled.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"])));
|
|
2129
|
+
const Text = forwardRef(function Text2(props, ref) {
|
|
2130
|
+
const {
|
|
2131
|
+
accent = false,
|
|
2132
|
+
align,
|
|
2133
|
+
children: childrenProp,
|
|
2134
|
+
muted = false,
|
|
2135
|
+
size = 2,
|
|
2136
|
+
textOverflow,
|
|
2137
|
+
weight,
|
|
2138
|
+
...restProps
|
|
2139
|
+
} = props;
|
|
2140
|
+
let children = childrenProp;
|
|
2141
|
+
if (textOverflow === "ellipsis") {
|
|
2142
|
+
children = /* @__PURE__ */jsx(SpanWithTextOverflow$1, {
|
|
2143
|
+
children
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
return /* @__PURE__ */jsx(Root$y, {
|
|
2147
|
+
"data-ui": "Text",
|
|
2148
|
+
...restProps,
|
|
2149
|
+
$accent: accent,
|
|
2150
|
+
$align: useArrayProp(align),
|
|
2151
|
+
$muted: muted,
|
|
2152
|
+
ref,
|
|
2153
|
+
$size: useArrayProp(size),
|
|
2154
|
+
$weight: weight,
|
|
2155
|
+
children: /* @__PURE__ */jsx("span", {
|
|
2156
|
+
children
|
|
2157
|
+
})
|
|
2158
|
+
});
|
|
2159
|
+
});
|
|
2148
2160
|
function badgeStyle(props) {
|
|
2149
2161
|
const {
|
|
2150
2162
|
$tone
|
|
@@ -4776,7 +4788,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
4776
4788
|
content,
|
|
4777
4789
|
disabled,
|
|
4778
4790
|
fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
|
|
4779
|
-
padding =
|
|
4791
|
+
padding = 2,
|
|
4780
4792
|
placement: placementProp = "bottom",
|
|
4781
4793
|
portal: portalProp,
|
|
4782
4794
|
radius = 2,
|