@udecode/react-utils 39.0.0 → 42.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 CHANGED
@@ -6,6 +6,10 @@ declare const Box: React.ForwardRefExoticComponent<{
6
6
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>>;
7
7
  type BoxProps = React.ComponentPropsWithRef<typeof Box>;
8
8
 
9
+ declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
10
+ children: React.ReactNode;
11
+ }) => React.JSX.Element>;
12
+
9
13
  type PortalBodyProps = {
10
14
  children: React.ReactNode;
11
15
  element?: Element;
@@ -18,10 +22,6 @@ declare const Text: React.ForwardRefExoticComponent<{
18
22
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<any>>;
19
23
  type TextProps = React.ComponentPropsWithRef<typeof Text>;
20
24
 
21
- declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
22
- children: React.ReactNode;
23
- }) => React.JSX.Element>;
24
-
25
25
  /** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */
26
26
  declare const composeEventHandlers: <E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
27
27
  checkForDefaultPrevented?: boolean | undefined;
@@ -84,12 +84,26 @@ declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => void;
84
84
  */
85
85
  declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => void;
86
86
 
87
+ declare function useEffectOnce(effect: React.EffectCallback, deps: React.DependencyList): void;
88
+
87
89
  declare const CAN_USE_DOM: boolean;
88
90
  /**
89
91
  * Prevent warning on SSR by falling back to React.useEffect when DOM isn't
90
92
  * available
91
93
  */
92
- declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
94
+ declare const useIsomorphicLayoutEffect: typeof React.useEffect;
95
+
96
+ declare function useMemoOnce<T>(factory: () => T, deps: React.DependencyList): T;
97
+
98
+ /**
99
+ * Re-render only when the selector result changes.
100
+ *
101
+ * @param selector A function that derives a value from deps
102
+ * @param deps Dependencies on which to run the selector
103
+ * @param equalityFn Optional comparison function to detect changes in the
104
+ * derived value
105
+ */
106
+ declare function useMemoizedSelector<R>(selector: () => R, deps: React.DependencyList, equalityFn?: (a: R, b: R) => boolean): R;
93
107
 
94
108
  declare const DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
95
109
  type UseOnClickOutsideCallback<T extends Event = Event> = (event: T) => void;
@@ -127,4 +141,4 @@ type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.Intri
127
141
  */
128
142
  declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
