@udecode/react-utils 52.0.0 → 52.0.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.ts +1 -1
- package/dist/index.js +69 -18
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ declare const CAN_USE_DOM: boolean;
|
|
|
112
112
|
* Prevent warning on SSR by falling back to React.useEffect when DOM isn't
|
|
113
113
|
* available
|
|
114
114
|
*/
|
|
115
|
-
declare const useIsomorphicLayoutEffect: typeof React.
|
|
115
|
+
declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/useMemoizedSelector.d.ts
|
|
118
118
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import ReactDOM from "react-dom";
|
|
@@ -5,12 +6,35 @@ import { isDefined } from "@udecode/utils";
|
|
|
5
6
|
import { clsx } from "clsx";
|
|
6
7
|
|
|
7
8
|
//#region src/createSlotComponent.tsx
|
|
8
|
-
const createSlotComponent = (element) => React.forwardRef((
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const createSlotComponent = (element) => React.forwardRef((t0, ref) => {
|
|
10
|
+
const $ = c(8);
|
|
11
|
+
let as;
|
|
12
|
+
let props;
|
|
13
|
+
let t1;
|
|
14
|
+
if ($[0] !== t0) {
|
|
15
|
+
({as, asChild: t1, ...props} = t0);
|
|
16
|
+
$[0] = t0;
|
|
17
|
+
$[1] = as;
|
|
18
|
+
$[2] = props;
|
|
19
|
+
$[3] = t1;
|
|
20
|
+
} else {
|
|
21
|
+
as = $[1];
|
|
22
|
+
props = $[2];
|
|
23
|
+
t1 = $[3];
|
|
24
|
+
}
|
|
25
|
+
const Comp = (t1 === void 0 ? false : t1) ? Slot : as || element;
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[4] !== Comp || $[5] !== props || $[6] !== ref) {
|
|
28
|
+
t2 = /* @__PURE__ */ React.createElement(Comp, {
|
|
29
|
+
ref,
|
|
30
|
+
...props
|
|
31
|
+
});
|
|
32
|
+
$[4] = Comp;
|
|
33
|
+
$[5] = props;
|
|
34
|
+
$[6] = ref;
|
|
35
|
+
$[7] = t2;
|
|
36
|
+
} else t2 = $[7];
|
|
37
|
+
return t2;
|
|
14
38
|
});
|
|
15
39
|
|
|
16
40
|
//#endregion
|
|
@@ -19,7 +43,17 @@ const Box = createSlotComponent("div");
|
|
|
19
43
|
|
|
20
44
|
//#endregion
|
|
21
45
|
//#region src/MemoizedChildren.tsx
|
|
22
|
-
const MemoizedChildren = React.memo((
|
|
46
|
+
const MemoizedChildren = React.memo((t0) => {
|
|
47
|
+
const $ = c(2);
|
|
48
|
+
const { children } = t0;
|
|
49
|
+
let t1;
|
|
50
|
+
if ($[0] !== children) {
|
|
51
|
+
t1 = /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
52
|
+
$[0] = children;
|
|
53
|
+
$[1] = t1;
|
|
54
|
+
} else t1 = $[1];
|
|
55
|
+
return t1;
|
|
56
|
+
});
|
|
23
57
|
|
|
24
58
|
//#endregion
|
|
25
59
|
//#region src/PortalBody.tsx
|
|
@@ -101,7 +135,9 @@ const useComposedRef = (...refs) => {
|
|
|
101
135
|
*/
|
|
102
136
|
const createPrimitiveComponent = (element) => {
|
|
103
137
|
const Comp = createSlotComponent(element);
|
|
104
|
-
return ({ propsHook, stateHook } = {}) => React.forwardRef((
|
|
138
|
+
return ({ propsHook, stateHook } = {}) => React.forwardRef((t0, ref) => {
|
|
139
|
+
const $ = c(9);
|
|
140
|
+
const { asChild, className: classNameProp, getClassName, options, state: stateProp, ...props } = t0;
|
|
105
141
|
const state = isDefined(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
|
|
106
142
|
const { hidden, props: hookProps, ref: hookRef } = propsHook ? propsHook(state) : {
|
|
107
143
|
hidden: false,
|
|
@@ -115,15 +151,30 @@ const createPrimitiveComponent = (element) => {
|
|
|
115
151
|
...props.style
|
|
116
152
|
} : void 0;
|
|
117
153
|
if (!asChild && hidden) return null;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
154
|
+
const T0 = Comp;
|
|
155
|
+
const t1 = props.setProps?.(hookProps ?? {}) ?? {};
|
|
156
|
+
let t2;
|
|
157
|
+
if ($[0] !== T0 || $[1] !== _ref || $[2] !== asChild || $[3] !== className || $[4] !== hookProps || $[5] !== props || $[6] !== style || $[7] !== t1) {
|
|
158
|
+
t2 = /* @__PURE__ */ React.createElement(T0, {
|
|
159
|
+
asChild,
|
|
160
|
+
ref: _ref,
|
|
161
|
+
...hookProps,
|
|
162
|
+
className,
|
|
163
|
+
style,
|
|
164
|
+
...props,
|
|
165
|
+
...t1
|
|
166
|
+
});
|
|
167
|
+
$[0] = T0;
|
|
168
|
+
$[1] = _ref;
|
|
169
|
+
$[2] = asChild;
|
|
170
|
+
$[3] = className;
|
|
171
|
+
$[4] = hookProps;
|
|
172
|
+
$[5] = props;
|
|
173
|
+
$[6] = style;
|
|
174
|
+
$[7] = t1;
|
|
175
|
+
$[8] = t2;
|
|
176
|
+
} else t2 = $[8];
|
|
177
|
+
return t2;
|
|
127
178
|
});
|
|
128
179
|
};
|
|
129
180
|
|
|
@@ -204,7 +255,7 @@ const hasIgnoreClass = (e, ignoreClass) => {
|
|
|
204
255
|
let el = e.target || e;
|
|
205
256
|
while (el) {
|
|
206
257
|
if (Array.isArray(ignoreClass)) {
|
|
207
|
-
if (ignoreClass.some((c) => checkClass(el, c))) return true;
|
|
258
|
+
if (ignoreClass.some((c$1) => checkClass(el, c$1))) return true;
|
|
208
259
|
} else if (checkClass(el, ignoreClass)) return true;
|
|
209
260
|
el = el.parentElement;
|
|
210
261
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udecode/react-utils",
|
|
3
|
-
"version": "52.0.
|
|
3
|
+
"version": "52.0.1",
|
|
4
4
|
"description": "React utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utils"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@radix-ui/react-slot": "^1.2.3",
|
|
40
|
-
"@udecode/utils": "52.0.
|
|
40
|
+
"@udecode/utils": "52.0.1",
|
|
41
41
|
"clsx": "^2.1.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|