@udecode/react-utils 52.0.1 → 52.3.4

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/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Ziad Beyens, Dylan Schiemann, Joe Anderson, Felix Feng
4
+
5
+ Unless otherwise specified in a LICENSE file within an individual package directory,
6
+ this license applies to all files in this repository outside of those package directories.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -112,7 +112,7 @@ declare const CAN_USE_DOM: boolean;
112
112
  * Prevent warning on SSR by falling back to React.useEffect when DOM isn't
113
113
  * available
114
114
  */
115
- declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
115
+ declare const useIsomorphicLayoutEffect: typeof React.useEffect;
116
116
  //#endregion
117
117
  //#region src/useMemoizedSelector.d.ts
118
118
  /**
@@ -123,7 +123,7 @@ declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
123
123
  * @param equalityFn Optional comparison function to detect changes in the
124
124
  * derived value
125
125
  */
126
- declare function useMemoizedSelector<R$1>(selector: () => R$1, deps: React.DependencyList, equalityFn?: (a: R$1, b: R$1) => boolean): R$1;
126
+ declare function useMemoizedSelector<R>(selector: () => R, deps: React.DependencyList, equalityFn?: (a: R, b: R) => boolean): R;
127
127
  //#endregion
128
128
  //#region src/useOnClickOutside.d.ts
129
129
  declare const DEFAULT_IGNORE_CLASS = "ignore-onclickoutside";
