@sanity/ui 2.14.4-canary.2 → 2.14.4
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/_chunks-cjs/_visual-editing.js +64 -84
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +64 -84
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_legacy/_visual-editing.esm.js +64 -84
- package/dist/_legacy/_visual-editing.esm.js.map +1 -1
- package/dist/index.d.mts +6 -26
- package/dist/index.d.ts +6 -26
- package/dist/index.esm.js +187 -182
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +185 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -182
- package/dist/index.mjs.map +1 -1
- package/package.json +41 -27
- package/src/core/components/toast/styles.ts +53 -57
- package/src/core/components/toast/toast.tsx +34 -127
- package/src/core/components/toast/toastProvider.tsx +142 -49
- package/src/core/constants.ts +29 -42
- package/src/core/primitives/grid/grid.tsx +0 -1
- package/src/core/primitives/popover/popoverCard.tsx +8 -20
- package/src/core/primitives/tooltip/tooltip.tsx +61 -24
- package/src/core/primitives/tooltip/tooltipCard.tsx +6 -7
- package/src/core/utils/layer/layer.tsx +1 -1
- package/src/core/components/toast/toastLayer.tsx +0 -50
package/dist/index.d.mts
CHANGED
|
@@ -2488,18 +2488,7 @@ export declare type ThemeShadow = ThemeShadow_2
|
|
|
2488
2488
|
* @public
|
|
2489
2489
|
*/
|
|
2490
2490
|
export declare function Toast(
|
|
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
|
-
>,
|
|
2491
|
+
props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
|
|
2503
2492
|
): React.JSX.Element
|
|
2504
2493
|
|
|
2505
2494
|
export declare namespace Toast {
|
|
@@ -2514,17 +2503,6 @@ export declare interface ToastContextValue {
|
|
|
2514
2503
|
push: (params: ToastParams) => string
|
|
2515
2504
|
}
|
|
2516
2505
|
|
|
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
|
-
|
|
2528
2506
|
/**
|
|
2529
2507
|
* @public
|
|
2530
2508
|
*/
|
|
@@ -2544,12 +2522,11 @@ export declare interface ToastParams {
|
|
|
2544
2522
|
export declare interface ToastProps {
|
|
2545
2523
|
closable?: boolean
|
|
2546
2524
|
description?: React.ReactNode
|
|
2547
|
-
onClose
|
|
2525
|
+
onClose?: () => void
|
|
2548
2526
|
radius?: number | number[]
|
|
2549
2527
|
title?: React.ReactNode
|
|
2550
2528
|
status?: 'error' | 'warning' | 'success' | 'info'
|
|
2551
2529
|
duration?: number
|
|
2552
|
-
updatedAt?: number
|
|
2553
2530
|
}
|
|
2554
2531
|
|
|
2555
2532
|
/**
|
|
@@ -2564,8 +2541,11 @@ export declare namespace ToastProvider {
|
|
|
2564
2541
|
/**
|
|
2565
2542
|
* @public
|
|
2566
2543
|
*/
|
|
2567
|
-
export declare interface ToastProviderProps
|
|
2544
|
+
export declare interface ToastProviderProps {
|
|
2568
2545
|
children?: React.ReactNode
|
|
2546
|
+
padding?: number | number[]
|
|
2547
|
+
paddingX?: number | number[]
|
|
2548
|
+
paddingY?: number | number[]
|
|
2569
2549
|
zOffset?: number | number[]
|
|
2570
2550
|
}
|
|
2571
2551
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2488,18 +2488,7 @@ export declare type ThemeShadow = ThemeShadow_2
|
|
|
2488
2488
|
* @public
|
|
2489
2489
|
*/
|
|
2490
2490
|
export declare function Toast(
|
|
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
|
-
>,
|
|
2491
|
+
props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
|
|
2503
2492
|
): React.JSX.Element
|
|
2504
2493
|
|
|
2505
2494
|
export declare namespace Toast {
|
|
@@ -2514,17 +2503,6 @@ export declare interface ToastContextValue {
|
|
|
2514
2503
|
push: (params: ToastParams) => string
|
|
2515
2504
|
}
|
|
2516
2505
|
|
|
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
|
-
|
|
2528
2506
|
/**
|
|
2529
2507
|
* @public
|
|
2530
2508
|
*/
|
|
@@ -2544,12 +2522,11 @@ export declare interface ToastParams {
|
|
|
2544
2522
|
export declare interface ToastProps {
|
|
2545
2523
|
closable?: boolean
|
|
2546
2524
|
description?: React.ReactNode
|
|
2547
|
-
onClose
|
|
2525
|
+
onClose?: () => void
|
|
2548
2526
|
radius?: number | number[]
|
|
2549
2527
|
title?: React.ReactNode
|
|
2550
2528
|
status?: 'error' | 'warning' | 'success' | 'info'
|
|
2551
2529
|
duration?: number
|
|
2552
|
-
updatedAt?: number
|
|
2553
2530
|
}
|
|
2554
2531
|
|
|
2555
2532
|
/**
|
|
@@ -2564,8 +2541,11 @@ export declare namespace ToastProvider {
|
|
|
2564
2541
|
/**
|
|
2565
2542
|
* @public
|
|
2566
2543
|
*/
|
|
2567
|
-
export declare interface ToastProviderProps
|
|
2544
|
+
export declare interface ToastProviderProps {
|
|
2568
2545
|
children?: React.ReactNode
|
|
2546
|
+
padding?: number | number[]
|
|
2547
|
+
paddingX?: number | number[]
|
|
2548
|
+
paddingY?: number | number[]
|
|
2569
2549
|
zOffset?: number | number[]
|
|
2570
2550
|
}
|
|
2571
2551
|
|
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,
|
|
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";
|
|
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";
|
|
3
3
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
4
4
|
import { SpinnerIcon, ChevronDownIcon, CloseIcon, ToggleArrowRightIcon } from "@sanity/icons";
|
|
5
5
|
import { useState, useRef, useEffect, useImperativeHandle, Component, forwardRef, useReducer, useCallback, useMemo, cloneElement, Children, isValidElement, Fragment, useContext, useSyncExternalStore, startTransition, 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";
|
|
10
9
|
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]),
|
|
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) => {
|
|
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,
|
|
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
|
|
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]);
|
|
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$
|
|
718
|
+
setOpen(_temp$1), 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$
|
|
820
|
+
function _temp$1(v) {
|
|
821
821
|
return !v;
|
|
822
822
|
}
|
|
823
823
|
const keyframe = keyframes`
|
|
@@ -966,7 +966,55 @@ 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
|
|
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 = {
|
|
970
1018
|
error: "critical",
|
|
971
1019
|
warning: "caution",
|
|
972
1020
|
success: "positive",
|
|
@@ -976,214 +1024,171 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
|
976
1024
|
warning: "caution",
|
|
977
1025
|
success: "positive",
|
|
978
1026
|
info: "neutral"
|
|
979
|
-
},
|
|
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 = {
|
|
1027
|
+
}, ROLES = {
|
|
997
1028
|
error: "alert",
|
|
998
1029
|
warning: "alert",
|
|
999
1030
|
success: "alert",
|
|
1000
1031
|
info: "alert"
|
|
1001
|
-
}
|
|
1032
|
+
}, StyledToast = /* @__PURE__ */ styled(Card).withConfig({
|
|
1033
|
+
displayName: "StyledToast",
|
|
1034
|
+
componentId: "sc-1icz8ea-0"
|
|
1035
|
+
})(rootStyles);
|
|
1002
1036
|
function Toast(props) {
|
|
1003
|
-
const
|
|
1037
|
+
const $ = c(30);
|
|
1038
|
+
let closable, description, duration, onClose, restProps, status, t0, title;
|
|
1039
|
+
$[0] !== props ? ({
|
|
1004
1040
|
closable,
|
|
1005
1041
|
description,
|
|
1006
1042
|
duration,
|
|
1007
1043
|
onClose,
|
|
1008
|
-
radius
|
|
1044
|
+
radius: t0,
|
|
1009
1045
|
title,
|
|
1010
1046
|
status,
|
|
1011
|
-
updatedAt,
|
|
1012
1047
|
...restProps
|
|
1013
|
-
} = props,
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
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
|
-
] });
|
|
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;
|
|
1052
1070
|
}
|
|
1053
1071
|
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);
|
|
1089
1072
|
function useMounted() {
|
|
1090
|
-
return useSyncExternalStore(subscribe, _temp
|
|
1073
|
+
return useSyncExternalStore(subscribe, _temp, _temp2);
|
|
1091
1074
|
}
|
|
1092
1075
|
function _temp2() {
|
|
1093
1076
|
return !1;
|
|
1094
1077
|
}
|
|
1095
|
-
function _temp
|
|
1078
|
+
function _temp() {
|
|
1096
1079
|
return !0;
|
|
1097
1080
|
}
|
|
1098
1081
|
const subscribe = () => () => {
|
|
1099
1082
|
}, 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%;`;
|
|
1122
1083
|
let toastId = 0;
|
|
1123
1084
|
function generateToastId() {
|
|
1124
1085
|
return String(toastId++);
|
|
1125
1086
|
}
|
|
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%;`;
|
|
1126
1094
|
function ToastProvider(props) {
|
|
1127
|
-
const $ = c(
|
|
1095
|
+
const $ = c(22), {
|
|
1128
1096
|
children,
|
|
1129
|
-
padding,
|
|
1097
|
+
padding: t0,
|
|
1130
1098
|
paddingX,
|
|
1131
1099
|
paddingY,
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
} = props, zOffset = t0 === void 0 ? 1 : t0;
|
|
1100
|
+
zOffset
|
|
1101
|
+
} = props, padding = t0 === void 0 ? 4 : t0;
|
|
1135
1102
|
let t1;
|
|
1136
1103
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
|
|
1137
|
-
const [state,
|
|
1138
|
-
let t2
|
|
1139
|
-
$[1] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
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 = {
|
|
1140
1138
|
version: 0,
|
|
1141
1139
|
push: (params) => {
|
|
1142
|
-
const id = params.id || generateToastId(), duration = params.duration || 5e3
|
|
1143
|
-
|
|
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;
|
|
1144
1142
|
setState((prevState) => {
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
duration
|
|
1164
|
-
}
|
|
1165
|
-
}]);
|
|
1166
|
-
});
|
|
1167
|
-
}), id;
|
|
1143
|
+
const idx = prevState.findIndex((t) => t.id === id);
|
|
1144
|
+
if (idx > -1) {
|
|
1145
|
+
const toasts = prevState.slice(0);
|
|
1146
|
+
return toasts.splice(idx, 1), toasts;
|
|
1147
|
+
}
|
|
1148
|
+
return prevState;
|
|
1149
|
+
}), timeoutId !== void 0 && (clearTimeout(timeoutId), delete toastsRef.current[id]);
|
|
1150
|
+
};
|
|
1151
|
+
return setState((prevState_0) => prevState_0.filter((t_0) => t_0.id !== id).concat([{
|
|
1152
|
+
dismiss,
|
|
1153
|
+
id,
|
|
1154
|
+
params: {
|
|
1155
|
+
...params,
|
|
1156
|
+
duration
|
|
1157
|
+
}
|
|
1158
|
+
}])), toastsRef.current[id] && (clearTimeout(toastsRef.current[id].timeoutId), delete toastsRef.current[id]), toastsRef.current[id] = {
|
|
1159
|
+
timeoutId: setTimeout(dismiss, duration)
|
|
1160
|
+
}, id;
|
|
1168
1161
|
}
|
|
1169
|
-
}, $[
|
|
1170
|
-
const value =
|
|
1171
|
-
let
|
|
1172
|
-
$[
|
|
1173
|
-
|
|
1174
|
-
|
|
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: [
|
|
1175
1189
|
children,
|
|
1176
|
-
|
|
1177
|
-
] }), $[
|
|
1178
|
-
}
|
|
1179
|
-
function _temp(t0) {
|
|
1180
|
-
const {
|
|
1181
|
-
dismiss: dismiss_0,
|
|
1182
|
-
id: id_0,
|
|
1183
|
-
params: params_0,
|
|
1184
|
-
updatedAt
|
|
1185
|
-
} = t0;
|
|
1186
|
-
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);
|
|
1190
|
+
t13
|
|
1191
|
+
] }), $[19] = children, $[20] = t13, $[21] = t14) : t14 = $[21], t14;
|
|
1187
1192
|
}
|
|
1188
1193
|
ToastProvider.displayName = "ToastProvider";
|
|
1189
1194
|
function useToast() {
|
|
@@ -1561,7 +1566,7 @@ const TreeGroup = memo(function(props) {
|
|
|
1561
1566
|
if (rootRef.current)
|
|
1562
1567
|
return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
|
|
1563
1568
|
}, [expanded, itemPath, registerItem, selected]);
|
|
1564
|
-
const
|
|
1569
|
+
const content = /* @__PURE__ */ jsxs(Flex, { padding, children: [
|
|
1565
1570
|
/* @__PURE__ */ jsxs(Box, { marginRight: space, style: {
|
|
1566
1571
|
visibility: IconComponent || children ? "visible" : "hidden",
|
|
1567
1572
|
pointerEvents: "none"
|
|
@@ -1574,10 +1579,10 @@ const TreeGroup = memo(function(props) {
|
|
|
1574
1579
|
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
|
|
1575
1580
|
] });
|
|
1576
1581
|
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: [
|
|
1577
|
-
/* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, 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 }),
|
|
1578
1583
|
/* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { hidden: !expanded, children }) })
|
|
1579
1584
|
] }) : /* @__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: [
|
|
1580
|
-
/* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children:
|
|
1585
|
+
/* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content }),
|
|
1581
1586
|
/* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { expanded, children }) })
|
|
1582
1587
|
] });
|
|
1583
1588
|
});
|