@sanity/ui 4.0.7 → 4.1.0

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.
Files changed (41) hide show
  1. package/dist/{arrow-CL8xmdbg.js → arrow-C6TlkggA.js} +5 -4
  2. package/dist/arrow-C6TlkggA.js.map +1 -0
  3. package/dist/autocomplete.d.ts.map +1 -1
  4. package/dist/autocomplete.js +35 -39
  5. package/dist/autocomplete.js.map +1 -1
  6. package/dist/breadcrumbs.d.ts.map +1 -1
  7. package/dist/breadcrumbs.js +28 -30
  8. package/dist/breadcrumbs.js.map +1 -1
  9. package/dist/{button-DQH2KIbq.js → button-D3iEd7Je.js} +7 -7
  10. package/dist/button-D3iEd7Je.js.map +1 -0
  11. package/dist/button-dnqMFkWg.d.ts.map +1 -1
  12. package/dist/{hotkeys-BPlacpG8.js → hotkeys-Bi6Q5963.js} +26 -26
  13. package/dist/hotkeys-Bi6Q5963.js.map +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +310 -344
  16. package/dist/index.js.map +1 -1
  17. package/dist/layer-BK7xWHcE.js +61 -0
  18. package/dist/layer-BK7xWHcE.js.map +1 -0
  19. package/dist/layer-ChlP9Ik6.d.ts.map +1 -1
  20. package/dist/menu.d.ts.map +1 -1
  21. package/dist/menu.js +46 -34
  22. package/dist/menu.js.map +1 -1
  23. package/dist/{popover-CEbjxiPx.js → popover-CdBTZDvj.js} +2 -2
  24. package/dist/{popover-CEbjxiPx.js.map → popover-CdBTZDvj.js.map} +1 -1
  25. package/dist/popover.js +1 -1
  26. package/dist/styles.css +408 -0
  27. package/dist/{textInput-B6ZZJSOj.js → textInput-Bu3QuADZ.js} +36 -48
  28. package/dist/textInput-Bu3QuADZ.js.map +1 -0
  29. package/dist/toast.d.ts.map +1 -1
  30. package/dist/toast.js +77 -73
  31. package/dist/toast.js.map +1 -1
  32. package/dist/tooltip.d.ts.map +1 -1
  33. package/dist/tooltip.js +87 -90
  34. package/dist/tooltip.js.map +1 -1
  35. package/package.json +6 -5
  36. package/dist/arrow-CL8xmdbg.js.map +0 -1
  37. package/dist/button-DQH2KIbq.js.map +0 -1
  38. package/dist/hotkeys-BPlacpG8.js.map +0 -1
  39. package/dist/layer-DGn7KJIB.js +0 -61
  40. package/dist/layer-DGn7KJIB.js.map +0 -1
  41. package/dist/textInput-B6ZZJSOj.js.map +0 -1
@@ -3,8 +3,9 @@ import { a as isHTMLElement, c as isHTMLTextAreaElement, i as isHTMLButtonElemen
3
3
  import { t as getTheme_v2 } from "./getTheme_v2-y09KqtEb.js";
4
4
  import { l as useRootTheme, m as focusRingStyle, p as focusRingBorderStyle, s as Card, v as responsiveRadiusStyle, y as Box } from "./useLayer-jUJIz8mh.js";
5
5
  import { n as Text } from "./stack-BGFEokua.js";
6
- import { t as Button } from "./button-DQH2KIbq.js";
6
+ import { t as Button } from "./button-D3iEd7Je.js";
7
7
  import { c } from "react/compiler-runtime";
8
+ import { clsx } from "clsx/lite";
8
9
  import { isValidElement, useEffect, useImperativeHandle, useRef } from "react";
9
10
  import { css, styled } from "styled-components";
10
11
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -100,10 +101,6 @@ function responsiveInputPaddingIconRightStyle(props) {
100
101
  $iconRight: !0
101
102
  });
102
103
  }
