@sanity/ui 2.0.0-beta.8 → 2.0.0-beta.9

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.esm.js CHANGED
@@ -1,6 +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 { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useLayoutEffect, forwardRef, useId, useCallback, cloneElement, isValidElement, createElement, Component, memo, useReducer, Children, Fragment as Fragment$1, startTransition } from 'react';
4
+ import ReactIs, { isElement as isElement$1, isFragment, isValidElementType } from 'react-is';
4
5
  import styled, { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, keyframes } from 'styled-components';
5
6
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from '@sanity/icons';
6
7
  import Refractor from 'react-refractor';
@@ -17,350 +18,6 @@ const rgbToHsl = rgbToHsl$1;
17
18
  const rgba = rgba$1;
18
19
  const screen = screen$1;
19
20
  const studioTheme = buildTheme();
20
- function getDefaultExportFromCjs(x) {
21
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
22
- }
23
- var reactIs = {
24
- exports: {}
25
- };
26
- var reactIs_development = {};
27
-
28
- /**
29
- * @license React
30
- * react-is.development.js
31
- *
32
- * Copyright (c) Facebook, Inc. and its affiliates.
33
- *
34
- * This source code is licensed under the MIT license found in the
35
- * LICENSE file in the root directory of this source tree.
36
- */
37
-
38
- var hasRequiredReactIs_development;
39
- function requireReactIs_development() {
40
- if (hasRequiredReactIs_development) return reactIs_development;
41
- hasRequiredReactIs_development = 1;
42
- if (process.env.NODE_ENV !== "production") {
43
- (function () {
44
- // ATTENTION
45
- // When adding new symbols to this file,
46
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
47
- // The Symbol used to tag the ReactElement-like types.
48
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
49
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
50
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
51
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
52
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
53
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
54
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
55
- var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
56
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
57
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
58
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
59
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
60
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
61
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
62
-
63
- // -----------------------------------------------------------------------------
64
-
65
- var enableScopeAPI = false; // Experimental Create Event Handle API.
66
- var enableCacheElement = false;
67
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
68
-
69
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
70
- // stuff. Intended to enable React core members to more easily debug scheduling
71
- // issues in DEV builds.
72
-
73
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
74
-
75
- var REACT_MODULE_REFERENCE;
76
- {
77
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
78
- }
79
- function isValidElementType(type) {
80
- if (typeof type === 'string' || typeof type === 'function') {
81
- return true;
82
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
83
-
84
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
85
- return true;
86
- }
87
- if (typeof type === 'object' && type !== null) {
88
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE ||
89
- // This needs to include all possible module reference object
90
- // types supported by any Flight configuration anywhere since
91
- // we don't know which Flight build this will end up being used
92
- // with.
93
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
94
- return true;
95
- }
96
- }
97
- return false;
98
- }
99
- function typeOf(object) {
100
- if (typeof object === 'object' && object !== null) {
101
- var $$typeof = object.$$typeof;
102
- switch ($$typeof) {
103
- case REACT_ELEMENT_TYPE:
104
- var type = object.type;
105
- switch (type) {
106
- case REACT_FRAGMENT_TYPE:
107
- case REACT_PROFILER_TYPE:
108
- case REACT_STRICT_MODE_TYPE:
109
- case REACT_SUSPENSE_TYPE:
110
- case REACT_SUSPENSE_LIST_TYPE:
111
- return type;
112
- default:
113
- var $$typeofType = type && type.$$typeof;
114
- switch ($$typeofType) {
115
- case REACT_SERVER_CONTEXT_TYPE:
116
- case REACT_CONTEXT_TYPE:
117
- case REACT_FORWARD_REF_TYPE:
118
- case REACT_LAZY_TYPE:
119
- case REACT_MEMO_TYPE:
120
- case REACT_PROVIDER_TYPE:
121
- return $$typeofType;
122
- default:
123
- return $$typeof;
124
- }
125
- }
126
- case REACT_PORTAL_TYPE:
127
- return $$typeof;
128
- }
129
- }
130
- return undefined;
131
- }
132
- var ContextConsumer = REACT_CONTEXT_TYPE;
133
- var ContextProvider = REACT_PROVIDER_TYPE;
134
- var Element = REACT_ELEMENT_TYPE;
135
- var ForwardRef = REACT_FORWARD_REF_TYPE;
136
- var Fragment = REACT_FRAGMENT_TYPE;
137
- var Lazy = REACT_LAZY_TYPE;
138
- var Memo = REACT_MEMO_TYPE;
139
- var Portal = REACT_PORTAL_TYPE;
140
- var Profiler = REACT_PROFILER_TYPE;
141
- var StrictMode = REACT_STRICT_MODE_TYPE;
142
- var Suspense = REACT_SUSPENSE_TYPE;
143
- var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
144
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
145
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
146
-
147
- function isAsyncMode(object) {
148
- {
149
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
150
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
151
-
152
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
153
- }
154
- }
155
- return false;
156
- }
157
- function isConcurrentMode(object) {
158
- {
159
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
160
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
161
-
162
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
163
- }
164
- }
165
- return false;
166
- }
167
- function isContextConsumer(object) {
168
- return typeOf(object) === REACT_CONTEXT_TYPE;
169
- }
170
- function isContextProvider(object) {
171
- return typeOf(object) === REACT_PROVIDER_TYPE;
172
- }
173
- function isElement(object) {
174
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
175
- }
176
- function isForwardRef(object) {
177
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
178
- }
179
- function isFragment(object) {
180
- return typeOf(object) === REACT_FRAGMENT_TYPE;
181
- }
182
- function isLazy(object) {
183
- return typeOf(object) === REACT_LAZY_TYPE;
184
- }
185
- function isMemo(object) {
186
- return typeOf(object) === REACT_MEMO_TYPE;
187
- }
188
- function isPortal(object) {
189
- return typeOf(object) === REACT_PORTAL_TYPE;
190
- }
191
- function isProfiler(object) {
192
- return typeOf(object) === REACT_PROFILER_TYPE;
193
- }
194
- function isStrictMode(object) {
195
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
196
- }
197
- function isSuspense(object) {
198
- return typeOf(object) === REACT_SUSPENSE_TYPE;
199
- }
200
- function isSuspenseList(object) {
201
- return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
202
- }
203
- reactIs_development.ContextConsumer = ContextConsumer;
204
- reactIs_development.ContextProvider = ContextProvider;
205
- reactIs_development.Element = Element;
206
- reactIs_development.ForwardRef = ForwardRef;
207
- reactIs_development.Fragment = Fragment;
208
- reactIs_development.Lazy = Lazy;
209
- reactIs_development.Memo = Memo;
210
- reactIs_development.Portal = Portal;
211
- reactIs_development.Profiler = Profiler;
212
- reactIs_development.StrictMode = StrictMode;
213
- reactIs_development.Suspense = Suspense;
214
- reactIs_development.SuspenseList = SuspenseList;
215
- reactIs_development.isAsyncMode = isAsyncMode;
216
- reactIs_development.isConcurrentMode = isConcurrentMode;
217
- reactIs_development.isContextConsumer = isContextConsumer;
218
- reactIs_development.isContextProvider = isContextProvider;
219
- reactIs_development.isElement = isElement;
220
- reactIs_development.isForwardRef = isForwardRef;
221
- reactIs_development.isFragment = isFragment;
222
- reactIs_development.isLazy = isLazy;
223
- reactIs_development.isMemo = isMemo;
224
- reactIs_development.isPortal = isPortal;
225
- reactIs_development.isProfiler = isProfiler;
226
- reactIs_development.isStrictMode = isStrictMode;
227
- reactIs_development.isSuspense = isSuspense;
228
- reactIs_development.isSuspenseList = isSuspenseList;
229
- reactIs_development.isValidElementType = isValidElementType;
230
- reactIs_development.typeOf = typeOf;
231
- })();
232
- }
233
- return reactIs_development;
234
- }
235
- var reactIs_production_min = {};
236
-
237
- /**
238
- * @license React
239
- * react-is.production.min.js
240
- *
241
- * Copyright (c) Facebook, Inc. and its affiliates.
242
- *
243
- * This source code is licensed under the MIT license found in the
244
- * LICENSE file in the root directory of this source tree.
245
- */
246
-
247
- var hasRequiredReactIs_production_min;
248
- function requireReactIs_production_min() {
249
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
250
- hasRequiredReactIs_production_min = 1;
251
- var b = Symbol.for("react.element"),
252
- c = Symbol.for("react.portal"),
253
- d = Symbol.for("react.fragment"),
254
- e = Symbol.for("react.strict_mode"),
255
- f = Symbol.for("react.profiler"),
256
- g = Symbol.for("react.provider"),
257
- h = Symbol.for("react.context"),
258
- k = Symbol.for("react.server_context"),
259
- l = Symbol.for("react.forward_ref"),
260
- m = Symbol.for("react.suspense"),
261
- n = Symbol.for("react.suspense_list"),
262
- p = Symbol.for("react.memo"),
263
- q = Symbol.for("react.lazy"),
264
- t = Symbol.for("react.offscreen"),
265
- u;
266
- u = Symbol.for("react.module.reference");
267
- function v(a) {
268
- if ("object" === typeof a && null !== a) {
269
- var r = a.$$typeof;
270
- switch (r) {
271
- case b:
272
- switch (a = a.type, a) {
273
- case d:
274
- case f:
275
- case e:
276
- case m:
277
- case n:
278
- return a;
279
- default:
280
- switch (a = a && a.$$typeof, a) {
281
- case k:
282
- case h:
283
- case l:
284
- case q:
285
- case p:
286
- case g:
287
- return a;
288
- default:
289
- return r;
290
- }
291
- }
292
- case c:
293
- return r;
294
- }
295
- }
296
- }
297
- reactIs_production_min.ContextConsumer = h;
298
- reactIs_production_min.ContextProvider = g;
299
- reactIs_production_min.Element = b;
300
- reactIs_production_min.ForwardRef = l;
301
- reactIs_production_min.Fragment = d;
302
- reactIs_production_min.Lazy = q;
303
- reactIs_production_min.Memo = p;
304
- reactIs_production_min.Portal = c;
305
- reactIs_production_min.Profiler = f;
306
- reactIs_production_min.StrictMode = e;
307
- reactIs_production_min.Suspense = m;
308
- reactIs_production_min.SuspenseList = n;
309
- reactIs_production_min.isAsyncMode = function () {
310
- return !1;
311
- };
312
- reactIs_production_min.isConcurrentMode = function () {
313
- return !1;
314
- };
315
- reactIs_production_min.isContextConsumer = function (a) {
316
- return v(a) === h;
317
- };
318
- reactIs_production_min.isContextProvider = function (a) {
319
- return v(a) === g;
320
- };
321
- reactIs_production_min.isElement = function (a) {
322
- return "object" === typeof a && null !== a && a.$$typeof === b;
323
- };
324
- reactIs_production_min.isForwardRef = function (a) {
325
- return v(a) === l;
326
- };
327
- reactIs_production_min.isFragment = function (a) {
328
- return v(a) === d;
329
- };
330
- reactIs_production_min.isLazy = function (a) {
331
- return v(a) === q;
332
- };
333
- reactIs_production_min.isMemo = function (a) {
334
- return v(a) === p;
335
- };
336
- reactIs_production_min.isPortal = function (a) {
337
- return v(a) === c;
338
- };
339
- reactIs_production_min.isProfiler = function (a) {
340
- return v(a) === f;
341
- };
342
- reactIs_production_min.isStrictMode = function (a) {
343
- return v(a) === e;
344
- };
345
- reactIs_production_min.isSuspense = function (a) {
346
- return v(a) === m;
347
- };
348
- reactIs_production_min.isSuspenseList = function (a) {
349
- return v(a) === n;
350
- };
351
- reactIs_production_min.isValidElementType = function (a) {
352
- return "string" === typeof a || "function" === typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? !0 : !1;
353
- };
354
- reactIs_production_min.typeOf = v;
355
- return reactIs_production_min;
356
- }
357
- if (process.env.NODE_ENV === 'production') {
358
- reactIs.exports = requireReactIs_production_min();
359
- } else {
360
- reactIs.exports = requireReactIs_development();
361
- }
362
- var reactIsExports = reactIs.exports;
363
- var ReactIs = /*@__PURE__*/getDefaultExportFromCjs(reactIsExports);
364
21
  const EMPTY_ARRAY = [];
