@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.mjs CHANGED
@@ -45,8 +45,8 @@ function _responsive(media, values, callback) {
45
45
  [`@media screen and (min-width: ${media[mediaIndex - 1]}px)`]: statement
46
46
  });
47
47
  }
48
- function _getArrayProp(val, defaultVal) {
49
- return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
48
+ function _getArrayProp(val) {
49
+ return val === void 0 ? EMPTY_ARRAY : Array.isArray(val) ? val : [val];
50
50
  }
51
51
  function _getResponsiveSpace(theme, props, spaceIndexes = EMPTY_ARRAY) {
52
52
  if (!Array.isArray(spaceIndexes))
@@ -153,12 +153,21 @@ function responsiveTextAlignStyle(props) {
153
153
  function responsiveTextFont(props) {
154
154
  return responsiveFont("text", props);
155
155
  }
156
- function useArrayProp(val, defaultVal) {
157
- const $ = c(3);
156
+ function useArrayProp(val) {
157
+ const $ = c(6);
158
158
  let t0;
159
- $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getArrayProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
160
- const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
161
- return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
159
+ $[0] !== val ? (t0 = () => [_getArrayProp(val), JSON.stringify(val)], $[0] = val, $[1] = t0) : t0 = $[1];
160
+ const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1;
161
+ let result = cachedVal, t2;
162
+ $[2] !== val ? (t2 = JSON.stringify(val), $[2] = val, $[3] = t2) : t2 = $[3];
163
+ const hash = t2;
164
+ if (hash !== cachedHash) {
165
+ let t3;
166
+ $[4] !== val ? (t3 = _getArrayProp(val), $[4] = val, $[5] = t3) : t3 = $[5];
167
+ const current = t3;
168
+ setCache([current, hash]), result = current;
169
+ }
170
+ return result;
162
171
  }
163
172
  function _getElements(element, elementsArg) {
164
173
  const ret = [element];
@@ -3509,9 +3518,8 @@ function PortalProvider(props) {
3509
3518
  const $ = c(7), {
3510
3519
  boundaryElement,
3511
3520
  children,
3512
- element,
3513
- __unstable_elements: elementsProp
3514
- } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$3, _temp2$1);
3521
+ element
3522
+ } = props, elements = useUnique(props.__unstable_elements), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$3, _temp2$1);
3515
3523
  let t0;
3516
3524
  const t1 = boundaryElement || null, t2 = element || fallbackElement;
3517
3525
  let t3;
@@ -3535,10 +3543,11 @@ PortalProvider.displayName = "PortalProvider";
3535
3543
  const emptySubscribe = () => () => {
3536
3544
  };
3537
3545
  function useUnique(value) {
3538
- const valueRef = useRef(value);
3539
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
3546
+ const [cachedValue, setCachedValue] = useState(value);
3547
+ let result = cachedValue;
3548
+ return isEqual(cachedValue, value) || (setCachedValue(value), result = value), result;
3540
3549
  }
3541
- function _isEqual(objA, objB) {
3550
+ function isEqual(objA, objB) {
3542
3551
  if (!objA || !objB)
3543
3552
  return objA === objB;
3544
3553
  const keysA = Object.keys(objA), keysB = Object.keys(objB);