@sanity/ui 4.0.0-next.4 → 4.0.0-next.6
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/README.md +4 -0
- package/dist/_system-CTe2lb5l.d.ts +40 -0
- package/dist/_system-CTe2lb5l.d.ts.map +1 -0
- package/dist/arrow-BaxgKzOL.js +161 -0
- package/dist/arrow-BaxgKzOL.js.map +1 -0
- package/dist/autocomplete.d.ts +140 -0
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete.js +475 -0
- package/dist/autocomplete.js.map +1 -0
- package/dist/breadcrumbs.d.ts +18 -0
- package/dist/breadcrumbs.d.ts.map +1 -0
- package/dist/breadcrumbs.js +116 -0
- package/dist/breadcrumbs.js.map +1 -0
- package/dist/button-BDLRd1Rr.js +174 -0
- package/dist/button-BDLRd1Rr.js.map +1 -0
- package/dist/button-dnqMFkWg.d.ts +76 -0
- package/dist/button-dnqMFkWg.d.ts.map +1 -0
- package/dist/card-C0a0wQTc.d.ts +7 -0
- package/dist/card-C0a0wQTc.d.ts.map +1 -0
- package/dist/code.d.ts +20 -0
- package/dist/code.d.ts.map +1 -0
- package/dist/code.js +85 -0
- package/dist/code.js.map +1 -0
- package/dist/codeFontStyle-DYUujk7K.js +11 -0
- package/dist/codeFontStyle-DYUujk7K.js.map +1 -0
- package/dist/component-DVlwaWB-.d.ts +25 -0
- package/dist/component-DVlwaWB-.d.ts.map +1 -0
- package/dist/element-BYgCE_iK.js +51 -0
- package/dist/element-BYgCE_iK.js.map +1 -0
- package/dist/{getScopedTheme-CqaSCfTH.js → factory-CvRcEQ36.js} +6 -753
- package/dist/factory-CvRcEQ36.js.map +1 -0
- package/dist/flex-BYRpBTOc.js +69 -0
- package/dist/flex-BYRpBTOc.js.map +1 -0
- package/dist/font-EtfxKPUz.d.ts +49 -0
- package/dist/font-EtfxKPUz.d.ts.map +1 -0
- package/dist/getElementRef-5HZQ-Owu.js +91 -0
- package/dist/getElementRef-5HZQ-Owu.js.map +1 -0
- package/dist/getScopedTheme-C-sZsyAz.js +267 -0
- package/dist/getScopedTheme-C-sZsyAz.js.map +1 -0
- package/dist/getTheme_v2-y09KqtEb.js +487 -0
- package/dist/getTheme_v2-y09KqtEb.js.map +1 -0
- package/dist/grid-D88j-N7f.js +108 -0
- package/dist/grid-D88j-N7f.js.map +1 -0
- package/dist/helpers-bwfx1e-Y.js +67 -0
- package/dist/helpers-bwfx1e-Y.js.map +1 -0
- package/dist/hotkeys-aHdaZFAl.js +151 -0
- package/dist/hotkeys-aHdaZFAl.js.map +1 -0
- package/dist/index.d.ts +138 -922
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +201 -4418
- package/dist/index.js.map +1 -1
- package/dist/layer-ChlP9Ik6.d.ts +242 -0
- package/dist/layer-ChlP9Ik6.d.ts.map +1 -0
- package/dist/layer-DeCVQfUb.js +61 -0
- package/dist/layer-DeCVQfUb.js.map +1 -0
- package/dist/menu.d.ts +146 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +614 -0
- package/dist/menu.js.map +1 -0
- package/dist/popover-CMlQeKn0.d.ts +96 -0
- package/dist/popover-CMlQeKn0.d.ts.map +1 -0
- package/dist/popover-DfXz9lUl.js +417 -0
- package/dist/popover-DfXz9lUl.js.map +1 -0
- package/dist/popover.d.ts +2 -0
- package/dist/popover.js +3 -0
- package/dist/responsiveFont-hN1mZFjm.js +55 -0
- package/dist/responsiveFont-hN1mZFjm.js.map +1 -0
- package/dist/{rgba-LmTDhX0u.d.ts → rgba-BSYaEUW6.d.ts} +4 -87
- package/dist/rgba-BSYaEUW6.d.ts.map +1 -0
- package/dist/selectable-B0GUIL74.d.ts +7 -0
- package/dist/selectable-B0GUIL74.d.ts.map +1 -0
- package/dist/stack-C5WV-BRh.js +98 -0
- package/dist/stack-C5WV-BRh.js.map +1 -0
- package/dist/styles.css +28 -0
- package/dist/textInput-DhCo-b3N.js +321 -0
- package/dist/textInput-DhCo-b3N.js.map +1 -0
- package/dist/theme.d.ts +3 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +3 -1
- package/dist/theme.js.map +1 -1
- package/dist/toast.d.ts +73 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +297 -0
- package/dist/toast.js.map +1 -0
- package/dist/tooltip.d.ts +88 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +446 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/useClickOutsideEvent-lEVhDFCQ.js +36 -0
- package/dist/useClickOutsideEvent-lEVhDFCQ.js.map +1 -0
- package/dist/useElementSize-BJvbGHq8.js +51 -0
- package/dist/useElementSize-BJvbGHq8.js.map +1 -0
- package/dist/useLayer-9Pz-GG0r.js +704 -0
- package/dist/useLayer-9Pz-GG0r.js.map +1 -0
- package/package.json +15 -3
- package/dist/getScopedTheme-CqaSCfTH.js.map +0 -1
- package/dist/rgba-LmTDhX0u.d.ts.map +0 -1
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
import { a as rem, i as _responsive, n as _getArrayProp, o as EMPTY_ARRAY, r as _getResponsiveSpace, s as EMPTY_RECORD } from "./helpers-bwfx1e-Y.js";
|
|
2
|
+
import { t as getTheme_v2 } from "./getTheme_v2-y09KqtEb.js";
|
|
3
|
+
import { t as getScopedTheme } from "./getScopedTheme-C-sZsyAz.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { createContext, useContext, useDebugValue, useEffect, useState, useSyncExternalStore } from "react";
|
|
6
|
+
import { ThemeProvider, css, styled, useTheme } from "styled-components";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { isValidElementType } from "react-is";
|
|
9
|
+
const BASE_STYLE$1 = { "&[data-as=\"ul\"],&[data-as=\"ol\"]": { listStyle: "none" } }, BOX_SIZING = {
|
|
10
|
+
content: "content-box",
|
|
11
|
+
border: "border-box"
|
|
12
|
+
}, BOX_HEIGHT = {
|
|
13
|
+
stretch: "stretch",
|
|
14
|
+
fill: "100%"
|
|
15
|
+
};
|
|
16
|
+
function boxStyle() {
|
|
17
|
+
return BASE_STYLE$1;
|
|
18
|
+
}
|
|
19
|
+
function responsiveBoxStyle() {
|
|
20
|
+
return [
|
|
21
|
+
responsiveBoxSizingStyle,
|
|
22
|
+
responsiveBoxHeightStyle,
|
|
23
|
+
responsiveBoxOverflowStyle,
|
|
24
|
+
responsiveBoxDisplayStyle
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function responsiveBoxDisplayStyle(props) {
|
|
28
|
+
let { media } = getTheme_v2(props.theme);
|
|
29
|
+
return _responsive(media, props.$display, (display) => ({ "&:not([hidden])": { display } }));
|
|
30
|
+
}
|
|
31
|
+
function responsiveBoxSizingStyle(props) {
|
|
32
|
+
let { media } = getTheme_v2(props.theme);
|
|
33
|
+
return _responsive(media, props.$sizing, (sizing) => ({ boxSizing: BOX_SIZING[sizing] }));
|
|
34
|
+
}
|
|
35
|
+
function responsiveBoxHeightStyle(props) {
|
|
36
|
+
let { media } = getTheme_v2(props.theme);
|
|
37
|
+
return _responsive(media, props.$height, (height) => ({ height: BOX_HEIGHT[height] }));
|
|
38
|
+
}
|
|
39
|
+
function responsiveBoxOverflowStyle(props) {
|
|
40
|
+
let { media } = getTheme_v2(props.theme);
|
|
41
|
+
return _responsive(media, props.$overflow, (overflow) => ({ overflow }));
|
|
42
|
+
}
|
|
43
|
+
const BASE_STYLE = {
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
minHeight: 0
|
|
46
|
+
};
|
|
47
|
+
function flexItemStyle() {
|
|
48
|
+
return [BASE_STYLE, responsiveFlexItemStyle];
|
|
49
|
+
}
|
|
50
|
+
function responsiveFlexItemStyle(props) {
|
|
51
|
+
let { media } = getTheme_v2(props.theme);
|
|
52
|
+
return props.$flex ? _responsive(media, props.$flex, (flex) => ({ flex: `${flex}` })) : EMPTY_ARRAY;
|
|
53
|
+
}
|
|
54
|
+
function responsiveGridItemStyle() {
|
|
55
|
+
return [
|
|
56
|
+
responsiveGridItemRowStyle,
|
|
57
|
+
responsiveGridItemRowStartStyle,
|
|
58
|
+
responsiveGridItemRowEndStyle,
|
|
59
|
+
responsiveGridItemColumnStyle,
|
|
60
|
+
responsiveGridItemColumnStartStyle,
|
|
61
|
+
responsiveGridItemColumnEndStyle
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
const GRID_ITEM_ROW = {
|
|
65
|
+
auto: "auto",
|
|
66
|
+
full: "1 / -1"
|
|
67
|
+
}, GRID_ITEM_COLUMN = {
|
|
68
|
+
auto: "auto",
|
|
69
|
+
full: "1 / -1"
|
|
70
|
+
};
|
|
71
|
+
function responsiveGridItemRowStyle(props) {
|
|
72
|
+
let { media } = getTheme_v2(props.theme);
|
|
73
|
+
return _responsive(media, props.$row, (row) => typeof row == "number" ? { gridRow: `span ${row} / span ${row}` } : { gridRow: GRID_ITEM_ROW[row] });
|
|
74
|
+
}
|
|
75
|
+
function responsiveGridItemRowStartStyle(props) {
|
|
76
|
+
let { media } = getTheme_v2(props.theme);
|
|
77
|
+
return _responsive(media, props.$rowStart, (rowStart) => ({ gridRowStart: `${rowStart}` }));
|
|
78
|
+
}
|
|
79
|
+
function responsiveGridItemRowEndStyle(props) {
|
|
80
|
+
let { media } = getTheme_v2(props.theme);
|
|
81
|
+
return _responsive(media, props.$rowEnd, (rowEnd) => ({ gridRowEnd: `${rowEnd}` }));
|
|
82
|
+
}
|
|
83
|
+
function responsiveGridItemColumnStyle(props) {
|
|
84
|
+
let { media } = getTheme_v2(props.theme);
|
|
85
|
+
return _responsive(media, props.$column, (column) => typeof column == "number" ? { gridColumn: `span ${column} / span ${column}` } : { gridColumn: GRID_ITEM_COLUMN[column] });
|
|
86
|
+
}
|
|
87
|
+
function responsiveGridItemColumnStartStyle(props) {
|
|
88
|
+
let { media } = getTheme_v2(props.theme);
|
|
89
|
+
return _responsive(media, props.$columnStart, (columnStart) => ({ gridColumnStart: `${columnStart}` }));
|
|
90
|
+
}
|
|
91
|
+
function responsiveGridItemColumnEndStyle(props) {
|
|
92
|
+
let { media } = getTheme_v2(props.theme);
|
|
93
|
+
return _responsive(media, props.$columnEnd, (columnEnd) => ({ gridColumnEnd: `${columnEnd}` }));
|
|
94
|
+
}
|
|
95
|
+
function responsiveMarginStyle(props) {
|
|
96
|
+
let { theme } = props;
|
|
97
|
+
return [
|
|
98
|
+
_getResponsiveSpace(theme, ["margin"], props.$margin),
|
|
99
|
+
_getResponsiveSpace(theme, ["marginLeft", "marginRight"], props.$marginX),
|
|
100
|
+
_getResponsiveSpace(theme, ["marginTop", "marginBottom"], props.$marginY),
|
|
101
|
+
_getResponsiveSpace(theme, ["marginTop"], props.$marginTop),
|
|
102
|
+
_getResponsiveSpace(theme, ["marginRight"], props.$marginRight),
|
|
103
|
+
_getResponsiveSpace(theme, ["marginBottom"], props.$marginBottom),
|
|
104
|
+
_getResponsiveSpace(theme, ["marginLeft"], props.$marginLeft)
|
|
105
|
+
].filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
function responsivePaddingStyle(props) {
|
|
108
|
+
let { theme } = props;
|
|
109
|
+
return [
|
|
110
|
+
_getResponsiveSpace(theme, ["padding"], props.$padding),
|
|
111
|
+
_getResponsiveSpace(theme, ["paddingLeft", "paddingRight"], props.$paddingX),
|
|
112
|
+
_getResponsiveSpace(theme, ["paddingTop", "paddingBottom"], props.$paddingY),
|
|
113
|
+
_getResponsiveSpace(theme, ["paddingTop"], props.$paddingTop),
|
|
114
|
+
_getResponsiveSpace(theme, ["paddingRight"], props.$paddingRight),
|
|
115
|
+
_getResponsiveSpace(theme, ["paddingBottom"], props.$paddingBottom),
|
|
116
|
+
_getResponsiveSpace(theme, ["paddingLeft"], props.$paddingLeft)
|
|
117
|
+
].filter(Boolean);
|
|
118
|
+
}
|
|
119
|
+
const StyledBox = /* @__PURE__ */ styled.div.withConfig({
|
|
120
|
+
displayName: "StyledBox",
|
|
121
|
+
componentId: "sc-w5d1un-0"
|
|
122
|
+
})(boxStyle, flexItemStyle, responsiveBoxStyle, responsiveGridItemStyle, responsiveMarginStyle, responsivePaddingStyle), Box = function Box(props) {
|
|
123
|
+
let $ = c(110), flex, gridColumn, gridColumnEnd, gridColumnStart, gridRow, gridRowEnd, gridRowStart, height, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, overflow, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, ref, restProps, sizing, t0, t1, t2, t3;
|
|
124
|
+
$[0] === props ? (flex = $[1], gridColumn = $[2], gridColumnEnd = $[3], gridColumnStart = $[4], gridRow = $[5], gridRowEnd = $[6], gridRowStart = $[7], height = $[8], marginBottom = $[9], marginLeft = $[10], marginRight = $[11], marginTop = $[12], marginX = $[13], marginY = $[14], overflow = $[15], paddingBottom = $[16], paddingLeft = $[17], paddingRight = $[18], paddingTop = $[19], paddingX = $[20], paddingY = $[21], ref = $[22], restProps = $[23], sizing = $[24], t0 = $[25], t1 = $[26], t2 = $[27], t3 = $[28]) : ({as: t0, ref, gridColumn, gridColumnStart, gridColumnEnd, display: t1, flex, height, margin: t2, marginX, marginY, marginTop, marginRight, marginBottom, marginLeft, overflow, padding: t3, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, gridRow, gridRowStart, gridRowEnd, sizing, ...restProps} = props, $[0] = props, $[1] = flex, $[2] = gridColumn, $[3] = gridColumnEnd, $[4] = gridColumnStart, $[5] = gridRow, $[6] = gridRowEnd, $[7] = gridRowStart, $[8] = height, $[9] = marginBottom, $[10] = marginLeft, $[11] = marginRight, $[12] = marginTop, $[13] = marginX, $[14] = marginY, $[15] = overflow, $[16] = paddingBottom, $[17] = paddingLeft, $[18] = paddingRight, $[19] = paddingTop, $[20] = paddingX, $[21] = paddingY, $[22] = ref, $[23] = restProps, $[24] = sizing, $[25] = t0, $[26] = t1, $[27] = t2, $[28] = t3);
|
|
125
|
+
let asProp = t0 === void 0 ? "div" : t0, display = t1 === void 0 ? "block" : t1, margin = t2 === void 0 ? 0 : t2, padding = t3 === void 0 ? 0 : t3, t4 = typeof asProp == "string" ? asProp : void 0, t5;
|
|
126
|
+
$[29] === gridColumn ? t5 = $[30] : (t5 = _getArrayProp(gridColumn), $[29] = gridColumn, $[30] = t5);
|
|
127
|
+
let t6;
|
|
128
|
+
$[31] === gridColumnStart ? t6 = $[32] : (t6 = _getArrayProp(gridColumnStart), $[31] = gridColumnStart, $[32] = t6);
|
|
129
|
+
let t7;
|
|
130
|
+
$[33] === gridColumnEnd ? t7 = $[34] : (t7 = _getArrayProp(gridColumnEnd), $[33] = gridColumnEnd, $[34] = t7);
|
|
131
|
+
let t8;
|
|
132
|
+
$[35] === display ? t8 = $[36] : (t8 = _getArrayProp(display), $[35] = display, $[36] = t8);
|
|
133
|
+
let t9;
|
|
134
|
+
$[37] === flex ? t9 = $[38] : (t9 = _getArrayProp(flex), $[37] = flex, $[38] = t9);
|
|
135
|
+
let t10;
|
|
136
|
+
$[39] === height ? t10 = $[40] : (t10 = _getArrayProp(height), $[39] = height, $[40] = t10);
|
|
137
|
+
let t11;
|
|
138
|
+
$[41] === margin ? t11 = $[42] : (t11 = _getArrayProp(margin), $[41] = margin, $[42] = t11);
|
|
139
|
+
let t12;
|
|
140
|
+
$[43] === marginX ? t12 = $[44] : (t12 = _getArrayProp(marginX), $[43] = marginX, $[44] = t12);
|
|
141
|
+
let t13;
|
|
142
|
+
$[45] === marginY ? t13 = $[46] : (t13 = _getArrayProp(marginY), $[45] = marginY, $[46] = t13);
|
|
143
|
+
let t14;
|
|
144
|
+
$[47] === marginTop ? t14 = $[48] : (t14 = _getArrayProp(marginTop), $[47] = marginTop, $[48] = t14);
|
|
145
|
+
let t15;
|
|
146
|
+
$[49] === marginRight ? t15 = $[50] : (t15 = _getArrayProp(marginRight), $[49] = marginRight, $[50] = t15);
|
|
147
|
+
let t16;
|
|
148
|
+
$[51] === marginBottom ? t16 = $[52] : (t16 = _getArrayProp(marginBottom), $[51] = marginBottom, $[52] = t16);
|
|
149
|
+
let t17;
|
|
150
|
+
$[53] === marginLeft ? t17 = $[54] : (t17 = _getArrayProp(marginLeft), $[53] = marginLeft, $[54] = t17);
|
|
151
|
+
let t18;
|
|
152
|
+
$[55] === overflow ? t18 = $[56] : (t18 = _getArrayProp(overflow), $[55] = overflow, $[56] = t18);
|
|
153
|
+
let t19;
|
|
154
|
+
$[57] === padding ? t19 = $[58] : (t19 = _getArrayProp(padding), $[57] = padding, $[58] = t19);
|
|
155
|
+
let t20;
|
|
156
|
+
$[59] === paddingX ? t20 = $[60] : (t20 = _getArrayProp(paddingX), $[59] = paddingX, $[60] = t20);
|
|
157
|
+
let t21;
|
|
158
|
+
$[61] === paddingY ? t21 = $[62] : (t21 = _getArrayProp(paddingY), $[61] = paddingY, $[62] = t21);
|
|
159
|
+
let t22;
|
|
160
|
+
$[63] === paddingTop ? t22 = $[64] : (t22 = _getArrayProp(paddingTop), $[63] = paddingTop, $[64] = t22);
|
|
161
|
+
let t23;
|
|
162
|
+
$[65] === paddingRight ? t23 = $[66] : (t23 = _getArrayProp(paddingRight), $[65] = paddingRight, $[66] = t23);
|
|
163
|
+
let t24;
|
|
164
|
+
$[67] === paddingBottom ? t24 = $[68] : (t24 = _getArrayProp(paddingBottom), $[67] = paddingBottom, $[68] = t24);
|
|
165
|
+
let t25;
|
|
166
|
+
$[69] === paddingLeft ? t25 = $[70] : (t25 = _getArrayProp(paddingLeft), $[69] = paddingLeft, $[70] = t25);
|
|
167
|
+
let t26;
|
|
168
|
+
$[71] === gridRow ? t26 = $[72] : (t26 = _getArrayProp(gridRow), $[71] = gridRow, $[72] = t26);
|
|
169
|
+
let t27;
|
|
170
|
+
$[73] === gridRowStart ? t27 = $[74] : (t27 = _getArrayProp(gridRowStart), $[73] = gridRowStart, $[74] = t27);
|
|
171
|
+
let t28;
|
|
172
|
+
$[75] === gridRowEnd ? t28 = $[76] : (t28 = _getArrayProp(gridRowEnd), $[75] = gridRowEnd, $[76] = t28);
|
|
173
|
+
let t29;
|
|
174
|
+
$[77] === sizing ? t29 = $[78] : (t29 = _getArrayProp(sizing), $[77] = sizing, $[78] = t29);
|
|
175
|
+
let t30;
|
|
176
|
+
return $[79] !== asProp || $[80] !== props.children || $[81] !== ref || $[82] !== restProps || $[83] !== t10 || $[84] !== t11 || $[85] !== t12 || $[86] !== t13 || $[87] !== t14 || $[88] !== t15 || $[89] !== t16 || $[90] !== t17 || $[91] !== t18 || $[92] !== t19 || $[93] !== t20 || $[94] !== t21 || $[95] !== t22 || $[96] !== t23 || $[97] !== t24 || $[98] !== t25 || $[99] !== t26 || $[100] !== t27 || $[101] !== t28 || $[102] !== t29 || $[103] !== t4 || $[104] !== t5 || $[105] !== t6 || $[106] !== t7 || $[107] !== t8 || $[108] !== t9 ? (t30 = /* @__PURE__ */ jsx(StyledBox, {
|
|
177
|
+
"data-as": t4,
|
|
178
|
+
"data-ui": "Box",
|
|
179
|
+
...restProps,
|
|
180
|
+
$column: t5,
|
|
181
|
+
$columnStart: t6,
|
|
182
|
+
$columnEnd: t7,
|
|
183
|
+
$display: t8,
|
|
184
|
+
$flex: t9,
|
|
185
|
+
$height: t10,
|
|
186
|
+
$margin: t11,
|
|
187
|
+
$marginX: t12,
|
|
188
|
+
$marginY: t13,
|
|
189
|
+
$marginTop: t14,
|
|
190
|
+
$marginRight: t15,
|
|
191
|
+
$marginBottom: t16,
|
|
192
|
+
$marginLeft: t17,
|
|
193
|
+
$overflow: t18,
|
|
194
|
+
$padding: t19,
|
|
195
|
+
$paddingX: t20,
|
|
196
|
+
$paddingY: t21,
|
|
197
|
+
$paddingTop: t22,
|
|
198
|
+
$paddingRight: t23,
|
|
199
|
+
$paddingBottom: t24,
|
|
200
|
+
$paddingLeft: t25,
|
|
201
|
+
$row: t26,
|
|
202
|
+
$rowStart: t27,
|
|
203
|
+
$rowEnd: t28,
|
|
204
|
+
$sizing: t29,
|
|
205
|
+
as: asProp,
|
|
206
|
+
ref,
|
|
207
|
+
children: props.children
|
|
208
|
+
}), $[79] = asProp, $[80] = props.children, $[81] = ref, $[82] = restProps, $[83] = t10, $[84] = t11, $[85] = t12, $[86] = t13, $[87] = t14, $[88] = t15, $[89] = t16, $[90] = t17, $[91] = t18, $[92] = t19, $[93] = t20, $[94] = t21, $[95] = t22, $[96] = t23, $[97] = t24, $[98] = t25, $[99] = t26, $[100] = t27, $[101] = t28, $[102] = t29, $[103] = t4, $[104] = t5, $[105] = t6, $[106] = t7, $[107] = t8, $[108] = t9, $[109] = t30) : t30 = $[109], t30;
|
|
209
|
+
};
|
|
210
|
+
function responsiveRadiusStyle(props) {
|
|
211
|
+
let { media, radius } = getTheme_v2(props.theme);
|
|
212
|
+
return _responsive(media, props.$radius, (value) => {
|
|
213
|
+
let borderRadius = 0;
|
|
214
|
+
return typeof value == "number" && (borderRadius = rem(radius[value])), value === "full" && (borderRadius = "9999px"), { borderRadius };
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
function useTheme$1() {
|
|
221
|
+
return useTheme();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
function useTheme_v2() {
|
|
227
|
+
let $ = c(2), t0 = useTheme(), t1;
|
|
228
|
+
return $[0] === t0 ? t1 = $[1] : (t1 = getTheme_v2(t0), $[0] = t0, $[1] = t1), t1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
function _cardColorStyle(base, color, checkered = !1) {
|
|
234
|
+
return {
|
|
235
|
+
"--card-backdrop-color": base.backdrop,
|
|
236
|
+
"--card-focus-ring-color": base.focusRing,
|
|
237
|
+
"--card-shadow-outline-color": base.shadow.outline,
|
|
238
|
+
"--card-shadow-umbra-color": base.shadow.umbra,
|
|
239
|
+
"--card-shadow-penumbra-color": base.shadow.penumbra,
|
|
240
|
+
"--card-shadow-ambient-color": base.shadow.ambient,
|
|
241
|
+
"--card-accent-fg-color": color.accent.fg,
|
|
242
|
+
"--card-avatar-gray-bg-color": color.avatar.gray.bg,
|
|
243
|
+
"--card-avatar-gray-fg-color": color.avatar.gray.fg,
|
|
244
|
+
"--card-avatar-blue-bg-color": color.avatar.blue.bg,
|
|
245
|
+
"--card-avatar-blue-fg-color": color.avatar.blue.fg,
|
|
246
|
+
"--card-avatar-purple-bg-color": color.avatar.purple.bg,
|
|
247
|
+
"--card-avatar-purple-fg-color": color.avatar.purple.fg,
|
|
248
|
+
"--card-avatar-magenta-bg-color": color.avatar.magenta.bg,
|
|
249
|
+
"--card-avatar-magenta-fg-color": color.avatar.magenta.fg,
|
|
250
|
+
"--card-avatar-red-bg-color": color.avatar.red.bg,
|
|
251
|
+
"--card-avatar-red-fg-color": color.avatar.red.fg,
|
|
252
|
+
"--card-avatar-orange-bg-color": color.avatar.orange.bg,
|
|
253
|
+
"--card-avatar-orange-fg-color": color.avatar.orange.fg,
|
|
254
|
+
"--card-avatar-yellow-bg-color": color.avatar.yellow.bg,
|
|
255
|
+
"--card-avatar-yellow-fg-color": color.avatar.yellow.fg,
|
|
256
|
+
"--card-avatar-green-bg-color": color.avatar.green.bg,
|
|
257
|
+
"--card-avatar-green-fg-color": color.avatar.green.fg,
|
|
258
|
+
"--card-avatar-cyan-bg-color": color.avatar.cyan.bg,
|
|
259
|
+
"--card-avatar-cyan-fg-color": color.avatar.cyan.fg,
|
|
260
|
+
"--card-bg-color": color.bg,
|
|
261
|
+
"--card-bg-image": checkered ? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.muted.bg} 0% 50%)` : void 0,
|
|
262
|
+
"--card-border-color": color.border,
|
|
263
|
+
"--card-badge-default-bg-color": color.badge.default.bg,
|
|
264
|
+
"--card-badge-default-dot-color": color.badge.default.dot,
|
|
265
|
+
"--card-badge-default-fg-color": color.badge.default.fg,
|
|
266
|
+
"--card-badge-default-icon-color": color.badge.default.icon,
|
|
267
|
+
"--card-badge-neutral-bg-color": color.badge.neutral?.bg,
|
|
268
|
+
"--card-badge-neutral-dot-color": color.badge.neutral?.dot,
|
|
269
|
+
"--card-badge-neutral-fg-color": color.badge.neutral?.fg,
|
|
270
|
+
"--card-badge-neutral-icon-color": color.badge.neutral?.icon,
|
|
271
|
+
"--card-badge-primary-bg-color": color.badge.primary.bg,
|
|
272
|
+
"--card-badge-primary-dot-color": color.badge.primary.dot,
|
|
273
|
+
"--card-badge-primary-fg-color": color.badge.primary.fg,
|
|
274
|
+
"--card-badge-primary-icon-color": color.badge.primary.icon,
|
|
275
|
+
"--card-badge-suggest-bg-color": color.badge.suggest?.bg,
|
|
276
|
+
"--card-badge-suggest-dot-color": color.badge.suggest?.dot,
|
|
277
|
+
"--card-badge-suggest-fg-color": color.badge.suggest?.fg,
|
|
278
|
+
"--card-badge-suggest-icon-color": color.badge.suggest?.icon,
|
|
279
|
+
"--card-badge-positive-bg-color": color.badge.positive.bg,
|
|
280
|
+
"--card-badge-positive-dot-color": color.badge.positive.dot,
|
|
281
|
+
"--card-badge-positive-fg-color": color.badge.positive.fg,
|
|
282
|
+
"--card-badge-positive-icon-color": color.badge.positive.icon,
|
|
283
|
+
"--card-badge-caution-bg-color": color.badge.caution.bg,
|
|
284
|
+
"--card-badge-caution-dot-color": color.badge.caution.dot,
|
|
285
|
+
"--card-badge-caution-fg-color": color.badge.caution.fg,
|
|
286
|
+
"--card-badge-caution-icon-color": color.badge.caution.icon,
|
|
287
|
+
"--card-badge-critical-bg-color": color.badge.critical.bg,
|
|
288
|
+
"--card-badge-critical-dot-color": color.badge.critical.dot,
|
|
289
|
+
"--card-badge-critical-fg-color": color.badge.critical.fg,
|
|
290
|
+
"--card-badge-critical-icon-color": color.badge.critical.icon,
|
|
291
|
+
"--card-code-bg-color": color.code.bg,
|
|
292
|
+
"--card-code-fg-color": color.code.fg,
|
|
293
|
+
"--card-fg-color": color.fg,
|
|
294
|
+
"--card-icon-color": color.icon,
|
|
295
|
+
"--card-kbd-bg-color": color.kbd.bg,
|
|
296
|
+
"--card-kbd-border-color": color.kbd.border,
|
|
297
|
+
"--card-kbd-fg-color": color.kbd.fg,
|
|
298
|
+
"--card-link-fg-color": color.link.fg,
|
|
299
|
+
"--card-muted-bg-color": color.muted.bg,
|
|
300
|
+
"--card-muted-fg-color": color.muted.fg,
|
|
301
|
+
"--card-skeleton-color-from": color.skeleton.from,
|
|
302
|
+
"--card-skeleton-color-to": color.skeleton.to,
|
|
303
|
+
"--card-bg2-color": color.muted.bg,
|
|
304
|
+
"--card-link-color": color.link.fg,
|
|
305
|
+
"--card-hairline-soft-color": color.border,
|
|
306
|
+
"--card-hairline-hard-color": color.border
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function focusRingBorderStyle(border) {
|
|
310
|
+
return `inset 0 0 0 ${border.width}px ${border.color}`;
|
|
311
|
+
}
|
|
312
|
+
function focusRingStyle(opts) {
|
|
313
|
+
let { base, border, focusRing } = opts, focusRingOutsetWidth = focusRing.offset + focusRing.width, focusRingInsetWidth = 0 - focusRing.offset, bgColor = base ? base.bg : "var(--card-bg-color)";
|
|
314
|
+
return [
|
|
315
|
+
focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
|
|
316
|
+
border && focusRingBorderStyle(border),
|
|
317
|
+
focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
|
|
318
|
+
focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`
|
|
319
|
+
].filter(Boolean).join(",");
|
|
320
|
+
}
|
|
321
|
+
function responsiveBorderStyle() {
|
|
322
|
+
return [
|
|
323
|
+
border,
|
|
324
|
+
borderTop,
|
|
325
|
+
borderRight,
|
|
326
|
+
borderBottom,
|
|
327
|
+
borderLeft
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
function border(props) {
|
|
331
|
+
let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
332
|
+
return _responsive(media, props.$border, (value) => value ? { "&&": { border: borderStyle } } : { "&&": { border: 0 } });
|
|
333
|
+
}
|
|
334
|
+
function borderTop(props) {
|
|
335
|
+
let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
336
|
+
return _responsive(media, props.$borderTop, (value) => value ? { "&&": { borderTop: borderStyle } } : { "&&": { borderTop: 0 } });
|
|
337
|
+
}
|
|
338
|
+
function borderRight(props) {
|
|
339
|
+
let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
340
|
+
return _responsive(media, props.$borderRight, (value) => value ? { "&&": { borderRight: borderStyle } } : { "&&": { borderRight: 0 } });
|
|
341
|
+
}
|
|
342
|
+
function borderBottom(props) {
|
|
343
|
+
let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
344
|
+
return _responsive(media, props.$borderBottom, (value) => value ? { "&&": { borderBottom: borderStyle } } : { "&&": { borderBottom: 0 } });
|
|
345
|
+
}
|
|
346
|
+
function borderLeft(props) {
|
|
347
|
+
let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
348
|
+
return _responsive(media, props.$borderLeft, (value) => value ? { "&&": { borderLeft: borderStyle } } : { "&&": { borderLeft: 0 } });
|
|
349
|
+
}
|
|
350
|
+
function toBoxShadow(shadow, color) {
|
|
351
|
+
return `${shadow.map(rem).join(" ")} ${color}`;
|
|
352
|
+
}
|
|
353
|
+
function shadowStyle(shadow, outlineWidth = 1) {
|
|
354
|
+
return shadow ? { boxShadow: `${`0 0 0 ${rem(outlineWidth)} var(--card-shadow-outline-color)`}, ${toBoxShadow(shadow.umbra, "var(--card-shadow-umbra-color)")}, ${toBoxShadow(shadow.penumbra, "var(--card-shadow-penumbra-color)")}, ${toBoxShadow(shadow.ambient, "var(--card-shadow-ambient-color)")}` } : EMPTY_RECORD;
|
|
355
|
+
}
|
|
356
|
+
function responsiveShadowStyle(props) {
|
|
357
|
+
let { card, media, shadow } = getTheme_v2(props.theme);
|
|
358
|
+
return _responsive(media, props.$shadow, (index) => shadowStyle(shadow[index], card.shadow.outline));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Gets the global scope instance in a given environment.
|
|
362
|
+
*
|
|
363
|
+
* The strategy is to return the most modern, and if not, the most common:
|
|
364
|
+
* - The `globalThis` variable is the modern approach to accessing the global scope
|
|
365
|
+
* - The `window` variable is the global scope in a web browser
|
|
366
|
+
* - The `self` variable is the global scope in workers and others
|
|
367
|
+
* - The `global` variable is the global scope in Node.js
|
|
368
|
+
*/
|
|
369
|
+
function getGlobalScope() {
|
|
370
|
+
if (typeof globalThis < "u") return globalThis;
|
|
371
|
+
if (typeof window < "u") return window;
|
|
372
|
+
if (typeof self < "u") return self;
|
|
373
|
+
if (typeof global < "u") return global;
|
|
374
|
+
throw Error("@sanity/ui: could not locate global scope");
|
|
375
|
+
}
|
|
376
|
+
const globalScope = getGlobalScope();
|
|
377
|
+
/**
|
|
378
|
+
* As `@sanity/ui` is declared as a dependency, and may be duplicated, sometimes across major versions
|
|
379
|
+
* it's critical that vital react contexts are shared even when there is a duplicate.
|
|
380
|
+
* If we used a model similar to `sanity` itself, or `styled-components`, this would be unnecessary as
|
|
381
|
+
* those libraries enforce single instances.
|
|
382
|
+
* Since we don't enforce it we have to support a sanity plugin being able to call hooks like `useToast`, and then
|
|
383
|
+
* read the context setup by `sanity`, which calls `ToastProvider`, even if the provider and hook are different instances in memory.
|
|
384
|
+
* It's also why it's vital that all changes to globally scoped providers remain fully backwards compatible to v1.
|
|
385
|
+
*/
|
|
386
|
+
function createGlobalScopedContext(key, defaultValue) {
|
|
387
|
+
let symbol = Symbol.for(key);
|
|
388
|
+
/**
|
|
389
|
+
* Prevent errors about re-renders on React SSR on Next.js App Router
|
|
390
|
+
*/
|
|
391
|
+
if (typeof document > "u") {
|
|
392
|
+
let context = createContext(defaultValue);
|
|
393
|
+
return context.displayName = key, context;
|
|
394
|
+
}
|
|
395
|
+
return globalScope[symbol] = globalScope[symbol] || createContext(defaultValue), globalScope[symbol];
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @internal
|
|
399
|
+
*/
|
|
400
|
+
const ThemeContext = createGlobalScopedContext("@sanity/ui/context/theme", null);
|
|
401
|
+
/**
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
404
|
+
function ThemeProvider$1(props) {
|
|
405
|
+
let $ = c(15), parentTheme = useContext(ThemeContext), { children } = props, scheme = props.scheme ?? (parentTheme?.scheme || "light"), rootTheme = props.theme ?? (parentTheme?.theme || null), tone = props.tone ?? (parentTheme?.tone || "default"), t0;
|
|
406
|
+
bb0: {
|
|
407
|
+
if (!rootTheme) {
|
|
408
|
+
t0 = null;
|
|
409
|
+
break bb0;
|
|
410
|
+
}
|
|
411
|
+
let t1;
|
|
412
|
+
$[0] !== rootTheme || $[1] !== scheme || $[2] !== tone ? (t1 = {
|
|
413
|
+
version: 0,
|
|
414
|
+
theme: rootTheme,
|
|
415
|
+
scheme,
|
|
416
|
+
tone
|
|
417
|
+
}, $[0] = rootTheme, $[1] = scheme, $[2] = tone, $[3] = t1) : t1 = $[3], t0 = t1;
|
|
418
|
+
}
|
|
419
|
+
let themeContext = t0, t1;
|
|
420
|
+
bb1: {
|
|
421
|
+
if (!rootTheme) {
|
|
422
|
+
t1 = null;
|
|
423
|
+
break bb1;
|
|
424
|
+
}
|
|
425
|
+
let t2;
|
|
426
|
+
$[4] !== rootTheme || $[5] !== scheme || $[6] !== tone ? (t2 = getScopedTheme(rootTheme, scheme, tone), $[4] = rootTheme, $[5] = scheme, $[6] = tone, $[7] = t2) : t2 = $[7], t1 = t2;
|
|
427
|
+
}
|
|
428
|
+
let theme = t1;
|
|
429
|
+
if (!theme) {
|
|
430
|
+
let t2;
|
|
431
|
+
return $[8] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("pre", { children: "ThemeProvider: no \"theme\" property provided" }), $[8] = t2) : t2 = $[8], t2;
|
|
432
|
+
}
|
|
433
|
+
let t2;
|
|
434
|
+
$[9] !== children || $[10] !== theme ? (t2 = /* @__PURE__ */ jsx(ThemeProvider, {
|
|
435
|
+
theme,
|
|
436
|
+
children
|
|
437
|
+
}), $[9] = children, $[10] = theme, $[11] = t2) : t2 = $[11];
|
|
438
|
+
let t3;
|
|
439
|
+
return $[12] !== t2 || $[13] !== themeContext ? (t3 = /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
440
|
+
value: themeContext,
|
|
441
|
+
children: t2
|
|
442
|
+
}), $[12] = t2, $[13] = themeContext, $[14] = t3) : t3 = $[14], t3;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* @public
|
|
446
|
+
*/
|
|
447
|
+
function useRootTheme() {
|
|
448
|
+
let value = useContext(ThemeContext);
|
|
449
|
+
if (!value) throw Error("useRootTheme(): missing context value");
|
|
450
|
+
return value;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
function ThemeColorProvider(props) {
|
|
456
|
+
let $ = c(5), { children, scheme, tone } = props, root = useRootTheme(), t0 = scheme || root.scheme, t1;
|
|
457
|
+
return $[0] !== children || $[1] !== root.theme || $[2] !== t0 || $[3] !== tone ? (t1 = /* @__PURE__ */ jsx(ThemeProvider$1, {
|
|
458
|
+
scheme: t0,
|
|
459
|
+
theme: root.theme,
|
|
460
|
+
tone,
|
|
461
|
+
children
|
|
462
|
+
}), $[0] = children, $[1] = root.theme, $[2] = t0, $[3] = tone, $[4] = t1) : t1 = $[4], t1;
|
|
463
|
+
}
|
|
464
|
+
function cardStyle(props) {
|
|
465
|
+
return [cardBaseStyle(props), cardColorStyle(props)];
|
|
466
|
+
}
|
|
467
|
+
function cardBaseStyle(props) {
|
|
468
|
+
let { $checkered } = props, { space } = getTheme_v2(props.theme);
|
|
469
|
+
return css`${$checkered && css`background-size:${space[3]}px ${space[3]}px;background-position:50% 50%;background-image:var(--card-bg-image);`} &[data-as='button']{-webkit-font-smoothing:inherit;appearance:none;outline:none;font:inherit;text-align:inherit;border:0;width:-moz-available;width:-webkit-fill-available;width:stretch;}&[data-as='a']{outline:none;text-decoration:none;}&[data-as='pre']{font:inherit;}`;
|
|
470
|
+
}
|
|
471
|
+
function cardColorStyle(props) {
|
|
472
|
+
let { $checkered, $focusRing, $muted } = props, { card, color, style } = getTheme_v2(props.theme), border = {
|
|
473
|
+
width: card.border.width,
|
|
474
|
+
color: "var(--card-border-color)"
|
|
475
|
+
};
|
|
476
|
+
return css`color-scheme:${color._dark ? "dark" : "light"};${_cardColorStyle(color, color, $checkered)} background-color:${$muted ? "var(--card-muted-bg-color)" : "var(--card-bg-color)"};color:var(--card-fg-color);&[data-as='button']{--card-focus-ring-box-shadow:none;cursor:default;box-shadow:var(--card-focus-ring-box-shadow);&:disabled{${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}}&:not(:disabled){&[data-pressed]{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}&[data-selected]{${_cardColorStyle(color, color.selectable.default.selected, $checkered)}}@media (hover:hover){&:not([data-pressed]):not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}}&:active{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}}}&:focus-visible{--card-focus-ring-box-shadow:${$focusRing ? focusRingStyle({
|
|
477
|
+
base: color,
|
|
478
|
+
border,
|
|
479
|
+
focusRing: card.focusRing
|
|
480
|
+
}) : void 0};}}}&[data-as='a']{cursor:pointer;box-shadow:var(--card-focus-ring-box-shadow);&[data-disabled]{${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}}&:not([data-disabled]){&[data-pressed]{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}&[data-selected]{${_cardColorStyle(color, color.selectable.default.selected, $checkered)}}@media (hover:hover){&:not([data-pressed]):not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}}&:active{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}}}&:focus-visible{--card-focus-ring-box-shadow:${$focusRing ? focusRingStyle({
|
|
481
|
+
base: color,
|
|
482
|
+
border,
|
|
483
|
+
focusRing: card.focusRing
|
|
484
|
+
}) : void 0};}}}${style?.card?.root}`;
|
|
485
|
+
}
|
|
486
|
+
const StyledCard = /* @__PURE__ */ styled(Box).withConfig({
|
|
487
|
+
displayName: "StyledCard",
|
|
488
|
+
componentId: "sc-46g0j2-0"
|
|
489
|
+
})(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle), Card = function Card(props) {
|
|
490
|
+
let $ = c(57), asProp, border, borderBottom, borderLeft, borderRight, borderTop, muted, pressed, ref, restProps, scheme, selected, shadow, t0, t1, t2, t3;
|
|
491
|
+
$[0] === props ? (asProp = $[1], border = $[2], borderBottom = $[3], borderLeft = $[4], borderRight = $[5], borderTop = $[6], muted = $[7], pressed = $[8], ref = $[9], restProps = $[10], scheme = $[11], selected = $[12], shadow = $[13], t0 = $[14], t1 = $[15], t2 = $[16], t3 = $[17]) : ({__unstable_checkered: t0, __unstable_focusRing: t1, as: asProp, border, borderTop, borderRight, borderBottom, borderLeft, muted, pressed, radius: t2, ref, scheme, selected, shadow, tone: t3, ...restProps} = props, $[0] = props, $[1] = asProp, $[2] = border, $[3] = borderBottom, $[4] = borderLeft, $[5] = borderRight, $[6] = borderTop, $[7] = muted, $[8] = pressed, $[9] = ref, $[10] = restProps, $[11] = scheme, $[12] = selected, $[13] = shadow, $[14] = t0, $[15] = t1, $[16] = t2, $[17] = t3);
|
|
492
|
+
let checkered = t0 !== void 0 && t0, focusRing = t1 !== void 0 && t1, radius = t2 === void 0 ? 0 : t2, toneProp = t3 === void 0 ? "default" : t3, as = isValidElementType(asProp) ? asProp : "div", rootTheme = useRootTheme(), tone = toneProp === "inherit" ? rootTheme.tone : toneProp, t4 = typeof as == "string" ? as : void 0, t5 = rootTheme.scheme, t6;
|
|
493
|
+
$[18] === border ? t6 = $[19] : (t6 = _getArrayProp(border), $[18] = border, $[19] = t6);
|
|
494
|
+
let t7;
|
|
495
|
+
$[20] === borderTop ? t7 = $[21] : (t7 = _getArrayProp(borderTop), $[20] = borderTop, $[21] = t7);
|
|
496
|
+
let t8;
|
|
497
|
+
$[22] === borderRight ? t8 = $[23] : (t8 = _getArrayProp(borderRight), $[22] = borderRight, $[23] = t8);
|
|
498
|
+
let t9;
|
|
499
|
+
$[24] === borderBottom ? t9 = $[25] : (t9 = _getArrayProp(borderBottom), $[24] = borderBottom, $[25] = t9);
|
|
500
|
+
let t10;
|
|
501
|
+
$[26] === borderLeft ? t10 = $[27] : (t10 = _getArrayProp(borderLeft), $[26] = borderLeft, $[27] = t10);
|
|
502
|
+
let t11;
|
|
503
|
+
$[28] === radius ? t11 = $[29] : (t11 = _getArrayProp(radius), $[28] = radius, $[29] = t11);
|
|
504
|
+
let t12;
|
|
505
|
+
$[30] === shadow ? t12 = $[31] : (t12 = _getArrayProp(shadow), $[30] = shadow, $[31] = t12);
|
|
506
|
+
let t13 = checkered ? "" : void 0, t14 = pressed ? "" : void 0, t15 = selected ? "" : void 0, t16;
|
|
507
|
+
$[32] !== as || $[33] !== checkered || $[34] !== focusRing || $[35] !== muted || $[36] !== ref || $[37] !== restProps || $[38] !== rootTheme.scheme || $[39] !== selected || $[40] !== t10 || $[41] !== t11 || $[42] !== t12 || $[43] !== t13 || $[44] !== t14 || $[45] !== t15 || $[46] !== t4 || $[47] !== t6 || $[48] !== t7 || $[49] !== t8 || $[50] !== t9 || $[51] !== tone ? (t16 = /* @__PURE__ */ jsx(StyledCard, {
|
|
508
|
+
"data-as": t4,
|
|
509
|
+
"data-scheme": t5,
|
|
510
|
+
"data-ui": "Card",
|
|
511
|
+
"data-tone": tone,
|
|
512
|
+
...restProps,
|
|
513
|
+
$border: t6,
|
|
514
|
+
$borderTop: t7,
|
|
515
|
+
$borderRight: t8,
|
|
516
|
+
$borderBottom: t9,
|
|
517
|
+
$borderLeft: t10,
|
|
518
|
+
$checkered: checkered,
|
|
519
|
+
$focusRing: focusRing,
|
|
520
|
+
$muted: muted,
|
|
521
|
+
$radius: t11,
|
|
522
|
+
$shadow: t12,
|
|
523
|
+
$tone: tone,
|
|
524
|
+
"data-checkered": t13,
|
|
525
|
+
"data-pressed": t14,
|
|
526
|
+
"data-selected": t15,
|
|
527
|
+
forwardedAs: as,
|
|
528
|
+
ref,
|
|
529
|
+
selected
|
|
530
|
+
}), $[32] = as, $[33] = checkered, $[34] = focusRing, $[35] = muted, $[36] = ref, $[37] = restProps, $[38] = rootTheme.scheme, $[39] = selected, $[40] = t10, $[41] = t11, $[42] = t12, $[43] = t13, $[44] = t14, $[45] = t15, $[46] = t4, $[47] = t6, $[48] = t7, $[49] = t8, $[50] = t9, $[51] = tone, $[52] = t16) : t16 = $[52];
|
|
531
|
+
let t17;
|
|
532
|
+
return $[53] !== scheme || $[54] !== t16 || $[55] !== tone ? (t17 = /* @__PURE__ */ jsx(ThemeColorProvider, {
|
|
533
|
+
scheme,
|
|
534
|
+
tone,
|
|
535
|
+
children: t16
|
|
536
|
+
}), $[53] = scheme, $[54] = t16, $[55] = tone, $[56] = t17) : t17 = $[56], t17;
|
|
537
|
+
};
|
|
538
|
+
function _getMediaQuery(media, index) {
|
|
539
|
+
return index === 0 ? `screen and (max-width: ${media[index] - 1}px)` : index === media.length ? `screen and (min-width: ${media[index - 1]}px)` : `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`;
|
|
540
|
+
}
|
|
541
|
+
function _createMediaStore(media) {
|
|
542
|
+
let mediaLen = media.length, sizes, getSizes = () => {
|
|
543
|
+
if (!sizes) {
|
|
544
|
+
sizes = [];
|
|
545
|
+
for (let index = mediaLen; index > -1; --index) {
|
|
546
|
+
let mediaQuery = _getMediaQuery(media, index);
|
|
547
|
+
sizes.push({
|
|
548
|
+
index,
|
|
549
|
+
mq: window.matchMedia(mediaQuery)
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return sizes;
|
|
554
|
+
}, getSnapshot = () => {
|
|
555
|
+
for (let { index, mq } of getSizes()) if (mq.matches) return index;
|
|
556
|
+
return 0;
|
|
557
|
+
}, subscribe = (onStoreChange) => {
|
|
558
|
+
let disposeFns = [];
|
|
559
|
+
for (let { mq } of getSizes()) {
|
|
560
|
+
let handleChange = () => {
|
|
561
|
+
mq.matches && onStoreChange();
|
|
562
|
+
};
|
|
563
|
+
mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
|
|
564
|
+
}
|
|
565
|
+
return () => {
|
|
566
|
+
for (let disposeFn of disposeFns) disposeFn();
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
return {
|
|
570
|
+
getSnapshot,
|
|
571
|
+
subscribe
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Only called during server-side rendering, and hydration if using hydrateRoot
|
|
576
|
+
* Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query
|
|
577
|
+
* and we assume `(prefers-color-scheme: light)` since it's the most common scheme
|
|
578
|
+
*
|
|
579
|
+
* @link https://beta.reactjs.org/apis/react/useSyncExternalStore#adding-support-for-server-rendering
|
|
580
|
+
*/
|
|
581
|
+
function getServerSnapshot() {
|
|
582
|
+
return 0;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* This API might change. DO NOT USE IN PRODUCTION.
|
|
586
|
+
* @beta
|
|
587
|
+
*/
|
|
588
|
+
function useMediaIndex() {
|
|
589
|
+
let $ = c(2), { media } = useTheme_v2(), t0;
|
|
590
|
+
$[0] === media ? t0 = $[1] : (t0 = _createMediaStore(media), $[0] = media, $[1] = t0);
|
|
591
|
+
let store = t0;
|
|
592
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Efficiently subscribes to `window.matchMedia` queries
|
|
596
|
+
*
|
|
597
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
598
|
+
*
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
function useMatchMedia(mediaQueryString, getServerSnapshot) {
|
|
602
|
+
let $ = c(4);
|
|
603
|
+
useDebugValue(mediaQueryString);
|
|
604
|
+
let t0;
|
|
605
|
+
$[0] === mediaQueryString ? t0 = $[1] : (t0 = (onStoreChange) => {
|
|
606
|
+
let media = window.matchMedia(mediaQueryString);
|
|
607
|
+
return media.addEventListener("change", onStoreChange), () => media.removeEventListener("change", onStoreChange);
|
|
608
|
+
}, $[0] = mediaQueryString, $[1] = t0);
|
|
609
|
+
let t1;
|
|
610
|
+
return $[2] === mediaQueryString ? t1 = $[3] : (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1), useSyncExternalStore(t0, t1, getServerSnapshot);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Returns true if motion should be reduced
|
|
614
|
+
*
|
|
615
|
+
* @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
|
|
616
|
+
*
|
|
617
|
+
* If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
|
|
618
|
+
* Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
|
|
619
|
+
* @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
|
|
620
|
+
*
|
|
621
|
+
* @public
|
|
622
|
+
*/
|
|
623
|
+
function usePrefersReducedMotion(t0) {
|
|
624
|
+
return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$1 : t0);
|
|
625
|
+
}
|
|
626
|
+
function _temp$1() {
|
|
627
|
+
return !1;
|
|
628
|
+
}
|
|
629
|
+
function isRecord(value) {
|
|
630
|
+
return !!(value && typeof value == "object" && !Array.isArray(value));
|
|
631
|
+
}
|
|
632
|
+
function getLayerContext(contextValue) {
|
|
633
|
+
if (!isRecord(contextValue) || contextValue.version !== 0) throw Error("the context value is not compatible");
|
|
634
|
+
if (!contextValue) throw Error("components using `useLayer()` should be wrapped in a <LayerProvider>.");
|
|
635
|
+
if (contextValue.version === 0) return contextValue;
|
|
636
|
+
throw Error("could not get layer context");
|
|
637
|
+
}
|
|
638
|
+
const LayerContext = createGlobalScopedContext("@sanity/ui/context/layer", null);
|
|
639
|
+
/**
|
|
640
|
+
* @public
|
|
641
|
+
*/
|
|
642
|
+
function LayerProvider(props) {
|
|
643
|
+
let $ = c(21), { children, zOffset: t0 } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext), t1;
|
|
644
|
+
$[0] === parentContextValue ? t1 = $[1] : (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1);
|
|
645
|
+
let parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, t2;
|
|
646
|
+
$[2] === zOffsetProp ? t2 = $[3] : (t2 = _getArrayProp(zOffsetProp), $[2] = zOffsetProp, $[3] = t2);
|
|
647
|
+
let zOffset = t2, maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], t3;
|
|
648
|
+
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[4] = t3) : t3 = $[4];
|
|
649
|
+
let [, setChildLayers] = useState(t3), [size, setSize] = useState(0), isTopLayer = size === 0, t4;
|
|
650
|
+
$[5] !== parentRegisterChild || $[6] !== setChildLayers ? (t4 = (childLevel) => {
|
|
651
|
+
let parentDispose = parentRegisterChild?.(childLevel);
|
|
652
|
+
return childLevel === void 0 ? setSize(_temp) : setChildLayers((state) => {
|
|
653
|
+
let prevLen = state[childLevel] ?? 0, nextState = {
|
|
654
|
+
...state,
|
|
655
|
+
[childLevel]: prevLen + 1
|
|
656
|
+
};
|
|
657
|
+
return setSize(Object.keys(nextState).length), nextState;
|
|
658
|
+
}), () => {
|
|
659
|
+
childLevel === void 0 ? setSize(_temp2) : setChildLayers((state_0) => {
|
|
660
|
+
let nextState_0 = { ...state_0 };
|
|
661
|
+
return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
|
|
662
|
+
}), parentDispose?.();
|
|
663
|
+
};
|
|
664
|
+
}, $[5] = parentRegisterChild, $[6] = setChildLayers, $[7] = t4) : t4 = $[7];
|
|
665
|
+
let registerChild = t4, t5, t6;
|
|
666
|
+
$[8] !== level || $[9] !== parentRegisterChild ? (t5 = () => parentRegisterChild?.(level), t6 = [level, parentRegisterChild], $[8] = level, $[9] = parentRegisterChild, $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]), useEffect(t5, t6);
|
|
667
|
+
let t7;
|
|
668
|
+
$[12] !== isTopLayer || $[13] !== level || $[14] !== registerChild || $[15] !== size || $[16] !== zIndex ? (t7 = {
|
|
669
|
+
version: 0,
|
|
670
|
+
isTopLayer,
|
|
671
|
+
level,
|
|
672
|
+
registerChild,
|
|
673
|
+
size,
|
|
674
|
+
zIndex
|
|
675
|
+
}, $[12] = isTopLayer, $[13] = level, $[14] = registerChild, $[15] = size, $[16] = zIndex, $[17] = t7) : t7 = $[17];
|
|
676
|
+
let value = t7, t8;
|
|
677
|
+
return $[18] !== children || $[19] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, {
|
|
678
|
+
value,
|
|
679
|
+
children
|
|
680
|
+
}), $[18] = children, $[19] = value, $[20] = t8) : t8 = $[20], t8;
|
|
681
|
+
}
|
|
682
|
+
function _temp2(v_0) {
|
|
683
|
+
return v_0 - 1;
|
|
684
|
+
}
|
|
685
|
+
function _temp(v) {
|
|
686
|
+
return v + 1;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* @public
|
|
690
|
+
*/
|
|
691
|
+
function useLayer() {
|
|
692
|
+
let $ = c(2), value = useContext(LayerContext);
|
|
693
|
+
if (!value) throw Error("useLayer(): missing context value");
|
|
694
|
+
try {
|
|
695
|
+
let t1;
|
|
696
|
+
return $[0] === value ? t1 = $[1] : (t1 = getLayerContext(value), $[0] = value, $[1] = t1), t1;
|
|
697
|
+
} catch (t0) {
|
|
698
|
+
let err = t0;
|
|
699
|
+
throw err instanceof Error ? Error(`useLayer(): ${err.message}`) : Error(`useLayer(): ${err}`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
export { useTheme_v2 as _, useMatchMedia as a, responsivePaddingStyle as b, ThemeColorProvider as c, createGlobalScopedContext as d, globalScope as f, useTheme$1 as g, _cardColorStyle as h, usePrefersReducedMotion as i, useRootTheme as l, focusRingStyle as m, LayerProvider as n, useMediaIndex as o, focusRingBorderStyle as p, isRecord as r, Card as s, useLayer as t, ThemeProvider$1 as u, responsiveRadiusStyle as v, flexItemStyle as x, Box as y };
|
|
703
|
+
|
|
704
|
+
//# sourceMappingURL=useLayer-9Pz-GG0r.js.map
|