365
22
  const EMPTY_RECORD = {};
366
23
  const POPOVER_MOTION_PROPS = {
@@ -872,7 +529,7 @@ var gatherActiveObservationsAtDepth = function (depth) {
872
529
  });
873
530
  });
874
531
  };
875
- var process$1 = function () {
532
+ var process = function () {
876
533
  var depth = 0;
877
534
  gatherActiveObservationsAtDepth(depth);
878
535
  while (hasActiveObservations()) {
@@ -953,7 +610,7 @@ var Scheduler = function () {
953
610
  queueResizeObserver(function () {
954
611
  var elementsHaveResized = false;
955
612
  try {
956
- elementsHaveResized = process$1();
613
+ elementsHaveResized = process();
957
614
  } finally {
958
615
  scheduled = false;
959
616
  timeout = until - time();
@@ -2343,7 +2000,7 @@ const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
2343
2000
  });
2344
2001
  function childrenToElementArray(children) {
2345
2002
  const childrenArray = Array.isArray(children) ? children : [children];
2346
- return childrenArray.filter(node => reactIsExports.isElement(node) || reactIsExports.isFragment(node) || typeof node === "string");
2003
+ return childrenArray.filter(node => isElement$1(node) || isFragment(node) || typeof node === "string");
2347
2004
  }
2348
2005
  var __freeze$B = Object.freeze;
2349
2006
  var __defProp$C = Object.defineProperty;
@@ -2828,7 +2485,7 @@ const Button = forwardRef(function Button2(props, ref) {
2828
2485
  gap: space,
2829
2486
  children: [icon && /* @__PURE__ */jsxs(Text, {
2830
2487
  size: fontSize,
2831
- children: [isValidElement(icon) && icon, reactIsExports.isValidElementType(icon) && createElement(icon)]
2488
+ children: [isValidElement(icon) && icon, isValidElementType(icon) && createElement(icon)]
2832
2489
  }), text && /* @__PURE__ */jsx(Box, {
2833
2490
  flex: iconRight ? 1 : void 0,
2834
2491
  children: /* @__PURE__ */jsx(Text, {
@@ -2841,7 +2498,7 @@ const Button = forwardRef(function Button2(props, ref) {
2841
2498
  })
2842
2499
  }), iconRight && /* @__PURE__ */jsxs(Text, {
2843
2500
  size: fontSize,
2844
- children: [isValidElement(iconRight) && iconRight, reactIsExports.isValidElementType(iconRight) && createElement(iconRight)]
2501
+ children: [isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && createElement(iconRight)]
2845
2502
  })]
2846
2503
  })
2847
2504
  }), children && /* @__PURE__ */jsx(Box, {
@@ -2913,7 +2570,7 @@ const Card = forwardRef(function Card2(props, ref) {
2913
2570
  tone: toneProp = "default",
2914
2571
  ...restProps
2915
2572
  } = props;
2916
- const as = reactIsExports.isValidElementType(asProp) ? asProp : "div";
2573
+ const as = isValidElementType(asProp) ? asProp : "div";
2917
2574
  const rootTheme = useRootTheme();
2918
2575
  const tone = toneProp === "inherit" ? rootTheme.tone : toneProp;
2919
2576
  return /* @__PURE__ */jsx(ThemeColorProvider, {
@@ -5052,13 +4709,13 @@ const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
5052
4709
  padding,
5053
4710
  children: /* @__PURE__ */jsxs(Text, {
5054
4711
  size: fontSize,
5055
- children: [isValidElement(icon) && icon, reactIsExports.isValidElementType(icon) && createElement(icon)]
4712
+ children: [isValidElement(icon) && icon, isValidElementType(icon) && createElement(icon)]
5056
4713
  })
5057
4714
  }), !$hasClearButton && iconRight && /* @__PURE__ */jsx(RightBox, {
5058
4715
  padding,
5059
4716
  children: /* @__PURE__ */jsxs(Text, {
5060
4717
  size: fontSize,
5061
- children: [isValidElement(iconRight) && iconRight, reactIsExports.isValidElementType(iconRight) && createElement(iconRight)]
4718
+ children: [isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && createElement(iconRight)]
5062
4719
  })
5063
4720
  })]
5064
4721
  }), [__unstable_disableFocusRing, border, fontSize, icon, iconRight, padding, radius, rootTheme, $hasClearButton, $hasPrefix, $hasSuffix]);
@@ -6862,7 +6519,7 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
6862
6519
  registerElement,
6863
6520
  shouldFocus
6864
6521
  }), [buttonElement, handleMenuClickOutside, handleMenuEscape, handleItemClick, id, handleBlur, registerElement, shouldFocus]);
6865
- const menu = reactIsExports.isElement(menuProp) ? cloneElement(menuProp, menuProps) : null;
6522
+ const menu = isElement$1(menuProp) ? cloneElement(menuProp, menuProps) : null;
6866
6523
  const setButtonRef = useCallback(el => {
6867
6524
  if (typeof ref === "function") {
6868
6525
  ref(el);
@@ -6871,7 +6528,7 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
6871
6528
  }
6872
6529
  setButtonElement(el);
6873
6530
  }, [ref]);
6874
- const button = useMemo(() => reactIsExports.isElement(buttonProp) ? cloneElement(buttonProp, {
6531
+ const button = useMemo(() => isElement$1(buttonProp) ? cloneElement(buttonProp, {
6875
6532
  "data-ui": "MenuButton",
6876
6533
  id,
6877
6534
  onClick: handleButtonClick,
@@ -7058,7 +6715,7 @@ function MenuGroup(props) {
7058
6715
  padding,
7059
6716
  children: [icon && /* @__PURE__ */jsxs(Text, {
7060
6717
  size: fontSize,
7061
- children: [isValidElement(icon) && icon, reactIsExports.isValidElementType(icon) && createElement(icon)]
6718
+ children: [isValidElement(icon) && icon, isValidElementType(icon) && createElement(icon)]
7062
6719
  }), /* @__PURE__ */jsx(Box, {
7063
6720
  flex: 1,
7064
6721
  children: /* @__PURE__ */jsx(Text, {
@@ -7161,7 +6818,7 @@ const MenuItem = forwardRef(function MenuItem2(props, forwardedRef) {
7161
6818
  ...paddingProps,
7162
6819
  children: [icon && /* @__PURE__ */jsxs(Text, {
7163
6820
  size: fontSize,
7164
- children: [isValidElement(icon) && icon, reactIsExports.isValidElementType(icon) && createElement(icon)]
6821
+ children: [isValidElement(icon) && icon, isValidElementType(icon) && createElement(icon)]
7165
6822
  }), text && /* @__PURE__ */jsx(Box, {
7166
6823
  flex: 1,
7167
6824
  children: /* @__PURE__ */jsx(Text, {
@@ -7179,7 +6836,7 @@ const MenuItem = forwardRef(function MenuItem2(props, forwardedRef) {
7179
6836
  }
7180
6837
  }), iconRight && /* @__PURE__ */jsxs(Text, {
7181
6838
  size: fontSize,
7182
- children: [isValidElement(iconRight) && iconRight, reactIsExports.isValidElementType(iconRight) && createElement(iconRight)]
6839
+ children: [isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && createElement(iconRight)]
7183
6840
  })]
7184
6841
  }), children && /* @__PURE__ */jsx(Box, {
7185
6842
  as: "span",