@strapi/ui-primitives 2.0.0-beta.4 → 2.0.0-beta.5
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/helpers/events.d.ts +4 -1
- package/dist/hooks/useCallbackRef.d.ts +6 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
package/dist/helpers/events.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare function composeEventHandlers<E>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {
|
|
2
|
+
checkForDefaultPrevented?: boolean | undefined;
|
|
3
|
+
}): (event: E) => void;
|
|
4
|
+
export { composeEventHandlers };
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
3
|
+
* prop or avoid re-executing effects when passed as a dependency
|
|
4
|
+
*/
|
|
5
|
+
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
|
|
6
|
+
export { useCallbackRef };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,7 +23,6 @@ const reactCollection = require("@radix-ui/react-collection");
|
|
|
23
23
|
const reactDirection = require("@radix-ui/react-direction");
|
|
24
24
|
const reactUsePrevious = require("@radix-ui/react-use-previous");
|
|
25
25
|
const reactVisuallyHidden = require("@radix-ui/react-visually-hidden");
|
|
26
|
-
const reactUseCallbackRef = require("@radix-ui/react-use-callback-ref");
|
|
27
26
|
function _interopNamespace(e) {
|
|
28
27
|
if (e && e.__esModule)
|
|
29
28
|
return e;
|
|
@@ -996,6 +995,13 @@ const Combobox$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
996
995
|
Trigger: Trigger$1,
|
|
997
996
|
Viewport: Viewport$1
|
|
998
997
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
998
|
+
function useCallbackRef(callback) {
|
|
999
|
+
const callbackRef = React__namespace.useRef(callback);
|
|
1000
|
+
React__namespace.useEffect(() => {
|
|
1001
|
+
callbackRef.current = callback;
|
|
1002
|
+
});
|
|
1003
|
+
return React__namespace.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
1004
|
+
}
|
|
999
1005
|
const OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
1000
1006
|
const SELECTION_KEYS = [" ", "Enter"];
|
|
1001
1007
|
const SELECT_NAME = "Select";
|
|
@@ -2079,7 +2085,7 @@ const BubbleSelect = React__namespace.forwardRef(
|
|
|
2079
2085
|
);
|
|
2080
2086
|
BubbleSelect.displayName = "BubbleSelect";
|
|
2081
2087
|
function useTypeaheadSearch(onSearchChange) {
|
|
2082
|
-
const handleSearchChange =
|
|
2088
|
+
const handleSearchChange = useCallbackRef(onSearchChange);
|
|
2083
2089
|
const searchRef = React__namespace.useRef("");
|
|
2084
2090
|
const timerRef = React__namespace.useRef(0);
|
|
2085
2091
|
const handleTypeaheadSearch = React__namespace.useCallback(
|
|
@@ -2180,17 +2186,20 @@ const Select$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
2180
2186
|
Viewport,
|
|
2181
2187
|
createSelectScope
|
|
2182
2188
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
}
|
|
2189
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
2190
|
+
return function handleEvent(event) {
|
|
2191
|
+
originalEventHandler?.(event);
|
|
2192
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
2193
|
+
return ourEventHandler?.(event);
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2191
2197
|
exports.Combobox = Combobox$1;
|
|
2192
2198
|
exports.Select = Select$1;
|
|
2199
|
+
exports.composeEventHandlers = composeEventHandlers;
|
|
2193
2200
|
exports.createCollection = createCollection;
|
|
2201
|
+
exports.useCallbackRef = useCallbackRef;
|
|
2194
2202
|
exports.useCollator = useCollator;
|
|
2195
2203
|
exports.useFilter = useFilter;
|
|
2204
|
+
exports.usePrev = usePrev;
|
|
2196
2205
|
//# sourceMappingURL=index.js.map
|