@sanity/ui 5.0.0-alpha.8 → 5.0.0-alpha.9
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 +25 -0
- package/dist/index.js +47 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/badge/Badge.tsx +53 -0
- package/src/components/badge/badge.css +6 -0
- package/src/components/badge/badge.props.ts +31 -0
- package/src/components/index.css +1 -0
- package/src/index.ts +1 -0
- package/src/version.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,31 @@ declare const ALIGN_ITEMS: readonly [
|
|
|
16
16
|
/** @public */
|
|
17
17
|
export declare type AlignItems = (typeof ALIGN_ITEMS)[number];
|
|
18
18
|
|
|
19
|
+
/** @public */
|
|
20
|
+
export declare function Badge<T extends ElementType = "span">({
|
|
21
|
+
tone,
|
|
22
|
+
...props
|
|
23
|
+
}: BadgeProps<T> &
|
|
24
|
+
Omit<ComponentPropsWithRef<T>, keyof BadgeProps<T>>): JSX.Element;
|
|
25
|
+
|
|
26
|
+
/** @public */
|
|
27
|
+
export declare interface BadgeProps<
|
|
28
|
+
T extends React.ElementType = "span",
|
|
29
|
+
> extends ToneProps {
|
|
30
|
+
/**
|
|
31
|
+
* HTML element to render.
|
|
32
|
+
*/
|
|
33
|
+
as?: T;
|
|
34
|
+
/**
|
|
35
|
+
* Shows an icon in the start position (left side in left-to-right languages).
|
|
36
|
+
*/
|
|
37
|
+
iconStart?: React.ElementType | React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Sets Badge's text label. Use instead of children unless you have a special use case.
|
|
40
|
+
*/
|
|
41
|
+
text?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
19
44
|
declare type BorderProps = {
|
|
20
45
|
/** CSS **border** property */
|
|
21
46
|
border?: Responsive<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ function getCompositeValue(propValue, propDef, key) {
|
|
|
99
99
|
compositeValue = mapping?.[propValue];
|
|
100
100
|
return compositeValue;
|
|
101
101
|
}
|
|
102
|
-
const HASH = "
|
|
102
|
+
const HASH = "fd663f";
|
|
103
103
|
function suffixClassName(className) {
|
|
104
104
|
return `${className}-${HASH}`;
|
|
105
105
|
}
|
|
@@ -2045,7 +2045,53 @@ function TooltipGroup(props) {
|
|
|
2045
2045
|
let t6;
|
|
2046
2046
|
return $[8] !== Component || $[9] !== children || $[10] !== handleBlur || $[11] !== handleMouseLeave || $[12] !== handleTransitionEnd || $[13] !== rest || $[14] !== t3 || $[15] !== t5 ? (t6 = /* @__PURE__ */ jsx(Component, { className: t3, style: t5, "data-ui": "TooltipGroup", ref, onTransitionEnd: handleTransitionEnd, onMouseLeave: handleMouseLeave, onBlur: handleBlur, ...rest, children }), $[8] = Component, $[9] = children, $[10] = handleBlur, $[11] = handleMouseLeave, $[12] = handleTransitionEnd, $[13] = rest, $[14] = t3, $[15] = t5, $[16] = t6) : t6 = $[16], t6;
|
|
2047
2047
|
}
|
|
2048
|
+
const badgeProps = {
|
|
2049
|
+
as: {
|
|
2050
|
+
type: "string"
|
|
2051
|
+
},
|
|
2052
|
+
iconStart: {
|
|
2053
|
+
type: "string"
|
|
2054
|
+
},
|
|
2055
|
+
text: {
|
|
2056
|
+
type: "string"
|
|
2057
|
+
},
|
|
2058
|
+
...toneProps
|
|
2059
|
+
}, badgeClassName = suffixClassName("sui-Badge");
|
|
2060
|
+
function Badge(t0) {
|
|
2061
|
+
const $ = c(20);
|
|
2062
|
+
let T0, children, t1, t2, t3, t4, t5, text;
|
|
2063
|
+
if ($[0] !== t0) {
|
|
2064
|
+
const {
|
|
2065
|
+
tone: t62,
|
|
2066
|
+
...props
|
|
2067
|
+
} = t0, tone = t62 === void 0 ? "neutral" : t62, {
|
|
2068
|
+
as,
|
|
2069
|
+
children: t72,
|
|
2070
|
+
className,
|
|
2071
|
+
style,
|
|
2072
|
+
iconStart: IconStart,
|
|
2073
|
+
text: t8,
|
|
2074
|
+
...rest
|
|
2075
|
+
} = getProps({
|
|
2076
|
+
tone,
|
|
2077
|
+
...props
|
|
2078
|
+
}, badgeProps);
|
|
2079
|
+
children = t72, text = t8;
|
|
2080
|
+
const Component = as || "span", badgeClasses = clsx(badgeClassName, `${IconStart ? "sui-p1" : "sui-px2 sui-py1"} sui-radius-full sui-display-inline-flex sui-align-items-center sui-gap1`);
|
|
2081
|
+
T0 = Component, t1 = clsx(badgeClasses, className), t2 = style, t3 = "Badge", t4 = rest, t5 = IconStart && (isValidElement(IconStart) ? IconStart : /* @__PURE__ */ jsx(Icon, { icon: IconStart, marginX: -1, marginY: -2, size: 0 })), $[0] = t0, $[1] = T0, $[2] = children, $[3] = t1, $[4] = t2, $[5] = t3, $[6] = t4, $[7] = t5, $[8] = text;
|
|
2082
|
+
} else
|
|
2083
|
+
T0 = $[1], children = $[2], t1 = $[3], t2 = $[4], t3 = $[5], t4 = $[6], t5 = $[7], text = $[8];
|
|
2084
|
+
let t6;
|
|
2085
|
+
$[9] !== text ? (t6 = text && /* @__PURE__ */ jsx(Text, { size: 1, trim: !0, children: text }), $[9] = text, $[10] = t6) : t6 = $[10];
|
|
2086
|
+
let t7;
|
|
2087
|
+
return $[11] !== T0 || $[12] !== children || $[13] !== t1 || $[14] !== t2 || $[15] !== t3 || $[16] !== t4 || $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxs(T0, { className: t1, style: t2, "data-ui": t3, ...t4, children: [
|
|
2088
|
+
t5,
|
|
2089
|
+
t6,
|
|
2090
|
+
children
|
|
2091
|
+
] }), $[11] = T0, $[12] = children, $[13] = t1, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19], t7;
|
|
2092
|
+
}
|
|
2048
2093
|
export {
|
|
2094
|
+
Badge,
|
|
2049
2095
|
Box,
|
|
2050
2096
|
Button,
|
|
2051
2097
|
Card,
|