@udecode/react-utils 49.0.15 → 51.1.2
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 +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +86 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -101
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -93,8 +93,6 @@ declare const CAN_USE_DOM: boolean;
|
|
|
93
93
|
*/
|
|
94
94
|
declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
|
95
95
|
|
|
96
|
-
declare function useMemoOnce<T>(factory: () => T, deps: React.DependencyList): T;
|
|
97
|
-
|
|
98
96
|
/**
|
|
99
97
|
* Re-render only when the selector result changes.
|
|
100
98
|
*
|
|
@@ -107,14 +105,14 @@ declare function useMemoizedSelector<R>(selector: () => R, deps: React.Dependenc
|
|
|
107
105
|
|
|
108
106
|
declare const DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
|
|
109
107
|
type UseOnClickOutsideCallback<T extends Event = Event> = (event: T) => void;
|
|
110
|
-
|
|
108
|
+
type UseOnClickOutsideOptions = {
|
|
111
109
|
detectIFrame?: boolean;
|
|
112
110
|
disabled?: boolean;
|
|
113
111
|
eventTypes?: string[];
|
|
114
112
|
excludeScrollbar?: boolean;
|
|
115
113
|
ignoreClass?: string[] | string;
|
|
116
114
|
refs?: Refs;
|
|
117
|
-
}
|
|
115
|
+
};
|
|
118
116
|
type UseOnClickOutsideReturn = (element: El | null) => void;
|
|
119
117
|
type El = HTMLElement;
|
|
120
118
|
type Refs = React.RefObject<El | null>[];
|
|
@@ -133,6 +131,8 @@ declare const useStableFn: <A extends unknown[], R>(fn: (...args: A) => R, deps?
|
|
|
133
131
|
|
|
134
132
|
declare const useStableMemo: <T>(producer: () => T, deps?: React.DependencyList) => T;
|
|
135
133
|
|
|
134
|
+
/** biome-ignore-all lint/correctness/useJsxKeyInIterable: biome */
|
|
135
|
+
|
|
136
136
|
/**
|
|
137
137
|
* Wrap a component into multiple providers. If there are any props that you
|
|
138
138
|
* want a provider to receive, you can simply pass an array.
|
|
@@ -152,4 +152,4 @@ type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.Intri
|
|
|
152
152
|
*/
|
|
153
153
|
declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
|
|
154
154
|
|
|
155
|
-
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect,
|
|
155
|
+
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect, useMemoizedSelector, useOnClickOutside, useStableFn, useStableMemo, withProviders, withRef };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,8 +93,6 @@ declare const CAN_USE_DOM: boolean;
|
|
|
93
93
|
*/
|
|
94
94
|
declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
|
95
95
|
|
|
96
|
-
declare function useMemoOnce<T>(factory: () => T, deps: React.DependencyList): T;
|
|
97
|
-
|
|
98
96
|
/**
|
|
99
97
|
* Re-render only when the selector result changes.
|
|
100
98
|
*
|
|
@@ -107,14 +105,14 @@ declare function useMemoizedSelector<R>(selector: () => R, deps: React.Dependenc
|
|
|
107
105
|
|
|
108
106
|
declare const DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
|
|
109
107
|
type UseOnClickOutsideCallback<T extends Event = Event> = (event: T) => void;
|
|
110
|
-
|
|
108
|
+
type UseOnClickOutsideOptions = {
|
|
111
109
|
detectIFrame?: boolean;
|
|
112
110
|
disabled?: boolean;
|
|
113
111
|
eventTypes?: string[];
|
|
114
112
|
excludeScrollbar?: boolean;
|
|
115
113
|
ignoreClass?: string[] | string;
|
|
116
114
|
refs?: Refs;
|
|
117
|
-
}
|
|
115
|
+
};
|
|
118
116
|
type UseOnClickOutsideReturn = (element: El | null) => void;
|
|
119
117
|
type El = HTMLElement;
|
|
120
118
|
type Refs = React.RefObject<El | null>[];
|
|
@@ -133,6 +131,8 @@ declare const useStableFn: <A extends unknown[], R>(fn: (...args: A) => R, deps?
|
|
|
133
131
|
|
|
134
132
|
declare const useStableMemo: <T>(producer: () => T, deps?: React.DependencyList) => T;
|
|
135
133
|
|
|
134
|
+
/** biome-ignore-all lint/correctness/useJsxKeyInIterable: biome */
|
|
135
|
+
|
|
136
136
|
/**
|
|
137
137
|
* Wrap a component into multiple providers. If there are any props that you
|
|
138
138
|
* want a provider to receive, you can simply pass an array.
|
|
@@ -152,4 +152,4 @@ type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.Intri
|
|
|
152
152
|
*/
|
|
153
153
|
declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
|
|
154
154
|
|
|
155
|
-
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect,
|
|
155
|
+
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect, useMemoizedSelector, useOnClickOutside, useStableFn, useStableMemo, withProviders, withRef };
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,6 @@ __export(index_exports, {
|
|
|
44
44
|
useComposedRef: () => useComposedRef,
|
|
45
45
|
useEffectOnce: () => useEffectOnce,
|
|
46
46
|
useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect,
|
|
47
|
-
useMemoOnce: () => useMemoOnce,
|
|
48
47
|
useMemoizedSelector: () => useMemoizedSelector,
|
|
49
48
|
useOnClickOutside: () => useOnClickOutside,
|
|
50
49
|
useStableFn: () => useStableFn,
|
|
@@ -55,8 +54,8 @@ __export(index_exports, {
|
|
|
55
54
|
module.exports = __toCommonJS(index_exports);
|
|
56
55
|
|
|
57
56
|
// src/createSlotComponent.tsx
|
|
58
|
-
var import_react = __toESM(require("react"));
|
|
59
57
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
58
|
+
var import_react = __toESM(require("react"));
|
|
60
59
|
var createSlotComponent = (element) => import_react.default.forwardRef(({ as, asChild = false, ...props }, ref) => {
|
|
61
60
|
const Comp = asChild ? import_react_slot.Slot : as || element;
|
|
62
61
|
return /* @__PURE__ */ import_react.default.createElement(Comp, { ref, ...props });
|
|
@@ -68,20 +67,17 @@ var Box = createSlotComponent("div");
|
|
|
68
67
|
// src/MemoizedChildren.tsx
|
|
69
68
|
var import_react2 = __toESM(require("react"));
|
|
70
69
|
var MemoizedChildren = import_react2.default.memo(
|
|
71
|
-
({ children }) =>
|
|
72
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children);
|
|
73
|
-
}
|
|
70
|
+
({ children }) => /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children)
|
|
74
71
|
);
|
|
75
72
|
|
|
76
73
|
// src/PortalBody.tsx
|
|
77
|
-
var import_react3 = __toESM(require("react"));
|
|
78
74
|
var import_react_dom = __toESM(require("react-dom"));
|
|
79
75
|
var PortalBody = ({
|
|
80
76
|
children,
|
|
81
77
|
element
|
|
82
78
|
}) => {
|
|
83
79
|
const container = element || typeof window !== "undefined" ? document.body : void 0;
|
|
84
|
-
if (!container) return
|
|
80
|
+
if (!container) return children;
|
|
85
81
|
return import_react_dom.default.createPortal(children, element || document.body);
|
|
86
82
|
};
|
|
87
83
|
|
|
@@ -97,16 +93,17 @@ var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDef
|
|
|
97
93
|
};
|
|
98
94
|
|
|
99
95
|
// src/createPrimitiveComponent.tsx
|
|
100
|
-
var import_react5 = __toESM(require("react"));
|
|
101
96
|
var import_utils = require("@udecode/utils");
|
|
102
97
|
var import_clsx = require("clsx");
|
|
98
|
+
var import_react4 = __toESM(require("react"));
|
|
103
99
|
|
|
104
100
|
// src/useComposedRef.ts
|
|
105
|
-
var
|
|
101
|
+
var import_react3 = __toESM(require("react"));
|
|
106
102
|
var setRef = (ref, value) => {
|
|
107
103
|
if (typeof ref === "function") {
|
|
108
104
|
return ref(value);
|
|
109
|
-
}
|
|
105
|
+
}
|
|
106
|
+
if (ref !== null && ref !== void 0) {
|
|
110
107
|
ref.current = value;
|
|
111
108
|
}
|
|
112
109
|
};
|
|
@@ -120,12 +117,14 @@ var composeRefs = (...refs) => (node) => {
|
|
|
120
117
|
});
|
|
121
118
|
if (cleanups.length > 0) {
|
|
122
119
|
return () => {
|
|
123
|
-
|
|
120
|
+
for (const cleanup of cleanups) {
|
|
121
|
+
cleanup?.();
|
|
122
|
+
}
|
|
124
123
|
};
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
126
|
var useComposedRef = (...refs) => {
|
|
128
|
-
return
|
|
127
|
+
return import_react3.default.useCallback(composeRefs(...refs), refs);
|
|
129
128
|
};
|
|
130
129
|
|
|
131
130
|
// src/createPrimitiveComponent.tsx
|
|
@@ -134,59 +133,57 @@ var createPrimitiveComponent = (element) => {
|
|
|
134
133
|
return ({
|
|
135
134
|
propsHook,
|
|
136
135
|
stateHook
|
|
137
|
-
} = {}) =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
);
|
|
171
|
-
};
|
|
136
|
+
} = {}) => import_react4.default.forwardRef(
|
|
137
|
+
({
|
|
138
|
+
asChild,
|
|
139
|
+
className: classNameProp,
|
|
140
|
+
getClassName,
|
|
141
|
+
options,
|
|
142
|
+
state: stateProp,
|
|
143
|
+
...props
|
|
144
|
+
}, ref) => {
|
|
145
|
+
const state = (0, import_utils.isDefined)(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
|
|
146
|
+
const {
|
|
147
|
+
hidden,
|
|
148
|
+
props: hookProps,
|
|
149
|
+
ref: hookRef
|
|
150
|
+
} = propsHook ? propsHook(state) : { hidden: false, props: {}, ref: null };
|
|
151
|
+
const _ref = useComposedRef(ref, hookRef);
|
|
152
|
+
const className = (0, import_utils.isDefined)(hookProps?.className) || (0, import_utils.isDefined)(classNameProp) ? (0, import_clsx.clsx)(hookProps?.className, classNameProp) : void 0;
|
|
153
|
+
const style = hookProps?.style || props.style ? { ...hookProps?.style, ...props.style } : void 0;
|
|
154
|
+
if (!asChild && hidden) return null;
|
|
155
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
156
|
+
Comp,
|
|
157
|
+
{
|
|
158
|
+
asChild,
|
|
159
|
+
ref: _ref,
|
|
160
|
+
...hookProps,
|
|
161
|
+
className,
|
|
162
|
+
style,
|
|
163
|
+
...props,
|
|
164
|
+
...props.setProps?.(hookProps ?? {}) ?? {}
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
172
169
|
};
|
|
173
170
|
|
|
174
171
|
// src/createPrimitiveElement.tsx
|
|
175
|
-
var
|
|
172
|
+
var import_react5 = __toESM(require("react"));
|
|
176
173
|
function createPrimitiveElement(tag) {
|
|
177
|
-
return
|
|
174
|
+
return import_react5.default.forwardRef(
|
|
178
175
|
function CreateComponent(props, ref) {
|
|
179
|
-
return
|
|
176
|
+
return import_react5.default.createElement(tag, { ...props, ref });
|
|
180
177
|
}
|
|
181
178
|
);
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
// src/useEffectOnce.ts
|
|
185
|
-
var
|
|
182
|
+
var import_react6 = __toESM(require("react"));
|
|
186
183
|
function useEffectOnce(effect, deps) {
|
|
187
|
-
const initialized =
|
|
188
|
-
const prevDepsRef =
|
|
189
|
-
|
|
184
|
+
const initialized = import_react6.default.useRef(false);
|
|
185
|
+
const prevDepsRef = import_react6.default.useRef(deps);
|
|
186
|
+
import_react6.default.useEffect(() => {
|
|
190
187
|
const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
|
|
191
188
|
if (!initialized.current || depsChanged) {
|
|
192
189
|
initialized.current = true;
|
|
@@ -197,30 +194,16 @@ function useEffectOnce(effect, deps) {
|
|
|
197
194
|
}
|
|
198
195
|
|
|
199
196
|
// src/useIsomorphicLayoutEffect.ts
|
|
200
|
-
var
|
|
197
|
+
var import_react7 = __toESM(require("react"));
|
|
201
198
|
var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
|
|
202
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
203
|
-
|
|
204
|
-
// src/useMemoOnce.ts
|
|
205
|
-
var import_react9 = __toESM(require("react"));
|
|
206
|
-
function useMemoOnce(factory, deps) {
|
|
207
|
-
const initialized = import_react9.default.useRef(false);
|
|
208
|
-
const prevDepsRef = import_react9.default.useRef(deps);
|
|
209
|
-
const memoizedValueRef = import_react9.default.useRef(void 0);
|
|
210
|
-
if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
|
|
211
|
-
initialized.current = true;
|
|
212
|
-
prevDepsRef.current = deps;
|
|
213
|
-
memoizedValueRef.current = factory();
|
|
214
|
-
}
|
|
215
|
-
return memoizedValueRef.current;
|
|
216
|
-
}
|
|
199
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? import_react7.default.useLayoutEffect : import_react7.default.useEffect;
|
|
217
200
|
|
|
218
201
|
// src/useMemoizedSelector.ts
|
|
219
|
-
var
|
|
202
|
+
var import_react8 = __toESM(require("react"));
|
|
220
203
|
function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
221
|
-
const [memoizedValue, setMemoizedValue] =
|
|
222
|
-
const previousValueRef =
|
|
223
|
-
|
|
204
|
+
const [memoizedValue, setMemoizedValue] = import_react8.default.useState(() => selector());
|
|
205
|
+
const previousValueRef = import_react8.default.useRef(memoizedValue);
|
|
206
|
+
import_react8.default.useEffect(() => {
|
|
224
207
|
const newValue = selector();
|
|
225
208
|
if (!equalityFn(previousValueRef.current, newValue)) {
|
|
226
209
|
setMemoizedValue(newValue);
|
|
@@ -231,7 +214,7 @@ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
|
231
214
|
}
|
|
232
215
|
|
|
233
216
|
// src/useOnClickOutside.ts
|
|
234
|
-
var
|
|
217
|
+
var import_react9 = __toESM(require("react"));
|
|
235
218
|
var canUsePassiveEvents = () => {
|
|
236
219
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
237
220
|
return false;
|
|
@@ -270,21 +253,23 @@ var useOnClickOutside = (callback, {
|
|
|
270
253
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
271
254
|
refs: refsOpt
|
|
272
255
|
} = {}) => {
|
|
273
|
-
const [refsState, setRefsState] =
|
|
274
|
-
const callbackRef =
|
|
256
|
+
const [refsState, setRefsState] = import_react9.default.useState([]);
|
|
257
|
+
const callbackRef = import_react9.default.useRef(callback);
|
|
275
258
|
callbackRef.current = callback;
|
|
276
|
-
const ref =
|
|
259
|
+
const ref = import_react9.default.useCallback(
|
|
277
260
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
278
261
|
[]
|
|
279
262
|
);
|
|
280
|
-
|
|
263
|
+
import_react9.default.useEffect(
|
|
281
264
|
() => {
|
|
282
265
|
if (!refsOpt?.length && refsState.length === 0) return;
|
|
283
266
|
const getEls = () => {
|
|
284
267
|
const els = [];
|
|
285
|
-
(refsOpt || refsState)
|
|
286
|
-
(
|
|
287
|
-
|
|
268
|
+
for (const { current } of refsOpt || refsState) {
|
|
269
|
+
if (current) {
|
|
270
|
+
els.push(current);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
288
273
|
return els;
|
|
289
274
|
};
|
|
290
275
|
const handler = (e) => {
|
|
@@ -300,22 +285,22 @@ var useOnClickOutside = (callback, {
|
|
|
300
285
|
}, 0)
|
|
301
286
|
);
|
|
302
287
|
const removeEventListener = () => {
|
|
303
|
-
eventTypes
|
|
304
|
-
|
|
288
|
+
for (const type of eventTypes) {
|
|
289
|
+
document.removeEventListener(
|
|
305
290
|
type,
|
|
306
291
|
handler,
|
|
307
292
|
getEventOptions(type)
|
|
308
|
-
)
|
|
309
|
-
|
|
293
|
+
);
|
|
294
|
+
}
|
|
310
295
|
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
311
296
|
};
|
|
312
297
|
if (disabled) {
|
|
313
298
|
removeEventListener();
|
|
314
299
|
return;
|
|
315
300
|
}
|
|
316
|
-
eventTypes
|
|
317
|
-
|
|
318
|
-
|
|
301
|
+
for (const type of eventTypes) {
|
|
302
|
+
document.addEventListener(type, handler, getEventOptions(type));
|
|
303
|
+
}
|
|
319
304
|
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
320
305
|
return () => removeEventListener();
|
|
321
306
|
},
|
|
@@ -334,41 +319,41 @@ var useOnClickOutside = (callback, {
|
|
|
334
319
|
};
|
|
335
320
|
|
|
336
321
|
// src/useStableFn.ts
|
|
337
|
-
var
|
|
322
|
+
var import_react10 = __toESM(require("react"));
|
|
338
323
|
var useStableFn = (fn, deps = []) => {
|
|
339
|
-
const fnRef =
|
|
324
|
+
const fnRef = import_react10.default.useRef(fn);
|
|
340
325
|
fnRef.current = fn;
|
|
341
|
-
return
|
|
326
|
+
return import_react10.default.useCallback((...args) => fnRef.current(...args), deps);
|
|
342
327
|
};
|
|
343
328
|
|
|
344
329
|
// src/useStableMemo.ts
|
|
345
|
-
var
|
|
330
|
+
var import_react11 = __toESM(require("react"));
|
|
346
331
|
var useStableMemo = (producer, deps) => {
|
|
347
|
-
const [value, setValue] =
|
|
348
|
-
|
|
332
|
+
const [value, setValue] = import_react11.default.useState(producer);
|
|
333
|
+
import_react11.default.useLayoutEffect(() => {
|
|
349
334
|
setValue(producer);
|
|
350
335
|
}, deps);
|
|
351
336
|
return value;
|
|
352
337
|
};
|
|
353
338
|
|
|
354
339
|
// src/withProviders.tsx
|
|
355
|
-
var
|
|
340
|
+
var import_react12 = __toESM(require("react"));
|
|
356
341
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
357
342
|
(acc, prov) => {
|
|
358
343
|
let Provider = prov;
|
|
359
344
|
if (Array.isArray(prov)) {
|
|
360
345
|
[Provider] = prov;
|
|
361
|
-
return /* @__PURE__ */
|
|
346
|
+
return /* @__PURE__ */ import_react12.default.createElement(Provider, { ...prov[1] }, acc);
|
|
362
347
|
}
|
|
363
|
-
return /* @__PURE__ */
|
|
348
|
+
return /* @__PURE__ */ import_react12.default.createElement(Provider, null, acc);
|
|
364
349
|
},
|
|
365
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ import_react12.default.createElement(WrappedComponent, { ...props })
|
|
366
351
|
);
|
|
367
352
|
|
|
368
353
|
// src/withRef.tsx
|
|
369
|
-
var
|
|
354
|
+
var import_react13 = __toESM(require("react"));
|
|
370
355
|
function withRef(renderFunction) {
|
|
371
|
-
return
|
|
356
|
+
return import_react13.default.forwardRef(renderFunction);
|
|
372
357
|
}
|
|
373
358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
374
359
|
0 && (module.exports = {
|
|
@@ -386,7 +371,6 @@ function withRef(renderFunction) {
|
|
|
386
371
|
useComposedRef,
|
|
387
372
|
useEffectOnce,
|
|
388
373
|
useIsomorphicLayoutEffect,
|
|
389
|
-
useMemoOnce,
|
|
390
374
|
useMemoizedSelector,
|
|
391
375
|
useOnClickOutside,
|
|
392
376
|
useStableFn,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoOnce.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/useStableFn.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Box';\nexport * from './MemoizedChildren';\nexport * from './PortalBody';\nexport * from './Text';\nexport * from './composeEventHandlers';\nexport * from './createPrimitiveComponent';\nexport * from './createPrimitiveElement';\nexport * from './createSlotComponent';\nexport * from './useComposedRef';\nexport * from './useEffectOnce';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMemoOnce';\nexport * from './useMemoizedSelector';\nexport * from './useOnClickOutside';\nexport * from './useStableFn';\nexport * from './useStableMemo';\nexport * from './withProviders';\nexport * from './withRef';\n","import React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nexport const createSlotComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n } & P\n >(({ as, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : (as as T) || element;\n\n return <Comp ref={ref} {...props} />;\n });\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Box = createSlotComponent('div');\n\nexport type BoxProps = React.ComponentPropsWithRef<typeof Box>;\n","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n","import React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return (<>{children}</>) as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","import React from 'react';\n\nimport { isDefined } from '@udecode/utils';\nimport { clsx } from 'clsx';\n\nimport { createSlotComponent } from './createSlotComponent';\nimport { useComposedRef } from './useComposedRef';\n\n/**\n * Primitive component factory. It uses hooks for managing state and props, and\n * forwards references to child components. Component props:\n *\n * - `asChild`: If true, the component will be rendered as a `Slot`\n * {@link https://www.radix-ui.com/docs/primitives/utilities/slot}.\n * - `options`: Options passed to the state hook.\n * - `state`: Provide your state instead of using the state hook.\n * - `className`: Class name to be merged to the component.\n * - `style`: Style object to be merged to the component.\n * - `setProps`: Function to set props from the props hook.\n * - `...props`: Props to be passed to the component. Props hook return value:\n * - `ref`: Reference to be forwarded to the component.\n * - `props`: Props to be passed to the component.\n * - `hidden`: If true, the component will not be rendered.\n *\n * @example\n * const MyButton = createPrimitiveComponent(Button)({\n * stateHook: useButtonState,\n * propsHook: useButton,\n * });\n *\n * @param {React.ElementType} element The base component or native HTML element.\n * @returns {function} A primitive component.\n */\nexport const createPrimitiveComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) => {\n const Comp = createSlotComponent<T, P>(element);\n\n return <SH extends (options: any) => any, PH extends (state: any) => any>({\n propsHook,\n stateHook,\n }: {\n propsHook?: PH;\n stateHook?: SH;\n } = {}) => {\n return React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n className?: string;\n options?: Parameters<SH>[0];\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\n setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n } & P\n >(\n (\n {\n asChild,\n className: classNameProp,\n getClassName,\n options,\n state: stateProp,\n ...props\n },\n ref\n ) => {\n const state = isDefined(stateProp)\n ? stateProp\n : stateHook\n ? stateHook(options as any)\n : undefined;\n const {\n hidden,\n props: hookProps,\n ref: hookRef,\n } = propsHook\n ? propsHook(state)\n : { hidden: false, props: {}, ref: null };\n\n const _ref = useComposedRef(ref, hookRef);\n const className =\n isDefined(hookProps?.className) || isDefined(classNameProp)\n ? clsx(hookProps?.className, classNameProp)\n : undefined;\n const style =\n hookProps?.style || props.style\n ? { ...hookProps?.style, ...props.style }\n : undefined;\n\n if (!asChild && hidden) return null;\n\n return (\n <Comp\n ref={_ref}\n asChild={asChild}\n {...hookProps}\n className={className}\n style={style}\n {...props}\n {...(props.setProps?.(hookProps ?? {}) ?? {})}\n />\n );\n }\n );\n };\n};\n","import React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value This utility takes care of different types\n * of refs: callback refs and React.RefObject(s)\n */\nconst setRef = <T>(ref: PossibleRef<T>, value: T) => {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.RefObject<T>).current = value;\n }\n};\n\n/**\n * A utility to compose multiple refs together Accepts callback refs and\n * React.RefObject(s)\n */\nexport const composeRefs =\n <T>(...refs: PossibleRef<T>[]) =>\n (node: T) => {\n const cleanups: ((() => void) | undefined)[] = [];\n\n refs.forEach((ref) => {\n const cleanup = setRef(ref, node);\n if (typeof cleanup === 'function') {\n cleanups.push(cleanup);\n }\n });\n\n // Return a cleanup function if any refs returned cleanup functions\n if (cleanups.length > 0) {\n return () => {\n cleanups.forEach((cleanup) => cleanup?.());\n };\n }\n };\n\n/**\n * A custom hook that composes multiple refs Accepts callback refs and\n * React.RefObject(s)\n */\nexport const useComposedRef = <T>(...refs: PossibleRef<T>[]) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n};\n","import React, { type JSX } from 'react';\n\nexport function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(\n tag: T\n) {\n return React.forwardRef<HTMLElementTagNameMap[T], JSX.IntrinsicElements[T]>(\n function CreateComponent(props, ref) {\n return React.createElement(tag, { ...props, ref });\n }\n );\n}\n","import React from 'react';\n\nexport function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\nexport function useMemoOnce<T>(\n factory: () => T,\n deps: React.DependencyList\n): T {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n const memoizedValueRef = React.useRef<T>(undefined);\n\n if (\n !initialized.current ||\n deps.some((dep, i) => dep !== prevDepsRef.current[i])\n ) {\n initialized.current = true;\n prevDepsRef.current = deps;\n memoizedValueRef.current = factory();\n }\n\n return memoizedValueRef.current!;\n}\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n get() {\n passive = true;\n },\n });\n const noop = () => null;\n\n window.addEventListener('test', noop, options);\n window.removeEventListener('test', noop, options);\n\n return passive;\n};\n\nexport const DEFAULT_IGNORE_CLASS = 'ignore-onclickoutside';\n\nexport type UseOnClickOutsideCallback<T extends Event = Event> = (\n event: T\n) => void;\n\nexport interface UseOnClickOutsideOptions {\n detectIFrame?: boolean;\n disabled?: boolean;\n eventTypes?: string[];\n excludeScrollbar?: boolean;\n ignoreClass?: string[] | string;\n refs?: Refs;\n}\n\nexport type UseOnClickOutsideReturn = (element: El | null) => void;\n\ntype El = HTMLElement;\n\ntype Refs = React.RefObject<El | null>[];\n\nconst checkClass = (el: HTMLElement, cl: string): boolean =>\n el.classList?.contains(cl);\n\nconst hasIgnoreClass = (e: any, ignoreClass: string[] | string): boolean => {\n let el = e.target || e;\n\n while (el) {\n if (Array.isArray(ignoreClass)) {\n if (ignoreClass.some((c) => checkClass(el, c))) return true;\n } else if (checkClass(el, ignoreClass)) {\n return true;\n }\n\n el = el.parentElement;\n }\n\n return false;\n};\n\nconst clickedOnScrollbar = (e: MouseEvent): boolean =>\n document.documentElement.clientWidth <= e.clientX ||\n document.documentElement.clientHeight <= e.clientY;\n\nconst getEventOptions = (type: string): { passive: boolean } | boolean =>\n type.includes('touch') && canUsePassiveEvents() ? { passive: true } : false;\n\nexport const useOnClickOutside = (\n callback: UseOnClickOutsideCallback,\n {\n detectIFrame = true,\n disabled,\n eventTypes = ['mousedown', 'touchstart'],\n excludeScrollbar,\n ignoreClass = DEFAULT_IGNORE_CLASS,\n refs: refsOpt,\n }: UseOnClickOutsideOptions = {}\n): UseOnClickOutsideReturn => {\n const [refsState, setRefsState] = React.useState<Refs>([]);\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n const ref: UseOnClickOutsideReturn = React.useCallback(\n (el) => setRefsState((prevState) => [...prevState, { current: el }]),\n []\n );\n\n React.useEffect(\n () => {\n if (!refsOpt?.length && refsState.length === 0) return;\n\n const getEls = () => {\n const els: El[] = [];\n (refsOpt || refsState).forEach(\n ({ current }) => current && els.push(current)\n );\n\n return els;\n };\n\n const handler = (e: any) => {\n if (\n !hasIgnoreClass(e, ignoreClass) &&\n !(excludeScrollbar && clickedOnScrollbar(e)) &&\n getEls().every((el) => !el.contains(e.target))\n )\n callbackRef.current(e);\n };\n\n const blurHandler = (e: FocusEvent) =>\n // On firefox the iframe becomes document.activeElement in the next event loop\n setTimeout(() => {\n const { activeElement } = document;\n\n if (\n activeElement?.tagName === 'IFRAME' &&\n !hasIgnoreClass(activeElement, ignoreClass) &&\n !getEls().includes(activeElement as HTMLIFrameElement)\n )\n callbackRef.current(e);\n }, 0);\n\n const removeEventListener = () => {\n eventTypes.forEach((type) =>\n document.removeEventListener(\n type,\n handler,\n getEventOptions(type) as any\n )\n );\n\n if (detectIFrame) window.removeEventListener('blur', blurHandler);\n };\n\n if (disabled) {\n removeEventListener();\n\n return;\n }\n\n eventTypes.forEach((type) =>\n document.addEventListener(type, handler, getEventOptions(type))\n );\n\n if (detectIFrame) window.addEventListener('blur', blurHandler);\n\n return () => removeEventListener();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n refsState,\n ignoreClass,\n excludeScrollbar,\n disabled,\n detectIFrame,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(eventTypes),\n ]\n );\n\n return ref;\n};\n","import React, { type DependencyList } from 'react';\n\n/**\n * Create a stable version of a function that can be used in dependency arrays\n * without causing hooks like useEffect to re-run if the function changes.\n * Calling the returned function always calls the most recent version of the\n * function that was passed to useStableFn.\n *\n * If you do want the function to be replaced when certain dependency values\n * change, include those values in the dependency array of useStableFn.\n */\nexport const useStableFn = <A extends unknown[], R>(\n fn: (...args: A) => R,\n deps: DependencyList = []\n) => {\n const fnRef = React.useRef(fn);\n fnRef.current = fn;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback((...args: A) => fnRef.current(...args), deps);\n};\n","import React from 'react';\n\nexport const useStableMemo = <T>(\n producer: () => T,\n deps?: React.DependencyList\n): T => {\n const [value, setValue] = React.useState(producer);\n\n React.useLayoutEffect(() => {\n setValue(producer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return value;\n};\n","import React from 'react';\n\n/**\n * Wrap a component into multiple providers. If there are any props that you\n * want a provider to receive, you can simply pass an array.\n */\nexport const withProviders =\n (...providers: any[]) =>\n <T,>(WrappedComponent: React.FC<T>) =>\n (props: T) =>\n providers.reduceRight(\n (acc, prov) => {\n let Provider = prov;\n\n if (Array.isArray(prov)) {\n [Provider] = prov;\n\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n\n return <Provider>{acc}</Provider>;\n },\n <WrappedComponent {...(props as any)} />\n );\n","import React, { type JSX } from 'react';\n\ntype ElementType<P = any> =\n | React.ComponentType<P>\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements];\n\ntype ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<T>\n>;\n\ntype InferElementRef<T> =\n T extends ElementType<any>\n ? T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<\n React.HTMLAttributes<infer R>,\n any\n >\n ? R\n : never\n : T extends React.ComponentType<any>\n ? T extends React.ComponentClass<any>\n ? InstanceType<T>\n : T extends React.ForwardRefExoticComponent<any>\n ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R>\n ? R\n : never\n : never\n : never\n : never;\n\n/**\n * Shorter alternative to `React.forwardRef`.\n *\n * @generic1 Component type or element type\n * @generic2 Extended prop types\n */\nexport function withRef<T extends ElementType, P = {}>(\n renderFunction: React.ForwardRefRenderFunction<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n >\n): ForwardRefComponent<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n> {\n return React.forwardRef(renderFunction as any) as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAElB,wBAAqB;AAEd,IAAM,sBAAsB,CAIjC,YAEA,aAAAA,QAAM,WAMJ,CAAC,EAAE,IAAI,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC5C,QAAM,OAAO,UAAU,yBAAQ,MAAY;AAE3C,SAAO,6BAAAA,QAAA,cAAC,QAAK,KAAW,GAAG,OAAO;AACpC,CAAC;;;AChBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,IAAAC,gBAAkB;AAEX,IAAM,mBAAmB,cAAAC,QAAM;AAAA,EACpC,CAAC,EAAE,SAAS,MAAqC;AAC/C,WAAO,8BAAAA,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AAAA,EACrB;AACF;;;ACNA,IAAAC,gBAAkB;AAClB,uBAAqB;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAQ,8BAAAC,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AAEpC,SAAO,iBAAAC,QAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACHvC,IAAM,uBACX,CACE,sBACA,iBACA,EAAE,2BAA2B,KAAK,IAAI,CAAC,MAEzC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B,QAAM,UAAU;AAEhB,SAAO,eAAAA,QAAM,YAAY,IAAI,SAAY,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI;AACvE;;;ACnBA,IAAAC,iBAAkB;AAEX,IAAM,gBAAgB,CAC3B,UACA,SACM;AACN,QAAM,CAAC,OAAO,QAAQ,IAAI,eAAAC,QAAM,SAAS,QAAQ;AAEjD,iBAAAA,QAAM,gBAAgB,MAAM;AAC1B,aAAS,QAAQ;AAAA,EAEnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,IAAAC,iBAAkB;AAMX,IAAM,gBACX,IAAI,cACJ,CAAK,qBACL,CAAC,UACC,UAAU;AAAA,EACR,CAAC,KAAK,SAAS;AACb,QAAI,WAAW;AAEf,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,OAAC,QAAQ,IAAI;AAEb,aAAO,+BAAAC,QAAA,cAAC,YAAU,GAAG,KAAK,CAAC,KAAI,GAAI;AAAA,IACrC;AAEA,WAAO,+BAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,+BAAAA,QAAA,cAAC,oBAAkB,GAAI,OAAe;AACxC;;;ACvBJ,IAAAC,iBAAgC;AAwCzB,SAAS,QACd,gBAOA;AACA,SAAO,eAAAC,QAAM,WAAW,cAAqB;AAC/C;","names":["React","import_react","React","import_react","React","ReactDOM","import_react","import_react","React","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/useStableFn.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Box';\nexport * from './MemoizedChildren';\nexport * from './PortalBody';\nexport * from './Text';\nexport * from './composeEventHandlers';\nexport * from './createPrimitiveComponent';\nexport * from './createPrimitiveElement';\nexport * from './createSlotComponent';\nexport * from './useComposedRef';\nexport * from './useEffectOnce';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMemoizedSelector';\nexport * from './useOnClickOutside';\nexport * from './useStableFn';\nexport * from './useStableMemo';\nexport * from './withProviders';\nexport * from './withRef';\n","import { Slot } from '@radix-ui/react-slot';\nimport React from 'react';\n\nexport const createSlotComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n } & P\n >(({ as, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : (as as T) || element;\n\n return <Comp ref={ref} {...props} />;\n });\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Box = createSlotComponent('div');\n\nexport type BoxProps = React.ComponentPropsWithRef<typeof Box>;\n","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => <>{children}</>\n);\n","import type React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return children as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","import { isDefined } from '@udecode/utils';\nimport { clsx } from 'clsx';\nimport React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\nimport { useComposedRef } from './useComposedRef';\n\n/**\n * Primitive component factory. It uses hooks for managing state and props, and\n * forwards references to child components. Component props:\n *\n * - `asChild`: If true, the component will be rendered as a `Slot`\n * {@link https://www.radix-ui.com/docs/primitives/utilities/slot}.\n * - `options`: Options passed to the state hook.\n * - `state`: Provide your state instead of using the state hook.\n * - `className`: Class name to be merged to the component.\n * - `style`: Style object to be merged to the component.\n * - `setProps`: Function to set props from the props hook.\n * - `...props`: Props to be passed to the component. Props hook return value:\n * - `ref`: Reference to be forwarded to the component.\n * - `props`: Props to be passed to the component.\n * - `hidden`: If true, the component will not be rendered.\n *\n * @example\n * const MyButton = createPrimitiveComponent(Button)({\n * stateHook: useButtonState,\n * propsHook: useButton,\n * });\n *\n * @param {React.ElementType} element The base component or native HTML element.\n * @returns {function} A primitive component.\n */\nexport const createPrimitiveComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) => {\n const Comp = createSlotComponent<T, P>(element);\n\n return <SH extends (options: any) => any, PH extends (state: any) => any>({\n propsHook,\n stateHook,\n }: {\n propsHook?: PH;\n stateHook?: SH;\n } = {}) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n className?: string;\n options?: Parameters<SH>[0];\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\n setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n } & P\n >(\n (\n {\n asChild,\n className: classNameProp,\n getClassName,\n options,\n state: stateProp,\n ...props\n },\n ref\n ) => {\n const state = isDefined(stateProp)\n ? stateProp\n : stateHook\n ? stateHook(options as any)\n : undefined;\n const {\n hidden,\n props: hookProps,\n ref: hookRef,\n } = propsHook\n ? propsHook(state)\n : { hidden: false, props: {}, ref: null };\n\n const _ref = useComposedRef(ref, hookRef);\n const className =\n isDefined(hookProps?.className) || isDefined(classNameProp)\n ? clsx(hookProps?.className, classNameProp)\n : undefined;\n const style =\n hookProps?.style || props.style\n ? { ...hookProps?.style, ...props.style }\n : undefined;\n\n if (!asChild && hidden) return null;\n\n return (\n <Comp\n asChild={asChild}\n ref={_ref}\n {...hookProps}\n className={className}\n style={style}\n {...props}\n {...(props.setProps?.(hookProps ?? {}) ?? {})}\n />\n );\n }\n );\n};\n","import React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value This utility takes care of different types\n * of refs: callback refs and React.RefObject(s)\n */\nconst setRef = <T>(ref: PossibleRef<T>, value: T) => {\n if (typeof ref === 'function') {\n return ref(value);\n }\n if (ref !== null && ref !== undefined) {\n (ref as React.RefObject<T>).current = value;\n }\n};\n\n/**\n * A utility to compose multiple refs together Accepts callback refs and\n * React.RefObject(s)\n */\nexport const composeRefs =\n <T>(...refs: PossibleRef<T>[]) =>\n (node: T) => {\n const cleanups: ((() => void) | undefined)[] = [];\n\n refs.forEach((ref) => {\n const cleanup = setRef(ref, node);\n if (typeof cleanup === 'function') {\n cleanups.push(cleanup);\n }\n });\n\n // Return a cleanup function if any refs returned cleanup functions\n if (cleanups.length > 0) {\n return () => {\n for (const cleanup of cleanups) {\n cleanup?.();\n }\n };\n }\n };\n\n/**\n * A custom hook that composes multiple refs Accepts callback refs and\n * React.RefObject(s)\n */\nexport const useComposedRef = <T>(...refs: PossibleRef<T>[]) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n};\n","import React, { type JSX } from 'react';\n\nexport function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(\n tag: T\n) {\n return React.forwardRef<HTMLElementTagNameMap[T], JSX.IntrinsicElements[T]>(\n function CreateComponent(props, ref) {\n return React.createElement(tag, { ...props, ref });\n }\n );\n}\n","import React from 'react';\n\nexport function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n get() {\n passive = true;\n },\n });\n const noop = () => null;\n\n window.addEventListener('test', noop, options);\n window.removeEventListener('test', noop, options);\n\n return passive;\n};\n\nexport const DEFAULT_IGNORE_CLASS = 'ignore-onclickoutside';\n\nexport type UseOnClickOutsideCallback<T extends Event = Event> = (\n event: T\n) => void;\n\nexport type UseOnClickOutsideOptions = {\n detectIFrame?: boolean;\n disabled?: boolean;\n eventTypes?: string[];\n excludeScrollbar?: boolean;\n ignoreClass?: string[] | string;\n refs?: Refs;\n};\n\nexport type UseOnClickOutsideReturn = (element: El | null) => void;\n\ntype El = HTMLElement;\n\ntype Refs = React.RefObject<El | null>[];\n\nconst checkClass = (el: HTMLElement, cl: string): boolean =>\n el.classList?.contains(cl);\n\nconst hasIgnoreClass = (e: any, ignoreClass: string[] | string): boolean => {\n let el = e.target || e;\n\n while (el) {\n if (Array.isArray(ignoreClass)) {\n if (ignoreClass.some((c) => checkClass(el, c))) return true;\n } else if (checkClass(el, ignoreClass)) {\n return true;\n }\n\n el = el.parentElement;\n }\n\n return false;\n};\n\nconst clickedOnScrollbar = (e: MouseEvent): boolean =>\n document.documentElement.clientWidth <= e.clientX ||\n document.documentElement.clientHeight <= e.clientY;\n\nconst getEventOptions = (type: string): { passive: boolean } | boolean =>\n type.includes('touch') && canUsePassiveEvents() ? { passive: true } : false;\n\nexport const useOnClickOutside = (\n callback: UseOnClickOutsideCallback,\n {\n detectIFrame = true,\n disabled,\n eventTypes = ['mousedown', 'touchstart'],\n excludeScrollbar,\n ignoreClass = DEFAULT_IGNORE_CLASS,\n refs: refsOpt,\n }: UseOnClickOutsideOptions = {}\n): UseOnClickOutsideReturn => {\n const [refsState, setRefsState] = React.useState<Refs>([]);\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n const ref: UseOnClickOutsideReturn = React.useCallback(\n (el) => setRefsState((prevState) => [...prevState, { current: el }]),\n []\n );\n\n React.useEffect(\n () => {\n if (!refsOpt?.length && refsState.length === 0) return;\n\n const getEls = () => {\n const els: El[] = [];\n for (const { current } of refsOpt || refsState) {\n if (current) {\n els.push(current);\n }\n }\n\n return els;\n };\n\n const handler = (e: any) => {\n if (\n !hasIgnoreClass(e, ignoreClass) &&\n !(excludeScrollbar && clickedOnScrollbar(e)) &&\n getEls().every((el) => !el.contains(e.target))\n )\n callbackRef.current(e);\n };\n\n const blurHandler = (e: FocusEvent) =>\n // On firefox the iframe becomes document.activeElement in the next event loop\n setTimeout(() => {\n const { activeElement } = document;\n\n if (\n activeElement?.tagName === 'IFRAME' &&\n !hasIgnoreClass(activeElement, ignoreClass) &&\n !getEls().includes(activeElement as HTMLIFrameElement)\n )\n callbackRef.current(e);\n }, 0);\n\n const removeEventListener = () => {\n for (const type of eventTypes) {\n document.removeEventListener(\n type,\n handler,\n getEventOptions(type) as any\n );\n }\n\n if (detectIFrame) window.removeEventListener('blur', blurHandler);\n };\n\n if (disabled) {\n removeEventListener();\n\n return;\n }\n\n for (const type of eventTypes) {\n document.addEventListener(type, handler, getEventOptions(type));\n }\n\n if (detectIFrame) window.addEventListener('blur', blurHandler);\n\n return () => removeEventListener();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n refsState,\n ignoreClass,\n excludeScrollbar,\n disabled,\n detectIFrame,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(eventTypes),\n ]\n );\n\n return ref;\n};\n","import React, { type DependencyList } from 'react';\n\n/**\n * Create a stable version of a function that can be used in dependency arrays\n * without causing hooks like useEffect to re-run if the function changes.\n * Calling the returned function always calls the most recent version of the\n * function that was passed to useStableFn.\n *\n * If you do want the function to be replaced when certain dependency values\n * change, include those values in the dependency array of useStableFn.\n */\nexport const useStableFn = <A extends unknown[], R>(\n fn: (...args: A) => R,\n deps: DependencyList = []\n) => {\n const fnRef = React.useRef(fn);\n fnRef.current = fn;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback((...args: A) => fnRef.current(...args), deps);\n};\n","import React from 'react';\n\nexport const useStableMemo = <T>(\n producer: () => T,\n deps?: React.DependencyList\n): T => {\n const [value, setValue] = React.useState(producer);\n\n React.useLayoutEffect(() => {\n setValue(producer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return value;\n};\n","/** biome-ignore-all lint/correctness/useJsxKeyInIterable: biome */\nimport React from 'react';\n\n/**\n * Wrap a component into multiple providers. If there are any props that you\n * want a provider to receive, you can simply pass an array.\n */\nexport const withProviders =\n (...providers: any[]) =>\n <T,>(WrappedComponent: React.FC<T>) =>\n (props: T) =>\n providers.reduceRight(\n (acc, prov) => {\n let Provider = prov;\n\n if (Array.isArray(prov)) {\n [Provider] = prov;\n\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n\n return <Provider>{acc}</Provider>;\n },\n <WrappedComponent {...(props as any)} />\n );\n","import React, { type JSX } from 'react';\n\ntype ElementType<P = any> =\n | React.ComponentType<P>\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements];\n\ntype ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<T>\n>;\n\ntype InferElementRef<T> = T extends ElementType<any>\n ? T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<\n React.HTMLAttributes<infer R>,\n any\n >\n ? R\n : never\n : T extends React.ComponentType<any>\n ? T extends React.ComponentClass<any>\n ? InstanceType<T>\n : T extends React.ForwardRefExoticComponent<any>\n ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R>\n ? R\n : never\n : never\n : never\n : never;\n\n/**\n * Shorter alternative to `React.forwardRef`.\n *\n * @generic1 Component type or element type\n * @generic2 Extended prop types\n */\nexport function withRef<T extends ElementType, P = {}>(\n renderFunction: React.ForwardRefRenderFunction<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n >\n): ForwardRefComponent<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n> {\n return React.forwardRef(renderFunction as any) as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAAqB;AACrB,mBAAkB;AAEX,IAAM,sBAAsB,CAIjC,YAEA,aAAAA,QAAM,WAMJ,CAAC,EAAE,IAAI,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC5C,QAAM,OAAO,UAAU,yBAAQ,MAAY;AAE3C,SAAO,6BAAAA,QAAA,cAAC,QAAK,KAAW,GAAG,OAAO;AACpC,CAAC;;;ACfI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,IAAAC,gBAAkB;AAEX,IAAM,mBAAmB,cAAAC,QAAM;AAAA,EACpC,CAAC,EAAE,SAAS,MAAqC,8BAAAA,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AAC/D;;;ACHA,uBAAqB;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,iBAAAC,QAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACHvC,IAAM,uBACX,CACE,sBACA,iBACA,EAAE,2BAA2B,KAAK,IAAI,CAAC,MAEzC,CAAC,UAAa;AACZ,yBAAuB,KAAK;AAE5B,MACE,6BAA6B,SAC7B,CAAE,MAA2B,kBAC7B;AACA,WAAO,kBAAkB,KAAK;AAAA,EAChC;AACF;;;AChBF,mBAA0B;AAC1B,kBAAqB;AACrB,I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AU,GAAG,KAAK,CAAC,KAAI,GAAI;AAAA,IACrC;AAEA,WAAO,+BAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,+BAAAA,QAAA,cAAC,oBAAkB,GAAI,OAAe;AACxC;;;ACxBJ,IAAAC,iBAAgC;AAuCzB,SAAS,QACd,gBAOA;AACA,SAAO,eAAAC,QAAM,WAAW,cAAqB;AAC/C;","names":["React","import_react","React","ReactDOM","import_react","import_react","React","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/createSlotComponent.tsx
|
|
2
|
-
import React from "react";
|
|
3
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import React from "react";
|
|
4
4
|
var createSlotComponent = (element) => React.forwardRef(({ as, asChild = false, ...props }, ref) => {
|
|
5
5
|
const Comp = asChild ? Slot : as || element;
|
|
6
6
|
return /* @__PURE__ */ React.createElement(Comp, { ref, ...props });
|
|
@@ -12,20 +12,17 @@ var Box = createSlotComponent("div");
|
|
|
12
12
|
// src/MemoizedChildren.tsx
|
|
13
13
|
import React2 from "react";
|
|
14
14
|
var MemoizedChildren = React2.memo(
|
|
15
|
-
({ children }) =>
|
|
16
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
|
|
17
|
-
}
|
|
15
|
+
({ children }) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, children)
|
|
18
16
|
);
|
|
19
17
|
|
|
20
18
|
// src/PortalBody.tsx
|
|
21
|
-
import React3 from "react";
|
|
22
19
|
import ReactDOM from "react-dom";
|
|
23
20
|
var PortalBody = ({
|
|
24
21
|
children,
|
|
25
22
|
element
|
|
26
23
|
}) => {
|
|
27
24
|
const container = element || typeof window !== "undefined" ? document.body : void 0;
|
|
28
|
-
if (!container) return
|
|
25
|
+
if (!container) return children;
|
|
29
26
|
return ReactDOM.createPortal(children, element || document.body);
|
|
30
27
|
};
|
|
31
28
|
|
|
@@ -41,16 +38,17 @@ var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDef
|
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
// src/createPrimitiveComponent.tsx
|
|
44
|
-
import React5 from "react";
|
|
45
41
|
import { isDefined } from "@udecode/utils";
|
|
46
42
|
import { clsx } from "clsx";
|
|
43
|
+
import React4 from "react";
|
|
47
44
|
|
|
48
45
|
// src/useComposedRef.ts
|
|
49
|
-
import
|
|
46
|
+
import React3 from "react";
|
|
50
47
|
var setRef = (ref, value) => {
|
|
51
48
|
if (typeof ref === "function") {
|
|
52
49
|
return ref(value);
|
|
53
|
-
}
|
|
50
|
+
}
|
|
51
|
+
if (ref !== null && ref !== void 0) {
|
|
54
52
|
ref.current = value;
|
|
55
53
|
}
|
|
56
54
|
};
|
|
@@ -64,12 +62,14 @@ var composeRefs = (...refs) => (node) => {
|
|
|
64
62
|
});
|
|
65
63
|
if (cleanups.length > 0) {
|
|
66
64
|
return () => {
|
|
67
|
-
|
|
65
|
+
for (const cleanup of cleanups) {
|
|
66
|
+
cleanup?.();
|
|
67
|
+
}
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
var useComposedRef = (...refs) => {
|
|
72
|
-
return
|
|
72
|
+
return React3.useCallback(composeRefs(...refs), refs);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
// src/createPrimitiveComponent.tsx
|
|
@@ -78,59 +78,57 @@ var createPrimitiveComponent = (element) => {
|
|
|
78
78
|
return ({
|
|
79
79
|
propsHook,
|
|
80
80
|
stateHook
|
|
81
|
-
} = {}) =>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
);
|
|
115
|
-
};
|
|
81
|
+
} = {}) => React4.forwardRef(
|
|
82
|
+
({
|
|
83
|
+
asChild,
|
|
84
|
+
className: classNameProp,
|
|
85
|
+
getClassName,
|
|
86
|
+
options,
|
|
87
|
+
state: stateProp,
|
|
88
|
+
...props
|
|
89
|
+
}, ref) => {
|
|
90
|
+
const state = isDefined(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
|
|
91
|
+
const {
|
|
92
|
+
hidden,
|
|
93
|
+
props: hookProps,
|
|
94
|
+
ref: hookRef
|
|
95
|
+
} = propsHook ? propsHook(state) : { hidden: false, props: {}, ref: null };
|
|
96
|
+
const _ref = useComposedRef(ref, hookRef);
|
|
97
|
+
const className = isDefined(hookProps?.className) || isDefined(classNameProp) ? clsx(hookProps?.className, classNameProp) : void 0;
|
|
98
|
+
const style = hookProps?.style || props.style ? { ...hookProps?.style, ...props.style } : void 0;
|
|
99
|
+
if (!asChild && hidden) return null;
|
|
100
|
+
return /* @__PURE__ */ React4.createElement(
|
|
101
|
+
Comp,
|
|
102
|
+
{
|
|
103
|
+
asChild,
|
|
104
|
+
ref: _ref,
|
|
105
|
+
...hookProps,
|
|
106
|
+
className,
|
|
107
|
+
style,
|
|
108
|
+
...props,
|
|
109
|
+
...props.setProps?.(hookProps ?? {}) ?? {}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
116
114
|
};
|
|
117
115
|
|
|
118
116
|
// src/createPrimitiveElement.tsx
|
|
119
|
-
import
|
|
117
|
+
import React5 from "react";
|
|
120
118
|
function createPrimitiveElement(tag) {
|
|
121
|
-
return
|
|
119
|
+
return React5.forwardRef(
|
|
122
120
|
function CreateComponent(props, ref) {
|
|
123
|
-
return
|
|
121
|
+
return React5.createElement(tag, { ...props, ref });
|
|
124
122
|
}
|
|
125
123
|
);
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
// src/useEffectOnce.ts
|
|
129
|
-
import
|
|
127
|
+
import React6 from "react";
|
|
130
128
|
function useEffectOnce(effect, deps) {
|
|
131
|
-
const initialized =
|
|
132
|
-
const prevDepsRef =
|
|
133
|
-
|
|
129
|
+
const initialized = React6.useRef(false);
|
|
130
|
+
const prevDepsRef = React6.useRef(deps);
|
|
131
|
+
React6.useEffect(() => {
|
|
134
132
|
const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
|
|
135
133
|
if (!initialized.current || depsChanged) {
|
|
136
134
|
initialized.current = true;
|
|
@@ -141,30 +139,16 @@ function useEffectOnce(effect, deps) {
|
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
// src/useIsomorphicLayoutEffect.ts
|
|
144
|
-
import
|
|
142
|
+
import React7 from "react";
|
|
145
143
|
var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
|
|
146
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
147
|
-
|
|
148
|
-
// src/useMemoOnce.ts
|
|
149
|
-
import React9 from "react";
|
|
150
|
-
function useMemoOnce(factory, deps) {
|
|
151
|
-
const initialized = React9.useRef(false);
|
|
152
|
-
const prevDepsRef = React9.useRef(deps);
|
|
153
|
-
const memoizedValueRef = React9.useRef(void 0);
|
|
154
|
-
if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
|
|
155
|
-
initialized.current = true;
|
|
156
|
-
prevDepsRef.current = deps;
|
|
157
|
-
memoizedValueRef.current = factory();
|
|
158
|
-
}
|
|
159
|
-
return memoizedValueRef.current;
|
|
160
|
-
}
|
|
144
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? React7.useLayoutEffect : React7.useEffect;
|
|
161
145
|
|
|
162
146
|
// src/useMemoizedSelector.ts
|
|
163
|
-
import
|
|
147
|
+
import React8 from "react";
|
|
164
148
|
function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
165
|
-
const [memoizedValue, setMemoizedValue] =
|
|
166
|
-
const previousValueRef =
|
|
167
|
-
|
|
149
|
+
const [memoizedValue, setMemoizedValue] = React8.useState(() => selector());
|
|
150
|
+
const previousValueRef = React8.useRef(memoizedValue);
|
|
151
|
+
React8.useEffect(() => {
|
|
168
152
|
const newValue = selector();
|
|
169
153
|
if (!equalityFn(previousValueRef.current, newValue)) {
|
|
170
154
|
setMemoizedValue(newValue);
|
|
@@ -175,7 +159,7 @@ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
|
175
159
|
}
|
|
176
160
|
|
|
177
161
|
// src/useOnClickOutside.ts
|
|
178
|
-
import
|
|
162
|
+
import React9 from "react";
|
|
179
163
|
var canUsePassiveEvents = () => {
|
|
180
164
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
181
165
|
return false;
|
|
@@ -214,21 +198,23 @@ var useOnClickOutside = (callback, {
|
|
|
214
198
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
215
199
|
refs: refsOpt
|
|
216
200
|
} = {}) => {
|
|
217
|
-
const [refsState, setRefsState] =
|
|
218
|
-
const callbackRef =
|
|
201
|
+
const [refsState, setRefsState] = React9.useState([]);
|
|
202
|
+
const callbackRef = React9.useRef(callback);
|
|
219
203
|
callbackRef.current = callback;
|
|
220
|
-
const ref =
|
|
204
|
+
const ref = React9.useCallback(
|
|
221
205
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
222
206
|
[]
|
|
223
207
|
);
|
|
224
|
-
|
|
208
|
+
React9.useEffect(
|
|
225
209
|
() => {
|
|
226
210
|
if (!refsOpt?.length && refsState.length === 0) return;
|
|
227
211
|
const getEls = () => {
|
|
228
212
|
const els = [];
|
|
229
|
-
(refsOpt || refsState)
|
|
230
|
-
(
|
|
231
|
-
|
|
213
|
+
for (const { current } of refsOpt || refsState) {
|
|
214
|
+
if (current) {
|
|
215
|
+
els.push(current);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
232
218
|
return els;
|
|
233
219
|
};
|
|
234
220
|
const handler = (e) => {
|
|
@@ -244,22 +230,22 @@ var useOnClickOutside = (callback, {
|
|
|
244
230
|
}, 0)
|
|
245
231
|
);
|
|
246
232
|
const removeEventListener = () => {
|
|
247
|
-
eventTypes
|
|
248
|
-
|
|
233
|
+
for (const type of eventTypes) {
|
|
234
|
+
document.removeEventListener(
|
|
249
235
|
type,
|
|
250
236
|
handler,
|
|
251
237
|
getEventOptions(type)
|
|
252
|
-
)
|
|
253
|
-
|
|
238
|
+
);
|
|
239
|
+
}
|
|
254
240
|
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
255
241
|
};
|
|
256
242
|
if (disabled) {
|
|
257
243
|
removeEventListener();
|
|
258
244
|
return;
|
|
259
245
|
}
|
|
260
|
-
eventTypes
|
|
261
|
-
|
|
262
|
-
|
|
246
|
+
for (const type of eventTypes) {
|
|
247
|
+
document.addEventListener(type, handler, getEventOptions(type));
|
|
248
|
+
}
|
|
263
249
|
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
264
250
|
return () => removeEventListener();
|
|
265
251
|
},
|
|
@@ -278,41 +264,41 @@ var useOnClickOutside = (callback, {
|
|
|
278
264
|
};
|
|
279
265
|
|
|
280
266
|
// src/useStableFn.ts
|
|
281
|
-
import
|
|
267
|
+
import React10 from "react";
|
|
282
268
|
var useStableFn = (fn, deps = []) => {
|
|
283
|
-
const fnRef =
|
|
269
|
+
const fnRef = React10.useRef(fn);
|
|
284
270
|
fnRef.current = fn;
|
|
285
|
-
return
|
|
271
|
+
return React10.useCallback((...args) => fnRef.current(...args), deps);
|
|
286
272
|
};
|
|
287
273
|
|
|
288
274
|
// src/useStableMemo.ts
|
|
289
|
-
import
|
|
275
|
+
import React11 from "react";
|
|
290
276
|
var useStableMemo = (producer, deps) => {
|
|
291
|
-
const [value, setValue] =
|
|
292
|
-
|
|
277
|
+
const [value, setValue] = React11.useState(producer);
|
|
278
|
+
React11.useLayoutEffect(() => {
|
|
293
279
|
setValue(producer);
|
|
294
280
|
}, deps);
|
|
295
281
|
return value;
|
|
296
282
|
};
|
|
297
283
|
|
|
298
284
|
// src/withProviders.tsx
|
|
299
|
-
import
|
|
285
|
+
import React12 from "react";
|
|
300
286
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
301
287
|
(acc, prov) => {
|
|
302
288
|
let Provider = prov;
|
|
303
289
|
if (Array.isArray(prov)) {
|
|
304
290
|
[Provider] = prov;
|
|
305
|
-
return /* @__PURE__ */
|
|
291
|
+
return /* @__PURE__ */ React12.createElement(Provider, { ...prov[1] }, acc);
|
|
306
292
|
}
|
|
307
|
-
return /* @__PURE__ */
|
|
293
|
+
return /* @__PURE__ */ React12.createElement(Provider, null, acc);
|
|
308
294
|
},
|
|
309
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ React12.createElement(WrappedComponent, { ...props })
|
|
310
296
|
);
|
|
311
297
|
|
|
312
298
|
// src/withRef.tsx
|
|
313
|
-
import
|
|
299
|
+
import React13 from "react";
|
|
314
300
|
function withRef(renderFunction) {
|
|
315
|
-
return
|
|
301
|
+
return React13.forwardRef(renderFunction);
|
|
316
302
|
}
|
|
317
303
|
export {
|
|
318
304
|
Box,
|
|
@@ -329,7 +315,6 @@ export {
|
|
|
329
315
|
useComposedRef,
|
|
330
316
|
useEffectOnce,
|
|
331
317
|
useIsomorphicLayoutEffect,
|
|
332
|
-
useMemoOnce,
|
|
333
318
|
useMemoizedSelector,
|
|
334
319
|
useOnClickOutside,
|
|
335
320
|
useStableFn,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoOnce.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/useStableFn.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nexport const createSlotComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n } & P\n >(({ as, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : (as as T) || element;\n\n return <Comp ref={ref} {...props} />;\n });\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Box = createSlotComponent('div');\n\nexport type BoxProps = React.ComponentPropsWithRef<typeof Box>;\n","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n","import React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return (<>{children}</>) as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","import React from 'react';\n\nimport { isDefined } from '@udecode/utils';\nimport { clsx } from 'clsx';\n\nimport { createSlotComponent } from './createSlotComponent';\nimport { useComposedRef } from './useComposedRef';\n\n/**\n * Primitive component factory. It uses hooks for managing state and props, and\n * forwards references to child components. Component props:\n *\n * - `asChild`: If true, the component will be rendered as a `Slot`\n * {@link https://www.radix-ui.com/docs/primitives/utilities/slot}.\n * - `options`: Options passed to the state hook.\n * - `state`: Provide your state instead of using the state hook.\n * - `className`: Class name to be merged to the component.\n * - `style`: Style object to be merged to the component.\n * - `setProps`: Function to set props from the props hook.\n * - `...props`: Props to be passed to the component. Props hook return value:\n * - `ref`: Reference to be forwarded to the component.\n * - `props`: Props to be passed to the component.\n * - `hidden`: If true, the component will not be rendered.\n *\n * @example\n * const MyButton = createPrimitiveComponent(Button)({\n * stateHook: useButtonState,\n * propsHook: useButton,\n * });\n *\n * @param {React.ElementType} element The base component or native HTML element.\n * @returns {function} A primitive component.\n */\nexport const createPrimitiveComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) => {\n const Comp = createSlotComponent<T, P>(element);\n\n return <SH extends (options: any) => any, PH extends (state: any) => any>({\n propsHook,\n stateHook,\n }: {\n propsHook?: PH;\n stateHook?: SH;\n } = {}) => {\n return React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n className?: string;\n options?: Parameters<SH>[0];\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\n setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n } & P\n >(\n (\n {\n asChild,\n className: classNameProp,\n getClassName,\n options,\n state: stateProp,\n ...props\n },\n ref\n ) => {\n const state = isDefined(stateProp)\n ? stateProp\n : stateHook\n ? stateHook(options as any)\n : undefined;\n const {\n hidden,\n props: hookProps,\n ref: hookRef,\n } = propsHook\n ? propsHook(state)\n : { hidden: false, props: {}, ref: null };\n\n const _ref = useComposedRef(ref, hookRef);\n const className =\n isDefined(hookProps?.className) || isDefined(classNameProp)\n ? clsx(hookProps?.className, classNameProp)\n : undefined;\n const style =\n hookProps?.style || props.style\n ? { ...hookProps?.style, ...props.style }\n : undefined;\n\n if (!asChild && hidden) return null;\n\n return (\n <Comp\n ref={_ref}\n asChild={asChild}\n {...hookProps}\n className={className}\n style={style}\n {...props}\n {...(props.setProps?.(hookProps ?? {}) ?? {})}\n />\n );\n }\n );\n };\n};\n","import React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value This utility takes care of different types\n * of refs: callback refs and React.RefObject(s)\n */\nconst setRef = <T>(ref: PossibleRef<T>, value: T) => {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.RefObject<T>).current = value;\n }\n};\n\n/**\n * A utility to compose multiple refs together Accepts callback refs and\n * React.RefObject(s)\n */\nexport const composeRefs =\n <T>(...refs: PossibleRef<T>[]) =>\n (node: T) => {\n const cleanups: ((() => void) | undefined)[] = [];\n\n refs.forEach((ref) => {\n const cleanup = setRef(ref, node);\n if (typeof cleanup === 'function') {\n cleanups.push(cleanup);\n }\n });\n\n // Return a cleanup function if any refs returned cleanup functions\n if (cleanups.length > 0) {\n return () => {\n cleanups.forEach((cleanup) => cleanup?.());\n };\n }\n };\n\n/**\n * A custom hook that composes multiple refs Accepts callback refs and\n * React.RefObject(s)\n */\nexport const useComposedRef = <T>(...refs: PossibleRef<T>[]) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n};\n","import React, { type JSX } from 'react';\n\nexport function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(\n tag: T\n) {\n return React.forwardRef<HTMLElementTagNameMap[T], JSX.IntrinsicElements[T]>(\n function CreateComponent(props, ref) {\n return React.createElement(tag, { ...props, ref });\n }\n );\n}\n","import React from 'react';\n\nexport function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\nexport function useMemoOnce<T>(\n factory: () => T,\n deps: React.DependencyList\n): T {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n const memoizedValueRef = React.useRef<T>(undefined);\n\n if (\n !initialized.current ||\n deps.some((dep, i) => dep !== prevDepsRef.current[i])\n ) {\n initialized.current = true;\n prevDepsRef.current = deps;\n memoizedValueRef.current = factory();\n }\n\n return memoizedValueRef.current!;\n}\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n get() {\n passive = true;\n },\n });\n const noop = () => null;\n\n window.addEventListener('test', noop, options);\n window.removeEventListener('test', noop, options);\n\n return passive;\n};\n\nexport const DEFAULT_IGNORE_CLASS = 'ignore-onclickoutside';\n\nexport type UseOnClickOutsideCallback<T extends Event = Event> = (\n event: T\n) => void;\n\nexport interface UseOnClickOutsideOptions {\n detectIFrame?: boolean;\n disabled?: boolean;\n eventTypes?: string[];\n excludeScrollbar?: boolean;\n ignoreClass?: string[] | string;\n refs?: Refs;\n}\n\nexport type UseOnClickOutsideReturn = (element: El | null) => void;\n\ntype El = HTMLElement;\n\ntype Refs = React.RefObject<El | null>[];\n\nconst checkClass = (el: HTMLElement, cl: string): boolean =>\n el.classList?.contains(cl);\n\nconst hasIgnoreClass = (e: any, ignoreClass: string[] | string): boolean => {\n let el = e.target || e;\n\n while (el) {\n if (Array.isArray(ignoreClass)) {\n if (ignoreClass.some((c) => checkClass(el, c))) return true;\n } else if (checkClass(el, ignoreClass)) {\n return true;\n }\n\n el = el.parentElement;\n }\n\n return false;\n};\n\nconst clickedOnScrollbar = (e: MouseEvent): boolean =>\n document.documentElement.clientWidth <= e.clientX ||\n document.documentElement.clientHeight <= e.clientY;\n\nconst getEventOptions = (type: string): { passive: boolean } | boolean =>\n type.includes('touch') && canUsePassiveEvents() ? { passive: true } : false;\n\nexport const useOnClickOutside = (\n callback: UseOnClickOutsideCallback,\n {\n detectIFrame = true,\n disabled,\n eventTypes = ['mousedown', 'touchstart'],\n excludeScrollbar,\n ignoreClass = DEFAULT_IGNORE_CLASS,\n refs: refsOpt,\n }: UseOnClickOutsideOptions = {}\n): UseOnClickOutsideReturn => {\n const [refsState, setRefsState] = React.useState<Refs>([]);\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n const ref: UseOnClickOutsideReturn = React.useCallback(\n (el) => setRefsState((prevState) => [...prevState, { current: el }]),\n []\n );\n\n React.useEffect(\n () => {\n if (!refsOpt?.length && refsState.length === 0) return;\n\n const getEls = () => {\n const els: El[] = [];\n (refsOpt || refsState).forEach(\n ({ current }) => current && els.push(current)\n );\n\n return els;\n };\n\n const handler = (e: any) => {\n if (\n !hasIgnoreClass(e, ignoreClass) &&\n !(excludeScrollbar && clickedOnScrollbar(e)) &&\n getEls().every((el) => !el.contains(e.target))\n )\n callbackRef.current(e);\n };\n\n const blurHandler = (e: FocusEvent) =>\n // On firefox the iframe becomes document.activeElement in the next event loop\n setTimeout(() => {\n const { activeElement } = document;\n\n if (\n activeElement?.tagName === 'IFRAME' &&\n !hasIgnoreClass(activeElement, ignoreClass) &&\n !getEls().includes(activeElement as HTMLIFrameElement)\n )\n callbackRef.current(e);\n }, 0);\n\n const removeEventListener = () => {\n eventTypes.forEach((type) =>\n document.removeEventListener(\n type,\n handler,\n getEventOptions(type) as any\n )\n );\n\n if (detectIFrame) window.removeEventListener('blur', blurHandler);\n };\n\n if (disabled) {\n removeEventListener();\n\n return;\n }\n\n eventTypes.forEach((type) =>\n document.addEventListener(type, handler, getEventOptions(type))\n );\n\n if (detectIFrame) window.addEventListener('blur', blurHandler);\n\n return () => removeEventListener();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n refsState,\n ignoreClass,\n excludeScrollbar,\n disabled,\n detectIFrame,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(eventTypes),\n ]\n );\n\n return ref;\n};\n","import React, { type DependencyList } from 'react';\n\n/**\n * Create a stable version of a function that can be used in dependency arrays\n * without causing hooks like useEffect to re-run if the function changes.\n * Calling the returned function always calls the most recent version of the\n * function that was passed to useStableFn.\n *\n * If you do want the function to be replaced when certain dependency values\n * change, include those values in the dependency array of useStableFn.\n */\nexport const useStableFn = <A extends unknown[], R>(\n fn: (...args: A) => R,\n deps: DependencyList = []\n) => {\n const fnRef = React.useRef(fn);\n fnRef.current = fn;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback((...args: A) => fnRef.current(...args), deps);\n};\n","import React from 'react';\n\nexport const useStableMemo = <T>(\n producer: () => T,\n deps?: React.DependencyList\n): T => {\n const [value, setValue] = React.useState(producer);\n\n React.useLayoutEffect(() => {\n setValue(producer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return value;\n};\n","import React from 'react';\n\n/**\n * Wrap a component into multiple providers. If there are any props that you\n * want a provider to receive, you can simply pass an array.\n */\nexport const withProviders =\n (...providers: any[]) =>\n <T,>(WrappedComponent: React.FC<T>) =>\n (props: T) =>\n providers.reduceRight(\n (acc, prov) => {\n let Provider = prov;\n\n if (Array.isArray(prov)) {\n [Provider] = prov;\n\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n\n return <Provider>{acc}</Provider>;\n },\n <WrappedComponent {...(props as any)} />\n );\n","import React, { type JSX } from 'react';\n\ntype ElementType<P = any> =\n | React.ComponentType<P>\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements];\n\ntype ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<T>\n>;\n\ntype InferElementRef<T> =\n T extends ElementType<any>\n ? T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<\n React.HTMLAttributes<infer R>,\n any\n >\n ? R\n : never\n : T extends React.ComponentType<any>\n ? T extends React.ComponentClass<any>\n ? InstanceType<T>\n : T extends React.ForwardRefExoticComponent<any>\n ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R>\n ? R\n : never\n : never\n : never\n : never;\n\n/**\n * Shorter alternative to `React.forwardRef`.\n *\n * @generic1 Component type or element type\n * @generic2 Extended prop types\n */\nexport function withRef<T extends ElementType, P = {}>(\n renderFunction: React.ForwardRefRenderFunction<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n >\n): ForwardRefComponent<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n> {\n return React.forwardRef(renderFunction as any) as any;\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAElB,SAAS,YAAY;AAEd,IAAM,sBAAsB,CAIjC,YAEA,MAAM,WAMJ,CAAC,EAAE,IAAI,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC5C,QAAM,OAAO,UAAU,OAAQ,MAAY;AAE3C,SAAO,oCAAC,QAAK,KAAW,GAAG,OAAO;AACpC,CAAC;;;AChBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,OAAOA,YAAW;AAEX,IAAM,mBAAmBA,OAAM;AAAA,EACpC,CAAC,EAAE,SAAS,MAAqC;AAC/C,WAAO,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAAA,EACrB;AACF;;;ACNA,OAAOC,YAAW;AAClB,OAAO,cAAc;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAQ,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAEpC,SAAO,SAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACHvC,IAAM,uBACX,CACE,sBACA,iBACA,EAAE,2BAA2B,KAAK,IAAI,CAAC,MAEzC,CAAC,UAAa;AACZ,yBAAuB,KAAK;AAE5B,MACE,6BAA6B,SAC7B,CAAE,MAA2B,kBAC7B;AACA,WAAO,kBAAkB,KAAK;AAAA,EAChC;AACF;;;AChBF,OAAO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QAAQ;AAAA,EAEnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,OAAOC,aAAW;AAMX,IAAM,gBACX,IAAI,cACJ,CAAK,qBACL,CAAC,UACC,UAAU;AAAA,EACR,CAAC,KAAK,SAAS;AACb,QAAI,WAAW;AAEf,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,OAAC,QAAQ,IAAI;AAEb,aAAO,gBAAAA,QAAA,cAAC,YAAU,GAAG,KAAK,CAAC,KAAI,GAAI;AAAA,IACrC;AAEA,WAAO,gBAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,gBAAAA,QAAA,cAAC,oBAAkB,GAAI,OAAe;AACxC;;;ACvBJ,OAAOC,aAAyB;AAwCzB,SAAS,QACd,gBAOA;AACA,SAAOA,QAAM,WAAW,cAAqB;AAC/C;","names":["React","React","React","React","React","React","React","React","React","React","React","React","React","React","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/useStableFn.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React from 'react';\n\nexport const createSlotComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n } & P\n >(({ as, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : (as as T) || element;\n\n return <Comp ref={ref} {...props} />;\n });\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Box = createSlotComponent('div');\n\nexport type BoxProps = React.ComponentPropsWithRef<typeof Box>;\n","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => <>{children}</>\n);\n","import type React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return children as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","import { isDefined } from '@udecode/utils';\nimport { clsx } from 'clsx';\nimport React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\nimport { useComposedRef } from './useComposedRef';\n\n/**\n * Primitive component factory. It uses hooks for managing state and props, and\n * forwards references to child components. Component props:\n *\n * - `asChild`: If true, the component will be rendered as a `Slot`\n * {@link https://www.radix-ui.com/docs/primitives/utilities/slot}.\n * - `options`: Options passed to the state hook.\n * - `state`: Provide your state instead of using the state hook.\n * - `className`: Class name to be merged to the component.\n * - `style`: Style object to be merged to the component.\n * - `setProps`: Function to set props from the props hook.\n * - `...props`: Props to be passed to the component. Props hook return value:\n * - `ref`: Reference to be forwarded to the component.\n * - `props`: Props to be passed to the component.\n * - `hidden`: If true, the component will not be rendered.\n *\n * @example\n * const MyButton = createPrimitiveComponent(Button)({\n * stateHook: useButtonState,\n * propsHook: useButton,\n * });\n *\n * @param {React.ElementType} element The base component or native HTML element.\n * @returns {function} A primitive component.\n */\nexport const createPrimitiveComponent = <\n T extends React.ElementType,\n P extends React.ComponentPropsWithoutRef<T>,\n>(\n element: T\n) => {\n const Comp = createSlotComponent<T, P>(element);\n\n return <SH extends (options: any) => any, PH extends (state: any) => any>({\n propsHook,\n stateHook,\n }: {\n propsHook?: PH;\n stateHook?: SH;\n } = {}) =>\n React.forwardRef<\n any,\n {\n as?: React.ElementType;\n asChild?: boolean;\n className?: string;\n options?: Parameters<SH>[0];\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\n setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n } & P\n >(\n (\n {\n asChild,\n className: classNameProp,\n getClassName,\n options,\n state: stateProp,\n ...props\n },\n ref\n ) => {\n const state = isDefined(stateProp)\n ? stateProp\n : stateHook\n ? stateHook(options as any)\n : undefined;\n const {\n hidden,\n props: hookProps,\n ref: hookRef,\n } = propsHook\n ? propsHook(state)\n : { hidden: false, props: {}, ref: null };\n\n const _ref = useComposedRef(ref, hookRef);\n const className =\n isDefined(hookProps?.className) || isDefined(classNameProp)\n ? clsx(hookProps?.className, classNameProp)\n : undefined;\n const style =\n hookProps?.style || props.style\n ? { ...hookProps?.style, ...props.style }\n : undefined;\n\n if (!asChild && hidden) return null;\n\n return (\n <Comp\n asChild={asChild}\n ref={_ref}\n {...hookProps}\n className={className}\n style={style}\n {...props}\n {...(props.setProps?.(hookProps ?? {}) ?? {})}\n />\n );\n }\n );\n};\n","import React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value This utility takes care of different types\n * of refs: callback refs and React.RefObject(s)\n */\nconst setRef = <T>(ref: PossibleRef<T>, value: T) => {\n if (typeof ref === 'function') {\n return ref(value);\n }\n if (ref !== null && ref !== undefined) {\n (ref as React.RefObject<T>).current = value;\n }\n};\n\n/**\n * A utility to compose multiple refs together Accepts callback refs and\n * React.RefObject(s)\n */\nexport const composeRefs =\n <T>(...refs: PossibleRef<T>[]) =>\n (node: T) => {\n const cleanups: ((() => void) | undefined)[] = [];\n\n refs.forEach((ref) => {\n const cleanup = setRef(ref, node);\n if (typeof cleanup === 'function') {\n cleanups.push(cleanup);\n }\n });\n\n // Return a cleanup function if any refs returned cleanup functions\n if (cleanups.length > 0) {\n return () => {\n for (const cleanup of cleanups) {\n cleanup?.();\n }\n };\n }\n };\n\n/**\n * A custom hook that composes multiple refs Accepts callback refs and\n * React.RefObject(s)\n */\nexport const useComposedRef = <T>(...refs: PossibleRef<T>[]) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n};\n","import React, { type JSX } from 'react';\n\nexport function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(\n tag: T\n) {\n return React.forwardRef<HTMLElementTagNameMap[T], JSX.IntrinsicElements[T]>(\n function CreateComponent(props, ref) {\n return React.createElement(tag, { ...props, ref });\n }\n );\n}\n","import React from 'react';\n\nexport function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n get() {\n passive = true;\n },\n });\n const noop = () => null;\n\n window.addEventListener('test', noop, options);\n window.removeEventListener('test', noop, options);\n\n return passive;\n};\n\nexport const DEFAULT_IGNORE_CLASS = 'ignore-onclickoutside';\n\nexport type UseOnClickOutsideCallback<T extends Event = Event> = (\n event: T\n) => void;\n\nexport type UseOnClickOutsideOptions = {\n detectIFrame?: boolean;\n disabled?: boolean;\n eventTypes?: string[];\n excludeScrollbar?: boolean;\n ignoreClass?: string[] | string;\n refs?: Refs;\n};\n\nexport type UseOnClickOutsideReturn = (element: El | null) => void;\n\ntype El = HTMLElement;\n\ntype Refs = React.RefObject<El | null>[];\n\nconst checkClass = (el: HTMLElement, cl: string): boolean =>\n el.classList?.contains(cl);\n\nconst hasIgnoreClass = (e: any, ignoreClass: string[] | string): boolean => {\n let el = e.target || e;\n\n while (el) {\n if (Array.isArray(ignoreClass)) {\n if (ignoreClass.some((c) => checkClass(el, c))) return true;\n } else if (checkClass(el, ignoreClass)) {\n return true;\n }\n\n el = el.parentElement;\n }\n\n return false;\n};\n\nconst clickedOnScrollbar = (e: MouseEvent): boolean =>\n document.documentElement.clientWidth <= e.clientX ||\n document.documentElement.clientHeight <= e.clientY;\n\nconst getEventOptions = (type: string): { passive: boolean } | boolean =>\n type.includes('touch') && canUsePassiveEvents() ? { passive: true } : false;\n\nexport const useOnClickOutside = (\n callback: UseOnClickOutsideCallback,\n {\n detectIFrame = true,\n disabled,\n eventTypes = ['mousedown', 'touchstart'],\n excludeScrollbar,\n ignoreClass = DEFAULT_IGNORE_CLASS,\n refs: refsOpt,\n }: UseOnClickOutsideOptions = {}\n): UseOnClickOutsideReturn => {\n const [refsState, setRefsState] = React.useState<Refs>([]);\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n const ref: UseOnClickOutsideReturn = React.useCallback(\n (el) => setRefsState((prevState) => [...prevState, { current: el }]),\n []\n );\n\n React.useEffect(\n () => {\n if (!refsOpt?.length && refsState.length === 0) return;\n\n const getEls = () => {\n const els: El[] = [];\n for (const { current } of refsOpt || refsState) {\n if (current) {\n els.push(current);\n }\n }\n\n return els;\n };\n\n const handler = (e: any) => {\n if (\n !hasIgnoreClass(e, ignoreClass) &&\n !(excludeScrollbar && clickedOnScrollbar(e)) &&\n getEls().every((el) => !el.contains(e.target))\n )\n callbackRef.current(e);\n };\n\n const blurHandler = (e: FocusEvent) =>\n // On firefox the iframe becomes document.activeElement in the next event loop\n setTimeout(() => {\n const { activeElement } = document;\n\n if (\n activeElement?.tagName === 'IFRAME' &&\n !hasIgnoreClass(activeElement, ignoreClass) &&\n !getEls().includes(activeElement as HTMLIFrameElement)\n )\n callbackRef.current(e);\n }, 0);\n\n const removeEventListener = () => {\n for (const type of eventTypes) {\n document.removeEventListener(\n type,\n handler,\n getEventOptions(type) as any\n );\n }\n\n if (detectIFrame) window.removeEventListener('blur', blurHandler);\n };\n\n if (disabled) {\n removeEventListener();\n\n return;\n }\n\n for (const type of eventTypes) {\n document.addEventListener(type, handler, getEventOptions(type));\n }\n\n if (detectIFrame) window.addEventListener('blur', blurHandler);\n\n return () => removeEventListener();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n refsState,\n ignoreClass,\n excludeScrollbar,\n disabled,\n detectIFrame,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(eventTypes),\n ]\n );\n\n return ref;\n};\n","import React, { type DependencyList } from 'react';\n\n/**\n * Create a stable version of a function that can be used in dependency arrays\n * without causing hooks like useEffect to re-run if the function changes.\n * Calling the returned function always calls the most recent version of the\n * function that was passed to useStableFn.\n *\n * If you do want the function to be replaced when certain dependency values\n * change, include those values in the dependency array of useStableFn.\n */\nexport const useStableFn = <A extends unknown[], R>(\n fn: (...args: A) => R,\n deps: DependencyList = []\n) => {\n const fnRef = React.useRef(fn);\n fnRef.current = fn;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback((...args: A) => fnRef.current(...args), deps);\n};\n","import React from 'react';\n\nexport const useStableMemo = <T>(\n producer: () => T,\n deps?: React.DependencyList\n): T => {\n const [value, setValue] = React.useState(producer);\n\n React.useLayoutEffect(() => {\n setValue(producer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return value;\n};\n","/** biome-ignore-all lint/correctness/useJsxKeyInIterable: biome */\nimport React from 'react';\n\n/**\n * Wrap a component into multiple providers. If there are any props that you\n * want a provider to receive, you can simply pass an array.\n */\nexport const withProviders =\n (...providers: any[]) =>\n <T,>(WrappedComponent: React.FC<T>) =>\n (props: T) =>\n providers.reduceRight(\n (acc, prov) => {\n let Provider = prov;\n\n if (Array.isArray(prov)) {\n [Provider] = prov;\n\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n\n return <Provider>{acc}</Provider>;\n },\n <WrappedComponent {...(props as any)} />\n );\n","import React, { type JSX } from 'react';\n\ntype ElementType<P = any> =\n | React.ComponentType<P>\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements];\n\ntype ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<T>\n>;\n\ntype InferElementRef<T> = T extends ElementType<any>\n ? T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<\n React.HTMLAttributes<infer R>,\n any\n >\n ? R\n : never\n : T extends React.ComponentType<any>\n ? T extends React.ComponentClass<any>\n ? InstanceType<T>\n : T extends React.ForwardRefExoticComponent<any>\n ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R>\n ? R\n : never\n : never\n : never\n : never;\n\n/**\n * Shorter alternative to `React.forwardRef`.\n *\n * @generic1 Component type or element type\n * @generic2 Extended prop types\n */\nexport function withRef<T extends ElementType, P = {}>(\n renderFunction: React.ForwardRefRenderFunction<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n >\n): ForwardRefComponent<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n> {\n return React.forwardRef(renderFunction as any) as any;\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,OAAO,WAAW;AAEX,IAAM,sBAAsB,CAIjC,YAEA,MAAM,WAMJ,CAAC,EAAE,IAAI,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC5C,QAAM,OAAO,UAAU,OAAQ,MAAY;AAE3C,SAAO,oCAAC,QAAK,KAAW,GAAG,OAAO;AACpC,CAAC;;;ACfI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,OAAOA,YAAW;AAEX,IAAM,mBAAmBA,OAAM;AAAA,EACpC,CAAC,EAAE,SAAS,MAAqC,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAC/D;;;ACHA,OAAO,cAAc;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,SA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IAAM,gBACX,IAAI,cACJ,CAAK,qBACL,CAAC,UACC,UAAU;AAAA,EACR,CAAC,KAAK,SAAS;AACb,QAAI,WAAW;AAEf,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,OAAC,QAAQ,IAAI;AAEb,aAAO,gBAAAA,QAAA,cAAC,YAAU,GAAG,KAAK,CAAC,KAAI,GAAI;AAAA,IACrC;AAEA,WAAO,gBAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,gBAAAA,QAAA,cAAC,oBAAkB,GAAI,OAAe;AACxC;;;ACxBJ,OAAOC,aAAyB;AAuCzB,SAAS,QACd,gBAOA;AACA,SAAOA,QAAM,WAAW,cAAqB;AAC/C;","names":["React","React","React","React","React","React","React","React","React","React","React","React","React"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udecode/react-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "51.1.2",
|
|
4
4
|
"description": "React utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utils"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@radix-ui/react-slot": "^1.2.3",
|
|
45
|
-
"@udecode/utils": "
|
|
45
|
+
"@udecode/utils": "51.1.2",
|
|
46
46
|
"clsx": "^2.1.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|