@sanity/ui 2.14.3 → 2.14.4-canary.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.
package/dist/index.d.mts CHANGED
@@ -2488,7 +2488,18 @@ export declare type ThemeShadow = ThemeShadow_2
2488
2488
  * @public
2489
2489
  */
2490
2490
  export declare function Toast(
2491
- props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
2491
+ props: ToastProps &
2492
+ Omit<
2493
+ React.HTMLProps<HTMLDivElement>,
2494
+ | 'as'
2495
+ | 'height'
2496
+ | 'ref'
2497
+ | 'title'
2498
+ | 'onAnimationStart'
2499
+ | 'onDragStart'
2500
+ | 'onDragEnd'
2501
+ | 'onDrag'
2502
+ >,
2492
2503
  ): React.JSX.Element
2493
2504
 
2494
2505
  export declare namespace Toast {
@@ -2503,6 +2514,17 @@ export declare interface ToastContextValue {
2503
2514
  push: (params: ToastParams) => string
2504
2515
  }
2505
2516
 
2517
+ /**
2518
+ * @public
2519
+ */
2520
+ declare interface ToastLayerProps {
2521
+ children: React.ReactNode
2522
+ padding?: number | number[]
2523
+ paddingX?: number | number[]
2524
+ paddingY?: number | number[]
2525
+ gap?: number | number[]
2526
+ }
2527
+
2506
2528
  /**
2507
2529
  * @public
2508
2530
  */
@@ -2522,11 +2544,12 @@ export declare interface ToastParams {
2522
2544
  export declare interface ToastProps {
2523
2545
  closable?: boolean
2524
2546
  description?: React.ReactNode
2525
- onClose?: () => void
2547
+ onClose: () => void
2526
2548
  radius?: number | number[]
2527
2549
  title?: React.ReactNode
2528
2550
  status?: 'error' | 'warning' | 'success' | 'info'
2529
2551
  duration?: number
2552
+ updatedAt?: number
2530
2553
  }
2531
2554
 
2532
2555
  /**
@@ -2541,11 +2564,8 @@ export declare namespace ToastProvider {
2541
2564
  /**
2542
2565
  * @public
2543
2566
  */
2544
- export declare interface ToastProviderProps {
2567
+ export declare interface ToastProviderProps extends Omit<ToastLayerProps, 'children'> {
2545
2568
  children?: React.ReactNode
2546
- padding?: number | number[]
2547
- paddingX?: number | number[]
2548
- paddingY?: number | number[]
2549
2569
  zOffset?: number | number[]
2550
2570
  }
2551
2571
 
package/dist/index.d.ts CHANGED
@@ -2488,7 +2488,18 @@ export declare type ThemeShadow = ThemeShadow_2
2488
2488
  * @public
2489
2489
  */
2490
2490
  export declare function Toast(
2491
- props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
2491
+ props: ToastProps &
2492
+ Omit<
2493
+ React.HTMLProps<HTMLDivElement>,
2494
+ | 'as'
2495
+ | 'height'
2496
+ | 'ref'
2497
+ | 'title'
2498
+ | 'onAnimationStart'
2499
+ | 'onDragStart'
2500
+ | 'onDragEnd'
2501
+ | 'onDrag'
2502
+ >,
2492
2503
  ): React.JSX.Element
2493
2504
 
2494
2505
  export declare namespace Toast {
@@ -2503,6 +2514,17 @@ export declare interface ToastContextValue {
2503
2514
  push: (params: ToastParams) => string
2504
2515
  }
2505
2516
 
2517
+ /**
2518
+ * @public
2519
+ */
2520
+ declare interface ToastLayerProps {
2521
+ children: React.ReactNode
2522
+ padding?: number | number[]
2523
+ paddingX?: number | number[]
2524
+ paddingY?: number | number[]
2525
+ gap?: number | number[]
2526
+ }
2527
+
2506
2528
  /**
2507
2529
  * @public
2508
2530
  */
@@ -2522,11 +2544,12 @@ export declare interface ToastParams {
2522
2544
  export declare interface ToastProps {
2523
2545
  closable?: boolean
2524
2546
  description?: React.ReactNode
2525
- onClose?: () => void
2547
+ onClose: () => void
2526
2548
  radius?: number | number[]
2527
2549
  title?: React.ReactNode
2528
2550
  status?: 'error' | 'warning' | 'success' | 'info'
2529
2551
  duration?: number
2552
+ updatedAt?: number
2530
2553
  }
2531
2554
 
2532
2555
  /**
@@ -2541,11 +2564,8 @@ export declare namespace ToastProvider {
2541
2564
  /**
2542
2565
  * @public
2543
2566
  */
2544
- export declare interface ToastProviderProps {
2567
+ export declare interface ToastProviderProps extends Omit<ToastLayerProps, 'children'> {
2545
2568
  children?: React.ReactNode
2546
- padding?: number | number[]
2547
- paddingX?: number | number[]
2548
- paddingY?: number | number[]
2549
2569
  zOffset?: number | number[]
2550
2570
  }
2551
2571
 
package/dist/index.esm.js CHANGED
@@ -1,13 +1,13 @@
1
- import { EMPTY_ARRAY, useElementSize, Code, isHTMLElement, isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, Box, _isEnterToClickElement, Card, Text, useArrayProp, EMPTY_RECORD, Button, Stack, Popover, TextInput, useClickOutsideEvent, _responsive, createGlobalScopedContext, Container, Flex, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, useTheme_v2, usePrefersReducedMotion, Portal, containsOrEqualsElement, Layer, responsivePaddingStyle, responsiveRadiusStyle, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, isRecord, _cardColorStyle, rem } from "./_legacy/_visual-editing.esm.js";
2
- import { Arrow, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Checkbox, ConditionalWrapper, ElementQuery, Grid, Heading, Hotkeys, Inline, KBD, Label, LayerProvider, Menu, MenuDivider, MenuGroup, MenuItem, PortalProvider, Radio, Select, Spinner, SrOnly, Switch, Tab, TabList, TextArea, ThemeColorProvider, ThemeProvider, Tooltip, TooltipDelayGroupContext, TooltipDelayGroupProvider, VirtualList, _ResizeObserver, _elementSizeObserver, _fillCSSObject, _getArrayProp, _getResponsiveSpace, _isScrollable, createColorTheme, hexToRgb, hslToRgb, multiply, parseColor, responsiveCodeFontStyle, responsiveHeadingFont, responsiveLabelFont, responsiveTextAlignStyle, responsiveTextFont, rgbToHex, rgbToHsl, rgba, screen, studioTheme, useCustomValidity, useMatchMedia, useMediaIndex, usePrefersDark, useRootTheme, useTheme, useTooltipDelayGroup } from "./_legacy/_visual-editing.esm.js";
1
+ import { EMPTY_ARRAY, useElementSize, Code, isHTMLElement, isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, Box, _isEnterToClickElement, Card, Text, useArrayProp, EMPTY_RECORD, Button, Stack, Popover, TextInput, useClickOutsideEvent, _responsive, createGlobalScopedContext, Container, Flex, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, useTheme_v2, usePrefersReducedMotion, Portal, containsOrEqualsElement, Layer, responsivePaddingStyle, responsiveRadiusStyle, Grid, LayerProvider, isRecord, _cardColorStyle, rem } from "./_legacy/_visual-editing.esm.js";
2
+ import { Arrow, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Checkbox, ConditionalWrapper, ElementQuery, Heading, Hotkeys, Inline, KBD, Label, Menu, MenuDivider, MenuGroup, MenuItem, PortalProvider, Radio, Select, Spinner, SrOnly, Switch, Tab, TabList, TextArea, ThemeColorProvider, ThemeProvider, Tooltip, TooltipDelayGroupContext, TooltipDelayGroupProvider, VirtualList, _ResizeObserver, _elementSizeObserver, _fillCSSObject, _getArrayProp, _getResponsiveSpace, _isScrollable, createColorTheme, hexToRgb, hslToRgb, multiply, parseColor, responsiveCodeFontStyle, responsiveHeadingFont, responsiveLabelFont, responsiveTextAlignStyle, responsiveTextFont, rgbToHex, rgbToHsl, rgba, screen, studioTheme, useCustomValidity, useMatchMedia, useMediaIndex, usePrefersDark, useRootTheme, useTheme, useTooltipDelayGroup } from "./_legacy/_visual-editing.esm.js";
3
3
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
4
4
  import { SpinnerIcon, ChevronDownIcon, CloseIcon, ToggleArrowRightIcon } from "@sanity/icons";
5
- import { useState, useRef, useEffect, useImperativeHandle, Component, forwardRef, useReducer, useCallback, useMemo, cloneElement, Children, isValidElement, Fragment, useContext, useSyncExternalStore, startTransition, memo, useId } from "react";
5
+ import { useState, useRef, useEffect, useImperativeHandle, Component, forwardRef, useReducer, useCallback, useMemo, cloneElement, Children, isValidElement, Fragment, useContext, useSyncExternalStore, memo, useId } from "react";
6
6
  import { styled, keyframes, css } from "styled-components";
7
7
  import { c } from "react-compiler-runtime";
8
8
  import { getTheme_v2 } from "@sanity/ui/theme";
9
+ import { motion, AnimatePresence } from "framer-motion";
9
10
  import { getTheme_v2 as getTheme_v2$1 } from "./_legacy/getTheme_v2.esm.js";
10
- import { AnimatePresence, motion } from "framer-motion";
11
11
  function _getElements(element, elementsArg) {
12
12
  const ret = [element];
13
13
  for (const el of elementsArg)
@@ -390,7 +390,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
390
390
  dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
391
391
  }, [openButtonProps, dispatchOpen]), openButtonNode = useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Open", disabled: expanded, fontSize, icon: ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsx(TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = useCallback((event_5) => {
392
392
  event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
393
- }, [listFocused]), content = useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => {
393
+ }, [listFocused]), content2 = useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => {
394
394
  const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
395
395
  return /* @__PURE__ */ jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: cloneElement(renderOption(option_0), {
396
396
  disabled: loading,
@@ -398,12 +398,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
398
398
  tabIndex: listFocused && active ? 0 : -1
399
399
  }) }, option_0.value);
400
400
  }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover({
401
- content,
401
+ content: content2,
402
402
  hidden: !expanded,
403
403
  inputElement: inputElementRef.current,
404
404
  onMouseEnter: handlePopoverMouseEnter,
405
405
  onMouseLeave: handlePopoverMouseLeave
406
- }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
406
+ }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
407
407
  return /* @__PURE__ */ jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