103
- const ROOT_STYLE = css`&:not([hidden]){display:flex;}align-items:center;`;
104
- function textInputRootStyle() {
105
- return ROOT_STYLE;
106
- }
107
104
  function textInputBaseStyle(props) {
108
105
  let { $scheme, $tone, $weight } = props, { color, font } = getTheme_v2(props.theme);
109
106
  return css`appearance:none;background:none;border:0;border-radius:0;outline:none;width:100%;box-sizing:border-box;font-family:${font.text.family};font-weight:${$weight && font.text.weights[$weight] || font.text.weights.regular};margin:0;position:relative;z-index:1;display:block;&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-text-fill-color:var(--input-fg-color) !important;transition:background-color 5000s;transition-delay:86400s;}&[data-as='textarea']{resize:none;}color:var(--input-fg-color);&::placeholder{color:var(--input-placeholder-color);}&[data-scheme='${$scheme}'][data-tone='${$tone}']{--input-fg-color:${color.input.default.enabled.fg};--input-placeholder-color:${color.input.default.enabled.placeholder};&:not(:invalid):not(:disabled):not(:read-only){--input-fg-color:${color.input.default.enabled.fg};--input-placeholder-color:${color.input.default.enabled.placeholder};}&:not(:invalid):disabled{--input-fg-color:${color.input.default.disabled.fg};--input-placeholder-color:${color.input.default.disabled.placeholder};}&:invalid{--input-fg-color:${color.input.invalid.enabled.fg};--input-placeholder-color:${color.input.invalid.enabled.placeholder};}&:read-only{--input-fg-color:${color.input.default.readOnly.fg};--input-placeholder-color:${color.input.default.readOnly.placeholder};}}`;
@@ -146,37 +143,14 @@ function textInputRepresentationStyle(props) {
146
143
  width: input.border.width
147
144
  })};}}}`;
148
145
  }
149
- const CLEAR_BUTTON_BOX_STYLE = { zIndex: 2 }, StyledTextInput = /* @__PURE__ */ styled(Card).attrs({ forwardedAs: "span" }).withConfig({
150
- displayName: "StyledTextInput",
151
- componentId: "sc-zwsvc0-0"
152
- })(textInputRootStyle), InputRoot = styled.span.withConfig({
153
- displayName: "InputRoot",
154
- componentId: "sc-zwsvc0-1"
155
- })`flex:1;min-width:0;display:block;position:relative;`, Prefix = styled(Card).attrs({ forwardedAs: "span" }).withConfig({
156
- displayName: "Prefix",
157
- componentId: "sc-zwsvc0-2"
158
- })`border-top-right-radius:0;border-bottom-right-radius:0;& > span{display:block;margin:-1px;}`, Suffix = styled(Card).attrs({ forwardedAs: "span" }).withConfig({
159
- displayName: "Suffix",
160
- componentId: "sc-zwsvc0-3"
161
- })`border-top-left-radius:0;border-bottom-left-radius:0;& > span{display:block;margin:-1px;}`, Input = /* @__PURE__ */ styled.input.withConfig({
146
+ var inputRoot = "_1lyk8y1", textInputRoot = "_1lyk8y0";
147
+ const CLEAR_BUTTON_BOX_STYLE = { zIndex: 2 }, Input = /* @__PURE__ */ styled.input.withConfig({
162
148
  displayName: "Input",
163
- componentId: "sc-zwsvc0-4"
149
+ componentId: "sc-fkdyjt-0"
164
150
  })(responsiveInputPaddingStyle, textInputBaseStyle, textInputFontSizeStyle), Presentation = /* @__PURE__ */ styled.span.withConfig({
165
151
  displayName: "Presentation",
166
- componentId: "sc-zwsvc0-5"
167
- })(responsiveRadiusStyle, textInputRepresentationStyle), LeftBox = styled(Box).withConfig({
168
- displayName: "LeftBox",
169
- componentId: "sc-zwsvc0-6"
170
- })`position:absolute;top:0;left:0;`, RightBox = styled(Box).withConfig({
171
- displayName: "RightBox",
172
- componentId: "sc-zwsvc0-7"
173
- })`position:absolute;top:0;right:0;`, RightCard = styled(Card).withConfig({
174
- displayName: "RightCard",
175
- componentId: "sc-zwsvc0-8"
176
- })`background-color:transparent;position:absolute;top:0;right:0;`, TextInputClearButton = /* @__PURE__ */ styled(Button).withConfig({
177
- displayName: "TextInputClearButton",
178
- componentId: "sc-zwsvc0-9"
179
- })({ "&:not([hidden])": { display: "block" } });
152
+ componentId: "sc-fkdyjt-1"
153
+ })(responsiveRadiusStyle, textInputRepresentationStyle);
180
154
  /**
181
155
  * Single line text input.
182
156
  *
@@ -200,17 +174,20 @@ function TextInput(props) {
200
174
  event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
201
175
  }, $[29] = onClear, $[30] = t12);
202
176
  let handleClearClick = t12, t13;
203
- $[31] !== prefix || $[32] !== radius ? (t13 = prefix && /* @__PURE__ */ jsx(Prefix, {
177
+ $[31] !== prefix || $[32] !== radius ? (t13 = prefix && /* @__PURE__ */ jsx(Card, {
204
178
  borderTop: !0,
205
179
  borderLeft: !0,
206
180
  borderBottom: !0,
181
+ className: "_8fnjkq3",
182
+ as: "span",
207
183
  radius,
208
184
  sizing: "border",
209
185
  tone: "inherit",
210
186
  children: /* @__PURE__ */ jsx("span", { children: prefix })
211
187
  }), $[31] = prefix, $[32] = radius, $[33] = t13) : t13 = $[33];
212
188
  let prefixNode = t13, t14 = border ? "" : void 0, t15;
213
- $[34] !== IconComponent || $[35] !== fontSize || $[36] !== padding ? (t15 = IconComponent && /* @__PURE__ */ jsx(LeftBox, {
189
+ $[34] !== IconComponent || $[35] !== fontSize || $[36] !== padding ? (t15 = IconComponent && /* @__PURE__ */ jsx(Box, {
190
+ className: "_8fnjkq0",
214
191
  padding,
215
192
  children: /* @__PURE__ */ jsxs(Text, {
216
193
  size: fontSize,
@@ -218,7 +195,8 @@ function TextInput(props) {
218
195
  })
219
196
  }), $[34] = IconComponent, $[35] = fontSize, $[36] = padding, $[37] = t15) : t15 = $[37];
220
197
  let t16;
221
- $[38] !== $hasClearButton || $[39] !== IconRightComponent || $[40] !== fontSize || $[41] !== padding ? (t16 = !$hasClearButton && IconRightComponent && /* @__PURE__ */ jsx(RightBox, {
198
+ $[38] !== $hasClearButton || $[39] !== IconRightComponent || $[40] !== fontSize || $[41] !== padding ? (t16 = !$hasClearButton && IconRightComponent && /* @__PURE__ */ jsx(Box, {
199
+ className: "_8fnjkq1",
222
200
  padding,
223
201
  children: /* @__PURE__ */ jsxs(Text, {
224
202
  size: fontSize,
@@ -243,12 +221,13 @@ function TextInput(props) {
243
221
  let clearButtonBoxPadding = t18, t19;
244
222
  $[55] === padding ? t19 = $[56] : (t19 = padding.map(_temp3), $[55] = padding, $[56] = t19);
245
223
  let clearButtonPadding = t19, clearButtonProps = typeof clearButton == "object" ? clearButton : EMPTY_RECORD, t20;
246
- $[57] !== clearButton || $[58] !== clearButtonBoxPadding || $[59] !== clearButtonPadding || $[60] !== clearButtonProps || $[61] !== customValidity || $[62] !== disabled || $[63] !== fontSize || $[64] !== handleClearClick || $[65] !== radius || $[66] !== readOnly ? (t20 = !disabled && !readOnly && clearButton && /* @__PURE__ */ jsx(RightCard, {
247
- forwardedAs: "span",
224
+ $[57] !== clearButton || $[58] !== clearButtonBoxPadding || $[59] !== clearButtonPadding || $[60] !== clearButtonProps || $[61] !== customValidity || $[62] !== disabled || $[63] !== fontSize || $[64] !== handleClearClick || $[65] !== radius || $[66] !== readOnly ? (t20 = !disabled && !readOnly && clearButton && /* @__PURE__ */ jsx(Card, {
225
+ className: "_8fnjkq5",
226
+ as: "span",
248
227
  padding: clearButtonBoxPadding,
249
228
  style: CLEAR_BUTTON_BOX_STYLE,
250
229
  tone: customValidity ? "critical" : "inherit",
251
- children: /* @__PURE__ */ jsx(TextInputClearButton, {
230
+ children: /* @__PURE__ */ jsx(Button, {
252
231
  "aria-label": "Clear",
253
232
  "data-qa": "clear-button",
254
233
  fontSize,
@@ -257,15 +236,18 @@ function TextInput(props) {
257
236
  padding: clearButtonPadding,
258
237
  radius,
259
238
  ...clearButtonProps,
239
+ className: clsx("_8fnjkq2", clearButtonProps.className),
260
240
  onClick: handleClearClick,
261
241
  onMouseDown: handleClearMouseDown
262
242
  })
263
243
  }), $[57] = clearButton, $[58] = clearButtonBoxPadding, $[59] = clearButtonPadding, $[60] = clearButtonProps, $[61] = customValidity, $[62] = disabled, $[63] = fontSize, $[64] = handleClearClick, $[65] = radius, $[66] = readOnly, $[67] = t20) : t20 = $[67];
264
244
  let clearButtonNode = t20, t21;
265
- $[68] !== radius || $[69] !== suffix ? (t21 = suffix && /* @__PURE__ */ jsx(Suffix, {
245
+ $[68] !== radius || $[69] !== suffix ? (t21 = suffix && /* @__PURE__ */ jsx(Card, {
266
246
  borderTop: !0,
267
247
  borderRight: !0,
268
248
  borderBottom: !0,
249
+ className: "_8fnjkq4",
250
+ as: "span",
269
251
  radius,
270
252
  sizing: "border",
271
253
  tone: "inherit",
@@ -291,14 +273,20 @@ function TextInput(props) {
291
273
  type
292
274
  }), $[71] = $hasIcon, $[72] = disabled, $[73] = fontSize, $[74] = padding, $[75] = readOnly, $[76] = restProps, $[77] = rootTheme.scheme, $[78] = rootTheme.tone, $[79] = space, $[80] = t22, $[81] = type, $[82] = weight, $[83] = t23) : t23 = $[83];
293
275
  let t24;
294
- $[84] !== clearButtonNode || $[85] !== presentationNode || $[86] !== t23 ? (t24 = /* @__PURE__ */ jsxs(InputRoot, { children: [
295
- t23,
296
- presentationNode,
297
- clearButtonNode
298
- ] }), $[84] = clearButtonNode, $[85] = presentationNode, $[86] = t23, $[87] = t24) : t24 = $[87];
276
+ $[84] !== clearButtonNode || $[85] !== presentationNode || $[86] !== t23 ? (t24 = /* @__PURE__ */ jsxs("span", {
277
+ className: inputRoot,
278
+ children: [
279
+ t23,
280
+ presentationNode,
281
+ clearButtonNode
282
+ ]
283
+ }), $[84] = clearButtonNode, $[85] = presentationNode, $[86] = t23, $[87] = t24) : t24 = $[87];
299
284
  let t25;
300
- return $[88] !== prefixNode || $[89] !== rootTheme.tone || $[90] !== suffixNode || $[91] !== t24 ? (t25 = /* @__PURE__ */ jsxs(StyledTextInput, {
285
+ return $[88] !== prefixNode || $[89] !== rootTheme.tone || $[90] !== suffixNode || $[91] !== t24 ? (t25 = /* @__PURE__ */ jsxs(Card, {
286
+ as: "span",
287
+ className: textInputRoot,
301
288
  "data-ui": "TextInput",
289
+ display: "flex",
302
290
  tone: rootTheme.tone,
303
291
  children: [
304
292
  prefixNode,
@@ -316,6 +304,6 @@ function _temp2(v) {
316
304
  function _temp(event) {
317
305
  event.preventDefault(), event.stopPropagation();
318
306
  }
319
- export { textInputRootStyle as a, useCustomValidity as c, focusFirstDescendant as d, focusLastDescendant as f, _raf2 as h, textInputRepresentationStyle as i, _hasFocus as l, _raf as m, textInputBaseStyle as n, responsiveInputPaddingIconRightStyle as o, isFocusable as p, textInputFontSizeStyle as r, responsiveInputPaddingStyle as s, TextInput as t, attemptFocus as u };
307
+ export { textInputFontSizeStyle as a, responsiveInputPaddingStyle as c, attemptFocus as d, focusFirstDescendant as f, _raf2 as g, _raf as h, textInputBaseStyle as i, useCustomValidity as l, isFocusable as m, inputRoot as n, textInputRepresentationStyle as o, focusLastDescendant as p, textInputRoot as r, responsiveInputPaddingIconRightStyle as s, TextInput as t, _hasFocus as u };
320
308
 
321
- //# sourceMappingURL=textInput-B6ZZJSOj.js.map
309
+ //# sourceMappingURL=textInput-Bu3QuADZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textInput-Bu3QuADZ.js","names":["() => {\n ref.current?.setCustomValidity(customValidity || '')\n }","[customValidity, ref]","ref.current?.setCustomValidity","border = true","disabled = false","fontSizeProp = 2","gap = 3","paddingProp = 3","radiusProp = 2","type = 'text'","_getArrayProp(fontSizeProp)","_getArrayProp(paddingProp)","_getArrayProp(radiusProp)","_getArrayProp(gap)","() => ref.current","useCallback((event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n event.stopPropagation()\n }, [])","(event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (onClear) onClear()\n\n // Focus the input, in case focus has been lost when clicking the clear button\n ref.current?.focus()\n }","useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (onClear) onClear()\n\n // Focus the input, in case focus has been lost when clicking the clear button\n ref.current?.focus()\n },\n [onClear, ref],\n )","prefix && (\n <Card\n borderTop\n borderLeft\n borderBottom\n className={textInputPrefix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{prefix}</span>\n </Card>\n )","useMemo(\n () =>\n prefix && (\n <Card\n borderTop\n borderLeft\n borderBottom\n className={textInputPrefix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{prefix}</span>\n </Card>\n ),\n [prefix, radius],\n )","IconComponent && (\n <Box className={textInputLeftBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconComponent) && IconComponent}\n {isValidElementType(IconComponent) && <IconComponent />}\n </Text>\n </Box>\n )","!$hasClearButton && IconRightComponent && (\n <Box className={textInputRightBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconRightComponent) && IconRightComponent}\n {isValidElementType(IconRightComponent) && <IconRightComponent />}\n </Text>\n </Box>\n )","<Presentation\n $hasPrefix={$hasPrefix}\n $unstableDisableFocusRing={__unstable_disableFocusRing}\n $hasSuffix={$hasSuffix}\n $radius={radius}\n $scheme={rootTheme.scheme}\n $tone={rootTheme.tone}\n data-border={border ? '' : undefined}\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n >\n {IconComponent && (\n <Box className={textInputLeftBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconComponent) && IconComponent}\n {isValidElementType(IconComponent) && <IconComponent />}\n </Text>\n </Box>\n )}\n\n {!$hasClearButton && IconRightComponent && (\n <Box className={textInputRightBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconRightComponent) && IconRightComponent}\n {isValidElementType(IconRightComponent) && <IconRightComponent />}\n </Text>\n </Box>\n )}\n </Presentation>","scheme","tone","border ? '' : undefined","useMemo(\n () => (\n <Presentation\n $hasPrefix={$hasPrefix}\n $unstableDisableFocusRing={__unstable_disableFocusRing}\n $hasSuffix={$hasSuffix}\n $radius={radius}\n $scheme={rootTheme.scheme}\n $tone={rootTheme.tone}\n data-border={border ? '' : undefined}\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n >\n {IconComponent && (\n <Box className={textInputLeftBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconComponent) && IconComponent}\n {isValidElementType(IconComponent) && <IconComponent />}\n </Text>\n </Box>\n )}\n\n {!$hasClearButton && IconRightComponent && (\n <Box className={textInputRightBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconRightComponent) && IconRightComponent}\n {isValidElementType(IconRightComponent) && <IconRightComponent />}\n </Text>\n </Box>\n )}\n </Presentation>\n ),\n [\n __unstable_disableFocusRing,\n border,\n fontSize,\n IconComponent,\n IconRightComponent,\n padding,\n radius,\n rootTheme,\n $hasClearButton,\n $hasPrefix,\n $hasSuffix,\n ],\n )","padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n })","(v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }","useMemo(\n () =>\n padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }),\n [padding],\n )","padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 0\n if (v === 2) return 1\n\n return v - 1\n })","(v) => {\n if (v === 0) return 0\n if (v === 1) return 0\n if (v === 2) return 1\n\n return v - 1\n }","useMemo(\n () =>\n padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 0\n if (v === 2) return 1\n\n return v - 1\n }),\n [padding],\n )","!disabled &&\n !readOnly &&\n clearButton && (\n <Card\n className={textInputRightCard}\n as=\"span\"\n padding={clearButtonBoxPadding}\n style={CLEAR_BUTTON_BOX_STYLE}\n tone={customValidity ? 'critical' : 'inherit'}\n >\n <Button\n aria-label=\"Clear\"\n data-qa=\"clear-button\"\n fontSize={fontSize}\n icon={CloseIcon}\n mode=\"bleed\"\n padding={clearButtonPadding}\n radius={radius}\n {...clearButtonProps}\n className={clsx(textInputClearButton, clearButtonProps.className)}\n onClick={handleClearClick}\n onMouseDown={handleClearMouseDown}\n />\n </Card>\n )","clearButtonProps.className","useMemo(\n () =>\n !disabled &&\n !readOnly &&\n clearButton && (\n <Card\n className={textInputRightCard}\n as=\"span\"\n padding={clearButtonBoxPadding}\n style={CLEAR_BUTTON_BOX_STYLE}\n tone={customValidity ? 'critical' : 'inherit'}\n >\n <Button\n aria-label=\"Clear\"\n data-qa=\"clear-button\"\n fontSize={fontSize}\n icon={CloseIcon}\n mode=\"bleed\"\n padding={clearButtonPadding}\n radius={radius}\n {...clearButtonProps}\n className={clsx(textInputClearButton, clearButtonProps.className)}\n onClick={handleClearClick}\n onMouseDown={handleClearMouseDown}\n />\n </Card>\n ),\n [\n clearButton,\n clearButtonBoxPadding,\n clearButtonPadding,\n clearButtonProps,\n customValidity,\n disabled,\n fontSize,\n handleClearClick,\n handleClearMouseDown,\n radius,\n readOnly,\n ],\n )","suffix && (\n <Card\n borderTop\n borderRight\n borderBottom\n className={textInputSuffix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{suffix}</span>\n </Card>\n )","useMemo(\n () =>\n suffix && (\n <Card\n borderTop\n borderRight\n borderBottom\n className={textInputSuffix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{suffix}</span>\n </Card>\n ),\n [radius, suffix],\n )","<Input\n data-as=\"input\"\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n {...restProps}\n $fontSize={fontSize}\n $iconLeft={$hasIcon}\n $iconRight={$hasIconRight || $hasClearButton}\n $padding={padding}\n $scheme={rootTheme.scheme}\n $space={space}\n $tone={rootTheme.tone}\n $weight={weight}\n disabled={disabled}\n readOnly={readOnly}\n ref={ref}\n type={type}\n />","$hasIconRight || $hasClearButton","<span className={inputRoot}>\n <Input\n data-as=\"input\"\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n {...restProps}\n $fontSize={fontSize}\n $iconLeft={$hasIcon}\n $iconRight={$hasIconRight || $hasClearButton}\n $padding={padding}\n $scheme={rootTheme.scheme}\n $space={space}\n $tone={rootTheme.tone}\n $weight={weight}\n disabled={disabled}\n readOnly={readOnly}\n ref={ref}\n type={type}\n />\n\n {presentationNode}\n {clearButtonNode}\n </span>","<Card\n as=\"span\"\n className={textInputRoot}\n data-ui=\"TextInput\"\n display=\"flex\"\n tone={rootTheme.tone}\n >\n {prefixNode}\n\n <span className={inputRoot}>\n <Input\n data-as=\"input\"\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n {...restProps}\n $fontSize={fontSize}\n $iconLeft={$hasIcon}\n $iconRight={$hasIconRight || $hasClearButton}\n $padding={padding}\n $scheme={rootTheme.scheme}\n $space={space}\n $tone={rootTheme.tone}\n $weight={weight}\n disabled={disabled}\n readOnly={readOnly}\n ref={ref}\n type={type}\n />\n\n {presentationNode}\n {clearButtonNode}\n </span>\n\n {suffixNode}\n </Card>","v"],"sources":["../src/core/helpers/animation.ts","../src/core/helpers/focus.ts","../src/core/hooks/useCustomValidity.ts","../src/core/styles/input/responsiveInputPaddingStyle.ts","../src/core/styles/input/textInputStyle.ts","../src/core/styles/input/textInput.css.ts","../src/core/primitives/textInput/textInput.css.ts","../src/core/primitives/textInput/textInput.tsx"],"sourcesContent":["/**\n * @internal\n */\nexport function _raf(fn: () => void): () => void {\n const frameId = requestAnimationFrame(fn)\n\n return () => {\n cancelAnimationFrame(frameId)\n }\n}\n\n/**\n * @internal\n */\nexport function _raf2(fn: () => void): () => void {\n let innerDispose: (() => void) | null = null\n\n const outerDispose = _raf(() => {\n innerDispose = _raf(fn)\n })\n\n return () => {\n if (innerDispose) innerDispose()\n\n outerDispose()\n }\n}\n","import {\n isHTMLAnchorElement,\n isHTMLButtonElement,\n isHTMLElement,\n isHTMLInputElement,\n isHTMLSelectElement,\n isHTMLTextAreaElement,\n} from './element'\n\n// export const globalFocusState = {\n// IgnoreUtilFocusChanges: false,\n// }\n\n/**\n * @internal\n */\nexport function _hasFocus(element: HTMLElement): boolean {\n return Boolean(document.activeElement) && element.contains(document.activeElement)\n}\n\n/**\n * @internal\n */\nexport function isFocusable(element: HTMLElement): boolean {\n if (\n element.tabIndex > 0 ||\n (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)\n ) {\n return true\n }\n\n if (isHTMLAnchorElement(element)) {\n return Boolean(element.href) && element.rel !== 'ignore'\n }\n\n if (isHTMLInputElement(element)) {\n return element.type !== 'hidden' && element.type !== 'file' && !element.disabled\n }\n\n if (\n isHTMLButtonElement(element) ||\n isHTMLSelectElement(element) ||\n isHTMLTextAreaElement(element)\n ) {\n return !element.disabled\n }\n\n return false\n}\n\n/**\n * @internal\n */\nexport function attemptFocus(element: HTMLElement): boolean {\n if (!isFocusable(element)) {\n return false\n }\n\n // globalFocusState.IgnoreUtilFocusChanges = true\n\n try {\n element.focus()\n } catch {\n // ignore\n }\n\n // globalFocusState.IgnoreUtilFocusChanges = false\n\n return document.activeElement === element\n}\n\n/**\n * @internal\n */\nexport function focusFirstDescendant(element: HTMLElement): boolean {\n for (let i = 0; i < element.childNodes.length; i++) {\n const child = element.childNodes[i]\n\n if (isHTMLElement(child) && (attemptFocus(child) || focusFirstDescendant(child))) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * @internal\n */\nexport function focusLastDescendant(element: HTMLElement): boolean {\n for (let i = element.childNodes.length - 1; i >= 0; i--) {\n const child = element.childNodes[i]\n\n if (isHTMLElement(child) && (attemptFocus(child) || focusLastDescendant(child))) {\n return true\n }\n }\n\n return false\n}\n","import {useEffect} from 'react'\n\n/**\n * @beta\n */\nexport function useCustomValidity(\n ref: {current: null | {setCustomValidity: (validity: string) => void}},\n customValidity: string | undefined,\n): void {\n useEffect(() => {\n ref.current?.setCustomValidity(customValidity || '')\n }, [customValidity, ref])\n}\n","import {CSSObject} from '../../../theme/system/css'\nimport {getTheme_v2} from '../../../theme/versioning/getTheme_v2'\nimport {_responsive, rem} from '../helpers'\nimport {ThemeProps} from '../types'\n\nexport interface TextInputResponsivePaddingStyleProps {\n $fontSize: number[]\n $iconLeft?: boolean\n $iconRight?: boolean\n $padding: number[]\n $space: number[]\n}\n\nexport function responsiveInputPaddingStyle(\n props: TextInputResponsivePaddingStyleProps & ThemeProps,\n): CSSObject[] {\n const {$fontSize, $iconLeft, $iconRight, $padding, $space} = props\n const {font, media, space} = getTheme_v2(props.theme)\n const len = Math.max($padding.length, $space.length, $fontSize.length)\n const _padding: number[] = []\n const _space: number[] = []\n const _fontSize: number[] = []\n\n for (let i = 0; i < len; i += 1) {\n _fontSize[i] = $fontSize[i] === undefined ? _fontSize[i - 1] : $fontSize[i]\n _padding[i] = $padding[i] === undefined ? _padding[i - 1] : $padding[i]\n _space[i] = $space[i] === undefined ? _space[i - 1] : $space[i]\n }\n\n return _responsive(media, _padding, (_, i) => {\n const size = font.text.sizes[_fontSize[i]] || font.text.sizes[2]\n const emSize = size.lineHeight - size.ascenderHeight - size.descenderHeight\n const p = space[_padding[i]]\n const s = space[_space[i]]\n\n const styles = {\n paddingTop: rem(p - size.ascenderHeight),\n paddingRight: rem(p),\n paddingBottom: rem(p - size.descenderHeight),\n paddingLeft: rem(p),\n }\n\n if ($iconRight) styles.paddingRight = rem(p + emSize + s)\n if ($iconLeft) styles.paddingLeft = rem(p + emSize + s)\n\n return styles\n })\n}\n\nexport function responsiveInputPaddingIconRightStyle(\n props: {\n $fontSize: number[]\n $padding: number[]\n $space: number[]\n } & ThemeProps,\n): CSSObject[] {\n return responsiveInputPaddingStyle({...props, $iconRight: true})\n}\n","import {css} from 'styled-components'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {CSSObject} from '../../../theme/system/css'\nimport {ThemeFontWeightKey} from '../../../theme/system/font'\nimport {getTheme_v2} from '../../../theme/versioning/getTheme_v2'\nimport {CardTone} from '../../types/card'\nimport {focusRingBorderStyle, focusRingStyle} from '../focusRing'\nimport {_responsive, rem} from '../helpers'\nimport {ThemeProps} from '../types'\n\n/**\n * @internal\n */\nexport interface TextInputInputStyleProps {\n $fontSize: number[]\n $scheme: ThemeColorSchemeKey\n $tone: CardTone\n $weight?: ThemeFontWeightKey\n}\n\n/**\n * @internal\n */\nexport interface TextInputRepresentationStyleProps {\n $hasPrefix?: boolean\n $hasSuffix?: boolean\n $scheme: ThemeColorSchemeKey\n $tone: CardTone\n $unstableDisableFocusRing?: boolean\n}\n\nexport function textInputBaseStyle(\n props: TextInputInputStyleProps & ThemeProps,\n): ReturnType<typeof css> {\n const {$scheme, $tone, $weight} = props\n const {color, font} = getTheme_v2(props.theme)\n\n return css`\n appearance: none;\n background: none;\n border: 0;\n border-radius: 0;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n font-family: ${font.text.family};\n font-weight: ${($weight && font.text.weights[$weight]) || font.text.weights.regular};\n margin: 0;\n position: relative;\n z-index: 1;\n display: block;\n\n /* NOTE: This is a hack to disable Chrome’s autofill styles */\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-text-fill-color: var(--input-fg-color) !important;\n transition: background-color 5000s;\n transition-delay: 86400s /* 24h */;\n }\n\n /* &:is(textarea) */\n &[data-as='textarea'] {\n resize: none;\n }\n\n color: var(--input-fg-color);\n\n &::placeholder {\n color: var(--input-placeholder-color);\n }\n\n &[data-scheme='${$scheme}'][data-tone='${$tone}'] {\n --input-fg-color: ${color.input.default.enabled.fg};\n --input-placeholder-color: ${color.input.default.enabled.placeholder};\n\n /* enabled */\n &:not(:invalid):not(:disabled):not(:read-only) {\n --input-fg-color: ${color.input.default.enabled.fg};\n --input-placeholder-color: ${color.input.default.enabled.placeholder};\n }\n\n /* disabled */\n &:not(:invalid):disabled {\n --input-fg-color: ${color.input.default.disabled.fg};\n --input-placeholder-color: ${color.input.default.disabled.placeholder};\n }\n\n /* invalid */\n &:invalid {\n --input-fg-color: ${color.input.invalid.enabled.fg};\n --input-placeholder-color: ${color.input.invalid.enabled.placeholder};\n }\n\n /* readOnly */\n &:read-only {\n --input-fg-color: ${color.input.default.readOnly.fg};\n --input-placeholder-color: ${color.input.default.readOnly.placeholder};\n }\n }\n `\n}\n\nexport function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemeProps): CSSObject[] {\n const {font, media} = getTheme_v2(props.theme)\n\n return _responsive(media, props.$fontSize, (sizeIndex) => {\n const size = font.text.sizes[sizeIndex] || font.text.sizes[2]\n\n return {\n fontSize: rem(size.fontSize),\n lineHeight: `${size.lineHeight / size.fontSize}`,\n }\n })\n}\n\nexport function textInputRepresentationStyle(\n props: TextInputRepresentationStyleProps & ThemeProps,\n): ReturnType<typeof css> {\n const {$hasPrefix, $hasSuffix, $scheme, $tone, $unstableDisableFocusRing} = props\n const {color, input} = getTheme_v2(props.theme)\n\n return css`\n --input-box-shadow: none;\n\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: block;\n pointer-events: none;\n z-index: 0;\n\n background-color: var(--card-bg-color);\n box-shadow: var(--input-box-shadow);\n\n border-top-left-radius: ${$hasPrefix ? 0 : undefined};\n border-bottom-left-radius: ${$hasPrefix ? 0 : undefined};\n border-top-right-radius: ${$hasSuffix ? 0 : undefined};\n border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};\n\n &[data-scheme='${$scheme}'][data-tone='${$tone}'] {\n --card-bg-color: ${color.input.default.enabled.bg};\n --card-fg-color: ${color.input.default.enabled.fg};\n\n /* enabled */\n *:not(:disabled) + &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.default.enabled.border,\n width: input.border.width,\n })};\n }\n\n /* invalid */\n *:not(:disabled):invalid + & {\n --card-bg-color: ${color.input.invalid.enabled.bg};\n --card-fg-color: ${color.input.invalid.enabled.fg};\n\n &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.invalid.enabled.border,\n width: input.border.width,\n })};\n }\n }\n\n /* focused */\n *:not(:disabled):focus + & {\n &[data-border] {\n --input-box-shadow: ${\n $unstableDisableFocusRing\n ? undefined\n : focusRingStyle({\n border: {color: color.input.default.enabled.border, width: input.border.width},\n focusRing: input.text.focusRing,\n })\n };\n }\n\n &:not([data-border]) {\n --input-box-shadow: ${\n $unstableDisableFocusRing\n ? undefined\n : focusRingStyle({focusRing: input.text.focusRing})\n };\n }\n }\n\n /* disabled */\n *:not(:invalid):disabled + & {\n --card-bg-color: ${color.input.default.disabled.bg} !important;\n --card-fg-color: ${color.input.default.disabled.fg} !important;\n --card-icon-color: ${color.input.default.disabled.fg} !important;\n\n &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.default.disabled.border,\n width: input.border.width,\n })};\n }\n }\n\n *:invalid:disabled + & {\n --card-bg-color: ${color.input.invalid.disabled.bg} !important;\n --card-fg-color: ${color.input.invalid.disabled.fg} !important;\n --card-icon-color: ${color.input.invalid.disabled.fg} !important;\n\n &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.invalid.disabled.border,\n width: input.border.width,\n })};\n }\n }\n\n /* readOnly */\n *:not(:invalid):read-only + & {\n --card-bg-color: ${color.input.default.readOnly.bg} !important;\n --card-fg-color: ${color.input.default.readOnly.fg} !important;\n }\n\n *:invalid:read-only + & {\n --card-bg-color: ${color.input.invalid.readOnly.bg} !important;\n --card-fg-color: ${color.input.invalid.readOnly.fg} !important;\n }\n\n /* hovered */\n @media (hover: hover) {\n *:not(:disabled):not(:read-only):not(:invalid):hover + & {\n --card-bg-color: ${color.input.default.hovered.bg};\n --card-fg-color: ${color.input.default.hovered.fg};\n }\n\n *:invalid:not(:disabled):not(:read-only):hover + & {\n --card-bg-color: ${color.input.invalid.hovered.bg};\n --card-fg-color: ${color.input.invalid.hovered.fg};\n }\n\n *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.default.hovered.border,\n width: input.border.width,\n })};\n }\n\n *:invalid:not(:disabled):not(:read-only):not(:focus):hover + &[data-border] {\n --input-box-shadow: ${focusRingBorderStyle({\n color: color.input.invalid.hovered.border,\n width: input.border.width,\n })};\n }\n }\n }\n `\n}\n","import {style} from '@vanilla-extract/css'\n\nexport const textInputRoot = style({\n alignItems: 'center',\n selectors: {\n '&:not([hidden])': {\n display: 'flex',\n },\n },\n})\n\nexport const inputRoot = style({\n flex: 1,\n minWidth: 0,\n display: 'block',\n position: 'relative',\n})\n","import {globalStyle, style} from '@vanilla-extract/css'\n\nexport const textInputLeftBox = style({\n position: 'absolute',\n top: 0,\n left: 0,\n})\n\nexport const textInputRightBox = style({\n position: 'absolute',\n top: 0,\n right: 0,\n})\n\nexport const textInputClearButton = style({\n selectors: {\n '&:not([hidden])': {\n display: 'block',\n },\n },\n})\n\nexport const textInputPrefix = style({\n selectors: {\n '&&': {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n },\n },\n})\n\nglobalStyle(`${textInputPrefix} > span`, {\n display: 'block',\n margin: -1,\n})\n\nexport const textInputSuffix = style({\n selectors: {\n '&&': {\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n },\n },\n})\n\nglobalStyle(`${textInputSuffix} > span`, {\n display: 'block',\n margin: -1,\n})\n\nexport const textInputRightCard = style({\n position: 'absolute',\n top: 0,\n right: 0,\n selectors: {\n '&&': {\n backgroundColor: 'transparent',\n },\n },\n})\n","import {CloseIcon} from '@sanity/icons/Close'\nimport {clsx} from 'clsx/lite'\nimport {isValidElement, useCallback, useImperativeHandle, useMemo, useRef} from 'react'\nimport {isValidElementType} from 'react-is'\nimport {styled} from 'styled-components'\n\nimport {ThemeFontWeightKey} from '../../../theme/system/font'\nimport {EMPTY_RECORD} from '../../constants'\nimport {useCustomValidity} from '../../hooks/useCustomValidity'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {\n responsiveInputPaddingStyle,\n TextInputResponsivePaddingStyleProps,\n} from '../../styles/input/responsiveInputPaddingStyle'\nimport {\n textInputBaseStyle,\n textInputFontSizeStyle,\n TextInputInputStyleProps,\n textInputRepresentationStyle,\n TextInputRepresentationStyleProps,\n} from '../../styles/input/textInputStyle'\nimport {responsiveRadiusStyle} from '../../styles/radius/radiusStyle'\nimport {ResponsiveRadiusStyleProps} from '../../styles/radius/types'\nimport {useRootTheme} from '../../theme/useRootTheme'\nimport {Radius} from '../../types/radius'\nimport {Box} from '../box/box'\nimport {Button, ButtonOwnProps} from '../button/button'\nimport {Card} from '../card/card'\nimport {Text} from '../text/text'\n\nimport {inputRoot, textInputRoot} from '../../styles/input/textInput.css'\nimport {\n textInputClearButton,\n textInputLeftBox,\n textInputPrefix,\n textInputRightBox,\n textInputRightCard,\n textInputSuffix,\n} from './textInput.css'\n\n/**\n * @public\n */\nexport type TextInputClearButtonProps = ButtonOwnProps &\n Omit<React.HTMLProps<HTMLButtonElement>, 'as' | 'onClick' | 'onMouseDown' | 'ref'>\n\n/**\n * @public\n */\nexport type TextInputType =\n | 'search'\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'url'\n | 'month'\n | 'number'\n | 'password'\n | 'tel'\n | 'time'\n | 'text'\n | 'week'\n | 'color'\n\n/**\n * @public\n */\nexport interface TextInputProps {\n /**\n * @beta\n */\n __unstable_disableFocusRing?: boolean\n border?: boolean\n /**\n * @beta\n */\n clearButton?: boolean | TextInputClearButtonProps\n customValidity?: string\n fontSize?: number | number[]\n // oxlint-disable-next-line no-redundant-type-constituents\n icon?: React.ElementType | React.ReactNode\n // oxlint-disable-next-line no-redundant-type-constituents\n iconRight?: React.ElementType | React.ReactNode\n /**\n * @beta\n */\n onClear?: () => void\n padding?: number | number[]\n prefix?: React.ReactNode\n radius?: Radius | Radius[]\n /**\n * @deprecated Use `gap` instead.\n */\n space?: never\n gap?: number | number[]\n suffix?: React.ReactNode\n type?: TextInputType\n weight?: ThemeFontWeightKey\n}\n\nconst CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}\n\nconst Input = styled.input<TextInputResponsivePaddingStyleProps & TextInputInputStyleProps>(\n responsiveInputPaddingStyle,\n textInputBaseStyle,\n textInputFontSizeStyle,\n)\n\nconst Presentation = styled.span<ResponsiveRadiusStyleProps & TextInputRepresentationStyleProps>(\n responsiveRadiusStyle,\n textInputRepresentationStyle,\n)\n\n/**\n * Single line text input.\n *\n * @public\n */\nexport function TextInput(\n props: TextInputProps & Omit<React.HTMLProps<HTMLInputElement>, 'as' | 'prefix' | 'type'>,\n) {\n const {\n __unstable_disableFocusRing,\n border = true,\n clearButton,\n disabled = false,\n fontSize: fontSizeProp = 2,\n gap = 3,\n icon: IconComponent,\n iconRight: IconRightComponent,\n onClear,\n padding: paddingProp = 3,\n prefix,\n radius: radiusProp = 2,\n readOnly,\n ref: forwardedRef,\n suffix,\n customValidity,\n type = 'text',\n weight,\n ...restProps\n } = props\n const ref = useRef<HTMLInputElement | null>(null)\n\n const rootTheme = useRootTheme()\n\n const fontSize = _getArrayProp(fontSizeProp)\n const padding = _getArrayProp(paddingProp)\n const radius = _getArrayProp(radiusProp)\n const space = _getArrayProp(gap)\n\n // Transient properties\n const $hasClearButton = Boolean(clearButton)\n const $hasIcon = Boolean(IconComponent)\n const $hasIconRight = Boolean(IconRightComponent)\n const $hasSuffix = Boolean(suffix)\n const $hasPrefix = Boolean(prefix)\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n forwardedRef,\n () => ref.current,\n )\n\n useCustomValidity(ref, customValidity)\n\n // Prevent the clear button from taking the focus away from the input\n const handleClearMouseDown = useCallback((event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n event.stopPropagation()\n }, [])\n\n const handleClearClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (onClear) onClear()\n\n // Focus the input, in case focus has been lost when clicking the clear button\n ref.current?.focus()\n },\n [onClear, ref],\n )\n\n // Render prefix (memoized)\n const prefixNode = useMemo(\n () =>\n prefix && (\n <Card\n borderTop\n borderLeft\n borderBottom\n className={textInputPrefix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{prefix}</span>\n </Card>\n ),\n [prefix, radius],\n )\n\n // Render presentation (memoized)\n const presentationNode = useMemo(\n () => (\n <Presentation\n $hasPrefix={$hasPrefix}\n $unstableDisableFocusRing={__unstable_disableFocusRing}\n $hasSuffix={$hasSuffix}\n $radius={radius}\n $scheme={rootTheme.scheme}\n $tone={rootTheme.tone}\n data-border={border ? '' : undefined}\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n >\n {IconComponent && (\n <Box className={textInputLeftBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconComponent) && IconComponent}\n {isValidElementType(IconComponent) && <IconComponent />}\n </Text>\n </Box>\n )}\n\n {!$hasClearButton && IconRightComponent && (\n <Box className={textInputRightBox} padding={padding}>\n <Text size={fontSize}>\n {isValidElement(IconRightComponent) && IconRightComponent}\n {isValidElementType(IconRightComponent) && <IconRightComponent />}\n </Text>\n </Box>\n )}\n </Presentation>\n ),\n [\n __unstable_disableFocusRing,\n border,\n fontSize,\n IconComponent,\n IconRightComponent,\n padding,\n radius,\n rootTheme,\n $hasClearButton,\n $hasPrefix,\n $hasSuffix,\n ],\n )\n\n // Render clear button (memoized)\n const clearButtonBoxPadding = useMemo(\n () =>\n padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }),\n [padding],\n )\n const clearButtonPadding = useMemo(\n () =>\n padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 0\n if (v === 2) return 1\n\n return v - 1\n }),\n [padding],\n )\n const clearButtonProps: TextInputClearButtonProps = useMemo(\n () => (typeof clearButton === 'object' ? clearButton : EMPTY_RECORD),\n [clearButton],\n )\n const clearButtonNode = useMemo(\n () =>\n !disabled &&\n !readOnly &&\n clearButton && (\n <Card\n className={textInputRightCard}\n as=\"span\"\n padding={clearButtonBoxPadding}\n style={CLEAR_BUTTON_BOX_STYLE}\n tone={customValidity ? 'critical' : 'inherit'}\n >\n <Button\n aria-label=\"Clear\"\n data-qa=\"clear-button\"\n fontSize={fontSize}\n icon={CloseIcon}\n mode=\"bleed\"\n padding={clearButtonPadding}\n radius={radius}\n {...clearButtonProps}\n className={clsx(textInputClearButton, clearButtonProps.className)}\n onClick={handleClearClick}\n onMouseDown={handleClearMouseDown}\n />\n </Card>\n ),\n [\n clearButton,\n clearButtonBoxPadding,\n clearButtonPadding,\n clearButtonProps,\n customValidity,\n disabled,\n fontSize,\n handleClearClick,\n handleClearMouseDown,\n radius,\n readOnly,\n ],\n )\n\n // Render suffix (memoized)\n const suffixNode = useMemo(\n () =>\n suffix && (\n <Card\n borderTop\n borderRight\n borderBottom\n className={textInputSuffix}\n as=\"span\"\n radius={radius}\n sizing=\"border\"\n tone=\"inherit\"\n >\n <span>{suffix}</span>\n </Card>\n ),\n [radius, suffix],\n )\n\n return (\n <Card\n as=\"span\"\n className={textInputRoot}\n data-ui=\"TextInput\"\n display=\"flex\"\n tone={rootTheme.tone}\n >\n {prefixNode}\n\n <span className={inputRoot}>\n <Input\n data-as=\"input\"\n data-scheme={rootTheme.scheme}\n data-tone={rootTheme.tone}\n {...restProps}\n $fontSize={fontSize}\n $iconLeft={$hasIcon}\n $iconRight={$hasIconRight || $hasClearButton}\n $padding={padding}\n $scheme={rootTheme.scheme}\n $space={space}\n $tone={rootTheme.tone}\n $weight={weight}\n disabled={disabled}\n readOnly={readOnly}\n ref={ref}\n type={type}\n />\n\n {presentationNode}\n {clearButtonNode}\n </span>\n\n {suffixNode}\n </Card>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAgB,KAAK,IAA4B;CAC/C,IAAM,UAAU,sBAAsB,EAAE;CAExC,aAAa;EACX,qBAAqB,OAAO;CAC9B;AACF;;;;AAKA,SAAgB,MAAM,IAA4B;CAChD,IAAI,eAAoC,MAElC,eAAe,WAAW;EAC9B,eAAe,KAAK,EAAE;CACxB,CAAC;CAED,aAAa;EAGX,AAFI,gBAAc,aAAa,GAE/B,aAAa;CACf;AACF;;;;ACVA,SAAgB,UAAU,SAA+B;CACvD,OAAO,EAAQ,SAAS,iBAAkB,QAAQ,SAAS,SAAS,aAAa;AACnF;;;;AAKA,SAAgB,YAAY,SAA+B;CAwBzD,OAtBE,QAAQ,WAAW,KAClB,QAAQ,aAAa,KAAK,QAAQ,aAAa,UAAU,MAAM,OAEzD,KAGL,oBAAoB,OAAO,IACtB,EAAQ,QAAQ,QAAS,QAAQ,QAAQ,WAG9C,mBAAmB,OAAO,IACrB,QAAQ,SAAS,YAAY,QAAQ,SAAS,UAAU,CAAC,QAAQ,WAIxE,oBAAoB,OAAO,KAC3B,oBAAoB,OAAO,KAC3B,sBAAsB,OAAO,IAEtB,CAAC,QAAQ,WAGX;AACT;;;;AAKA,SAAgB,aAAa,SAA+B;CAC1D,IAAI,CAAC,YAAY,OAAO,GACtB,OAAO;CAKT,IAAI;EACF,QAAQ,MAAM;CAChB,QAA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D;EAAM,WAAW;EAAjB,UAAA;GACEA;GAmBC;GACA;EACG;KADH,EAAA,MAAA,iBADA,EAAA,MAAA,kBAnBDA,EAAAA,MAAAA;CAVJG,IAAAA;CADF,OAQK,EAAA,QAAA,cAAA,EAAA,QAFejB,UAAAA,QAAAA,EAAAA,QA4Bf,cAAA,EAAA,QAxBDgB,OATF,MAAA,qBAAC,MAAD;EACE,IAAG;EACH,WAAW;EACX,WAAQ;EACR,SAAQ;EACR,MAAM,UAAU;EALlB,UAAA;GAOG;GAEDA;GAwBC;EACG;KA3BH,EAAA,MAAA,YAFehB,EAAAA,MAAAA,UAAAA,MA4Bf,EAAA,MAAA,YAxBDgB,EAAAA,MAAAA,iCATFC;AAoCJ;AAhHkB,SAAA,OAAC,KAAM;CAKjB,OAJIC,QAAM,KACNA,QAAM,IAAU,IAChBA,QAAM,IAAU,IAEbA,MAAI;AACb;AAjBY,SAAA,OAAC,GAAM;CAKjB,OAJI,MAAM,IAAU,IAChB,MAAM,KACN,MAAM,IAAU,IAEb,IAAI;AACb;AA/FqC,SAAA,MAAC,OAA+C;CAEvF,AADA,MAAM,eAAe,GACrB,MAAM,gBAAgB;AACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"toast.d.ts","names":[],"sources":["../src/core/components/toast/toast.tsx","../src/core/components/toast/toastLayer.tsx","../src/core/components/toast/toastProvider.tsx","../src/core/components/toast/types.ts","../src/core/components/toast/useToast.ts"],"mappings":"AAsBA;;;UAAiB;EACf;EACA,cAAc,MAAM;EACpB;EACA;EACA,QAAQ,MAAM;EACd;EACA;EACA;;;;;;;;;iBAqBc,MACd,OAAO,aACL,KACE,MAAM,UAAU,oHAUnB,MAAM,IAAI;;;;UCxDI;EACf,UAAU,MAAM;EAChB;EACA;EACA;EACA;;;;;UCQe,2BAA2B,KAAK;EAC/C,WAAW,MAAM;EACjB;;;;;iBAMc,cAAc,OAAO,qBAAqB,MAAM,IAAI;;;;UC1BnD;EACf;EACA,cAAc,MAAM;EACpB;EACA;EACA;EACA,QAAQ,MAAM;EACd;;;;;UAMe;EACf;;;;;;;EAOA,OAAO,QAAQ;;;;;iBCfD,YAAY"}
1
+ {"version":3,"file":"toast.d.ts","names":[],"sources":["../src/core/components/toast/toast.tsx","../src/core/components/toast/toastLayer.tsx","../src/core/components/toast/toastProvider.tsx","../src/core/components/toast/types.ts","../src/core/components/toast/useToast.ts"],"mappings":"AAoBA;;;UAAiB;EACf;EACA,cAAc,MAAM;EACpB;EACA;EACA,QAAQ,MAAM;EACd;EACA;EACA;;;;;;;;;iBAqBc,MACd,OAAO,aACL,KACE,MAAM,UAAU,oHAUnB,MAAM,IAAI;;;;UCtDI;EACf,UAAU,MAAM;EAChB;EACA;EACA;EACA;;;;;UCQe,2BAA2B,KAAK;EAC/C,WAAW,MAAM;EACjB;;;;;iBAMc,cAAc,OAAO,qBAAqB,MAAM,IAAI;;;;UC1BnD;EACf;EACA,cAAc,MAAM;EACpB;EACA;EACA;EACA,QAAQ,MAAM;EACd;;;;;UAMe;EACf;;;;;;;EAOA,OAAO,QAAQ;;;;;iBCfD,YAAY"}
package/dist/toast.js CHANGED
@@ -1,13 +1,12 @@
1
1
  "use client";
2
- import { t as getTheme_v2 } from "./getTheme_v2-y09KqtEb.js";
3
- import { d as createGlobalScopedContext, i as usePrefersReducedMotion, n as LayerProvider, r as isRecord, s as Card, t as useLayer, y as Box } from "./useLayer-jUJIz8mh.js";
2
+ import { _ as useTheme_v2, d as createGlobalScopedContext, i as usePrefersReducedMotion, n as LayerProvider, r as isRecord, s as Card, t as useLayer, y as Box } from "./useLayer-jUJIz8mh.js";
4
3
  import { t as Flex } from "./flex-CySCBzQm.js";
5
4
  import { n as Text, t as Stack } from "./stack-BGFEokua.js";
6
- import { t as Button } from "./button-DQH2KIbq.js";
5
+ import { t as Button } from "./button-D3iEd7Je.js";
7
6
  import { t as Grid } from "./grid-I2TNptX-.js";
8
7
  import { c } from "react/compiler-runtime";
8
+ import { clsx } from "clsx/lite";
9
9
  import { startTransition, useContext, useState, useSyncExternalStore } from "react";
10
- import { styled } from "styled-components";
11
10
  import { jsx, jsxs } from "react/jsx-runtime";
12
11
  import { AnimatePresence, motion, stagger } from "motion/react";
13
12
  import { CloseIcon } from "@sanity/icons/Close";
@@ -21,25 +20,9 @@ const STATUS_CARD_TONE = {
21
20
  warning: "caution",
22
21
  success: "positive",
23
22
  info: "neutral"
24
- }, TextBox = styled(Flex).withConfig({
25
- displayName: "TextBox",
26
- componentId: "sc-iyk5nq-0"
27
- })`overflow-x:auto;`, StyledToast = styled(Card).withConfig({
28
- displayName: "StyledToast",
29
- componentId: "sc-iyk5nq-1"
30
- })`pointer-events:all;width:100%;position:relative;overflow:hidden;overflow:clip;&[data-has-duration]{padding-bottom:calc(${2}px / 2);}`, LoadingBar = styled.div.withConfig({
31
- displayName: "LoadingBar",
32
- componentId: "sc-iyk5nq-2"
33
- })`display:flex;position:absolute;bottom:0px;top:0px;left:0px;right:0px;pointer-events:none;z-index:-1;overflow:hidden;overflow:clip;background:transparent;align-items:flex-end;will-change:opacity;`, LoadingBarMask = styled(Card).withConfig({
34
- displayName: "LoadingBarMask",
35
- componentId: "sc-iyk5nq-3"
36
- })`position:absolute;top:0;left:-${2}px;right:-${2}px;bottom:${2}px;z-index:1;`, LoadingBarProgress = styled(Card).withConfig({
37
- displayName: "LoadingBarProgress",
38
- componentId: "sc-iyk5nq-4"
39
- })`display:block;height:100%;width:100%;transform-origin:0% 50%;background-color:${(props) => {
40
- let { color } = getTheme_v2(props.theme);
41
- return color.button.default[props.tone].enabled.bg;
42
- }};`, ROLES = {
23
+ };
24
+ var loadingBarProgress = "_1a5lj7y4", toast = "_1a5lj7y0", toastText = "_1a5lj7y1";
25
+ const ROLES = {
43
26
  error: "alert",
44
27
  warning: "alert",
45
28
  success: "alert",
@@ -53,45 +36,48 @@ const STATUS_CARD_TONE = {
53
36
  * @public
54
37
  */
55
38
  function Toast(props) {
56
- let $ = c(50), closable, description, duration, onClose, restProps, status, t0, title, updatedAt;
57
- $[0] === props ? (closable = $[1], description = $[2], duration = $[3], onClose = $[4], restProps = $[5], status = $[6], t0 = $[7], title = $[8], updatedAt = $[9]) : ({closable, description, duration, onClose, radius: t0, title, status, updatedAt, ...restProps} = props, $[0] = props, $[1] = closable, $[2] = description, $[3] = duration, $[4] = onClose, $[5] = restProps, $[6] = status, $[7] = t0, $[8] = title, $[9] = updatedAt);
39
+ let $ = c(54), className, closable, description, duration, onClose, restProps, status, t0, title, updatedAt;
40
+ $[0] === props ? (className = $[1], closable = $[2], description = $[3], duration = $[4], onClose = $[5], restProps = $[6], status = $[7], t0 = $[8], title = $[9], updatedAt = $[10]) : ({className, closable, description, duration, onClose, radius: t0, title, status, updatedAt, ...restProps} = props, $[0] = props, $[1] = className, $[2] = closable, $[3] = description, $[4] = duration, $[5] = onClose, $[6] = restProps, $[7] = status, $[8] = t0, $[9] = title, $[10] = updatedAt);
58
41
  let radius = t0 === void 0 ? 3 : t0, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = usePrefersReducedMotion() ? 0 : .26, t1;
59
- $[10] === visualDuration ? t1 = $[11] : (t1 = visualDuration ? {
42
+ $[11] === visualDuration ? t1 = $[12] : (t1 = visualDuration ? {
60
43
  type: "spring",
61
44
  visualDuration,
62
45
  bounce: .25
63
- } : { duration: 0 }, $[10] = visualDuration, $[11] = t1);
46
+ } : { duration: 0 }, $[11] = visualDuration, $[12] = t1);
64
47
  let transition = t1, hasDuration = duration && isFinite(duration) && duration < 20736e5, t2;
65
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t2 = ["hidden", "initial"], $[12] = t2) : t2 = $[12];
48
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t2 = ["hidden", "initial"], $[13] = t2) : t2 = $[13];
66
49
  let initial = t2, t3;
67
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t3 = ["visible", "slideIn"], $[13] = t3) : t3 = $[13];
50
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t3 = ["visible", "slideIn"], $[14] = t3) : t3 = $[14];
68
51
  let animate = t3, t4;
69
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["hidden", "slideOut"], $[14] = t4) : t4 = $[14];
70
- let exit = t4, t5 = hasDuration ? "" : void 0, t6;
71
- $[15] === title ? t6 = $[16] : (t6 = title && /* @__PURE__ */ jsx(Text, {
52
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["hidden", "slideOut"], $[15] = t4) : t4 = $[15];
53
+ let exit = t4, t5;
54
+ $[16] === className ? t5 = $[17] : (t5 = clsx(toast, className), $[16] = className, $[17] = t5);
55
+ let t6 = hasDuration ? "" : void 0, t7;
56
+ $[18] === title ? t7 = $[19] : (t7 = title && /* @__PURE__ */ jsx(Text, {
72
57
  size: 1,
73
58
  weight: "medium",
74
59
  children: title
75
- }), $[15] = title, $[16] = t6);
76
- let t7;
77
- $[17] !== description || $[18] !== transition ? (t7 = description && /* @__PURE__ */ jsx(MotionText, {
60
+ }), $[18] = title, $[19] = t7);
61
+ let t8;
62
+ $[20] !== description || $[21] !== transition ? (t8 = description && /* @__PURE__ */ jsx(MotionText, {
78
63
  muted: !0,
79
64
  size: 1,
80
65
  variants: content,
81
66
  transition,
82
67
  children: description
83
- }), $[17] = description, $[18] = transition, $[19] = t7) : t7 = $[19];
84
- let t8;
85
- $[20] !== t6 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsx(TextBox, {
68
+ }), $[20] = description, $[21] = transition, $[22] = t8) : t8 = $[22];
69
+ let t9;
70
+ $[23] !== t7 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsx(Flex, {
71
+ className: toastText,
86
72
  flex: 1,
87
73
  padding: 3,
88
74
  children: /* @__PURE__ */ jsxs(Stack, {
89
75
  gap: 3,
90
- children: [t6, t7]
76
+ children: [t7, t8]
91
77
  })
92
- }), $[20] = t6, $[21] = t7, $[22] = t8) : t8 = $[22];
93
- let t9;
94
- $[23] !== buttonTone || $[24] !== closable || $[25] !== onClose ? (t9 = closable && /* @__PURE__ */ jsx(Box, {
78
+ }), $[23] = t7, $[24] = t8, $[25] = t9) : t9 = $[25];
79
+ let t10;
80
+ $[26] !== buttonTone || $[27] !== closable || $[28] !== onClose ? (t10 = closable && /* @__PURE__ */ jsx(Box, {
95
81
  padding: 1,
96
82
  children: /* @__PURE__ */ jsx(Button, {
97
83
  as: "button",
@@ -102,52 +88,72 @@ function Toast(props) {
102
88
  onClick: onClose,
103
89
  style: { verticalAlign: "top" }
104
90
  })
105
- }), $[23] = buttonTone, $[24] = closable, $[25] = onClose, $[26] = t9) : t9 = $[26];
106
- let t10;
107
- $[27] !== t8 || $[28] !== t9 || $[29] !== transition ? (t10 = /* @__PURE__ */ jsxs(MotionFlex, {
91
+ }), $[26] = buttonTone, $[27] = closable, $[28] = onClose, $[29] = t10) : t10 = $[29];
92
+ let t11;
93
+ $[30] !== t10 || $[31] !== t9 || $[32] !== transition ? (t11 = /* @__PURE__ */ jsxs(MotionFlex, {
108
94
  align: "flex-start",
109
95
  variants: content,
110
96
  transition,
111
- children: [t8, t9]
112
- }), $[27] = t8, $[28] = t9, $[29] = transition, $[30] = t10) : t10 = $[30];
113
- let t11;
114
- $[31] !== cardTone || $[32] !== duration || $[33] !== hasDuration || $[34] !== onClose || $[35] !== radius || $[36] !== transition || $[37] !== updatedAt || $[38] !== visualDuration ? (t11 = hasDuration && /* @__PURE__ */ jsxs(MotionLoadingBar, {
97
+ children: [t9, t10]
98
+ }), $[30] = t10, $[31] = t9, $[32] = transition, $[33] = t11) : t11 = $[33];
99
+ let t12;
100
+ $[34] !== cardTone || $[35] !== duration || $[36] !== hasDuration || $[37] !== onClose || $[38] !== radius || $[39] !== transition || $[40] !== updatedAt || $[41] !== visualDuration ? (t12 = hasDuration && /* @__PURE__ */ jsxs(motion.div, {
101
+ className: "_1a5lj7y2",
115
102
  variants: content,
116
103
  transition,
117
- children: [/* @__PURE__ */ jsx(LoadingBarMask, {
104
+ children: [/* @__PURE__ */ jsx(Card, {
105
+ className: "_1a5lj7y3",
118
106
  tone: cardTone,
119
107
  radius
120
- }), /* @__PURE__ */ jsx(MotionLoadingBarProgress, {
108
+ }), /* @__PURE__ */ jsx(LoadingBarProgress, {
109
+ duration,
110
+ onComplete: onClose,
121
111
  tone: cardTone,
122
- initial: { scaleX: 0 },
123
- animate: { scaleX: 1 },
124
- transition: {
125
- delay: visualDuration,
126
- duration: duration / 1e3,
127
- ease: "linear"
128
- },
129
- onAnimationComplete: onClose
112
+ visualDuration
130
113
  }, `progress-${updatedAt}`)]
131
- }), $[31] = cardTone, $[32] = duration, $[33] = hasDuration, $[34] = onClose, $[35] = radius, $[36] = transition, $[37] = updatedAt, $[38] = visualDuration, $[39] = t11) : t11 = $[39];
132
- let t12;
133
- return $[40] !== cardTone || $[41] !== radius || $[42] !== restProps || $[43] !== role || $[44] !== t10 || $[45] !== t11 || $[46] !== t5 || $[47] !== transition || $[48] !== visualDuration ? (t12 = /* @__PURE__ */ jsxs(MotionToast, {
114
+ }), $[34] = cardTone, $[35] = duration, $[36] = hasDuration, $[37] = onClose, $[38] = radius, $[39] = transition, $[40] = updatedAt, $[41] = visualDuration, $[42] = t12) : t12 = $[42];
115
+ let t13;
116
+ return $[43] !== cardTone || $[44] !== radius || $[45] !== restProps || $[46] !== role || $[47] !== t11 || $[48] !== t12 || $[49] !== t5 || $[50] !== t6 || $[51] !== transition || $[52] !== visualDuration ? (t13 = /* @__PURE__ */ jsxs(MotionCard, {
117
+ className: t5,
134
118
  "data-ui": "Toast",
135
119
  role,
136
120
  ...restProps,
137
- "data-has-duration": t5,
121
+ "data-has-duration": t6,
138
122
  custom: visualDuration,
139
123
  radius,
140
124
  shadow: 2,
141
125
  tone: cardTone,
142
- forwardedAs: "li",
126
+ as: "li",
143
127
  layout: "position",
144
128
  variants: container,
145
129
  initial,
146
130
  animate,
147
131
  exit,
148
132
  transition,
149
- children: [t10, t11]
150
- }), $[40] = cardTone, $[41] = radius, $[42] = restProps, $[43] = role, $[44] = t10, $[45] = t11, $[46] = t5, $[47] = transition, $[48] = visualDuration, $[49] = t12) : t12 = $[49], t12;
133
+ children: [t11, t12]
134
+ }), $[43] = cardTone, $[44] = radius, $[45] = restProps, $[46] = role, $[47] = t11, $[48] = t12, $[49] = t5, $[50] = t6, $[51] = transition, $[52] = visualDuration, $[53] = t13) : t13 = $[53], t13;
135
+ }
136
+ function LoadingBarProgress(props) {
137
+ let $ = c(12), { duration, onComplete, tone, visualDuration } = props, { color } = useTheme_v2(), t0 = color.button.default[tone], t1;
138
+ $[0] === t0.enabled.bg ? t1 = $[1] : (t1 = { "--toast-loading-bar-bg": t0.enabled.bg }, $[0] = t0.enabled.bg, $[1] = t1);
139
+ let t2, t3;
140
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { scaleX: 0 }, t3 = { scaleX: 1 }, $[2] = t2, $[3] = t3) : (t2 = $[2], t3 = $[3]);
141
+ let t4 = duration / 1e3, t5;
142
+ $[4] !== t4 || $[5] !== visualDuration ? (t5 = {
143
+ delay: visualDuration,
144
+ duration: t4,
145
+ ease: "linear"
146
+ }, $[4] = t4, $[5] = visualDuration, $[6] = t5) : t5 = $[6];
147
+ let t6;
148
+ return $[7] !== onComplete || $[8] !== t1 || $[9] !== t5 || $[10] !== tone ? (t6 = /* @__PURE__ */ jsx(MotionCard, {
149
+ className: loadingBarProgress,
150
+ tone,
151
+ style: t1,
152
+ initial: t2,
153
+ animate: t3,
154
+ transition: t5,
155
+ onAnimationComplete: onComplete
156
+ }), $[7] = onComplete, $[8] = t1, $[9] = t5, $[10] = tone, $[11] = t6) : t6 = $[11], t6;
151
157
  }
152
158
  const container = {
153
159
  initial: {
@@ -176,7 +182,7 @@ const container = {
176
182
  initial: { willChange: "transform" },
177
183
  hidden: { opacity: 0 },
178
184
  visible: { opacity: 1 }
179
- }, MotionToast = motion.create(StyledToast), MotionFlex = motion.create(Flex), MotionText = motion.create(Text), MotionLoadingBar = motion.create(LoadingBar), MotionLoadingBarProgress = motion.create(LoadingBarProgress);
185
+ }, MotionCard = motion.create(Card), MotionFlex = motion.create(Flex), MotionText = motion.create(Text);
180
186
  /**
181
187
  * Some components should only render after mounting to the DOM, and not be rendered at all during SSR renderToString or equivalent.
182
188
  * @public
@@ -191,6 +197,7 @@ function _temp$1() {
191
197
  return !0;
192
198
  }
193
199
  const subscribe = () => () => {}, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null);
200
+ var toastLayer = "_1ojgmwx0";
194
201
  /**
195
202
  * @internal
196
203
  */
@@ -198,8 +205,9 @@ function ToastLayer(props) {
198
205
  let $ = c(9), { children, padding: t0, paddingX, paddingY, gap: t1 } = props, padding = t0 === void 0 ? 4 : t0, gap = t1 === void 0 ? 3 : t1, { zIndex } = useLayer(), t2;
199
206
  $[0] === zIndex ? t2 = $[1] : (t2 = { zIndex }, $[0] = zIndex, $[1] = t2);
200
207
  let t3;
201
- return $[2] !== children || $[3] !== gap || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsx(StyledLayer, {
202
- forwardedAs: "ul",
208
+ return $[2] !== children || $[3] !== gap || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsx(Grid, {
209
+ as: "ul",
210
+ className: toastLayer,
203
211
  "data-ui": "ToastProvider",
204
212
  padding,
205
213
  paddingX,
@@ -210,10 +218,6 @@ function ToastLayer(props) {
210
218
  children
211
219
  }), $[2] = children, $[3] = gap, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
212
220
  }
213
- const StyledLayer = styled(Grid).withConfig({
214
- displayName: "StyledLayer",
215
- componentId: "sc-7muzlg-0"
216
- })`box-sizing:border-box;position:fixed;right:0;bottom:0;list-style:none;pointer-events:none;max-width:420px;width:100%;`;
217
221
  let toastId = 0;
218
222
  /** @internal */
219
223
  function generateToastId() {