@@ -158,7 +158,7 @@ declare const useOnClickOutside: (callback: UseOnClickOutsideCallback, {
158
158
  * If you do want the function to be replaced when certain dependency values
159
159
  * change, include those values in the dependency array of useStableFn.
160
160
  */
161
- declare const useStableFn: <A extends unknown[], R$1>(fn: (...args: A) => R$1, deps?: DependencyList) => (...args: A) => R$1;
161
+ declare const useStableFn: <A extends unknown[], R>(fn: (...args: A) => R, deps?: DependencyList) => (...args: A) => R;
162
162
  //#endregion
163
163
  //#region src/useStableMemo.d.ts
164
164
  declare const useStableMemo: <T>(producer: () => T, deps?: React.DependencyList) => T;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c } from "react/compiler-runtime";
1
+ import { c } from "react-compiler-runtime";
2
2
  import { Slot } from "@radix-ui/react-slot";
3
3
  import React from "react";
4
4
  import ReactDOM from "react-dom";
@@ -136,8 +136,40 @@ const useComposedRef = (...refs) => {
136
136
  const createPrimitiveComponent = (element) => {
137
137
  const Comp = createSlotComponent(element);
138
138
  return ({ propsHook, stateHook } = {}) => React.forwardRef((t0, ref) => {
139
- const $ = c(9);
140
- const { asChild, className: classNameProp, getClassName, options, state: stateProp, ...props } = t0;
139
+ const $ = c(17);
140
+ let asChild;
141
+ let classNameProp;
142
+ let options;
143
+ let props;
144
+ let setProps;
145
+ let stateProp;
146
+ let styleProp;
147
+ if ($[0] !== t0) {
148
+ const { asChild: t1$1, className: t2$1, getClassName, options: t3, setProps: t4, state: t5, style: t6, ...t7 } = t0;
149
+ asChild = t1$1;
150
+ classNameProp = t2$1;
151
+ options = t3;
152
+ setProps = t4;
153
+ stateProp = t5;
154
+ styleProp = t6;
155
+ props = t7;
156
+ $[0] = t0;
157
+ $[1] = asChild;
158
+ $[2] = classNameProp;
159
+ $[3] = options;
160
+ $[4] = props;
161
+ $[5] = setProps;
162
+ $[6] = stateProp;
163
+ $[7] = styleProp;
164
+ } else {
165
+ asChild = $[1];
166
+ classNameProp = $[2];
167
+ options = $[3];
168
+ props = $[4];
169
+ setProps = $[5];
170
+ stateProp = $[6];
171
+ styleProp = $[7];
172
+ }
141
173
  const state = isDefined(stateProp) ? stateProp : stateHook ? stateHook(options) : void 0;
142
174
  const { hidden, props: hookProps, ref: hookRef } = propsHook ? propsHook(state) : {
143
175
  hidden: false,
@@ -146,15 +178,15 @@ const createPrimitiveComponent = (element) => {
146
178
  };
147
179
  const _ref = useComposedRef(ref, hookRef);
148
180
  const className = isDefined(hookProps?.className) || isDefined(classNameProp) ? clsx(hookProps?.className, classNameProp) : void 0;
149
- const style = hookProps?.style || props.style ? {
181
+ const style = hookProps?.style || styleProp ? {
150
182
  ...hookProps?.style,
151
- ...props.style
183
+ ...styleProp
152
184
  } : void 0;
153
185
  if (!asChild && hidden) return null;
154
186
  const T0 = Comp;
155
- const t1 = props.setProps?.(hookProps ?? {}) ?? {};
187
+ const t1 = setProps?.(hookProps ?? {}) ?? {};
156
188
  let t2;
157
- if ($[0] !== T0 || $[1] !== _ref || $[2] !== asChild || $[3] !== className || $[4] !== hookProps || $[5] !== props || $[6] !== style || $[7] !== t1) {
189
+ if ($[8] !== T0 || $[9] !== _ref || $[10] !== asChild || $[11] !== className || $[12] !== hookProps || $[13] !== props || $[14] !== style || $[15] !== t1) {
158
190
  t2 = /* @__PURE__ */ React.createElement(T0, {
159
191
  asChild,
160
192
  ref: _ref,
@@ -164,16 +196,16 @@ const createPrimitiveComponent = (element) => {
164
196
  ...props,
165
197
  ...t1
166
198
  });
167
- $[0] = T0;
168
- $[1] = _ref;
169
- $[2] = asChild;
170
- $[3] = className;
171
- $[4] = hookProps;
172
- $[5] = props;
173
- $[6] = style;
174
- $[7] = t1;
175
- $[8] = t2;
176
- } else t2 = $[8];
199
+ $[8] = T0;
200
+ $[9] = _ref;
201
+ $[10] = asChild;
202
+ $[11] = className;
203
+ $[12] = hookProps;
204
+ $[13] = props;
205
+ $[14] = style;
206
+ $[15] = t1;
207
+ $[16] = t2;
208
+ } else t2 = $[16];
177
209
  return t2;
178
210
  });
179
211
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udecode/react-utils",
3
- "version": "52.0.1",
3
+ "version": "52.3.4",
4
4
  "description": "React utils",
5
5
  "keywords": [
6
6
  "utils"
@@ -24,21 +24,11 @@
24
24
  "files": [
25
25
  "dist/**/*"
26
26
  ],
27
- "scripts": {
28
- "brl": "yarn p:brl",
29
- "build": "yarn p:build",
30
- "build:watch": "yarn p:build:watch",
31
- "clean": "yarn p:clean",
32
- "lint": "yarn p:lint",
33
- "lint:fix": "yarn p:lint:fix",
34
- "test": "yarn p:test",
35
- "test:watch": "yarn p:test:watch",
36
- "typecheck": "yarn p:typecheck"
37
- },
38
27
  "dependencies": {
39
28
  "@radix-ui/react-slot": "^1.2.3",
40
- "@udecode/utils": "52.0.1",
41
- "clsx": "^2.1.1"
29
+ "clsx": "^2.1.1",
30
+ "react-compiler-runtime": "^1.0.0",
31
+ "@udecode/utils": "52.3.4"
42
32
  },
43
33
  "peerDependencies": {
44
34
  "react": ">=18.0.0",
@@ -48,5 +38,19 @@
48
38
  "access": "public"
49
39
  },
50
40
  "type": "module",
51
- "module": "./dist/index.js"
52
- }
41
+ "module": "./dist/index.js",
42
+ "devDependencies": {
43
+ "@plate/scripts": "1.0.0"
44
+ },
45
+ "scripts": {
46
+ "brl": "plate-pkg p:brl",
47
+ "build": "plate-pkg p:build",
48
+ "build:watch": "plate-pkg p:build:watch",
49
+ "clean": "plate-pkg p:clean",
50
+ "lint": "plate-pkg p:lint",
51
+ "lint:fix": "plate-pkg p:lint:fix",
52
+ "test": "plate-pkg p:test",
53
+ "test:watch": "plate-pkg p:test:watch",
54
+ "typecheck": "plate-pkg p:typecheck"
55
+ }
56
+ }