@udecode/react-utils 49.0.13 → 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 +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +97 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -102
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -77,12 +77,12 @@ type PossibleRef<T> = React.Ref<T> | undefined;
|
|
|
77
77
|
* A utility to compose multiple refs together Accepts callback refs and
|
|
78
78
|
* React.RefObject(s)
|
|
79
79
|
*/
|
|
80
|
-
declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => () => void;
|
|
80
|
+
declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => (() => void) | undefined;
|
|
81
81
|
/**
|
|
82
82
|
* A custom hook that composes multiple refs Accepts callback refs and
|
|
83
83
|
* React.RefObject(s)
|
|
84
84
|
*/
|
|
85
|
-
declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => () => void;
|
|
85
|
+
declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => (() => void) | undefined;
|
|
86
86
|
|
|
87
87
|
declare function useEffectOnce(effect: React.EffectCallback, deps: React.DependencyList): void;
|
|
88
88
|
|
|
@@ -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
|
@@ -77,12 +77,12 @@ type PossibleRef<T> = React.Ref<T> | undefined;
|
|
|
77
77
|
* A utility to compose multiple refs together Accepts callback refs and
|
|
78
78
|
* React.RefObject(s)
|
|
79
79
|
*/
|
|
80
|
-
declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => () => void;
|
|
80
|
+
declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => (() => void) | undefined;
|
|
81
81
|
/**
|
|
82
82
|
* A custom hook that composes multiple refs Accepts callback refs and
|
|
83
83
|
* React.RefObject(s)
|
|
84
84
|
*/
|
|
85
|
-
declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => () => void;
|
|
85
|
+
declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => (() => void) | undefined;
|
|
86
86
|
|
|
87
87
|
declare function useEffectOnce(effect: React.EffectCallback, deps: React.DependencyList): void;
|
|
88
88
|
|
|
@@ -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,25 +93,38 @@ 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
|
};
|
|
113
110
|
var composeRefs = (...refs) => (node) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
111
|
+
const cleanups = [];
|
|
112
|
+
refs.forEach((ref) => {
|
|
113
|
+
const cleanup = setRef(ref, node);
|
|
114
|
+
if (typeof cleanup === "function") {
|
|
115
|
+
cleanups.push(cleanup);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
if (cleanups.length > 0) {
|
|
119
|
+
return () => {
|
|
120
|
+
for (const cleanup of cleanups) {
|
|
121
|
+
cleanup?.();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
116
125
|
};
|
|
117
126
|
var useComposedRef = (...refs) => {
|
|
118
|
-
return
|
|
127
|
+
return import_react3.default.useCallback(composeRefs(...refs), refs);
|
|
119
128
|
};
|
|
120
129
|
|
|
121
130
|
// src/createPrimitiveComponent.tsx
|
|
@@ -124,59 +133,57 @@ var createPrimitiveComponent = (element) => {
|
|
|
124
133
|
return ({
|
|
125
134
|
propsHook,
|
|
126
135
|
stateHook
|
|
127
|
-
} = {}) =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
};
|
|
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
|
+
);
|
|
162
169
|
};
|
|
163
170
|
|
|
164
171
|
// src/createPrimitiveElement.tsx
|
|
165
|
-
var
|
|
172
|
+
var import_react5 = __toESM(require("react"));
|
|
166
173
|
function createPrimitiveElement(tag) {
|
|
167
|
-
return
|
|
174
|
+
return import_react5.default.forwardRef(
|
|
168
175
|
function CreateComponent(props, ref) {
|
|
169
|
-
return
|
|
176
|
+
return import_react5.default.createElement(tag, { ...props, ref });
|
|
170
177
|
}
|
|
171
178
|
);
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
// src/useEffectOnce.ts
|
|
175
|
-
var
|
|
182
|
+
var import_react6 = __toESM(require("react"));
|
|
176
183
|
function useEffectOnce(effect, deps) {
|
|
177
|
-
const initialized =
|
|
178
|
-
const prevDepsRef =
|
|
179
|
-
|
|
184
|
+
const initialized = import_react6.default.useRef(false);
|
|
185
|
+
const prevDepsRef = import_react6.default.useRef(deps);
|
|
186
|
+
import_react6.default.useEffect(() => {
|
|
180
187
|
const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
|
|
181
188
|
if (!initialized.current || depsChanged) {
|
|
182
189
|
initialized.current = true;
|
|
@@ -187,30 +194,16 @@ function useEffectOnce(effect, deps) {
|
|
|
187
194
|
}
|
|
188
195
|
|
|
189
196
|
// src/useIsomorphicLayoutEffect.ts
|
|
190
|
-
var
|
|
197
|
+
var import_react7 = __toESM(require("react"));
|
|
191
198
|
var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
|
|
192
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
193
|
-
|
|
194
|
-
// src/useMemoOnce.ts
|
|
195
|
-
var import_react9 = __toESM(require("react"));
|
|
196
|
-
function useMemoOnce(factory, deps) {
|
|
197
|
-
const initialized = import_react9.default.useRef(false);
|
|
198
|
-
const prevDepsRef = import_react9.default.useRef(deps);
|
|
199
|
-
const memoizedValueRef = import_react9.default.useRef(void 0);
|
|
200
|
-
if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
|
|
201
|
-
initialized.current = true;
|
|
202
|
-
prevDepsRef.current = deps;
|
|
203
|
-
memoizedValueRef.current = factory();
|
|
204
|
-
}
|
|
205
|
-
return memoizedValueRef.current;
|
|
206
|
-
}
|
|
199
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? import_react7.default.useLayoutEffect : import_react7.default.useEffect;
|
|
207
200
|
|
|
208
201
|
// src/useMemoizedSelector.ts
|
|
209
|
-
var
|
|
202
|
+
var import_react8 = __toESM(require("react"));
|
|
210
203
|
function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
211
|
-
const [memoizedValue, setMemoizedValue] =
|
|
212
|
-
const previousValueRef =
|
|
213
|
-
|
|
204
|
+
const [memoizedValue, setMemoizedValue] = import_react8.default.useState(() => selector());
|
|
205
|
+
const previousValueRef = import_react8.default.useRef(memoizedValue);
|
|
206
|
+
import_react8.default.useEffect(() => {
|
|
214
207
|
const newValue = selector();
|
|
215
208
|
if (!equalityFn(previousValueRef.current, newValue)) {
|
|
216
209
|
setMemoizedValue(newValue);
|
|
@@ -221,7 +214,7 @@ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
|
221
214
|
}
|
|
222
215
|
|
|
223
216
|
// src/useOnClickOutside.ts
|
|
224
|
-
var
|
|
217
|
+
var import_react9 = __toESM(require("react"));
|
|
225
218
|
var canUsePassiveEvents = () => {
|
|
226
219
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
227
220
|
return false;
|
|
@@ -260,21 +253,23 @@ var useOnClickOutside = (callback, {
|
|
|
260
253
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
261
254
|
refs: refsOpt
|
|
262
255
|
} = {}) => {
|
|
263
|
-
const [refsState, setRefsState] =
|
|
264
|
-
const callbackRef =
|
|
256
|
+
const [refsState, setRefsState] = import_react9.default.useState([]);
|
|
257
|
+
const callbackRef = import_react9.default.useRef(callback);
|
|
265
258
|
callbackRef.current = callback;
|
|
266
|
-
const ref =
|
|
259
|
+
const ref = import_react9.default.useCallback(
|
|
267
260
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
268
261
|
[]
|
|
269
262
|
);
|
|
270
|
-
|
|
263
|
+
import_react9.default.useEffect(
|
|
271
264
|
() => {
|
|
272
265
|
if (!refsOpt?.length && refsState.length === 0) return;
|
|
273
266
|
const getEls = () => {
|
|
274
267
|
const els = [];
|
|
275
|
-
(refsOpt || refsState)
|
|
276
|
-
(
|
|
277
|
-
|
|
268
|
+
for (const { current } of refsOpt || refsState) {
|
|
269
|
+
if (current) {
|
|
270
|
+
els.push(current);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
278
273
|
return els;
|
|
279
274
|
};
|
|
280
275
|
const handler = (e) => {
|
|
@@ -290,22 +285,22 @@ var useOnClickOutside = (callback, {
|
|
|
290
285
|
}, 0)
|
|
291
286
|
);
|
|
292
287
|
const removeEventListener = () => {
|
|
293
|
-
eventTypes
|
|
294
|
-
|
|
288
|
+
for (const type of eventTypes) {
|
|
289
|
+
document.removeEventListener(
|
|
295
290
|
type,
|
|
296
291
|
handler,
|
|
297
292
|
getEventOptions(type)
|
|
298
|
-
)
|
|
299
|
-
|
|
293
|
+
);
|
|
294
|
+
}
|
|
300
295
|
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
301
296
|
};
|
|
302
297
|
if (disabled) {
|
|
303
298
|
removeEventListener();
|
|
304
299
|
return;
|
|
305
300
|
}
|
|
306
|
-
eventTypes
|
|
307
|
-
|
|
308
|
-
|
|
301
|
+
for (const type of eventTypes) {
|
|
302
|
+
document.addEventListener(type, handler, getEventOptions(type));
|
|
303
|
+
}
|
|
309
304
|
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
310
305
|
return () => removeEventListener();
|
|
311
306
|
},
|
|
@@ -324,41 +319,41 @@ var useOnClickOutside = (callback, {
|
|
|
324
319
|
};
|
|
325
320
|
|
|
326
321
|
// src/useStableFn.ts
|
|
327
|
-
var
|
|
322
|
+
var import_react10 = __toESM(require("react"));
|
|
328
323
|
var useStableFn = (fn, deps = []) => {
|
|
329
|
-
const fnRef =
|
|
324
|
+
const fnRef = import_react10.default.useRef(fn);
|
|
330
325
|
fnRef.current = fn;
|
|
331
|
-
return
|
|
326
|
+
return import_react10.default.useCallback((...args) => fnRef.current(...args), deps);
|
|
332
327
|
};
|
|
333
328
|
|
|
334
329
|
// src/useStableMemo.ts
|
|
335
|
-
var
|
|
330
|
+
var import_react11 = __toESM(require("react"));
|
|
336
331
|
var useStableMemo = (producer, deps) => {
|
|
337
|
-
const [value, setValue] =
|
|
338
|
-
|
|
332
|
+
const [value, setValue] = import_react11.default.useState(producer);
|
|
333
|
+
import_react11.default.useLayoutEffect(() => {
|
|
339
334
|
setValue(producer);
|
|
340
335
|
}, deps);
|
|
341
336
|
return value;
|
|
342
337
|
};
|
|
343
338
|
|
|
344
339
|
// src/withProviders.tsx
|
|
345
|
-
var
|
|
340
|
+
var import_react12 = __toESM(require("react"));
|
|
346
341
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
347
342
|
(acc, prov) => {
|
|
348
343
|
let Provider = prov;
|
|
349
344
|
if (Array.isArray(prov)) {
|
|
350
345
|
[Provider] = prov;
|
|
351
|
-
return /* @__PURE__ */
|
|
346
|
+
return /* @__PURE__ */ import_react12.default.createElement(Provider, { ...prov[1] }, acc);
|
|
352
347
|
}
|
|
353
|
-
return /* @__PURE__ */
|
|
348
|
+
return /* @__PURE__ */ import_react12.default.createElement(Provider, null, acc);
|
|
354
349
|
},
|
|
355
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ import_react12.default.createElement(WrappedComponent, { ...props })
|
|
356
351
|
);
|
|
357
352
|
|
|
358
353
|
// src/withRef.tsx
|
|
359
|
-
var
|
|
354
|
+
var import_react13 = __toESM(require("react"));
|
|
360
355
|
function withRef(renderFunction) {
|
|
361
|
-
return
|
|
356
|
+
return import_react13.default.forwardRef(renderFunction);
|
|
362
357
|
}
|
|
363
358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
364
359
|
0 && (module.exports = {
|
|
@@ -376,7 +371,6 @@ function withRef(renderFunction) {
|
|
|
376
371
|
useComposedRef,
|
|
377
372
|
useEffectOnce,
|
|
378
373
|
useIsomorphicLayoutEffect,
|
|
379
|
-
useMemoOnce,
|
|
380
374
|
useMemoizedSelector,
|
|
381
375
|
useOnClickOutside,
|
|
382
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 unrefs = refs.map((ref) => setRef(ref, node)).filter(unref => unref !== undefined);\n return () => unrefs.forEach(unref => unref());\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,CAAC,UAAa;AACZ,yBAAuB,KAAK;AAE5B,MACE,6BAA6B,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AI,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;AA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AAS,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,25 +38,38 @@ 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
|
};
|
|
57
55
|
var composeRefs = (...refs) => (node) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
56
|
+
const cleanups = [];
|
|
57
|
+
refs.forEach((ref) => {
|
|
58
|
+
const cleanup = setRef(ref, node);
|
|
59
|
+
if (typeof cleanup === "function") {
|
|
60
|
+
cleanups.push(cleanup);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (cleanups.length > 0) {
|
|
64
|
+
return () => {
|
|
65
|
+
for (const cleanup of cleanups) {
|
|
66
|
+
cleanup?.();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
60
70
|
};
|
|
61
71
|
var useComposedRef = (...refs) => {
|
|
62
|
-
return
|
|
72
|
+
return React3.useCallback(composeRefs(...refs), refs);
|
|
63
73
|
};
|
|
64
74
|
|
|
65
75
|
// src/createPrimitiveComponent.tsx
|
|
@@ -68,59 +78,57 @@ var createPrimitiveComponent = (element) => {
|
|
|
68
78
|
return ({
|
|
69
79
|
propsHook,
|
|
70
80
|
stateHook
|
|
71
|
-
} = {}) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
};
|
|
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
|
+
);
|
|
106
114
|
};
|
|
107
115
|
|
|
108
116
|
// src/createPrimitiveElement.tsx
|
|
109
|
-
import
|
|
117
|
+
import React5 from "react";
|
|
110
118
|
function createPrimitiveElement(tag) {
|
|
111
|
-
return
|
|
119
|
+
return React5.forwardRef(
|
|
112
120
|
function CreateComponent(props, ref) {
|
|
113
|
-
return
|
|
121
|
+
return React5.createElement(tag, { ...props, ref });
|
|
114
122
|
}
|
|
115
123
|
);
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
// src/useEffectOnce.ts
|
|
119
|
-
import
|
|
127
|
+
import React6 from "react";
|
|
120
128
|
function useEffectOnce(effect, deps) {
|
|
121
|
-
const initialized =
|
|
122
|
-
const prevDepsRef =
|
|
123
|
-
|
|
129
|
+
const initialized = React6.useRef(false);
|
|
130
|
+
const prevDepsRef = React6.useRef(deps);
|
|
131
|
+
React6.useEffect(() => {
|
|
124
132
|
const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
|
|
125
133
|
if (!initialized.current || depsChanged) {
|
|
126
134
|
initialized.current = true;
|
|
@@ -131,30 +139,16 @@ function useEffectOnce(effect, deps) {
|
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
// src/useIsomorphicLayoutEffect.ts
|
|
134
|
-
import
|
|
142
|
+
import React7 from "react";
|
|
135
143
|
var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
|
|
136
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
137
|
-
|
|
138
|
-
// src/useMemoOnce.ts
|
|
139
|
-
import React9 from "react";
|
|
140
|
-
function useMemoOnce(factory, deps) {
|
|
141
|
-
const initialized = React9.useRef(false);
|
|
142
|
-
const prevDepsRef = React9.useRef(deps);
|
|
143
|
-
const memoizedValueRef = React9.useRef(void 0);
|
|
144
|
-
if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
|
|
145
|
-
initialized.current = true;
|
|
146
|
-
prevDepsRef.current = deps;
|
|
147
|
-
memoizedValueRef.current = factory();
|
|
148
|
-
}
|
|
149
|
-
return memoizedValueRef.current;
|
|
150
|
-
}
|
|
144
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? React7.useLayoutEffect : React7.useEffect;
|
|
151
145
|
|
|
152
146
|
// src/useMemoizedSelector.ts
|
|
153
|
-
import
|
|
147
|
+
import React8 from "react";
|
|
154
148
|
function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
155
|
-
const [memoizedValue, setMemoizedValue] =
|
|
156
|
-
const previousValueRef =
|
|
157
|
-
|
|
149
|
+
const [memoizedValue, setMemoizedValue] = React8.useState(() => selector());
|
|
150
|
+
const previousValueRef = React8.useRef(memoizedValue);
|
|
151
|
+
React8.useEffect(() => {
|
|
158
152
|
const newValue = selector();
|
|
159
153
|
if (!equalityFn(previousValueRef.current, newValue)) {
|
|
160
154
|
setMemoizedValue(newValue);
|
|
@@ -165,7 +159,7 @@ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
|
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
// src/useOnClickOutside.ts
|
|
168
|
-
import
|
|
162
|
+
import React9 from "react";
|
|
169
163
|
var canUsePassiveEvents = () => {
|
|
170
164
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
171
165
|
return false;
|
|
@@ -204,21 +198,23 @@ var useOnClickOutside = (callback, {
|
|
|
204
198
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
205
199
|
refs: refsOpt
|
|
206
200
|
} = {}) => {
|
|
207
|
-
const [refsState, setRefsState] =
|
|
208
|
-
const callbackRef =
|
|
201
|
+
const [refsState, setRefsState] = React9.useState([]);
|
|
202
|
+
const callbackRef = React9.useRef(callback);
|
|
209
203
|
callbackRef.current = callback;
|
|
210
|
-
const ref =
|
|
204
|
+
const ref = React9.useCallback(
|
|
211
205
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
212
206
|
[]
|
|
213
207
|
);
|
|
214
|
-
|
|
208
|
+
React9.useEffect(
|
|
215
209
|
() => {
|
|
216
210
|
if (!refsOpt?.length && refsState.length === 0) return;
|
|
217
211
|
const getEls = () => {
|
|
218
212
|
const els = [];
|
|
219
|
-
(refsOpt || refsState)
|
|
220
|
-
(
|
|
221
|
-
|
|
213
|
+
for (const { current } of refsOpt || refsState) {
|
|
214
|
+
if (current) {
|
|
215
|
+
els.push(current);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
222
218
|
return els;
|
|
223
219
|
};
|
|
224
220
|
const handler = (e) => {
|
|
@@ -234,22 +230,22 @@ var useOnClickOutside = (callback, {
|
|
|
234
230
|
}, 0)
|
|
235
231
|
);
|
|
236
232
|
const removeEventListener = () => {
|
|
237
|
-
eventTypes
|
|
238
|
-
|
|
233
|
+
for (const type of eventTypes) {
|
|
234
|
+
document.removeEventListener(
|
|
239
235
|
type,
|
|
240
236
|
handler,
|
|
241
237
|
getEventOptions(type)
|
|
242
|
-
)
|
|
243
|
-
|
|
238
|
+
);
|
|
239
|
+
}
|
|
244
240
|
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
245
241
|
};
|
|
246
242
|
if (disabled) {
|
|
247
243
|
removeEventListener();
|
|
248
244
|
return;
|
|
249
245
|
}
|
|
250
|
-
eventTypes
|
|
251
|
-
|
|
252
|
-
|
|
246
|
+
for (const type of eventTypes) {
|
|
247
|
+
document.addEventListener(type, handler, getEventOptions(type));
|
|
248
|
+
}
|
|
253
249
|
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
254
250
|
return () => removeEventListener();
|
|
255
251
|
},
|
|
@@ -268,41 +264,41 @@ var useOnClickOutside = (callback, {
|
|
|
268
264
|
};
|
|
269
265
|
|
|
270
266
|
// src/useStableFn.ts
|
|
271
|
-
import
|
|
267
|
+
import React10 from "react";
|
|
272
268
|
var useStableFn = (fn, deps = []) => {
|
|
273
|
-
const fnRef =
|
|
269
|
+
const fnRef = React10.useRef(fn);
|
|
274
270
|
fnRef.current = fn;
|
|
275
|
-
return
|
|
271
|
+
return React10.useCallback((...args) => fnRef.current(...args), deps);
|
|
276
272
|
};
|
|
277
273
|
|
|
278
274
|
// src/useStableMemo.ts
|
|
279
|
-
import
|
|
275
|
+
import React11 from "react";
|
|
280
276
|
var useStableMemo = (producer, deps) => {
|
|
281
|
-
const [value, setValue] =
|
|
282
|
-
|
|
277
|
+
const [value, setValue] = React11.useState(producer);
|
|
278
|
+
React11.useLayoutEffect(() => {
|
|
283
279
|
setValue(producer);
|
|
284
280
|
}, deps);
|
|
285
281
|
return value;
|
|
286
282
|
};
|
|
287
283
|
|
|
288
284
|
// src/withProviders.tsx
|
|
289
|
-
import
|
|
285
|
+
import React12 from "react";
|
|
290
286
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
291
287
|
(acc, prov) => {
|
|
292
288
|
let Provider = prov;
|
|
293
289
|
if (Array.isArray(prov)) {
|
|
294
290
|
[Provider] = prov;
|
|
295
|
-
return /* @__PURE__ */
|
|
291
|
+
return /* @__PURE__ */ React12.createElement(Provider, { ...prov[1] }, acc);
|
|
296
292
|
}
|
|
297
|
-
return /* @__PURE__ */
|
|
293
|
+
return /* @__PURE__ */ React12.createElement(Provider, null, acc);
|
|
298
294
|
},
|
|
299
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ React12.createElement(WrappedComponent, { ...props })
|
|
300
296
|
);
|
|
301
297
|
|
|
302
298
|
// src/withRef.tsx
|
|
303
|
-
import
|
|
299
|
+
import React13 from "react";
|
|
304
300
|
function withRef(renderFunction) {
|
|
305
|
-
return
|
|
301
|
+
return React13.forwardRef(renderFunction);
|
|
306
302
|
}
|
|
307
303
|
export {
|
|
308
304
|
Box,
|
|
@@ -319,7 +315,6 @@ export {
|
|
|
319
315
|
useComposedRef,
|
|
320
316
|
useEffectOnce,
|
|
321
317
|
useIsomorphicLayoutEffect,
|
|
322
|
-
useMemoOnce,
|
|
323
318
|
useMemoizedSelector,
|
|
324
319
|
useOnClickOutside,
|
|
325
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 unrefs = refs.map((ref) => setRef(ref, node)).filter(unref => unref !== undefined);\n return () => unrefs.forEach(unref => unref());\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): Forw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;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,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,SAAS,iBAAiB;AAC1B,SAAS,YAAY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,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": {
|