@sanity/ui 2.8.23 → 2.8.24-canary.1

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.js CHANGED
@@ -39,8 +39,8 @@ function _responsive(media, values, callback) {
39
39
  [`@media screen and (min-width: ${media[mediaIndex - 1]}px)`]: statement
40
40
  });
41
41
  }
42
- function _getArrayProp(val, defaultVal) {
43
- return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
42
+ function _getArrayProp(val) {
43
+ return val === void 0 ? EMPTY_ARRAY : Array.isArray(val) ? val : [val];
44
44
  }
45
45
  function _getResponsiveSpace(theme$1, props, spaceIndexes = EMPTY_ARRAY) {
46
46
  if (!Array.isArray(spaceIndexes))
@@ -147,12 +147,21 @@ function responsiveTextAlignStyle(props) {
147
147
  function responsiveTextFont(props) {
148
148
  return responsiveFont("text", props);
149
149
  }
150
- function useArrayProp(val, defaultVal) {
151
- const $ = reactCompilerRuntime.c(3);
150
+ function useArrayProp(val) {
151
+ const $ = reactCompilerRuntime.c(6);
152
152
  let t0;
153
- $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getArrayProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
154
- const [t1, setCache] = react.useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
155
- return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
153
+ $[0] !== val ? (t0 = () => [_getArrayProp(val), JSON.stringify(val)], $[0] = val, $[1] = t0) : t0 = $[1];
154
+ const [t1, setCache] = react.useState(t0), [cachedVal, cachedHash] = t1;
155
+ let result = cachedVal, t2;
156
+ $[2] !== val ? (t2 = JSON.stringify(val), $[2] = val, $[3] = t2) : t2 = $[3];
157
+ const hash = t2;
158
+ if (hash !== cachedHash) {
159
+ let t3;
160
+ $[4] !== val ? (t3 = _getArrayProp(val), $[4] = val, $[5] = t3) : t3 = $[5];
161
+ const current = t3;
162
+ setCache([current, hash]), result = current;
163
+ }
164
+ return result;
156
165
  }
157
166
  function _getElements(element, elementsArg) {
158
167
  const ret = [element];
@@ -3503,9 +3512,8 @@ function PortalProvider(props) {
3503
3512
  const $ = reactCompilerRuntime.c(7), {
3504
3513
  boundaryElement,
3505
3514
  children,
3506
- element,
3507
- __unstable_elements: elementsProp
3508
- } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp$3, _temp2$1);
3515
+ element
3516
+ } = props, elements = useUnique(props.__unstable_elements), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp$3, _temp2$1);
3509
3517
  let t0;
3510
3518
  const t1 = boundaryElement || null, t2 = element || fallbackElement;
3511
3519
  let t3;
@@ -3529,10 +3537,11 @@ PortalProvider.displayName = "PortalProvider";
3529
3537
  const emptySubscribe = () => () => {
3530
3538
  };
3531
3539
  function useUnique(value) {
3532
- const valueRef = react.useRef(value);
3533
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
3540
+ const [cachedValue, setCachedValue] = react.useState(value);
3541
+ let result = cachedValue;
3542
+ return isEqual(cachedValue, value) || (setCachedValue(value), result = value), result;
3534
3543
  }
3535
- function _isEqual(objA, objB) {
3544
+ function isEqual(objA, objB) {
3536
3545
  if (!objA || !objB)
3537
3546
  return objA === objB;
3538
3547
  const keysA = Object.keys(objA), keysB = Object.keys(objB);