129
143
 
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 };
144
+ export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect, useMemoOnce, useMemoizedSelector, useOnClickOutside, useStableMemo, withProviders, withRef };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,10 @@ declare const Box: React.ForwardRefExoticComponent<{
6
6
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>>;
7
7
  type BoxProps = React.ComponentPropsWithRef<typeof Box>;
8
8
 
9
+ declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
10
+ children: React.ReactNode;
11
+ }) => React.JSX.Element>;
12
+
9
13
  type PortalBodyProps = {
10
14
  children: React.ReactNode;
11
15
  element?: Element;
@@ -18,10 +22,6 @@ declare const Text: React.ForwardRefExoticComponent<{
18
22
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<any>>;
19
23
  type TextProps = React.ComponentPropsWithRef<typeof Text>;
20
24
 
21
- declare const MemoizedChildren: React.MemoExoticComponent<({ children }: {
22
- children: React.ReactNode;
23
- }) => React.JSX.Element>;
24
-
25
25
  /** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */
26
26
  declare const composeEventHandlers: <E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
27
27
  checkForDefaultPrevented?: boolean | undefined;
@@ -84,12 +84,26 @@ declare const composeRefs: <T>(...refs: PossibleRef<T>[]) => (node: T) => void;
84
84
  */
85
85
  declare const useComposedRef: <T>(...refs: PossibleRef<T>[]) => (node: T) => void;
86
86
 
87
+ declare function useEffectOnce(effect: React.EffectCallback, deps: React.DependencyList): void;
88
+
87
89
  declare const CAN_USE_DOM: boolean;
88
90
  /**
89
91
  * Prevent warning on SSR by falling back to React.useEffect when DOM isn't
90
92
  * available
91
93
  */
92
- declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
94
+ declare const useIsomorphicLayoutEffect: typeof React.useEffect;
95
+
96
+ declare function useMemoOnce<T>(factory: () => T, deps: React.DependencyList): T;
97
+
98
+ /**
99
+ * Re-render only when the selector result changes.
100
+ *
101
+ * @param selector A function that derives a value from deps
102
+ * @param deps Dependencies on which to run the selector
103
+ * @param equalityFn Optional comparison function to detect changes in the
104
+ * derived value
105
+ */
106
+ declare function useMemoizedSelector<R>(selector: () => R, deps: React.DependencyList, equalityFn?: (a: R, b: R) => boolean): R;
93
107
 
94
108
  declare const DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
95
109
  type UseOnClickOutsideCallback<T extends Event = Event> = (event: T) => void;
@@ -127,4 +141,4 @@ type InferElementRef<T> = T extends ElementType<any> ? T extends keyof JSX.Intri
127
141
  */
128
142
  declare function withRef<T extends ElementType, P = {}>(renderFunction: React.ForwardRefRenderFunction<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>): ForwardRefComponent<InferElementRef<T>, React.ComponentPropsWithoutRef<T> & P>;
129
143
 
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 };
144
+ export { Box, type BoxProps, CAN_USE_DOM, DEFAULT_IGNORE_CLASS, MemoizedChildren, PortalBody, type PortalBodyProps, Text, type TextProps, type UseOnClickOutsideCallback, type UseOnClickOutsideOptions, type UseOnClickOutsideReturn, composeEventHandlers, composeRefs, createPrimitiveComponent, createPrimitiveElement, createSlotComponent, useComposedRef, useEffectOnce, useIsomorphicLayoutEffect, useMemoOnce, useMemoizedSelector, useOnClickOutside, useStableMemo, withProviders, withRef };
package/dist/index.js CHANGED
@@ -1,39 +1,10 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
6
  var __getProtoOf = Object.getPrototypeOf;
10
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
8
  var __export = (target, all) => {
38
9
  for (var name in all)
39
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
57
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
29
 
59
30
  // src/index.ts
60
- var src_exports = {};
61
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
62
33
  Box: () => Box,
63
34
  CAN_USE_DOM: () => CAN_USE_DOM,
64
35
  DEFAULT_IGNORE_CLASS: () => DEFAULT_IGNORE_CLASS,
@@ -71,57 +42,59 @@ __export(src_exports, {
71
42
  createPrimitiveElement: () => createPrimitiveElement,
72
43
  createSlotComponent: () => createSlotComponent,
73
44
  useComposedRef: () => useComposedRef,
45
+ useEffectOnce: () => useEffectOnce,
74
46
  useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect,
47
+ useMemoOnce: () => useMemoOnce,
48
+ useMemoizedSelector: () => useMemoizedSelector,
75
49
  useOnClickOutside: () => useOnClickOutside,
76
50
  useStableMemo: () => useStableMemo,
77
51
  withProviders: () => withProviders,
78
52
  withRef: () => withRef
79
53
  });
80
- module.exports = __toCommonJS(src_exports);
54
+ module.exports = __toCommonJS(index_exports);
81
55
 
82
56
  // src/createSlotComponent.tsx
83
57
  var import_react = __toESM(require("react"));
84
58
  var import_react_slot = require("@radix-ui/react-slot");
85
59
  var createSlotComponent = (element) => (
86
60
  // eslint-disable-next-line react/display-name
87
- import_react.default.forwardRef((_a2, ref) => {
88
- var _b = _a2, { as, asChild = false } = _b, props = __objRest(_b, ["as", "asChild"]);
61
+ import_react.default.forwardRef(({ as, asChild = false, ...props }, ref) => {
89
62
  const Comp = asChild ? import_react_slot.Slot : as || element;
90
- return /* @__PURE__ */ import_react.default.createElement(Comp, __spreadValues({ ref }, props));
63
+ return /* @__PURE__ */ import_react.default.createElement(Comp, { ref, ...props });
91
64
  })
92
65
  );
93
66
 
94
67
  // src/Box.tsx
95
68
  var Box = createSlotComponent("div");
96
69
 
97
- // src/PortalBody.tsx
70
+ // src/MemoizedChildren.tsx
98
71
  var import_react2 = __toESM(require("react"));
72
+ var MemoizedChildren = import_react2.default.memo(
73
+ ({ children }) => {
74
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children);
75
+ }
76
+ );
77
+
78
+ // src/PortalBody.tsx
79
+ var import_react3 = __toESM(require("react"));
99
80
  var import_react_dom = __toESM(require("react-dom"));
100
81
  var PortalBody = ({
101
82
  children,
102
83
  element
103
84
  }) => {
104
85
  const container = element || typeof window !== "undefined" ? document.body : void 0;
105
- if (!container) return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children);
86
+ if (!container) return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, children);
106
87
  return import_react_dom.default.createPortal(children, element || document.body);
107
88
  };
108
89
 
109
90
  // src/Text.tsx
110
91
  var Text = createSlotComponent("span");
111
92
 
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
-
120
93
  // src/composeEventHandlers.ts
121
94
  var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) => (event) => {
122
- originalEventHandler == null ? void 0 : originalEventHandler(event);
95
+ originalEventHandler?.(event);
123
96
  if (checkForDefaultPrevented === false || !event.defaultPrevented) {
124
- return ourEventHandler == null ? void 0 : ourEventHandler(event);
97
+ return ourEventHandler?.(event);
125
98
  }
126
99
  };
127
100
 
