@udecode/react-utils 37.0.0 → 39.0.0
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 +30 -21
- package/dist/index.d.ts +30 -21
- package/dist/index.js +42 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
declare const Box: React.ForwardRefExoticComponent<{
|
|
4
|
-
as?: React.ElementType
|
|
5
|
-
asChild?: boolean
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
asChild?: boolean;
|
|
6
6
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>>;
|
|
7
7
|
type BoxProps = React.ComponentPropsWithRef<typeof Box>;
|
|
8
8
|
|
|
@@ -13,13 +13,17 @@ type PortalBodyProps = {
|
|
|
13
13
|
declare const PortalBody: ({ children, element, }: PortalBodyProps) => React.ReactPortal;
|
|
14
14
|
|
|
15
15
|
declare const Text: React.ForwardRefExoticComponent<{
|
|
16
|
-
as?: React.ElementType
|
|
17
|
-
asChild?: boolean
|
|
16
|
+
as?: React.ElementType;
|
|
17
|
+
asChild?: boolean;
|
|
18
18
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<any>>;
|
|
19
19
|
type TextProps = React.ComponentPropsWithRef<typeof Text>;
|
|
20
20
|
|
|
21
|
+
declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}) => React.JSX.Element>;
|
|
24
|
+
|
|
21
25
|
/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */
|
|
22
|
-
declare const composeEventHandlers: <E>(originalEventHandler?: (
|
|
26
|
+
declare const composeEventHandlers: <E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
23
27
|
checkForDefaultPrevented?: boolean | undefined;
|
|
24
28
|
}) => (event: E) => void;
|
|
25
29
|
|
|
@@ -48,24 +52,24 @@ declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => vo
|
|
|
48
52
|
* @param {React.ElementType} element The base component or native HTML element.
|
|
49
53
|
* @returns {function} A primitive component.
|
|
50
54
|
*/
|
|
51
|
-
declare const createPrimitiveComponent: <T extends React.ElementType
|
|
52
|
-
propsHook?: PH
|
|
53
|
-
stateHook?: SH
|
|
55
|
+
declare const createPrimitiveComponent: <T extends React.ElementType, P extends React.ComponentPropsWithoutRef<T>>(element: T) => <SH extends (options: any) => any, PH extends (state: any) => any>({ propsHook, stateHook, }?: {
|
|
56
|
+
propsHook?: PH;
|
|
57
|
+
stateHook?: SH;
|
|
54
58
|
}) => React.ForwardRefExoticComponent<React.PropsWithoutRef<{
|
|
55
|
-
as?: React.ElementType
|
|
56
|
-
asChild?: boolean
|
|
57
|
-
className?: string
|
|
58
|
-
options?: Parameters<SH>[0]
|
|
59
|
-
setProps?: (
|
|
60
|
-
state?: Parameters<PH>[0]
|
|
61
|
-
style?: React.CSSProperties
|
|
59
|
+
as?: React.ElementType;
|
|
60
|
+
asChild?: boolean;
|
|
61
|
+
className?: string;
|
|
62
|
+
options?: Parameters<SH>[0];
|
|
63
|
+
setProps?: (hookProps: NonNullable<ReturnType<PH>["props"]>) => P;
|
|
64
|
+
state?: Parameters<PH>[0];
|
|
65
|
+
style?: React.CSSProperties;
|
|
62
66
|
} & P> & React.RefAttributes<any>>;
|
|
63
67
|
|
|
64
68
|
declare function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(tag: T): React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.IntrinsicElements[T]> & React.RefAttributes<HTMLElementTagNameMap[T]>>;
|
|
65
69
|
|
|
66
|
-
declare const createSlotComponent: <T extends React.ElementType
|
|
67
|
-
as?: React.ElementType
|
|
68
|
-
asChild?: boolean
|
|
70
|
+
declare const createSlotComponent: <T extends React.ElementType, P extends React.ComponentPropsWithoutRef<T>>(element: T) => React.ForwardRefExoticComponent<React.PropsWithoutRef<{
|
|
71
|
+
as?: React.ElementType;
|
|
72
|
+
asChild?: boolean;
|
|
69
73
|
} & P> & React.RefAttributes<any>>;
|
|
70
74
|
|
|
71
75
|
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
@@ -96,7 +100,7 @@ interface UseOnClickOutsideOptions {
|
|
|
96
100
|
disabled?: boolean;
|
|
97
101
|
eventTypes?: string[];
|
|
98
102
|
excludeScrollbar?: boolean;
|
|
99
|
-
ignoreClass?: string | string
|
|
103
|
+
ignoreClass?: string[] | string;
|
|
100
104
|
refs?: Refs;
|
|
101
105
|
}
|
|
102
106
|
type UseOnClickOutsideReturn = (element: El | null) => void;
|
|
@@ -110,12 +114,17 @@ declare const useStableMemo: <T>(producer: () => T, deps?: React.DependencyList)
|
|
|
110
114
|
*/
|
|
111
115
|
declare const withProviders: (...providers: any[]) => <T>(WrappedComponent: React.FC<T>) => (props: T) => any;
|
|
112
116
|
|
|
117
|
+
type ElementType<P = any> = {
|
|
118
|
+
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never;
|
|
119
|
+
}[keyof JSX.IntrinsicElements] | React.ComponentType<P>;
|
|
120
|
+
type ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
121
|
+
type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<React.HTMLAttributes<infer R>, any> ? R : never : T extends React.ComponentType<any> ? T extends React.ComponentClass<any> ? InstanceType<T> : T extends React.ForwardRefExoticComponent<any> ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R> ? R : never : never : never : never;
|
|
113
122
|
/**
|
|
114
123
|
* Shorter alternative to `React.forwardRef`.
|
|
115
124
|
*
|
|
116
125
|
* @generic1 Component type or element type
|
|
117
126
|
* @generic2 Extended prop types
|
|
118
127
|
*/
|
|
119
|
-
declare function withRef<T extends
|
|
128
|
+
declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
|
|
120
129
|
|
|
121
|
-
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useIsomorphicLayoutEffect, useOnClickOutside, useStableMemo, withProviders, withRef };
|
|
130
|
+
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, useIsomorphicLayoutEffect, useOnClickOutside, useStableMemo, withProviders, withRef };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
declare const Box: React.ForwardRefExoticComponent<{
|
|
4
|
-
as?: React.ElementType
|
|
5
|
-
asChild?: boolean
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
asChild?: boolean;
|
|
6
6
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>>;
|
|
7
7
|
type BoxProps = React.ComponentPropsWithRef<typeof Box>;
|
|
8
8
|
|
|
@@ -13,13 +13,17 @@ type PortalBodyProps = {
|
|
|
13
13
|
declare const PortalBody: ({ children, element, }: PortalBodyProps) => React.ReactPortal;
|
|
14
14
|
|
|
15
15
|
declare const Text: React.ForwardRefExoticComponent<{
|
|
16
|
-
as?: React.ElementType
|
|
17
|
-
asChild?: boolean
|
|
16
|
+
as?: React.ElementType;
|
|
17
|
+
asChild?: boolean;
|
|
18
18
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<any>>;
|
|
19
19
|
type TextProps = React.ComponentPropsWithRef<typeof Text>;
|
|
20
20
|
|
|
21
|
+
declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}) => React.JSX.Element>;
|
|
24
|
+
|
|
21
25
|
/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */
|
|
22
|
-
declare const composeEventHandlers: <E>(originalEventHandler?: (
|
|
26
|
+
declare const composeEventHandlers: <E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
23
27
|
checkForDefaultPrevented?: boolean | undefined;
|
|
24
28
|
}) => (event: E) => void;
|
|
25
29
|
|
|
@@ -48,24 +52,24 @@ declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => vo
|
|
|
48
52
|
* @param {React.ElementType} element The base component or native HTML element.
|
|
49
53
|
* @returns {function} A primitive component.
|
|
50
54
|
*/
|
|
51
|
-
declare const createPrimitiveComponent: <T extends React.ElementType
|
|
52
|
-
propsHook?: PH
|
|
53
|
-
stateHook?: SH
|
|
55
|
+
declare const createPrimitiveComponent: <T extends React.ElementType, P extends React.ComponentPropsWithoutRef<T>>(element: T) => <SH extends (options: any) => any, PH extends (state: any) => any>({ propsHook, stateHook, }?: {
|
|
56
|
+
propsHook?: PH;
|
|
57
|
+
stateHook?: SH;
|
|
54
58
|
}) => React.ForwardRefExoticComponent<React.PropsWithoutRef<{
|
|
55
|
-
as?: React.ElementType
|
|
56
|
-
asChild?: boolean
|
|
57
|
-
className?: string
|
|
58
|
-
options?: Parameters<SH>[0]
|
|
59
|
-
setProps?: (
|
|
60
|
-
state?: Parameters<PH>[0]
|
|
61
|
-
style?: React.CSSProperties
|
|
59
|
+
as?: React.ElementType;
|
|
60
|
+
asChild?: boolean;
|
|
61
|
+
className?: string;
|
|
62
|
+
options?: Parameters<SH>[0];
|
|
63
|
+
setProps?: (hookProps: NonNullable<ReturnType<PH>["props"]>) => P;
|
|
64
|
+
state?: Parameters<PH>[0];
|
|
65
|
+
style?: React.CSSProperties;
|
|
62
66
|
} & P> & React.RefAttributes<any>>;
|
|
63
67
|
|
|
64
68
|
declare function createPrimitiveElement<T extends keyof HTMLElementTagNameMap>(tag: T): React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.IntrinsicElements[T]> & React.RefAttributes<HTMLElementTagNameMap[T]>>;
|
|
65
69
|
|
|
66
|
-
declare const createSlotComponent: <T extends React.ElementType
|
|
67
|
-
as?: React.ElementType
|
|
68
|
-
asChild?: boolean
|
|
70
|
+
declare const createSlotComponent: <T extends React.ElementType, P extends React.ComponentPropsWithoutRef<T>>(element: T) => React.ForwardRefExoticComponent<React.PropsWithoutRef<{
|
|
71
|
+
as?: React.ElementType;
|
|
72
|
+
asChild?: boolean;
|
|
69
73
|
} & P> & React.RefAttributes<any>>;
|
|
70
74
|
|
|
71
75
|
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
@@ -96,7 +100,7 @@ interface UseOnClickOutsideOptions {
|
|
|
96
100
|
disabled?: boolean;
|
|
97
101
|
eventTypes?: string[];
|
|
98
102
|
excludeScrollbar?: boolean;
|
|
99
|
-
ignoreClass?: string | string
|
|
103
|
+
ignoreClass?: string[] | string;
|
|
100
104
|
refs?: Refs;
|
|
101
105
|
}
|
|
102
106
|
type UseOnClickOutsideReturn = (element: El | null) => void;
|
|
@@ -110,12 +114,17 @@ declare const useStableMemo: <T>(producer: () => T, deps?: React.DependencyList)
|
|
|
110
114
|
*/
|
|
111
115
|
declare const withProviders: (...providers: any[]) => <T>(WrappedComponent: React.FC<T>) => (props: T) => any;
|
|
112
116
|
|
|
117
|
+
type ElementType<P = any> = {
|
|
118
|
+
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never;
|
|
119
|
+
}[keyof JSX.IntrinsicElements] | React.ComponentType<P>;
|
|
120
|
+
type ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
121
|
+
type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<React.HTMLAttributes<infer R>, any> ? R : never : T extends React.ComponentType<any> ? T extends React.ComponentClass<any> ? InstanceType<T> : T extends React.ForwardRefExoticComponent<any> ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R> ? R : never : never : never : never;
|
|
113
122
|
/**
|
|
114
123
|
* Shorter alternative to `React.forwardRef`.
|
|
115
124
|
*
|
|
116
125
|
* @generic1 Component type or element type
|
|
117
126
|
* @generic2 Extended prop types
|
|
118
127
|
*/
|
|
119
|
-
declare function withRef<T extends
|
|
128
|
+
declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
|
|
120
129
|
|
|
121
|
-
export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useIsomorphicLayoutEffect, useOnClickOutside, useStableMemo, withProviders, withRef };
|
|
130
|
+
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, useIsomorphicLayoutEffect, useOnClickOutside, useStableMemo, withProviders, withRef };
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,7 @@ __export(src_exports, {
|
|
|
62
62
|
Box: () => Box,
|
|
63
63
|
CAN_USE_DOM: () => CAN_USE_DOM,
|
|
64
64
|
DEFAULT_IGNORE_CLASS: () => DEFAULT_IGNORE_CLASS,
|
|
65
|
+
MemoizedChildren: () => MemoizedChildren,
|
|
65
66
|
PortalBody: () => PortalBody,
|
|
66
67
|
Text: () => Text,
|
|
67
68
|
composeEventHandlers: () => composeEventHandlers,
|
|
@@ -101,14 +102,21 @@ var PortalBody = ({
|
|
|
101
102
|
element
|
|
102
103
|
}) => {
|
|
103
104
|
const container = element || typeof window !== "undefined" ? document.body : void 0;
|
|
104
|
-
if (!container)
|
|
105
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children);
|
|
105
|
+
if (!container) return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children);
|
|
106
106
|
return import_react_dom.default.createPortal(children, element || document.body);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
// src/Text.tsx
|
|
110
110
|
var Text = createSlotComponent("span");
|
|
111
111
|
|
|
112
|
+
// src/MemoizedChildren.tsx
|
|
113
|
+
var import_react3 = __toESM(require("react"));
|
|
114
|
+
var MemoizedChildren = import_react3.default.memo(
|
|
115
|
+
({ children }) => {
|
|
116
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, children);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
112
120
|
// src/composeEventHandlers.ts
|
|
113
121
|
var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) => (event) => {
|
|
114
122
|
originalEventHandler == null ? void 0 : originalEventHandler(event);
|
|
@@ -118,12 +126,12 @@ var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDef
|
|
|
118
126
|
};
|
|
119
127
|
|
|
120
128
|
// src/createPrimitiveComponent.tsx
|
|
121
|
-
var
|
|
129
|
+
var import_react5 = __toESM(require("react"));
|
|
122
130
|
var import_utils = require("@udecode/utils");
|
|
123
131
|
var import_clsx = require("clsx");
|
|
124
132
|
|
|
125
133
|
// src/useComposedRef.ts
|
|
126
|
-
var
|
|
134
|
+
var import_react4 = __toESM(require("react"));
|
|
127
135
|
var setRef = (ref, value) => {
|
|
128
136
|
if (typeof ref === "function") {
|
|
129
137
|
ref(value);
|
|
@@ -133,7 +141,7 @@ var setRef = (ref, value) => {
|
|
|
133
141
|
};
|
|
134
142
|
var composeRefs = (...refs) => (node) => refs.forEach((ref) => setRef(ref, node));
|
|
135
143
|
var useComposedRef = (...refs) => {
|
|
136
|
-
return
|
|
144
|
+
return import_react4.default.useCallback(composeRefs(...refs), refs);
|
|
137
145
|
};
|
|
138
146
|
|
|
139
147
|
// src/createPrimitiveComponent.tsx
|
|
@@ -143,7 +151,7 @@ var createPrimitiveComponent = (element) => {
|
|
|
143
151
|
propsHook,
|
|
144
152
|
stateHook
|
|
145
153
|
} = {}) => {
|
|
146
|
-
return
|
|
154
|
+
return import_react5.default.forwardRef(
|
|
147
155
|
(_a2, ref) => {
|
|
148
156
|
var _b = _a2, {
|
|
149
157
|
asChild,
|
|
@@ -168,13 +176,12 @@ var createPrimitiveComponent = (element) => {
|
|
|
168
176
|
const _ref = useComposedRef(ref, hookRef);
|
|
169
177
|
const className = (0, import_utils.isDefined)(hookProps == null ? void 0 : hookProps.className) || (0, import_utils.isDefined)(classNameProp) ? (0, import_clsx.clsx)(hookProps == null ? void 0 : hookProps.className, classNameProp) : void 0;
|
|
170
178
|
const style = (hookProps == null ? void 0 : hookProps.style) || props.style ? __spreadValues(__spreadValues({}, hookProps == null ? void 0 : hookProps.style), props.style) : void 0;
|
|
171
|
-
if (!asChild && hidden)
|
|
172
|
-
|
|
173
|
-
return /* @__PURE__ */ import_react4.default.createElement(
|
|
179
|
+
if (!asChild && hidden) return null;
|
|
180
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
174
181
|
Comp,
|
|
175
182
|
__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
ref: _ref,
|
|
184
|
+
asChild
|
|
178
185
|
}, hookProps), {
|
|
179
186
|
className,
|
|
180
187
|
style
|
|
@@ -186,23 +193,23 @@ var createPrimitiveComponent = (element) => {
|
|
|
186
193
|
};
|
|
187
194
|
|
|
188
195
|
// src/createPrimitiveElement.tsx
|
|
189
|
-
var
|
|
196
|
+
var import_react6 = __toESM(require("react"));
|
|
190
197
|
function createPrimitiveElement(tag) {
|
|
191
|
-
return
|
|
198
|
+
return import_react6.default.forwardRef(
|
|
192
199
|
function CreateComponent(props, ref) {
|
|
193
|
-
return
|
|
200
|
+
return import_react6.default.createElement(tag, __spreadProps(__spreadValues({}, props), { ref }));
|
|
194
201
|
}
|
|
195
202
|
);
|
|
196
203
|
}
|
|
197
204
|
|
|
198
205
|
// src/useIsomorphicLayoutEffect.ts
|
|
199
|
-
var
|
|
206
|
+
var import_react7 = __toESM(require("react"));
|
|
200
207
|
var _a;
|
|
201
208
|
var CAN_USE_DOM = typeof window !== "undefined" && ((_a = window.document) == null ? void 0 : _a.createElement) !== void 0;
|
|
202
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
209
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? import_react7.default.useLayoutEffect : import_react7.default.useEffect;
|
|
203
210
|
|
|
204
211
|
// src/useOnClickOutside.ts
|
|
205
|
-
var
|
|
212
|
+
var import_react8 = __toESM(require("react"));
|
|
206
213
|
var canUsePassiveEvents = () => {
|
|
207
214
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
208
215
|
return false;
|
|
@@ -227,8 +234,7 @@ var hasIgnoreClass = (e, ignoreClass) => {
|
|
|
227
234
|
let el = e.target || e;
|
|
228
235
|
while (el) {
|
|
229
236
|
if (Array.isArray(ignoreClass)) {
|
|
230
|
-
if (ignoreClass.some((c) => checkClass(el, c)))
|
|
231
|
-
return true;
|
|
237
|
+
if (ignoreClass.some((c) => checkClass(el, c))) return true;
|
|
232
238
|
} else if (checkClass(el, ignoreClass)) {
|
|
233
239
|
return true;
|
|
234
240
|
}
|
|
@@ -246,17 +252,16 @@ var useOnClickOutside = (callback, {
|
|
|
246
252
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
247
253
|
refs: refsOpt
|
|
248
254
|
} = {}) => {
|
|
249
|
-
const [refsState, setRefsState] =
|
|
250
|
-
const callbackRef =
|
|
255
|
+
const [refsState, setRefsState] = import_react8.default.useState([]);
|
|
256
|
+
const callbackRef = import_react8.default.useRef(callback);
|
|
251
257
|
callbackRef.current = callback;
|
|
252
|
-
const ref =
|
|
258
|
+
const ref = import_react8.default.useCallback(
|
|
253
259
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
254
260
|
[]
|
|
255
261
|
);
|
|
256
|
-
|
|
262
|
+
import_react8.default.useEffect(
|
|
257
263
|
() => {
|
|
258
|
-
if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0)
|
|
259
|
-
return;
|
|
264
|
+
if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0) return;
|
|
260
265
|
const getEls = () => {
|
|
261
266
|
const els = [];
|
|
262
267
|
(refsOpt || refsState).forEach(
|
|
@@ -284,8 +289,7 @@ var useOnClickOutside = (callback, {
|
|
|
284
289
|
getEventOptions(type)
|
|
285
290
|
)
|
|
286
291
|
);
|
|
287
|
-
if (detectIFrame)
|
|
288
|
-
window.removeEventListener("blur", blurHandler);
|
|
292
|
+
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
289
293
|
};
|
|
290
294
|
if (disabled) {
|
|
291
295
|
removeEventListener();
|
|
@@ -294,8 +298,7 @@ var useOnClickOutside = (callback, {
|
|
|
294
298
|
eventTypes.forEach(
|
|
295
299
|
(type) => document.addEventListener(type, handler, getEventOptions(type))
|
|
296
300
|
);
|
|
297
|
-
if (detectIFrame)
|
|
298
|
-
window.addEventListener("blur", blurHandler);
|
|
301
|
+
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
299
302
|
return () => removeEventListener();
|
|
300
303
|
},
|
|
301
304
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -313,39 +316,40 @@ var useOnClickOutside = (callback, {
|
|
|
313
316
|
};
|
|
314
317
|
|
|
315
318
|
// src/useStableMemo.ts
|
|
316
|
-
var
|
|
319
|
+
var import_react9 = __toESM(require("react"));
|
|
317
320
|
var useStableMemo = (producer, deps) => {
|
|
318
|
-
const [value, setValue] =
|
|
319
|
-
|
|
321
|
+
const [value, setValue] = import_react9.default.useState(producer);
|
|
322
|
+
import_react9.default.useLayoutEffect(() => {
|
|
320
323
|
setValue(producer);
|
|
321
324
|
}, deps);
|
|
322
325
|
return value;
|
|
323
326
|
};
|
|
324
327
|
|
|
325
328
|
// src/withProviders.tsx
|
|
326
|
-
var
|
|
329
|
+
var import_react10 = __toESM(require("react"));
|
|
327
330
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
328
331
|
(acc, prov) => {
|
|
329
332
|
let Provider = prov;
|
|
330
333
|
if (Array.isArray(prov)) {
|
|
331
334
|
[Provider] = prov;
|
|
332
|
-
return /* @__PURE__ */
|
|
335
|
+
return /* @__PURE__ */ import_react10.default.createElement(Provider, __spreadValues({}, prov[1]), acc);
|
|
333
336
|
}
|
|
334
|
-
return /* @__PURE__ */
|
|
337
|
+
return /* @__PURE__ */ import_react10.default.createElement(Provider, null, acc);
|
|
335
338
|
},
|
|
336
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ import_react10.default.createElement(WrappedComponent, __spreadValues({}, props))
|
|
337
340
|
);
|
|
338
341
|
|
|
339
342
|
// src/withRef.tsx
|
|
340
|
-
var
|
|
343
|
+
var import_react11 = __toESM(require("react"));
|
|
341
344
|
function withRef(renderFunction) {
|
|
342
|
-
return
|
|
345
|
+
return import_react11.default.forwardRef(renderFunction);
|
|
343
346
|
}
|
|
344
347
|
// Annotate the CommonJS export names for ESM import in node:
|
|
345
348
|
0 && (module.exports = {
|
|
346
349
|
Box,
|
|
347
350
|
CAN_USE_DOM,
|
|
348
351
|
DEFAULT_IGNORE_CLASS,
|
|
352
|
+
MemoizedChildren,
|
|
349
353
|
PortalBody,
|
|
350
354
|
Text,
|
|
351
355
|
composeEventHandlers,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/createSlotComponent.tsx","../src/Box.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useOnClickOutside.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Box';\nexport * from './PortalBody';\nexport * from './Text';\nexport * from './composeEventHandlers';\nexport * from './createPrimitiveComponent';\nexport * from './createPrimitiveElement';\nexport * from './createSlotComponent';\nexport * from './useComposedRef';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useOnClickOutside';\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 // eslint-disable-next-line react/display-name\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';\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","/* eslint-disable react/display-name */\n\nimport 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 setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\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};\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 ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<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 refs.forEach((ref) => setRef(ref, node));\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 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 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\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 // eslint-disable-next-line getter-return\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\ntype El = HTMLElement;\ntype Refs = React.RefObject<El>[];\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\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 // eslint-disable-next-line no-loop-func\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 // eslint-disable-next-line consistent-return\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 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 from 'react';\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<\n T extends React.ComponentType<any> | keyof HTMLElementTagNameMap,\n E = {},\n>(\n renderFunction: React.ForwardRefRenderFunction<\n React.ElementRef<T>,\n E & Omit<React.ComponentPropsWithoutRef<T>, keyof E>\n >\n) {\n return React.forwardRef(renderFunction);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAAA;AAAA,EAGA,aAAAA,QAAM,WAMJ,CAACC,KAAmC,QAAQ;AAA3C,aAAAA,KAAE,MAAI,UAAU,MAjBrB,IAiBK,IAA0B,kBAA1B,IAA0B,CAAxB,MAAI;AACP,UAAM,OAAO,UAAU,yBAAQ,MAAY;AAE3C,WAAO,6BAAAD,QAAA,cAAC,uBAAK,OAAc,MAAO;AAAA,EACpC,CAAC;AAAA;;;ACjBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,IAAAE,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;AAAW,WAAQ,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,+DAAuB;AAEvB,MACE,6BA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,QAAQ;AAAA,EAEnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,IAAAC,gBAAkB;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,8BAAAC,QAAA,cAAC,6BAAa,KAAK,CAAC,IAAI,GAAI;AAAA,IACrC;AAEA,WAAO,8BAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,8BAAAA,QAAA,cAAC,qCAAsB,MAAe;AACxC;;;ACvBJ,IAAAC,iBAAkB;AAQX,SAAS,QAId,gBAIA;AACA,SAAO,eAAAC,QAAM,WAAW,cAAc;AACxC;","names":["React","_a","import_react","React","ReactDOM","import_react","import_react","React","React","_a","_b","import_react","React","import_react","React","import_react","_a","React","import_react","React","import_react","React","import_react","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/createSlotComponent.tsx","../src/Box.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/MemoizedChildren.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useOnClickOutside.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Box';\nexport * from './PortalBody';\nexport * from './Text';\nexport * from './MemoizedChildren';\nexport * from './composeEventHandlers';\nexport * from './createPrimitiveComponent';\nexport * from './createPrimitiveElement';\nexport * from './createSlotComponent';\nexport * from './useComposedRef';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useOnClickOutside';\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 // eslint-disable-next-line react/display-name\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';\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","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\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","/* eslint-disable react/display-name */\n\nimport 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 setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\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 ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<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 refs.forEach((ref) => setRef(ref, node));\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 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 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\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 // eslint-disable-next-line getter-return\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\ntype El = HTMLElement;\ntype Refs = React.RefObject<El>[];\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\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 // eslint-disable-next-line no-loop-func\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 // eslint-disable-next-line consistent-return\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 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 from 'react';\n\ntype ElementType<P = any> =\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements]\n | React.ComponentType<P>;\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;;;ACAA,mBAAkB;AAElB,wBAAqB;AAEd,IAAM,sBAAsB,CAIjC;AAAA;AAAA,EAGA,aAAAA,QAAM,WAMJ,CAACC,KAAmC,QAAQ;AAA3C,aAAAA,KAAE,MAAI,UAAU,MAjB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;AACxC;;;ACvBJ,IAAAC,iBAAkB;AAwCX,SAAS,QACd,gBAOA;AACA,SAAO,eAAAC,QAAM,WAAW,cAAqB;AAC/C;","names":["React","_a","import_react","React","ReactDOM","import_react","React","import_react","import_react","React","React","_a","_b","import_react","React","import_react","React","import_react","_a","React","import_react","React","import_react","React","import_react","React"]}
|
package/dist/index.mjs
CHANGED
|
@@ -53,14 +53,21 @@ var PortalBody = ({
|
|
|
53
53
|
element
|
|
54
54
|
}) => {
|
|
55
55
|
const container = element || typeof window !== "undefined" ? document.body : void 0;
|
|
56
|
-
if (!container)
|
|
57
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
|
|
56
|
+
if (!container) return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
|
|
58
57
|
return ReactDOM.createPortal(children, element || document.body);
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
// src/Text.tsx
|
|
62
61
|
var Text = createSlotComponent("span");
|
|
63
62
|
|
|
63
|
+
// src/MemoizedChildren.tsx
|
|
64
|
+
import React3 from "react";
|
|
65
|
+
var MemoizedChildren = React3.memo(
|
|
66
|
+
({ children }) => {
|
|
67
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
64
71
|
// src/composeEventHandlers.ts
|
|
65
72
|
var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) => (event) => {
|
|
66
73
|
originalEventHandler == null ? void 0 : originalEventHandler(event);
|
|
@@ -70,12 +77,12 @@ var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDef
|
|
|
70
77
|
};
|
|
71
78
|
|
|
72
79
|
// src/createPrimitiveComponent.tsx
|
|
73
|
-
import
|
|
80
|
+
import React5 from "react";
|
|
74
81
|
import { isDefined } from "@udecode/utils";
|
|
75
82
|
import { clsx } from "clsx";
|
|
76
83
|
|
|
77
84
|
// src/useComposedRef.ts
|
|
78
|
-
import
|
|
85
|
+
import React4 from "react";
|
|
79
86
|
var setRef = (ref, value) => {
|
|
80
87
|
if (typeof ref === "function") {
|
|
81
88
|
ref(value);
|
|
@@ -85,7 +92,7 @@ var setRef = (ref, value) => {
|
|
|
85
92
|
};
|
|
86
93
|
var composeRefs = (...refs) => (node) => refs.forEach((ref) => setRef(ref, node));
|
|
87
94
|
var useComposedRef = (...refs) => {
|
|
88
|
-
return
|
|
95
|
+
return React4.useCallback(composeRefs(...refs), refs);
|
|
89
96
|
};
|
|
90
97
|
|
|
91
98
|
// src/createPrimitiveComponent.tsx
|
|
@@ -95,7 +102,7 @@ var createPrimitiveComponent = (element) => {
|
|
|
95
102
|
propsHook,
|
|
96
103
|
stateHook
|
|
97
104
|
} = {}) => {
|
|
98
|
-
return
|
|
105
|
+
return React5.forwardRef(
|
|
99
106
|
(_a2, ref) => {
|
|
100
107
|
var _b = _a2, {
|
|
101
108
|
asChild,
|
|
@@ -120,13 +127,12 @@ var createPrimitiveComponent = (element) => {
|
|
|
120
127
|
const _ref = useComposedRef(ref, hookRef);
|
|
121
128
|
const className = isDefined(hookProps == null ? void 0 : hookProps.className) || isDefined(classNameProp) ? clsx(hookProps == null ? void 0 : hookProps.className, classNameProp) : void 0;
|
|
122
129
|
const style = (hookProps == null ? void 0 : hookProps.style) || props.style ? __spreadValues(__spreadValues({}, hookProps == null ? void 0 : hookProps.style), props.style) : void 0;
|
|
123
|
-
if (!asChild && hidden)
|
|
124
|
-
|
|
125
|
-
return /* @__PURE__ */ React4.createElement(
|
|
130
|
+
if (!asChild && hidden) return null;
|
|
131
|
+
return /* @__PURE__ */ React5.createElement(
|
|
126
132
|
Comp,
|
|
127
133
|
__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
ref: _ref,
|
|
135
|
+
asChild
|
|
130
136
|
}, hookProps), {
|
|
131
137
|
className,
|
|
132
138
|
style
|
|
@@ -138,23 +144,23 @@ var createPrimitiveComponent = (element) => {
|
|
|
138
144
|
};
|
|
139
145
|
|
|
140
146
|
// src/createPrimitiveElement.tsx
|
|
141
|
-
import
|
|
147
|
+
import React6 from "react";
|
|
142
148
|
function createPrimitiveElement(tag) {
|
|
143
|
-
return
|
|
149
|
+
return React6.forwardRef(
|
|
144
150
|
function CreateComponent(props, ref) {
|
|
145
|
-
return
|
|
151
|
+
return React6.createElement(tag, __spreadProps(__spreadValues({}, props), { ref }));
|
|
146
152
|
}
|
|
147
153
|
);
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
// src/useIsomorphicLayoutEffect.ts
|
|
151
|
-
import
|
|
157
|
+
import React7 from "react";
|
|
152
158
|
var _a;
|
|
153
159
|
var CAN_USE_DOM = typeof window !== "undefined" && ((_a = window.document) == null ? void 0 : _a.createElement) !== void 0;
|
|
154
|
-
var useIsomorphicLayoutEffect = CAN_USE_DOM ?
|
|
160
|
+
var useIsomorphicLayoutEffect = CAN_USE_DOM ? React7.useLayoutEffect : React7.useEffect;
|
|
155
161
|
|
|
156
162
|
// src/useOnClickOutside.ts
|
|
157
|
-
import
|
|
163
|
+
import React8 from "react";
|
|
158
164
|
var canUsePassiveEvents = () => {
|
|
159
165
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function")
|
|
160
166
|
return false;
|
|
@@ -179,8 +185,7 @@ var hasIgnoreClass = (e, ignoreClass) => {
|
|
|
179
185
|
let el = e.target || e;
|
|
180
186
|
while (el) {
|
|
181
187
|
if (Array.isArray(ignoreClass)) {
|
|
182
|
-
if (ignoreClass.some((c) => checkClass(el, c)))
|
|
183
|
-
return true;
|
|
188
|
+
if (ignoreClass.some((c) => checkClass(el, c))) return true;
|
|
184
189
|
} else if (checkClass(el, ignoreClass)) {
|
|
185
190
|
return true;
|
|
186
191
|
}
|
|
@@ -198,17 +203,16 @@ var useOnClickOutside = (callback, {
|
|
|
198
203
|
ignoreClass = DEFAULT_IGNORE_CLASS,
|
|
199
204
|
refs: refsOpt
|
|
200
205
|
} = {}) => {
|
|
201
|
-
const [refsState, setRefsState] =
|
|
202
|
-
const callbackRef =
|
|
206
|
+
const [refsState, setRefsState] = React8.useState([]);
|
|
207
|
+
const callbackRef = React8.useRef(callback);
|
|
203
208
|
callbackRef.current = callback;
|
|
204
|
-
const ref =
|
|
209
|
+
const ref = React8.useCallback(
|
|
205
210
|
(el) => setRefsState((prevState) => [...prevState, { current: el }]),
|
|
206
211
|
[]
|
|
207
212
|
);
|
|
208
|
-
|
|
213
|
+
React8.useEffect(
|
|
209
214
|
() => {
|
|
210
|
-
if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0)
|
|
211
|
-
return;
|
|
215
|
+
if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0) return;
|
|
212
216
|
const getEls = () => {
|
|
213
217
|
const els = [];
|
|
214
218
|
(refsOpt || refsState).forEach(
|
|
@@ -236,8 +240,7 @@ var useOnClickOutside = (callback, {
|
|
|
236
240
|
getEventOptions(type)
|
|
237
241
|
)
|
|
238
242
|
);
|
|
239
|
-
if (detectIFrame)
|
|
240
|
-
window.removeEventListener("blur", blurHandler);
|
|
243
|
+
if (detectIFrame) window.removeEventListener("blur", blurHandler);
|
|
241
244
|
};
|
|
242
245
|
if (disabled) {
|
|
243
246
|
removeEventListener();
|
|
@@ -246,8 +249,7 @@ var useOnClickOutside = (callback, {
|
|
|
246
249
|
eventTypes.forEach(
|
|
247
250
|
(type) => document.addEventListener(type, handler, getEventOptions(type))
|
|
248
251
|
);
|
|
249
|
-
if (detectIFrame)
|
|
250
|
-
window.addEventListener("blur", blurHandler);
|
|
252
|
+
if (detectIFrame) window.addEventListener("blur", blurHandler);
|
|
251
253
|
return () => removeEventListener();
|
|
252
254
|
},
|
|
253
255
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -265,38 +267,39 @@ var useOnClickOutside = (callback, {
|
|
|
265
267
|
};
|
|
266
268
|
|
|
267
269
|
// src/useStableMemo.ts
|
|
268
|
-
import
|
|
270
|
+
import React9 from "react";
|
|
269
271
|
var useStableMemo = (producer, deps) => {
|
|
270
|
-
const [value, setValue] =
|
|
271
|
-
|
|
272
|
+
const [value, setValue] = React9.useState(producer);
|
|
273
|
+
React9.useLayoutEffect(() => {
|
|
272
274
|
setValue(producer);
|
|
273
275
|
}, deps);
|
|
274
276
|
return value;
|
|
275
277
|
};
|
|
276
278
|
|
|
277
279
|
// src/withProviders.tsx
|
|
278
|
-
import
|
|
280
|
+
import React10 from "react";
|
|
279
281
|
var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
|
|
280
282
|
(acc, prov) => {
|
|
281
283
|
let Provider = prov;
|
|
282
284
|
if (Array.isArray(prov)) {
|
|
283
285
|
[Provider] = prov;
|
|
284
|
-
return /* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ React10.createElement(Provider, __spreadValues({}, prov[1]), acc);
|
|
285
287
|
}
|
|
286
|
-
return /* @__PURE__ */
|
|
288
|
+
return /* @__PURE__ */ React10.createElement(Provider, null, acc);
|
|
287
289
|
},
|
|
288
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ React10.createElement(WrappedComponent, __spreadValues({}, props))
|
|
289
291
|
);
|
|
290
292
|
|
|
291
293
|
// src/withRef.tsx
|
|
292
|
-
import
|
|
294
|
+
import React11 from "react";
|
|
293
295
|
function withRef(renderFunction) {
|
|
294
|
-
return
|
|
296
|
+
return React11.forwardRef(renderFunction);
|
|
295
297
|
}
|
|
296
298
|
export {
|
|
297
299
|
Box,
|
|
298
300
|
CAN_USE_DOM,
|
|
299
301
|
DEFAULT_IGNORE_CLASS,
|
|
302
|
+
MemoizedChildren,
|
|
300
303
|
PortalBody,
|
|
301
304
|
Text,
|
|
302
305
|
composeEventHandlers,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createSlotComponent.tsx","../src/Box.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useOnClickOutside.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 // eslint-disable-next-line react/display-name\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';\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","/* eslint-disable react/display-name */\n\nimport 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 setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\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};\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 ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<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 refs.forEach((ref) => setRef(ref, node));\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 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 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\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 // eslint-disable-next-line getter-return\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\ntype El = HTMLElement;\ntype Refs = React.RefObject<El>[];\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\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 // eslint-disable-next-line no-loop-func\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 // eslint-disable-next-line consistent-return\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 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 from 'react';\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<\n T extends React.ComponentType<any> | keyof HTMLElementTagNameMap,\n E = {},\n>(\n renderFunction: React.ForwardRefRenderFunction<\n React.ElementRef<T>,\n E & Omit<React.ComponentPropsWithoutRef<T>, keyof E>\n >\n) {\n return React.forwardRef(renderFunction);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAS,YAAY;AAEd,IAAM,sBAAsB,CAIjC;AAAA;AAAA,EAGA,MAAM,WAMJ,CAACA,KAAmC,QAAQ;AAA3C,aAAAA,KAAE,MAAI,UAAU,MAjBrB,IAiBK,IAA0B,kBAA1B,IAA0B,CAAxB,MAAI;AACP,UAAM,OAAO,UAAU,OAAQ,MAAY;AAE3C,WAAO,oCAAC,uBAAK,OAAc,MAAO;AAAA,EACpC,CAAC;AAAA;;;ACjBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,OAAOC,YAAW;AAClB,OAAO,cAAc;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC;AAAW,WAAQ,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAEpC,SAAO,SAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACHvC,IAAM,uBACX,CACE,sBACA,iBACA,EAAE,2BAA2B,KAAK,IAA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EnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,OAAOC,YAAW;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,gBAAAC,OAAA,cAAC,6BAAa,KAAK,CAAC,IAAI,GAAI;AAAA,IACrC;AAEA,WAAO,gBAAAA,OAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,gBAAAA,OAAA,cAAC,qCAAsB,MAAe;AACxC;;;ACvBJ,OAAOC,aAAW;AAQX,SAAS,QAId,gBAIA;AACA,SAAOA,QAAM,WAAW,cAAc;AACxC;","names":["_a","React","React","React","React","_a","_b","React","React","React","React","_a","React","React","React","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/createSlotComponent.tsx","../src/Box.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/MemoizedChildren.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useOnClickOutside.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 // eslint-disable-next-line react/display-name\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';\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","import React from 'react';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\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","/* eslint-disable react/display-name */\n\nimport 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 setProps?: (hookProps: NonNullable<ReturnType<PH>['props']>) => P;\n state?: Parameters<PH>[0];\n style?: React.CSSProperties;\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 ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<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 refs.forEach((ref) => setRef(ref, node));\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 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 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\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 // eslint-disable-next-line getter-return\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\ntype El = HTMLElement;\ntype Refs = React.RefObject<El>[];\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\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 // eslint-disable-next-line no-loop-func\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 // eslint-disable-next-line consistent-return\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 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 from 'react';\n\ntype ElementType<P = any> =\n | {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K]\n ? K\n : never;\n }[keyof JSX.IntrinsicElements]\n | React.ComponentType<P>;\n\ntype ForwardRefComponent<T, P = {}> = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<T>\n>;\n\ntype InferElementRef<T> =\n T extends ElementType<any>\n ? T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T] extends React.DetailedHTMLProps<\n React.HTMLAttributes<infer R>,\n any\n >\n ? R\n : never\n : T extends React.ComponentType<any>\n ? T extends React.ComponentClass<any>\n ? InstanceType<T>\n : T extends React.ForwardRefExoticComponent<any>\n ? React.ComponentPropsWithRef<T>['ref'] extends React.Ref<infer R>\n ? R\n : never\n : never\n : never\n : never;\n\n/**\n * Shorter alternative to `React.forwardRef`.\n *\n * @generic1 Component type or element type\n * @generic2 Extended prop types\n */\nexport function withRef<T extends ElementType, P = {}>(\n renderFunction: React.ForwardRefRenderFunction<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n >\n): ForwardRefComponent<\n InferElementRef<T>,\n React.ComponentPropsWithoutRef<T> & P\n> {\n return React.forwardRef(renderFunction as any) as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAS,YAAY;AAEd,IAAM,sBAAsB,CAIjC;AAAA;AAAA,EAGA,MAAM,WAMJ,CAACA,KAAmC,QAAQ;AAA3C,aAAAA,KAAE,MAAI,UAAU,MAjBrB,IAiBK,IAA0B,kBAA1B,IAA0B,CAAxB,MAAI;AACP,UAAM,OAAO,UAAU,OAAQ,MAAY;AAE3C,WAAO,oCAAC,uBAAK,OAAc,MAAO;AAAA,EACpC,CAAC;AAAA;;;ACjBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,OAAOC,YAAW;AAClB,OAAO,cAAc;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAQ,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAEpC,SAAO,SAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACJ9C,OAAOC,YA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;AAEA,SAAO;AACT;;;ACtKA,OAAOE,YAAW;AAEX,IAAM,gBAAgB,CAC3B,UACA,SACM;AACN,QAAM,CAAC,OAAO,QAAQ,IAAIA,OAAM,SAAS,QAAQ;AAEjD,EAAAA,OAAM,gBAAgB,MAAM;AAC1B,aAAS,QAAQ;AAAA,EAEnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,OAAOC,aAAW;AAMX,IAAM,gBACX,IAAI,cACJ,CAAK,qBACL,CAAC,UACC,UAAU;AAAA,EACR,CAAC,KAAK,SAAS;AACb,QAAI,WAAW;AAEf,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,OAAC,QAAQ,IAAI;AAEb,aAAO,gBAAAC,QAAA,cAAC,6BAAa,KAAK,CAAC,IAAI,GAAI;AAAA,IACrC;AAEA,WAAO,gBAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,gBAAAA,QAAA,cAAC,qCAAsB,MAAe;AACxC;;;ACvBJ,OAAOC,aAAW;AAwCX,SAAS,QACd,gBAOA;AACA,SAAOA,QAAM,WAAW,cAAqB;AAC/C;","names":["_a","React","React","React","React","React","_a","_b","React","React","React","React","_a","React","React","React","React"]}
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udecode/react-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "39.0.0",
|
|
4
4
|
"description": "Udecode React utils",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"utils"
|
|
7
|
+
],
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/udecode/plate/issues"
|
|
10
|
+
},
|
|
6
11
|
"repository": {
|
|
7
12
|
"type": "git",
|
|
8
13
|
"url": "https://github.com/udecode/plate.git",
|
|
9
14
|
"directory": "packages/react-utils"
|
|
10
15
|
},
|
|
11
|
-
"
|
|
12
|
-
"url": "https://github.com/udecode/plate/issues"
|
|
13
|
-
},
|
|
16
|
+
"license": "MIT",
|
|
14
17
|
"sideEffects": false,
|
|
15
|
-
"main": "dist/index.js",
|
|
16
|
-
"module": "dist/index.mjs",
|
|
17
|
-
"types": "dist/index.d.ts",
|
|
18
|
-
"files": [
|
|
19
|
-
"dist/**/*"
|
|
20
|
-
],
|
|
21
18
|
"exports": {
|
|
22
19
|
".": {
|
|
23
20
|
"types": "./dist/index.d.ts",
|
|
@@ -26,10 +23,16 @@
|
|
|
26
23
|
"require": "./dist/index.js"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"module": "dist/index.mjs",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/**/*"
|
|
31
|
+
],
|
|
29
32
|
"scripts": {
|
|
33
|
+
"brl": "yarn p:brl",
|
|
30
34
|
"build": "yarn p:build",
|
|
31
35
|
"build:watch": "yarn p:build:watch",
|
|
32
|
-
"brl": "yarn p:brl",
|
|
33
36
|
"clean": "yarn p:clean",
|
|
34
37
|
"lint": "yarn p:lint",
|
|
35
38
|
"lint:fix": "yarn p:lint:fix",
|
|
@@ -38,17 +41,14 @@
|
|
|
38
41
|
"typecheck": "yarn p:typecheck"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|
|
41
|
-
"@radix-ui/react-slot": "^1.0
|
|
44
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
42
45
|
"@udecode/utils": "37.0.0",
|
|
43
|
-
"clsx": "^
|
|
46
|
+
"clsx": "^2.1.1"
|
|
44
47
|
},
|
|
45
48
|
"peerDependencies": {
|
|
46
49
|
"react": ">=16.8.0",
|
|
47
50
|
"react-dom": ">=16.8.0"
|
|
48
51
|
},
|
|
49
|
-
"keywords": [
|
|
50
|
-
"utils"
|
|
51
|
-
],
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
}
|