@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.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.esm.js +22 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -35
- package/src/core/hooks/useArrayProp.ts +8 -6
- package/src/core/styles/helpers.ts +2 -2
- package/src/core/utils/portal/portalProvider.tsx +10 -8
package/dist/index.d.mts
CHANGED
|
@@ -983,7 +983,7 @@ export declare interface FontWeightStyleProps {
|
|
|
983
983
|
/**
|
|
984
984
|
* @internal
|
|
985
985
|
*/
|
|
986
|
-
export declare function _getArrayProp<T = number>(val: T | T[] | undefined
|
|
986
|
+
export declare function _getArrayProp<T = number>(val: T | T[] | undefined): T[]
|
|
987
987
|
|
|
988
988
|
/**
|
|
989
989
|
* @internal
|
|
@@ -2706,7 +2706,6 @@ export declare interface TreeState {
|
|
|
2706
2706
|
*/
|
|
2707
2707
|
export declare function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
2708
2708
|
val: T | T[] | undefined,
|
|
2709
|
-
defaultVal?: T[],
|
|
2710
2709
|
): T[]
|
|
2711
2710
|
|
|
2712
2711
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -983,7 +983,7 @@ export declare interface FontWeightStyleProps {
|
|
|
983
983
|
/**
|
|
984
984
|
* @internal
|
|
985
985
|
*/
|
|
986
|
-
export declare function _getArrayProp<T = number>(val: T | T[] | undefined
|
|
986
|
+
export declare function _getArrayProp<T = number>(val: T | T[] | undefined): T[]
|
|
987
987
|
|
|
988
988
|
/**
|
|
989
989
|
* @internal
|
|
@@ -2706,7 +2706,6 @@ export declare interface TreeState {
|
|
|
2706
2706
|
*/
|
|
2707
2707
|
export declare function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
2708
2708
|
val: T | T[] | undefined,
|
|
2709
|
-
defaultVal?: T[],
|
|
2710
2709
|
): T[]
|
|
2711
2710
|
|
|
2712
2711
|
/**
|
package/dist/index.esm.js
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
|
|
49
|
-
return val === void 0 ?
|
|
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
|
|
157
|
-
const $ = c(
|
|
156
|
+
function useArrayProp(val) {
|
|
157
|
+
const $ = c(6);
|
|
158
158
|
let t0;
|
|
159
|
-
$[0] !==
|
|
160
|
-
const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1
|
|
161
|
-
|
|
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
|
-
|
|
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
|
|
3539
|
-
|
|
3546
|
+
const [cachedValue, setCachedValue] = useState(value);
|
|
3547
|
+
let result = cachedValue;
|
|
3548
|
+
return isEqual(cachedValue, value) || (setCachedValue(value), result = value), result;
|
|
3540
3549
|
}
|
|
3541
|
-
function
|
|
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);
|