@@ -152,21 +125,14 @@ var createPrimitiveComponent = (element) => {
152
125
  stateHook
153
126
  } = {}) => {
154
127
  return import_react5.default.forwardRef(
155
- (_a2, ref) => {
156
- var _b = _a2, {
157
- asChild,
158
- className: classNameProp,
159
- getClassName,
160
- options,
161
- state: stateProp
162
- } = _b, props = __objRest(_b, [
163
- "asChild",
164
- "className",
165
- "getClassName",
166
- "options",
167
- "state"
168
- ]);
169
- var _a3, _b2;
128
+ ({
129
+ asChild,
130
+ className: classNameProp,
131
+ getClassName,
132
+ options,
133
+ state: stateProp,
134
+ ...props
135
+ }, ref) => {
170
136
  const state = (0, import_utils.isDefined)(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
171
137
  const {
172
138
  hidden,
@@ -174,18 +140,20 @@ var createPrimitiveComponent = (element) => {
174
140
  ref: hookRef
175
141
  } = propsHook ? propsHook(state) : { hidden: false, props: {}, ref: null };
176
142
  const _ref = useComposedRef(ref, hookRef);
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;
178
- const style = (hookProps == null ? void 0 : hookProps.style) || props.style ? __spreadValues(__spreadValues({}, hookProps == null ? void 0 : hookProps.style), props.style) : void 0;
143
+ const className = (0, import_utils.isDefined)(hookProps?.className) || (0, import_utils.isDefined)(classNameProp) ? (0, import_clsx.clsx)(hookProps?.className, classNameProp) : void 0;
144
+ const style = hookProps?.style || props.style ? { ...hookProps?.style, ...props.style } : void 0;
179
145
  if (!asChild && hidden) return null;
180
146
  return /* @__PURE__ */ import_react5.default.createElement(
181
147
  Comp,
182
- __spreadValues(__spreadValues(__spreadProps(__spreadValues({
148
+ {
183
149
  ref: _ref,
184
- asChild
185
- }, hookProps), {
150
+ asChild,
151
+ ...hookProps,
186
152
  className,
187
- style
188
- }), props), (_b2 = (_a3 = props.setProps) == null ? void 0 : _a3.call(props, hookProps != null ? hookProps : {})) != null ? _b2 : {})
153
+ style,
154
+ ...props,
155
+ ...props.setProps?.(hookProps ?? {}) ?? {}
156
+ }
189
157
  );
190
158
  }
191
159
  );
@@ -197,19 +165,62 @@ var import_react6 = __toESM(require("react"));
197
165
  function createPrimitiveElement(tag) {
198
166
  return import_react6.default.forwardRef(
199
167
  function CreateComponent(props, ref) {
200
- return import_react6.default.createElement(tag, __spreadProps(__spreadValues({}, props), { ref }));
168
+ return import_react6.default.createElement(tag, { ...props, ref });
201
169
  }
202
170
  );
203
171
  }
204
172
 
205
- // src/useIsomorphicLayoutEffect.ts
173
+ // src/useEffectOnce.ts
206
174
  var import_react7 = __toESM(require("react"));
207
- var _a;
208
- var CAN_USE_DOM = typeof window !== "undefined" && ((_a = window.document) == null ? void 0 : _a.createElement) !== void 0;
209
- var useIsomorphicLayoutEffect = CAN_USE_DOM ? import_react7.default.useLayoutEffect : import_react7.default.useEffect;
175
+ function useEffectOnce(effect, deps) {
176
+ const initialized = import_react7.default.useRef(false);
177
+ const prevDepsRef = import_react7.default.useRef(deps);
178
+ import_react7.default.useEffect(() => {
179
+ const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
180
+ if (!initialized.current || depsChanged) {
181
+ initialized.current = true;
182
+ prevDepsRef.current = deps;
183
+ effect();
184
+ }
185
+ }, deps);
186
+ }
210
187
 
211
- // src/useOnClickOutside.ts
188
+ // src/useIsomorphicLayoutEffect.ts
212
189
  var import_react8 = __toESM(require("react"));
190
+ var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
191
+ var useIsomorphicLayoutEffect = CAN_USE_DOM ? import_react8.default.useLayoutEffect : import_react8.default.useEffect;
192
+
193
+ // src/useMemoOnce.ts
194
+ var import_react9 = __toESM(require("react"));
195
+ function useMemoOnce(factory, deps) {
196
+ const initialized = import_react9.default.useRef(false);
197
+ const prevDepsRef = import_react9.default.useRef(deps);
198
+ const memoizedValueRef = import_react9.default.useRef();
199
+ if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
200
+ initialized.current = true;
201
+ prevDepsRef.current = deps;
202
+ memoizedValueRef.current = factory();
203
+ }
204
+ return memoizedValueRef.current;
205
+ }
206
+
207
+ // src/useMemoizedSelector.ts
208
+ var import_react10 = __toESM(require("react"));
209
+ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
210
+ const [memoizedValue, setMemoizedValue] = import_react10.default.useState(() => selector());
211
+ const previousValueRef = import_react10.default.useRef(memoizedValue);
212
+ import_react10.default.useEffect(() => {
213
+ const newValue = selector();
214
+ if (!equalityFn(previousValueRef.current, newValue)) {
215
+ setMemoizedValue(newValue);
216
+ previousValueRef.current = newValue;
217
+ }
218
+ }, deps);
219
+ return memoizedValue;
220
+ }
221
+
222
+ // src/useOnClickOutside.ts
223
+ var import_react11 = __toESM(require("react"));
213
224
  var canUsePassiveEvents = () => {
214
225
  if (typeof window === "undefined" || typeof window.addEventListener !== "function")
215
226
  return false;
@@ -226,10 +237,7 @@ var canUsePassiveEvents = () => {
226
237
  return passive;
227
238
  };
228
239
  var DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
229
- var checkClass = (el, cl) => {
230
- var _a2;
231
- return (_a2 = el.classList) == null ? void 0 : _a2.contains(cl);
232
- };
240
+ var checkClass = (el, cl) => el.classList?.contains(cl);
233
241
  var hasIgnoreClass = (e, ignoreClass) => {
234
242
  let el = e.target || e;
235
243
  while (el) {
@@ -252,16 +260,16 @@ var useOnClickOutside = (callback, {
252
260
  ignoreClass = DEFAULT_IGNORE_CLASS,
253
261
  refs: refsOpt
254
262
  } = {}) => {
255
- const [refsState, setRefsState] = import_react8.default.useState([]);
256
- const callbackRef = import_react8.default.useRef(callback);
263
+ const [refsState, setRefsState] = import_react11.default.useState([]);
264
+ const callbackRef = import_react11.default.useRef(callback);
257
265
  callbackRef.current = callback;
258
- const ref = import_react8.default.useCallback(
266
+ const ref = import_react11.default.useCallback(
259
267
  (el) => setRefsState((prevState) => [...prevState, { current: el }]),
260
268
  []
261
269
  );
262
- import_react8.default.useEffect(
270
+ import_react11.default.useEffect(
263
271
  () => {
264
- if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0) return;
272
+ if (!refsOpt?.length && refsState.length === 0) return;
265
273
  const getEls = () => {
266
274
  const els = [];
267
275
  (refsOpt || refsState).forEach(
@@ -277,7 +285,7 @@ var useOnClickOutside = (callback, {
277
285
  // On firefox the iframe becomes document.activeElement in the next event loop
278
286
  setTimeout(() => {
279
287
  const { activeElement } = document;
280
- if ((activeElement == null ? void 0 : activeElement.tagName) === "IFRAME" && !hasIgnoreClass(activeElement, ignoreClass) && !getEls().includes(activeElement))
288
+ if (activeElement?.tagName === "IFRAME" && !hasIgnoreClass(activeElement, ignoreClass) && !getEls().includes(activeElement))
281
289
  callbackRef.current(e);
282
290
  }, 0)
283
291
  );
@@ -316,33 +324,33 @@ var useOnClickOutside = (callback, {
316
324
  };
317
325
 
318
326
  // src/useStableMemo.ts
319
- var import_react9 = __toESM(require("react"));
327
+ var import_react12 = __toESM(require("react"));
320
328
  var useStableMemo = (producer, deps) => {
321
- const [value, setValue] = import_react9.default.useState(producer);
322
- import_react9.default.useLayoutEffect(() => {
329
+ const [value, setValue] = import_react12.default.useState(producer);
330
+ import_react12.default.useLayoutEffect(() => {
323
331
  setValue(producer);
324
332
  }, deps);
325
333
  return value;
326
334
  };
327
335
 
328
336
  // src/withProviders.tsx
329
- var import_react10 = __toESM(require("react"));
337
+ var import_react13 = __toESM(require("react"));
330
338
  var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
331
339
  (acc, prov) => {
332
340
  let Provider = prov;
333
341
  if (Array.isArray(prov)) {
334
342
  [Provider] = prov;
335
- return /* @__PURE__ */ import_react10.default.createElement(Provider, __spreadValues({}, prov[1]), acc);
343
+ return /* @__PURE__ */ import_react13.default.createElement(Provider, { ...prov[1] }, acc);
336
344
  }
337
- return /* @__PURE__ */ import_react10.default.createElement(Provider, null, acc);
345
+ return /* @__PURE__ */ import_react13.default.createElement(Provider, null, acc);
338
346
  },
339
- /* @__PURE__ */ import_react10.default.createElement(WrappedComponent, __spreadValues({}, props))
347
+ /* @__PURE__ */ import_react13.default.createElement(WrappedComponent, { ...props })
340
348
  );
341
349
 
342
350
  // src/withRef.tsx
343
- var import_react11 = __toESM(require("react"));
351
+ var import_react14 = __toESM(require("react"));
344
352
  function withRef(renderFunction) {
345
- return import_react11.default.forwardRef(renderFunction);
353
+ return import_react14.default.forwardRef(renderFunction);
346
354
  }
347
355
  // Annotate the CommonJS export names for ESM import in node:
348
356
  0 && (module.exports = {
@@ -358,7 +366,10 @@ function withRef(renderFunction) {
358
366
  createPrimitiveElement,
359
367
  createSlotComponent,
360
368
  useComposedRef,
369
+ useEffectOnce,
361
370
  useIsomorphicLayoutEffect,
371
+ useMemoOnce,
372
+ useMemoizedSelector,
362
373
  useOnClickOutside,
363
374
  useStableMemo,
364
375
  withProviders,
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/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,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,UAAW,QAAQ,8BAAAC,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AAEpC,SAAO,iBAAAC,QAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACJ9C,IAA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AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,KAAK,UAAU,UAAU;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;;;ACtKA,IAAAC,gBAAkB;AAEX,IAAM,gBAAgB,CAC3B,UACA,SACM;AACN,QAAM,CAAC,OAAO,QAAQ,IAAI,cAAAC,QAAM,SAAS,QAAQ;AAEjD,gBAAAA,QAAM,gBAAgB,MAAM;AAC1B,aAAS,QAAQ;AAAA,EAEnB,GAAG,IAAI;AAEP,SAAO;AACT;;;ACdA,IAAAC,iBAAkB;AAMX,IAAM,gBACX,IAAI,cACJ,CAAK,qBACL,CAAC,UACC,UAAU;AAAA,EACR,CAAC,KAAK,SAAS;AACb,QAAI,WAAW;AAEf,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,OAAC,QAAQ,IAAI;AAEb,aAAO,+BAAAC,QAAA,cAAC,6BAAa,KAAK,CAAC,IAAI,GAAI;AAAA,IACrC;AAEA,WAAO,+BAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,+BAAAA,QAAA,cAAC,qCAAsB,MAAe;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"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoOnce.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/useStableMemo.ts","../src/withProviders.tsx","../src/withRef.tsx"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Box';\nexport * from './MemoizedChildren';\nexport * from './PortalBody';\nexport * from './Text';\nexport * from './composeEventHandlers';\nexport * from './createPrimitiveComponent';\nexport * from './createPrimitiveElement';\nexport * from './createSlotComponent';\nexport * from './useComposedRef';\nexport * from './useEffectOnce';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMemoOnce';\nexport * from './useMemoizedSelector';\nexport * from './useOnClickOutside';\nexport * from './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';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n","import React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return (<>{children}</>) as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","/* 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 function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\nexport function useMemoOnce<T>(\n factory: () => T,\n deps: React.DependencyList\n): T {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n const memoizedValueRef = React.useRef<T>();\n\n if (\n !initialized.current ||\n deps.some((dep, i) => dep !== prevDepsRef.current[i])\n ) {\n initialized.current = true;\n prevDepsRef.current = deps;\n memoizedValueRef.current = factory();\n }\n\n return memoizedValueRef.current!;\n}\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n // 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;AAA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d,gBAOA;AACA,SAAO,eAAAC,QAAM,WAAW,cAAqB;AAC/C;","names":["React","import_react","React","import_react","React","ReactDOM","import_react","import_react","React","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React","import_react","React"]}
package/dist/index.mjs CHANGED
@@ -1,78 +1,45 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
-
33
1
  // src/createSlotComponent.tsx
34
2
  import React from "react";
35
3
  import { Slot } from "@radix-ui/react-slot";
36
4
  var createSlotComponent = (element) => (
37
5
  // eslint-disable-next-line react/display-name
38
- React.forwardRef((_a2, ref) => {
39
- var _b = _a2, { as, asChild = false } = _b, props = __objRest(_b, ["as", "asChild"]);
6
+ React.forwardRef(({ as, asChild = false, ...props }, ref) => {
40
7
  const Comp = asChild ? Slot : as || element;
41
- return /* @__PURE__ */ React.createElement(Comp, __spreadValues({ ref }, props));
8
+ return /* @__PURE__ */ React.createElement(Comp, { ref, ...props });
42
9
  })
43
10
  );
44
11
 
45
12
  // src/Box.tsx
46
13
  var Box = createSlotComponent("div");
47
14
 
48
- // src/PortalBody.tsx
15
+ // src/MemoizedChildren.tsx
49
16
  import React2 from "react";
17
+ var MemoizedChildren = React2.memo(
18
+ ({ children }) => {
19
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
20
+ }
21
+ );
22
+
23
+ // src/PortalBody.tsx
24
+ import React3 from "react";
50
25
  import ReactDOM from "react-dom";
51
26
  var PortalBody = ({
52
27
  children,
53
28
  element
54
29
  }) => {
55
30
  const container = element || typeof window !== "undefined" ? document.body : void 0;
56
- if (!container) return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
31
+ if (!container) return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
57
32
  return ReactDOM.createPortal(children, element || document.body);
58
33
  };
59
34
 
60
35
  // src/Text.tsx
61
36
  var Text = createSlotComponent("span");
62
37
 
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
-
71
38
  // src/composeEventHandlers.ts
72
39
  var composeEventHandlers = (originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) => (event) => {
73
- originalEventHandler == null ? void 0 : originalEventHandler(event);
40
+ originalEventHandler?.(event);
74
41
  if (checkForDefaultPrevented === false || !event.defaultPrevented) {
75
- return ourEventHandler == null ? void 0 : ourEventHandler(event);
42
+ return ourEventHandler?.(event);
76
43
  }
77
44
  };
78
45
 
@@ -103,21 +70,14 @@ var createPrimitiveComponent = (element) => {
103
70
  stateHook
104
71
  } = {}) => {
105
72
  return React5.forwardRef(
106
- (_a2, ref) => {
107
- var _b = _a2, {
108
- asChild,
109
- className: classNameProp,
110
- getClassName,
111
- options,
112
- state: stateProp
113
- } = _b, props = __objRest(_b, [
114
- "asChild",
115
- "className",
116
- "getClassName",
117
- "options",
118
- "state"
119
- ]);
120
- var _a3, _b2;
73
+ ({
74
+ asChild,
75
+ className: classNameProp,
76
+ getClassName,
77
+ options,
78
+ state: stateProp,
79
+ ...props
80
+ }, ref) => {
121
81
  const state = isDefined(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
122
82
  const {
123
83
  hidden,
@@ -125,18 +85,20 @@ var createPrimitiveComponent = (element) => {
125
85
  ref: hookRef
126
86
  } = propsHook ? propsHook(state) : { hidden: false, props: {}, ref: null };
127
87
  const _ref = useComposedRef(ref, hookRef);
128
- const className = isDefined(hookProps == null ? void 0 : hookProps.className) || isDefined(classNameProp) ? clsx(hookProps == null ? void 0 : hookProps.className, classNameProp) : void 0;
129
- const style = (hookProps == null ? void 0 : hookProps.style) || props.style ? __spreadValues(__spreadValues({}, hookProps == null ? void 0 : hookProps.style), props.style) : void 0;
88
+ const className = isDefined(hookProps?.className) || isDefined(classNameProp) ? clsx(hookProps?.className, classNameProp) : void 0;
89
+ const style = hookProps?.style || props.style ? { ...hookProps?.style, ...props.style } : void 0;
130
90
  if (!asChild && hidden) return null;
131
91
  return /* @__PURE__ */ React5.createElement(
132
92
  Comp,
133
- __spreadValues(__spreadValues(__spreadProps(__spreadValues({
93
+ {
134
94
  ref: _ref,
135
- asChild
136
- }, hookProps), {
95
+ asChild,
96
+ ...hookProps,
137
97
  className,
138
- style
139
- }), props), (_b2 = (_a3 = props.setProps) == null ? void 0 : _a3.call(props, hookProps != null ? hookProps : {})) != null ? _b2 : {})
98
+ style,
99
+ ...props,
100
+ ...props.setProps?.(hookProps ?? {}) ?? {}
101
+ }
140
102
  );
141
103
  }
142
104
  );
@@ -148,19 +110,62 @@ import React6 from "react";
148
110
  function createPrimitiveElement(tag) {
149
111
  return React6.forwardRef(
150
112
  function CreateComponent(props, ref) {
151
- return React6.createElement(tag, __spreadProps(__spreadValues({}, props), { ref }));
113
+ return React6.createElement(tag, { ...props, ref });
152
114
  }
153
115
  );
154
116
  }
155
117
 
156
- // src/useIsomorphicLayoutEffect.ts
118
+ // src/useEffectOnce.ts
157
119
  import React7 from "react";
158
- var _a;
159
- var CAN_USE_DOM = typeof window !== "undefined" && ((_a = window.document) == null ? void 0 : _a.createElement) !== void 0;
160
- var useIsomorphicLayoutEffect = CAN_USE_DOM ? React7.useLayoutEffect : React7.useEffect;
120
+ function useEffectOnce(effect, deps) {
121
+ const initialized = React7.useRef(false);
122
+ const prevDepsRef = React7.useRef(deps);
123
+ React7.useEffect(() => {
124
+ const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);
125
+ if (!initialized.current || depsChanged) {
126
+ initialized.current = true;
127
+ prevDepsRef.current = deps;
128
+ effect();
129
+ }
130
+ }, deps);
131
+ }
161
132
 
162
- // src/useOnClickOutside.ts
133
+ // src/useIsomorphicLayoutEffect.ts
163
134
  import React8 from "react";
135
+ var CAN_USE_DOM = typeof window !== "undefined" && window.document?.createElement !== void 0;
136
+ var useIsomorphicLayoutEffect = CAN_USE_DOM ? React8.useLayoutEffect : React8.useEffect;
137
+
138
+ // src/useMemoOnce.ts
139
+ import React9 from "react";
140
+ function useMemoOnce(factory, deps) {
141
+ const initialized = React9.useRef(false);
142
+ const prevDepsRef = React9.useRef(deps);
143
+ const memoizedValueRef = React9.useRef();
144
+ if (!initialized.current || deps.some((dep, i) => dep !== prevDepsRef.current[i])) {
145
+ initialized.current = true;
146
+ prevDepsRef.current = deps;
147
+ memoizedValueRef.current = factory();
148
+ }
149
+ return memoizedValueRef.current;
150
+ }
151
+
152
+ // src/useMemoizedSelector.ts
153
+ import React10 from "react";
154
+ function useMemoizedSelector(selector, deps, equalityFn = (a, b) => a === b) {
155
+ const [memoizedValue, setMemoizedValue] = React10.useState(() => selector());
156
+ const previousValueRef = React10.useRef(memoizedValue);
157
+ React10.useEffect(() => {
158
+ const newValue = selector();
159
+ if (!equalityFn(previousValueRef.current, newValue)) {
160
+ setMemoizedValue(newValue);
161
+ previousValueRef.current = newValue;
162
+ }
163
+ }, deps);
164
+ return memoizedValue;
165
+ }
166
+
167
+ // src/useOnClickOutside.ts
168
+ import React11 from "react";
164
169
  var canUsePassiveEvents = () => {
165
170
  if (typeof window === "undefined" || typeof window.addEventListener !== "function")
166
171
  return false;
@@ -177,10 +182,7 @@ var canUsePassiveEvents = () => {
177
182
  return passive;
178
183
  };
179
184
  var DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
180
- var checkClass = (el, cl) => {
181
- var _a2;
182
- return (_a2 = el.classList) == null ? void 0 : _a2.contains(cl);
183
- };
185
+ var checkClass = (el, cl) => el.classList?.contains(cl);
184
186
  var hasIgnoreClass = (e, ignoreClass) => {
185
187
  let el = e.target || e;
186
188
  while (el) {
@@ -203,16 +205,16 @@ var useOnClickOutside = (callback, {
203
205
  ignoreClass = DEFAULT_IGNORE_CLASS,
204
206
  refs: refsOpt
205
207
  } = {}) => {
206
- const [refsState, setRefsState] = React8.useState([]);
207
- const callbackRef = React8.useRef(callback);
208
+ const [refsState, setRefsState] = React11.useState([]);
209
+ const callbackRef = React11.useRef(callback);
208
210
  callbackRef.current = callback;
209
- const ref = React8.useCallback(
211
+ const ref = React11.useCallback(
210
212
  (el) => setRefsState((prevState) => [...prevState, { current: el }]),
211
213
  []
212
214
  );
213
- React8.useEffect(
215
+ React11.useEffect(
214
216
  () => {
215
- if (!(refsOpt == null ? void 0 : refsOpt.length) && refsState.length === 0) return;
217
+ if (!refsOpt?.length && refsState.length === 0) return;
216
218
  const getEls = () => {
217
219
  const els = [];
218
220
  (refsOpt || refsState).forEach(
@@ -228,7 +230,7 @@ var useOnClickOutside = (callback, {
228
230
  // On firefox the iframe becomes document.activeElement in the next event loop
229
231
  setTimeout(() => {
230
232
  const { activeElement } = document;
231
- if ((activeElement == null ? void 0 : activeElement.tagName) === "IFRAME" && !hasIgnoreClass(activeElement, ignoreClass) && !getEls().includes(activeElement))
233
+ if (activeElement?.tagName === "IFRAME" && !hasIgnoreClass(activeElement, ignoreClass) && !getEls().includes(activeElement))
232
234
  callbackRef.current(e);
233
235
  }, 0)
234
236
  );
@@ -267,33 +269,33 @@ var useOnClickOutside = (callback, {
267
269
  };
268
270
 
269
271
  // src/useStableMemo.ts
270
- import React9 from "react";
272
+ import React12 from "react";
271
273
  var useStableMemo = (producer, deps) => {
272
- const [value, setValue] = React9.useState(producer);
273
- React9.useLayoutEffect(() => {
274
+ const [value, setValue] = React12.useState(producer);
275
+ React12.useLayoutEffect(() => {
274
276
  setValue(producer);
275
277
  }, deps);
276
278
  return value;
277
279
  };
278
280
 
279
281
  // src/withProviders.tsx
280
- import React10 from "react";
282
+ import React13 from "react";
281
283
  var withProviders = (...providers) => (WrappedComponent) => (props) => providers.reduceRight(
282
284
  (acc, prov) => {
283
285
  let Provider = prov;
284
286
  if (Array.isArray(prov)) {
285
287
  [Provider] = prov;
286
- return /* @__PURE__ */ React10.createElement(Provider, __spreadValues({}, prov[1]), acc);
288
+ return /* @__PURE__ */ React13.createElement(Provider, { ...prov[1] }, acc);
287
289
  }
288
- return /* @__PURE__ */ React10.createElement(Provider, null, acc);
290
+ return /* @__PURE__ */ React13.createElement(Provider, null, acc);
289
291
  },
290
- /* @__PURE__ */ React10.createElement(WrappedComponent, __spreadValues({}, props))
292
+ /* @__PURE__ */ React13.createElement(WrappedComponent, { ...props })
291
293
  );
292
294
 
293
295
  // src/withRef.tsx
294
- import React11 from "react";
296
+ import React14 from "react";
295
297
  function withRef(renderFunction) {
296
- return React11.forwardRef(renderFunction);
298
+ return React14.forwardRef(renderFunction);
297
299
  }
298
300
  export {
299
301
  Box,
@@ -308,7 +310,10 @@ export {
308
310
  createPrimitiveElement,
309
311
  createSlotComponent,
310
312
  useComposedRef,
313
+ useEffectOnce,
311
314
  useIsomorphicLayoutEffect,
315
+ useMemoOnce,
316
+ useMemoizedSelector,
312
317
  useOnClickOutside,
313
318
  useStableMemo,
314
319
  withProviders,
@@ -1 +1 @@
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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AA,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"]}
1
+ {"version":3,"sources":["../src/createSlotComponent.tsx","../src/Box.tsx","../src/MemoizedChildren.tsx","../src/PortalBody.tsx","../src/Text.tsx","../src/composeEventHandlers.ts","../src/createPrimitiveComponent.tsx","../src/useComposedRef.ts","../src/createPrimitiveElement.tsx","../src/useEffectOnce.ts","../src/useIsomorphicLayoutEffect.ts","../src/useMemoOnce.ts","../src/useMemoizedSelector.ts","../src/useOnClickOutside.ts","../src/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';\n\nexport const MemoizedChildren = React.memo(\n ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n","import React from 'react';\nimport ReactDOM from 'react-dom';\n\nexport type PortalBodyProps = { children: React.ReactNode; element?: Element };\n\nexport const PortalBody: ({\n children,\n element,\n}: PortalBodyProps) => React.ReactPortal = ({\n children,\n element,\n}: PortalBodyProps) => {\n const container =\n element || typeof window !== 'undefined' ? document.body : undefined;\n\n if (!container) return (<>{children}</>) as any;\n\n return ReactDOM.createPortal(children, element || document.body);\n};\n","import type React from 'react';\n\nimport { createSlotComponent } from './createSlotComponent';\n\nexport const Text = createSlotComponent('span');\n\nexport type TextProps = React.ComponentPropsWithRef<typeof Text>;\n","/** @see https://github.com/radix-ui/primitives/blob/b324ec2d7ddf13a2a115cb5b11478e24d2f45b87/packages/core/primitive/src/primitive.tsx#L1 */\nexport const composeEventHandlers =\n <E>(\n originalEventHandler?: (event: E) => void,\n ourEventHandler?: (event: E) => void,\n { checkForDefaultPrevented = true } = {}\n ) =>\n (event: E) => {\n originalEventHandler?.(event);\n\n if (\n checkForDefaultPrevented === false ||\n !(event as unknown as Event).defaultPrevented\n ) {\n return ourEventHandler?.(event);\n }\n };\n","/* 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 function useEffectOnce(\n effect: React.EffectCallback,\n deps: React.DependencyList\n) {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n\n React.useEffect(() => {\n const depsChanged = deps.some((dep, i) => dep !== prevDepsRef.current[i]);\n\n if (!initialized.current || depsChanged) {\n initialized.current = true;\n prevDepsRef.current = deps;\n effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n","import React from 'react';\n\nexport const CAN_USE_DOM =\n typeof window !== 'undefined' && window.document?.createElement !== undefined;\n\n/**\n * Prevent warning on SSR by falling back to React.useEffect when DOM isn't\n * available\n */\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n ? React.useLayoutEffect\n : React.useEffect;\n","import React from 'react';\n\nexport function useMemoOnce<T>(\n factory: () => T,\n deps: React.DependencyList\n): T {\n const initialized = React.useRef(false);\n const prevDepsRef = React.useRef(deps);\n const memoizedValueRef = React.useRef<T>();\n\n if (\n !initialized.current ||\n deps.some((dep, i) => dep !== prevDepsRef.current[i])\n ) {\n initialized.current = true;\n prevDepsRef.current = deps;\n memoizedValueRef.current = factory();\n }\n\n return memoizedValueRef.current!;\n}\n","import React from 'react';\n\n/**\n * Re-render only when the selector result changes.\n *\n * @param selector A function that derives a value from deps\n * @param deps Dependencies on which to run the selector\n * @param equalityFn Optional comparison function to detect changes in the\n * derived value\n */\nexport function useMemoizedSelector<R>(\n selector: () => R,\n deps: React.DependencyList,\n equalityFn: (a: R, b: R) => boolean = (a, b) => a === b\n) {\n // Initialize our state with the initial \"selected\" value.\n const [memoizedValue, setMemoizedValue] = React.useState<R>(() => selector());\n\n // Keep a ref of the previous value so we can compare in an effect.\n const previousValueRef = React.useRef<R>(memoizedValue);\n\n React.useEffect(() => {\n // Compute a new value by calling the selector.\n const newValue = selector();\n\n // If different, update state and the ref.\n if (!equalityFn(previousValueRef.current, newValue)) {\n setMemoizedValue(newValue);\n previousValueRef.current = newValue;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return memoizedValue;\n}\n","import React from 'react';\n\nconst canUsePassiveEvents = (): boolean => {\n if (\n typeof window === 'undefined' ||\n typeof window.addEventListener !== 'function'\n )\n return false;\n\n let passive = false;\n const options = Object.defineProperty({}, 'passive', {\n // 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,CAAC,EAAE,IAAI,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC5C,UAAM,OAAO,UAAU,OAAQ,MAAY;AAE3C,WAAO,oCAAC,QAAK,KAAW,GAAG,OAAO;AAAA,EACpC,CAAC;AAAA;;;ACjBI,IAAM,MAAM,oBAAoB,KAAK;;;ACJ5C,OAAOA,YAAW;AAEX,IAAM,mBAAmBA,OAAM;AAAA,EACpC,CAAC,EAAE,SAAS,MAAqC;AAC/C,WAAO,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAAA,EACrB;AACF;;;ACNA,OAAOC,YAAW;AAClB,OAAO,cAAc;AAId,IAAM,aAG8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,YACJ,WAAW,OAAO,WAAW,cAAc,SAAS,OAAO;AAE7D,MAAI,CAAC,UAAW,QAAQ,gBAAAA,OAAA,cAAAA,OAAA,gBAAG,QAAS;AAEpC,SAAO,SAAS,aAAa,UAAU,WAAW,SAAS,IAAI;AACjE;;;ACdO,IAAM,OAAO,oBAAoB,MAAM;;;ACHvC,IAAM,uBACX,CACE,sBACA,iBACA,EAAE,2BAA2B,KAAK,IAAI,CAAC,MAEzC,CAAC,UAAa;AACZ,yBAAuB,KAAK;AAE5B,MACE,6BAA6B,SAC7B,CAAE,MAA2B,kBAC7B;AACA,WAAO,kBAAkB,KAAK;AAAA,EAChC;AACF;;;ACdF,OAAOC,YAAW;AAElB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;;;ACLrB,OAAOC,YAAW;AAQlB,IAAM,SAAS,CAAI,KAAqB,UAAa;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A,YACA;AAAA,YACA,gBAAgB,IAAI;AAAA,UACtB;AAAA,QACF;AAEA,YAAI,aAAc,QAAO,oBAAoB,QAAQ,WAAW;AAAA,MAClE;AAEA,UAAI,UAAU;AACZ,4BAAoB;AAEpB;AAAA,MACF;AAEA,iBAAW;AAAA,QAAQ,CAAC,SAClB,SAAS,iBAAiB,MAAM,SAAS,gBAAgB,IAAI,CAAC;AAAA,MAChE;AAEA,UAAI,aAAc,QAAO,iBAAiB,QAAQ,WAAW;AAG7D,aAAO,MAAM,oBAAoB;AAAA,IACnC;AAAA;AAAA,IAEA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,KAAK,UAAU,UAAU;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;;;ACtKA,OAAOC,aAAW;AAEX,IAAM,gBAAgB,CAC3B,UACA,SACM;AACN,QAAM,CAAC,OAAO,QAAQ,IAAIA,QAAM,SAAS,QAAQ;AAEjD,EAAAA,QAAM,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,gBAAAA,QAAA,cAAC,YAAU,GAAG,KAAK,CAAC,KAAI,GAAI;AAAA,IACrC;AAEA,WAAO,gBAAAA,QAAA,cAAC,gBAAU,GAAI;AAAA,EACxB;AAAA,EACA,gBAAAA,QAAA,cAAC,oBAAkB,GAAI,OAAe;AACxC;;;ACvBJ,OAAOC,aAAW;AAwCX,SAAS,QACd,gBAOA;AACA,SAAOA,QAAM,WAAW,cAAqB;AAC/C;","names":["React","React","React","React","React","React","React","React","React","React","React","React","React","React"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udecode/react-utils",
3
- "version": "39.0.0",
3
+ "version": "42.0.0",
4
4
  "description": "Udecode React utils",
5
5
  "keywords": [
6
6
  "utils"
@@ -42,12 +42,12 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@radix-ui/react-slot": "^1.1.0",
45
- "@udecode/utils": "37.0.0",
45
+ "@udecode/utils": "42.0.0",
46
46
  "clsx": "^2.1.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "react": ">=16.8.0",
50
- "react-dom": ">=16.8.0"
49
+ "react": ">=18.0.0",
50
+ "react-dom": ">=18.0.0"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"