@sanity/ui 2.3.6 → 2.4.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.mjs CHANGED
@@ -8,6 +8,7 @@ import Refractor from "react-refractor";
8
8
  import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
9
9
  import { motion, AnimatePresence } from "framer-motion";
10
10
  import { createPortal } from "react-dom";
11
+ import { getTheme_v2 as getTheme_v2$1 } from "./_chunks-es/getTheme_v2.mjs";
11
12
  const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
12
13
  initial: {
13
14
  opacity: 0.5,
@@ -6142,7 +6143,49 @@ const CustomInline = styled(Inline)`
6142
6143
  children: props.children
6143
6144
  }
6144
6145
  );
6145
- }), STATUS_CARD_TONE = {
6146
+ }), TextBox = styled(Flex)`
6147
+ overflow-x: auto;
6148
+ `, loadingAnimation = keyframes`
6149
+ 0% {
6150
+ width: 0;
6151
+ }
6152
+ 100% {
6153
+ width: 100%;
6154
+ }
6155
+ `, LOADING_BAR_HEIGHT = 2;
6156
+ function rootStyles(props) {
6157
+ const { color } = getTheme_v2$1(props.theme), loadingBarColor = color.button.default[props.tone].enabled.bg;
6158
+ return props.$duration ? css`
6159
+ pointer-events: all;
6160
+ width: 100%;
6161
+ position: relative;
6162
+ overflow: hidden;
6163
+ overflow: clip;
6164
+ padding-bottom: ${LOADING_BAR_HEIGHT}px;
6165
+ &::before {
6166
+ content: '';
6167
+ position: absolute;
6168
+ bottom: 0px;
6169
+ height: ${LOADING_BAR_HEIGHT}px;
6170
+ background: ${loadingBarColor};
6171
+ animation-name: ${loadingAnimation};
6172
+ animation-duration: ${props.$duration}ms;
6173
+ animation-fill-mode: both;
6174
+ }
6175
+
6176
+ & > * {
6177
+ opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
6178
+ will-change: opacity;
6179
+ }
6180
+ ` : css`
6181
+ pointer-events: all;
6182
+ & > * {
6183
+ opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
6184
+ will-change: opacity;
6185
+ }
6186
+ `;
6187
+ }
6188
+ const STATUS_CARD_TONE = {
6146
6189
  error: "critical",
6147
6190
  warning: "caution",
6148
6191
  success: "positive",
@@ -6157,17 +6200,11 @@ const CustomInline = styled(Inline)`
6157
6200
  warning: "alert",
6158
6201
  success: "alert",
6159
6202
  info: "alert"
6160
- }, Root$2 = styled(Card)`
6161
- pointer-events: all;
6162
- & > * {
6163
- opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
6164
- will-change: opacity;
6165
- }
6166
- `, TextBox = styled(Flex)`
6167
- overflow-x: auto;
6168
- `;
6203
+ }, Root$2 = styled(Card)(
6204
+ rootStyles
6205
+ );
6169
6206
  function Toast(props) {
6170
- const { closable, description, onClose, radius = 3, title, status, ...restProps } = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
6207
+ const { closable, description, duration, onClose, radius = 3, title, status, ...restProps } = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
6171
6208
  return /* @__PURE__ */ jsx(
6172
6209
  Root$2,
6173
6210
  {
@@ -6178,6 +6215,7 @@ function Toast(props) {
6178
6215
  radius,
6179
6216
  shadow: 2,
6180
6217
  tone: cardTone,
6218
+ $duration: duration,
6181
6219
  children: /* @__PURE__ */ jsxs(Flex, { align: "flex-start", children: [
6182
6220
  /* @__PURE__ */ jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
6183
6221
  title && /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: title }),
@@ -6293,7 +6331,8 @@ function ToastProvider(props) {
6293
6331
  description: params.description,
6294
6332
  onClose: dismiss,
6295
6333
  status: params.status,
6296
- title: params.title
6334
+ title: params.title,
6335
+ duration: params.duration
6297
6336
  }
6298
6337
  )
6299
6338
  },