@sanity/ui 2.16.20 → 2.16.21
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 +104 -53
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/refractor.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +105 -54
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_chunks-es/refractor.mjs.map +1 -1
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
- package/src/core/components/tree/tree.tsx +0 -1
- package/src/core/hooks/useClickOutside.test.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refractor.js","sources":["../../src/core/primitives/code/refractor.tsx"],"sourcesContent":["import Refractor from 'react-refractor'\n\nexport default function LazyRefractor(\n props: Partial<Pick<React.ComponentProps<typeof Refractor>, 'language'>> & {\n value: React.ReactNode\n },\n) {\n const {language: languageProp, value} = props\n const language = typeof languageProp === 'string' ? languageProp : undefined\n const registered = language ? Refractor.hasLanguage(language as any) : false\n\n return (\n <>\n {!(language && registered) && <code>{value}</code>}\n {language && registered && <Refractor inline language={language} value={String(value)} />}\n </>\n )\n}\n\nLazyRefractor.displayName = 'LazyRefractor'\n"],"names":["LazyRefractor","props","$","_c","language","languageProp","value","undefined","t0","Refractor","hasLanguage","registered","t1","t2","String","t3","displayName"],"mappings":";;;;;;AAEA,SAAeA,cAAAC,OAAA;AAAA,QAAAC,IAAAC,uBAAA,EAAA,GAKb;AAAA,IAAAC,UAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwCL,OACxCG,WAAiB,OAAOC,gBAAiB,
|
|
1
|
+
{"version":3,"file":"refractor.js","sources":["../../src/core/primitives/code/refractor.tsx"],"sourcesContent":["import Refractor from 'react-refractor'\n\nexport default function LazyRefractor(\n props: Partial<Pick<React.ComponentProps<typeof Refractor>, 'language'>> & {\n value: React.ReactNode\n },\n) {\n const {language: languageProp, value} = props\n const language = typeof languageProp === 'string' ? languageProp : undefined\n const registered = language ? Refractor.hasLanguage(language as any) : false\n\n return (\n <>\n {!(language && registered) && <code>{value}</code>}\n {language && registered && <Refractor inline language={language} value={String(value)} />}\n </>\n )\n}\n\nLazyRefractor.displayName = 'LazyRefractor'\n"],"names":["LazyRefractor","props","$","_c","language","languageProp","value","undefined","t0","Refractor","hasLanguage","registered","t1","t2","String","t3","displayName"],"mappings":";;;;;;AAEA,SAAeA,cAAAC,OAAA;AAAA,QAAAC,IAAAC,uBAAA,EAAA,GAKb;AAAA,IAAAC,UAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwCL,OACxCG,WAAiB,OAAOC,gBAAiB,WAAxBA,eAAAE;AAA2D,MAAAC;AAAAN,WAAAE,YACzDI,KAAAJ,WAAWK,mBAAAA,QAASC,YAAaN,QAAuB,IAAxD,IAAyDF,OAAAE,UAAAF,OAAAM,MAAAA,KAAAN,EAAA,CAAA;AAA5E,QAAAS,aAAmBH;AAAyD,MAAAI;AAAAV,IAAA,CAAA,MAAAE,YAAAF,SAAAS,cAAAT,EAAA,CAAA,MAAAI,SAIvEM,KAAA,EAAER,YAAAO,8CAA2B,QAAA,EAAOL,UAAAA,MAAAA,CAAM,GAAOJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAU,MAAAA,KAAAV,EAAA,CAAA;AAAA,MAAAW;AAAAX,IAAA,CAAA,MAAAE,YAAAF,SAAAS,cAAAT,EAAA,CAAA,MAAAI,SACjDO,KAAAT,YAAAO,6CAA2BF,mBAAAA,SAAA,EAAU,QAAA,IAAiBL,UAAiB,OAAAU,OAAOR,KAAK,EAAA,CAAC,GAAIJ,OAAAE,UAAAF,OAAAS,YAAAT,OAAAI,OAAAJ,OAAAW,MAAAA,KAAAX,EAAA,CAAA;AAAA,MAAAa;AAAA,SAAAb,EAAA,EAAA,MAAAU,MAAAV,UAAAW,MAF3FE,4DACGH,UAAAA;AAAAA,IAAAA;AAAAA,IACAC;AAAAA,EAAAA,EAAAA,CAAwF,GACxFX,QAAAU,IAAAV,QAAAW,IAAAX,QAAAa,MAAAA,KAAAb,EAAA,EAAA,GAHHa;AAGG;AAIPf,cAAcgB,cAAc;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
|
-
import { useState, useEffect, useDebugValue, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, useRef, useImperativeHandle, lazy, Suspense,
|
|
4
|
+
import { useState, useEffect, useDebugValue, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, useRef, useImperativeHandle, lazy, Suspense, memo, useMemo, useCallback, useLayoutEffect } from "react";
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
|
|
6
6
|
import ReactIs, { isValidElementType } from "react-is";
|
|
7
7
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
|
|
@@ -2886,7 +2886,7 @@ const StyledArrow = /* @__PURE__ */ styled.div.withConfig({
|
|
|
2886
2886
|
displayName: "ShapePath",
|
|
2887
2887
|
componentId: "sc-12vzy6c-2"
|
|
2888
2888
|
})`fill:var(--card-bg-color);`, Arrow = forwardRef(function(props, ref) {
|
|
2889
|
-
const $ = c(
|
|
2889
|
+
const $ = c(29);
|
|
2890
2890
|
let h, restProps, t0, w;
|
|
2891
2891
|
$[0] !== props ? ({
|
|
2892
2892
|
width: w,
|
|
@@ -2896,40 +2896,47 @@ const StyledArrow = /* @__PURE__ */ styled.div.withConfig({
|
|
|
2896
2896
|
} = props, $[0] = props, $[1] = h, $[2] = restProps, $[3] = t0, $[4] = w) : (h = $[1], restProps = $[2], t0 = $[3], w = $[4]);
|
|
2897
2897
|
const radius = t0 === void 0 ? 0 : t0, {
|
|
2898
2898
|
card
|
|
2899
|
-
} = useTheme_v2(), strokeWidth = card.shadow.outline, center = w / 2
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2899
|
+
} = useTheme_v2(), strokeWidth = card.shadow.outline, center = w / 2;
|
|
2900
|
+
let t1;
|
|
2901
|
+
if ($[5] !== center || $[6] !== h || $[7] !== radius || $[8] !== w) {
|
|
2902
|
+
const points = [{
|
|
2903
|
+
x: 0,
|
|
2904
|
+
y: 0
|
|
2905
|
+
}, {
|
|
2906
|
+
x: radius,
|
|
2907
|
+
y: 0,
|
|
2908
|
+
radius
|
|
2909
|
+
}, {
|
|
2910
|
+
x: center,
|
|
2911
|
+
y: h - 1,
|
|
2912
|
+
radius
|
|
2913
|
+
}, {
|
|
2914
|
+
x: w - radius,
|
|
2915
|
+
y: 0,
|
|
2916
|
+
radius
|
|
2917
|
+
}, {
|
|
2918
|
+
x: w,
|
|
2919
|
+
y: 0
|
|
2920
|
+
}], cmds = getRoundedCommands(points);
|
|
2921
|
+
t1 = compileCommands(cmds), $[5] = center, $[6] = h, $[7] = radius, $[8] = w, $[9] = t1;
|
|
2922
|
+
} else
|
|
2923
|
+
t1 = $[9];
|
|
2924
|
+
const path = t1, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`, t2 = `0 0 ${w} ${w}`;
|
|
2925
|
+
let t3;
|
|
2926
|
+
$[10] !== strokeWidth || $[11] !== w ? (t3 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { x: 0, y: strokeWidth, width: w, height: w, fill: "white" }) }), $[10] = strokeWidth, $[11] = w, $[12] = t3) : t3 = $[12];
|
|
2927
|
+
const t4 = strokeWidth * 2;
|
|
2923
2928
|
let t5;
|
|
2924
|
-
$[
|
|
2929
|
+
$[13] !== strokePath || $[14] !== t4 ? (t5 = /* @__PURE__ */ jsx(StrokePath, { d: strokePath, mask: "url(#stroke-mask)", strokeWidth: t4 }), $[13] = strokePath, $[14] = t4, $[15] = t5) : t5 = $[15];
|
|
2925
2930
|
let t6;
|
|
2926
|
-
$[
|
|
2927
|
-
t2,
|
|
2928
|
-
t4,
|
|
2929
|
-
t5
|
|
2930
|
-
] }), $[13] = t1, $[14] = t2, $[15] = t4, $[16] = t5, $[17] = w, $[18] = t6) : t6 = $[18];
|
|
2931
|
+
$[16] !== fillPath ? (t6 = /* @__PURE__ */ jsx(ShapePath, { d: fillPath }), $[16] = fillPath, $[17] = t6) : t6 = $[17];
|
|
2931
2932
|
let t7;
|
|
2932
|
-
|
|
2933
|
+
$[18] !== t2 || $[19] !== t3 || $[20] !== t5 || $[21] !== t6 || $[22] !== w ? (t7 = /* @__PURE__ */ jsxs("svg", { width: w, height: w, viewBox: t2, children: [
|
|
2934
|
+
t3,
|
|
2935
|
+
t5,
|
|
2936
|
+
t6
|
|
2937
|
+
] }), $[18] = t2, $[19] = t3, $[20] = t5, $[21] = t6, $[22] = w, $[23] = t7) : t7 = $[23];
|
|
2938
|
+
let t8;
|
|
2939
|
+
return $[24] !== ref || $[25] !== restProps || $[26] !== t7 || $[27] !== w ? (t8 = /* @__PURE__ */ jsx(StyledArrow, { ...restProps, $w: w, ref, children: t7 }), $[24] = ref, $[25] = restProps, $[26] = t7, $[27] = w, $[28] = t8) : t8 = $[28], t8;
|
|
2933
2940
|
});
|
|
2934
2941
|
Arrow.displayName = "ForwardRef(Arrow)";
|
|
2935
2942
|
const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null);
|
|
@@ -3224,26 +3231,42 @@ const StyledVirtualList = styled.div.withConfig({
|
|
|
3224
3231
|
displayName: "ItemWrapper",
|
|
3225
3232
|
componentId: "sc-dlqsj4-1"
|
|
3226
3233
|
})`position:absolute;left:0;right:0;`, VirtualList = forwardRef(function(props, forwardedRef) {
|
|
3227
|
-
const
|
|
3228
|
-
|
|
3229
|
-
|
|
3234
|
+
const $ = c(56);
|
|
3235
|
+
let getItemKey, onChange, renderItem, restProps, t0, t1, t2;
|
|
3236
|
+
$[0] !== props ? ({
|
|
3237
|
+
as: t0,
|
|
3238
|
+
gap: t1,
|
|
3230
3239
|
getItemKey,
|
|
3231
|
-
items
|
|
3240
|
+
items: t2,
|
|
3232
3241
|
onChange,
|
|
3233
3242
|
renderItem,
|
|
3234
3243
|
...restProps
|
|
3235
|
-
} = props,
|
|
3244
|
+
} = props, $[0] = props, $[1] = getItemKey, $[2] = onChange, $[3] = renderItem, $[4] = restProps, $[5] = t0, $[6] = t1, $[7] = t2) : (getItemKey = $[1], onChange = $[2], renderItem = $[3], restProps = $[4], t0 = $[5], t1 = $[6], t2 = $[7]);
|
|
3245
|
+
const as = t0 === void 0 ? "div" : t0, gap = t1 === void 0 ? 0 : t1;
|
|
3246
|
+
let t3;
|
|
3247
|
+
$[8] !== t2 ? (t3 = t2 === void 0 ? [] : t2, $[8] = t2, $[9] = t3) : t3 = $[9];
|
|
3248
|
+
const items = t3, {
|
|
3236
3249
|
space
|
|
3237
3250
|
} = useTheme_v2(), ref = useRef(null), wrapperRef = useRef(null), [scrollTop, setScrollTop] = useState(0), [scrollHeight, setScrollHeight] = useState(0), [itemHeight, setItemHeight] = useState(-1);
|
|
3238
|
-
|
|
3239
|
-
|
|
3251
|
+
let t4;
|
|
3252
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[10] = t4) : t4 = $[10], useImperativeHandle(forwardedRef, t4);
|
|
3253
|
+
let t5;
|
|
3254
|
+
$[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
3255
|
+
if (!wrapperRef.current)
|
|
3256
|
+
return;
|
|
3240
3257
|
const firstElement = wrapperRef.current.firstChild;
|
|
3241
3258
|
firstElement instanceof HTMLElement && setItemHeight(firstElement.offsetHeight);
|
|
3242
|
-
}, [
|
|
3243
|
-
|
|
3259
|
+
}, $[11] = t5) : t5 = $[11];
|
|
3260
|
+
let t6;
|
|
3261
|
+
$[12] !== renderItem ? (t6 = [renderItem], $[12] = renderItem, $[13] = t6) : t6 = $[13], useEffect(t5, t6);
|
|
3262
|
+
let t7, t8;
|
|
3263
|
+
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => {
|
|
3264
|
+
if (!ref.current)
|
|
3265
|
+
return;
|
|
3244
3266
|
const scrollEl = findScrollable(ref.current.parentNode);
|
|
3245
3267
|
if (scrollEl) {
|
|
3246
|
-
if (!(scrollEl instanceof HTMLElement))
|
|
3268
|
+
if (!(scrollEl instanceof HTMLElement))
|
|
3269
|
+
return;
|
|
3247
3270
|
const handleScroll = () => {
|
|
3248
3271
|
setScrollTop(scrollEl.scrollTop);
|
|
3249
3272
|
};
|
|
@@ -3267,9 +3290,10 @@ const StyledVirtualList = styled.div.withConfig({
|
|
|
3267
3290
|
}), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll_0(), () => {
|
|
3268
3291
|
window.removeEventListener("scroll", handleScroll_0), window.removeEventListener("resize", handleResize);
|
|
3269
3292
|
};
|
|
3270
|
-
}, []);
|
|
3293
|
+
}, t8 = [], $[14] = t7, $[15] = t8) : (t7 = $[14], t8 = $[15]), useEffect(t7, t8);
|
|
3271
3294
|
const len = items.length, height = itemHeight ? len * (itemHeight + space[gap]) - space[gap] : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
|
|
3272
|
-
|
|
3295
|
+
let t10, t9;
|
|
3296
|
+
$[16] !== fromIndex || $[17] !== gap || $[18] !== itemHeight || $[19] !== onChange || $[20] !== scrollHeight || $[21] !== scrollTop || $[22] !== space || $[23] !== toIndex ? (t9 = () => {
|
|
3273
3297
|
onChange && onChange({
|
|
3274
3298
|
fromIndex,
|
|
3275
3299
|
gap: space[gap],
|
|
@@ -3278,16 +3302,43 @@ const StyledVirtualList = styled.div.withConfig({
|
|
|
3278
3302
|
scrollTop,
|
|
3279
3303
|
toIndex
|
|
3280
3304
|
});
|
|
3281
|
-
}, [fromIndex, gap, itemHeight, onChange, scrollHeight, scrollTop, space, toIndex]);
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3305
|
+
}, t10 = [fromIndex, gap, itemHeight, onChange, scrollHeight, scrollTop, space, toIndex], $[16] = fromIndex, $[17] = gap, $[18] = itemHeight, $[19] = onChange, $[20] = scrollHeight, $[21] = scrollTop, $[22] = space, $[23] = toIndex, $[24] = t10, $[25] = t9) : (t10 = $[24], t9 = $[25]), useEffect(t9, t10);
|
|
3306
|
+
let t11;
|
|
3307
|
+
bb0: {
|
|
3308
|
+
if (!renderItem || items.length === 0) {
|
|
3309
|
+
t11 = null;
|
|
3310
|
+
break bb0;
|
|
3311
|
+
}
|
|
3312
|
+
if (itemHeight === -1) {
|
|
3313
|
+
let t123;
|
|
3314
|
+
$[26] !== items[0] || $[27] !== renderItem ? (t123 = renderItem(items[0]), $[26] = items[0], $[27] = renderItem, $[28] = t123) : t123 = $[28];
|
|
3315
|
+
let t132;
|
|
3316
|
+
$[29] !== t123 ? (t132 = [/* @__PURE__ */ jsx(ItemWrapper, { children: t123 }, 0)], $[29] = t123, $[30] = t132) : t132 = $[30], t11 = t132;
|
|
3317
|
+
break bb0;
|
|
3318
|
+
}
|
|
3319
|
+
let t122;
|
|
3320
|
+
if ($[31] !== fromIndex || $[32] !== gap || $[33] !== getItemKey || $[34] !== itemHeight || $[35] !== items || $[36] !== renderItem || $[37] !== space || $[38] !== toIndex) {
|
|
3321
|
+
let t132;
|
|
3322
|
+
$[40] !== fromIndex || $[41] !== gap || $[42] !== getItemKey || $[43] !== itemHeight || $[44] !== renderItem || $[45] !== space ? (t132 = (item, _itemIndex) => {
|
|
3323
|
+
const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key2 = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
|
|
3324
|
+
return /* @__PURE__ */ jsx(ItemWrapper, { style: {
|
|
3325
|
+
top: itemIndex * (itemHeight + space[gap])
|
|
3326
|
+
}, children: node }, key2);
|
|
3327
|
+
}, $[40] = fromIndex, $[41] = gap, $[42] = getItemKey, $[43] = itemHeight, $[44] = renderItem, $[45] = space, $[46] = t132) : t132 = $[46], t122 = items.slice(fromIndex, toIndex).map(t132), $[31] = fromIndex, $[32] = gap, $[33] = getItemKey, $[34] = itemHeight, $[35] = items, $[36] = renderItem, $[37] = space, $[38] = toIndex, $[39] = t122;
|
|
3328
|
+
} else
|
|
3329
|
+
t122 = $[39];
|
|
3330
|
+
t11 = t122;
|
|
3331
|
+
}
|
|
3332
|
+
const children = t11;
|
|
3333
|
+
let t12;
|
|
3334
|
+
$[47] !== height ? (t12 = {
|
|
3288
3335
|
height
|
|
3289
|
-
}
|
|
3290
|
-
|
|
3336
|
+
}, $[47] = height, $[48] = t12) : t12 = $[48];
|
|
3337
|
+
const wrapperStyle = t12;
|
|
3338
|
+
let t13;
|
|
3339
|
+
$[49] !== children || $[50] !== wrapperStyle ? (t13 = /* @__PURE__ */ jsx("div", { ref: wrapperRef, style: wrapperStyle, children }), $[49] = children, $[50] = wrapperStyle, $[51] = t13) : t13 = $[51];
|
|
3340
|
+
let t14;
|
|
3341
|
+
return $[52] !== as || $[53] !== restProps || $[54] !== t13 ? (t14 = /* @__PURE__ */ jsx(StyledVirtualList, { as, "data-ui": "VirtualList", ...restProps, ref, children: t13 }), $[52] = as, $[53] = restProps, $[54] = t13, $[55] = t14) : t14 = $[55], t14;
|
|
3291
3342
|
});
|
|
3292
3343
|
VirtualList.displayName = "ForwardRef(VirtualList)";
|
|
3293
3344
|
function findScrollable(parentNode) {
|