408
408
  input,
409
409
  results
@@ -715,7 +715,7 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
715
715
  }, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), useEffect(t7, t8);
716
716
  let t9;
717
717
  $[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
718
- setOpen(_temp$1), setShouldFocus(null);
718
+ setOpen(_temp$2), setShouldFocus(null);
719
719
  }, $[12] = t9) : t9 = $[12];
720
720
  const handleButtonClick = t9;
721
721
  let t10;
@@ -817,7 +817,7 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
817
817
  return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
818
818
  });
819
819
  MenuButton.displayName = "ForwardRef(MenuButton)";
820
- function _temp$1(v) {
820
+ function _temp$2(v) {
821
821
  return !v;
822
822
  }
823
823
  const keyframe = keyframes`
@@ -966,55 +966,7 @@ const TabPanel = forwardRef(function(props, ref) {
966
966
  return $[3] !== flex || $[4] !== props.children || $[5] !== ref || $[6] !== restProps || $[7] !== t0 ? (t1 = /* @__PURE__ */ jsx(Box, { "data-ui": "TabPanel", ...restProps, flex, ref, role: "tabpanel", tabIndex: t0, children: props.children }), $[3] = flex, $[4] = props.children, $[5] = ref, $[6] = restProps, $[7] = t0, $[8] = t1) : t1 = $[8], t1;
967
967
  });
968
968
  TabPanel.displayName = "ForwardRef(TabPanel)";
969
- const TextBox = styled(Flex).withConfig({
970
- displayName: "TextBox",
971
- componentId: "sc-1rr7rxo-0"
972
- })`overflow-x:auto;`, loadingAnimation = keyframes`
973
- 0% {
974
- width: 0;
975
- }
976
- 100% {
977
- width: 100%;
978
- }
979
- `, LOADING_BAR_HEIGHT = 2;
980
- function rootStyles(props) {
981
- const {
982
- color
983
- } = getTheme_v2$1(props.theme), loadingBarColor = color.button.default[props.tone].enabled.bg;
984
- return props.$duration ? css`
985
- pointer-events: all;
986
- width: 100%;
987
- position: relative;
988
- overflow: hidden;
989
- overflow: clip;
990
- padding-bottom: ${LOADING_BAR_HEIGHT}px;
991
- &::before {
992
- content: '';
993
- position: absolute;
994
- bottom: 0px;
995
- height: ${LOADING_BAR_HEIGHT}px;
996
- background: ${loadingBarColor};
997
- animation-name: ${loadingAnimation};
998
- animation-duration: ${props.$duration}ms;
999
- animation-fill-mode: both;
1000
- animation-timing-function: linear;
1001
- opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
1002
- will-change: width;
1003
- }
1004
-
1005
- & > * {
1006
- opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
1007
- will-change: opacity;
1008
- }
1009
- ` : css`
1010
- pointer-events: all;
1011
- & > * {
1012
- opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
1013
- will-change: opacity;
1014
- }
1015
- `;
1016
- }
1017
- const STATUS_CARD_TONE = {
969
+ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
1018
970
  error: "critical",
1019
971
  warning: "caution",
1020
972
  success: "positive",
@@ -1024,121 +976,170 @@ const STATUS_CARD_TONE = {
1024
976
  warning: "caution",
1025
977
  success: "positive",
1026
978
  info: "neutral"
1027
- }, ROLES = {
979
+ }, TextBox = styled(Flex).withConfig({
980
+ displayName: "TextBox",
981
+ componentId: "sc-1rr7rxo-0"
982
+ })`overflow-x:auto;`, StyledToast = styled(Card).withConfig({
983
+ displayName: "StyledToast",
984
+ componentId: "sc-1rr7rxo-1"
985
+ })`pointer-events:all;width:100%;position:relative;overflow:hidden;overflow:clip;will-change:opacity,transform;&[data-has-duration]{padding-bottom:calc(${LOADING_BAR_HEIGHT}px / 2);}`, LoadingBar = styled.div.withConfig({
986
+ displayName: "LoadingBar",
987
+ componentId: "sc-1rr7rxo-2"
988
+ })`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;`, LoadingBarProgress = styled(Card).withConfig({
989
+ displayName: "LoadingBarProgress",
990
+ componentId: "sc-1rr7rxo-3"
991
+ })`display:block;height:100%;width:100%;transform-origin:0% 50%;background-color:${(props) => {
992
+ const {
993
+ color
994
+ } = getTheme_v2$1(props.theme);
995
+ return color.button.default[props.tone].enabled.bg;
996
+ }};`, ROLES = {
1028
997
  error: "alert",
1029
998
  warning: "alert",
1030
999
  success: "alert",
1031
1000
  info: "alert"
1032
- }, StyledToast = /* @__PURE__ */ styled(Card).withConfig({
1033
- displayName: "StyledToast",
1034
- componentId: "sc-1icz8ea-0"
1035
- })(rootStyles);
1001
+ };
1036
1002
  function Toast(props) {
1037
- const $ = c(30);
1038
- let closable, description, duration, onClose, restProps, status, t0, title;
1039
- $[0] !== props ? ({
1003
+ const {
1040
1004
  closable,
1041
1005
  description,
1042
1006
  duration,
1043
1007
  onClose,
1044
- radius: t0,
1008
+ radius = 3,
1045
1009
  title,
1046
1010
  status,
1011
+ updatedAt,
1047
1012
  ...restProps
1048
- } = props, $[0] = props, $[1] = closable, $[2] = description, $[3] = duration, $[4] = onClose, $[5] = restProps, $[6] = status, $[7] = t0, $[8] = title) : (closable = $[1], description = $[2], duration = $[3], onClose = $[4], restProps = $[5], status = $[6], t0 = $[7], title = $[8]);
1049
- const radius = t0 === void 0 ? 3 : t0, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
1050
- let t1;
1051
- $[9] !== title ? (t1 = title && /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: title }), $[9] = title, $[10] = t1) : t1 = $[10];
1052
- let t2;
1053
- $[11] !== description ? (t2 = description && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: description }), $[11] = description, $[12] = t2) : t2 = $[12];
1054
- let t3;
1055
- $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
1056
- t1,
1057
- t2
1058
- ] }) }), $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15];
1059
- let t4;
1060
- $[16] !== buttonTone || $[17] !== closable || $[18] !== onClose ? (t4 = closable && /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Button, { as: "button", icon: CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
1061
- verticalAlign: "top"
1062
- } }) }), $[16] = buttonTone, $[17] = closable, $[18] = onClose, $[19] = t4) : t4 = $[19];
1063
- let t5;
1064
- $[20] !== t3 || $[21] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, { align: "flex-start", children: [
1065
- t3,
1066
- t4
1067
- ] }), $[20] = t3, $[21] = t4, $[22] = t5) : t5 = $[22];
1068
- let t6;
1069
- return $[23] !== cardTone || $[24] !== duration || $[25] !== radius || $[26] !== restProps || $[27] !== role || $[28] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledToast, { "data-ui": "Toast", role, ...restProps, marginTop: 3, radius, shadow: 2, tone: cardTone, $duration: duration, children: t5 }), $[23] = cardTone, $[24] = duration, $[25] = radius, $[26] = restProps, $[27] = role, $[28] = t5, $[29] = t6) : t6 = $[29], t6;
1013
+ } = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
1014
+ let visualDuration = usePrefersReducedMotion() ? 0 : 0.26;
1015
+ const transition = visualDuration ? {
1016
+ type: "spring",
1017
+ visualDuration,
1018
+ bounce: 0.25
1019
+ } : {
1020
+ duration: 0
1021
+ }, hasDuration = duration && isFinite(duration);
1022
+ return /* @__PURE__ */ jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": hasDuration ? "" : void 0, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial: ["hidden", "initial"], animate: ["visible", "slideIn"], exit: ["hidden", "slideOut"], transition, children: [
1023
+ /* @__PURE__ */ jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
1024
+ /* @__PURE__ */ jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
1025
+ title && /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: title }),
1026
+ description && /* @__PURE__ */ jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description })
1027
+ ] }) }),
1028
+ closable && /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Button, { as: "button", icon: CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
1029
+ verticalAlign: "top"
1030
+ } }) })
1031
+ ] }),
1032
+ hasDuration && /* @__PURE__ */ jsxs(MotionLoadiongBar, { variants: content, transition, children: [
1033
+ /* @__PURE__ */ jsx(Card, { tone: cardTone, radius, style: {
1034
+ position: "absolute",
1035
+ right: -2,
1036
+ left: -2,
1037
+ top: 0,
1038
+ bottom: 2,
1039
+ zIndex: 1
1040
+ } }),
1041
+ /* @__PURE__ */ jsx(MotionLoadiongBarProgress, { tone: cardTone, initial: {
1042
+ scaleX: 0
1043
+ }, animate: {
1044
+ scaleX: 1
1045
+ }, transition: {
1046
+ delay: visualDuration,
1047
+ duration: duration / 1e3,
1048
+ ease: "linear"
1049
+ }, onAnimationComplete: onClose }, `${duration}-${updatedAt}`)
1050
+ ] })
1051
+ ] });
1070
1052
  }
1071
1053
  Toast.displayName = "Toast";
1054
+ const container = {
1055
+ initial: {
1056
+ y: 32,
1057
+ scale: 0.5,
1058
+ zIndex: 1
1059
+ },
1060
+ hidden: {
1061
+ opacity: 0
1062
+ },
1063
+ visible: (visualDuration) => visualDuration ? {
1064
+ opacity: 1,
1065
+ transition: {
1066
+ when: "beforeChildren",
1067
+ staggerChildren: visualDuration / 3,
1068
+ duration: visualDuration / 3
1069
+ }
1070
+ } : {
1071
+ opacity: 1
1072
+ },
1073
+ slideIn: {
1074
+ y: 0,
1075
+ scale: 1
1076
+ },
1077
+ slideOut: {
1078
+ zIndex: 0,
1079
+ scale: 0.75
1080
+ }
1081
+ }, content = {
1082
+ hidden: {
1083
+ opacity: 0
1084
+ },
1085
+ visible: {
1086
+ opacity: 1
1087
+ }
1088
+ }, MotionToast = motion.create(StyledToast), MotionFlex = motion.create(Flex), MotionText = motion.create(Text), MotionLoadiongBar = motion.create(LoadingBar), MotionLoadiongBarProgress = motion.create(LoadingBarProgress);
1072
1089
  function useMounted() {
1073
- return useSyncExternalStore(subscribe, _temp, _temp2);
1090
+ return useSyncExternalStore(subscribe, _temp$1, _temp2);
1074
1091
  }
1075
1092
  function _temp2() {
1076
1093
  return !1;
1077
1094
  }
1078
- function _temp() {
1095
+ function _temp$1() {
1079
1096
  return !0;
1080
1097
  }
1081
1098
  const subscribe = () => () => {
1082
1099
  }, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null);
1100
+ function ToastLayer(props) {
1101
+ const $ = c(9), {
1102
+ children,
1103
+ padding: t0,
1104
+ paddingX,
1105
+ paddingY,
1106
+ gap: t1
1107
+ } = props, padding = t0 === void 0 ? 4 : t0, gap = t1 === void 0 ? 3 : t1, {
1108
+ zIndex
1109
+ } = useLayer();
1110
+ let t2;
1111
+ $[0] !== zIndex ? (t2 = {
1112
+ zIndex
1113
+ }, $[0] = zIndex, $[1] = t2) : t2 = $[1];
1114
+ let t3;
1115
+ return $[2] !== children || $[3] !== gap || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsx(StyledLayer, { forwardedAs: "ul", "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: t2, children }), $[2] = children, $[3] = gap, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
1116
+ }
1117
+ ToastLayer.displayName = "ToastLayer";
1118
+ const StyledLayer = styled(Grid).withConfig({
1119
+ displayName: "StyledLayer",
1120
+ componentId: "sc-1tbwn58-0"
1121
+ })`box-sizing:border-box;position:fixed;right:0;bottom:0;list-style:none;pointer-events:none;max-width:420px;width:100%;`;
1083
1122
  let toastId = 0;
1084
1123
  function generateToastId() {
1085
1124
  return String(toastId++);
1086
1125
  }
1087
- const StyledToastProvider = styled(Layer).withConfig({
1088
- displayName: "StyledToastProvider",
1089
- componentId: "sc-17mn6j-0"
1090
- })`position:fixed;top:0;left:0;right:0;bottom:0;pointer-events:none;`, ToastContainer = styled.div.withConfig({
1091
- displayName: "ToastContainer",
1092
- componentId: "sc-17mn6j-1"
1093
- })`box-sizing:border-box;position:absolute;right:0;bottom:0;max-width:420px;width:100%;`;
1094
1126
  function ToastProvider(props) {
1095
- const $ = c(22), {
1127
+ const $ = c(13), {
1096
1128
  children,
1097
- padding: t0,
1129
+ padding,
1098
1130
  paddingX,
1099
1131
  paddingY,
1100
- zOffset
1101
- } = props, padding = t0 === void 0 ? 4 : t0;
1132
+ gap,
1133
+ zOffset: t0
1134
+ } = props, zOffset = t0 === void 0 ? 1 : t0;
1102
1135
  let t1;
1103
1136
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
1104
- const [state, _setState] = useState(t1);
1105
- let t2;
1106
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[1] = t2) : t2 = $[1];
1107
- const toastsRef = useRef(t2), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion();
1108
- let t3, t4, t5, t6;
1109
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
1110
- opacity: 0,
1111
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
1112
- y: 32,
1113
- scale: 0.25,
1114
- willChange: "transform"
1115
- }, t5 = {
1116
- opacity: 2,
1117
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 1,
1118
- y: 0,
1119
- scale: 1
1120
- }, t6 = {
1121
- opacity: 0,
1122
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
1123
- scale: 0.5
1124
- }, $[2] = t4, $[3] = t5, $[4] = t6) : (t4 = $[2], t5 = $[3], t6 = $[4]);
1125
- const t7 = prefersReducedMotion ? 0 : 0.2;
1126
- let t8;
1127
- $[5] !== t7 ? (t8 = {
1128
- initial: t4,
1129
- animate: t5,
1130
- exit: t6,
1131
- transition: {
1132
- duration: t7
1133
- }
1134
- }, $[5] = t7, $[6] = t8) : t8 = $[6], t3 = t8;
1135
- const variants = t3;
1136
- let t9, t10;
1137
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t10 = {
1137
+ const [state, setState] = useState(t1), mounted = useMounted();
1138
+ let t2, t3;
1139
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
1138
1140
  version: 0,
1139
1141
  push: (params) => {
1140
- const setState = (state_0) => startTransition(() => _setState(state_0)), id = params.id || generateToastId(), duration = params.duration || 5e3, dismiss = () => {
1141
- const timeoutId = toastsRef.current[id]?.timeoutId;
1142
+ const id = params.id || generateToastId(), duration = params.duration || 5e3, dismiss = () => {
1142
1143
  setState((prevState) => {
1143
1144
  const idx = prevState.findIndex((t) => t.id === id);
1144
1145
  if (idx > -1) {
@@ -1146,49 +1147,36 @@ function ToastProvider(props) {
1146
1147
  return toasts.splice(idx, 1), toasts;
1147
1148
  }
1148
1149
  return prevState;
1149
- }), timeoutId !== void 0 && (clearTimeout(timeoutId), delete toastsRef.current[id]);
1150
+ });
1150
1151
  };
1151
1152
  return setState((prevState_0) => prevState_0.filter((t_0) => t_0.id !== id).concat([{
1152
1153
  dismiss,
1153
1154
  id,
1155
+ updatedAt: Date.now(),
1154
1156
  params: {
1155
1157
  ...params,
1156
1158
  duration
1157
1159
  }
1158
- }])), toastsRef.current[id] && (clearTimeout(toastsRef.current[id].timeoutId), delete toastsRef.current[id]), toastsRef.current[id] = {
1159
- timeoutId: setTimeout(dismiss, duration)
1160
- }, id;
1160
+ }])), id;
1161
1161
  }
1162
- }, $[7] = t10) : t10 = $[7], t9 = t10;
1163
- const value = t9;
1164
- let t11, t12;
1165
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => () => {
1166
- for (const {
1167
- timeoutId: timeoutId_0
1168
- } of Object.values(toastsRef.current))
1169
- clearTimeout(timeoutId_0);
1170
- toastsRef.current = {};
1171
- }, t12 = [], $[8] = t11, $[9] = t12) : (t11 = $[8], t12 = $[9]), useEffect(t11, t12);
1172
- let t13;
1173
- $[10] !== mounted || $[11] !== padding || $[12] !== paddingX || $[13] !== paddingY || $[14] !== prefersReducedMotion || $[15] !== state || $[16] !== variants || $[17] !== zOffset ? (t13 = mounted && /* @__PURE__ */ jsx(StyledToastProvider, { "data-ui": "ToastProvider", zOffset, children: /* @__PURE__ */ jsx(ToastContainer, { children: /* @__PURE__ */ jsx(Box, { padding, paddingX, paddingY, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, children: state.map((t142) => {
1174
- const {
1175
- dismiss: dismiss_0,
1176
- id: id_0,
1177
- params: params_0
1178
- } = t142;
1179
- return /* @__PURE__ */ jsx(motion.div, { layout: "position", initial: "initial", animate: "animate", exit: "exit", variants, transition: prefersReducedMotion ? {
1180
- duration: 0
1181
- } : {
1182
- type: "spring",
1183
- damping: 30,
1184
- stiffness: 400
1185
- }, children: /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration }) }, id_0);
1186
- }) }) }) }) }), $[10] = mounted, $[11] = padding, $[12] = paddingX, $[13] = paddingY, $[14] = prefersReducedMotion, $[15] = state, $[16] = variants, $[17] = zOffset, $[18] = t13) : t13 = $[18];
1187
- let t14;
1188
- return $[19] !== children || $[20] !== t13 ? (t14 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
1162
+ }, $[1] = t3) : t3 = $[1], t2 = t3;
1163
+ const value = t2;
1164
+ let t4;
1165
+ $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
1166
+ let t5;
1167
+ return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
1189
1168
  children,
1190
- t13
1191
- ] }), $[19] = children, $[20] = t13, $[21] = t14) : t14 = $[21], t14;
1169
+ t4
1170
+ ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
1171
+ }
1172
+ function _temp(t0) {
1173
+ const {
1174
+ dismiss: dismiss_0,
1175
+ id: id_0,
1176
+ params: params_0,
1177
+ updatedAt
1178
+ } = t0;
1179
+ return /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration, updatedAt }, id_0);
1192
1180
  }
1193
1181
  ToastProvider.displayName = "ToastProvider";
1194
1182
  function useToast() {
@@ -1566,7 +1554,7 @@ const TreeGroup = memo(function(props) {
1566
1554
  if (rootRef.current)
1567
1555
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
1568
1556
  }, [expanded, itemPath, registerItem, selected]);
1569
- const content = /* @__PURE__ */ jsxs(Flex, { padding, children: [
1557
+ const content2 = /* @__PURE__ */ jsxs(Flex, { padding, children: [
1570
1558
  /* @__PURE__ */ jsxs(Box, { marginRight: space, style: {
1571
1559
  visibility: IconComponent || children ? "visible" : "hidden",
1572
1560
  pointerEvents: "none"
@@ -1579,10 +1567,10 @@ const TreeGroup = memo(function(props) {
1579
1567
  /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
1580
1568
  ] });
1581
1569
  return href ? /* @__PURE__ */ jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...restProps, onClick: handleClick, ref: rootRef, role: "none", children: [
1582
- /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content }),
1570
+ /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }),
1583
1571
  /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { hidden: !expanded, children }) })
1584
1572
  ] }) : /* @__PURE__ */ jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...restProps, "aria-expanded": expanded, onClick: handleClick, onKeyDown: handleKeyDown, ref: rootRef, role: "treeitem", tabIndex, children: [
1585
- /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content }),
1573
+ /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }),
1586
1574
  /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { expanded, children }) })
1587
1575
  ] });
1588
1576
  });