@povio/ui 2.3.0-rc.7 → 2.3.0-rc.8

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.
@@ -3,4 +3,4 @@ import { Key } from 'react-aria-components';
3
3
  import { SelectItem } from './select.types';
4
4
  export type QueryFn<TData = any> = (...args: any[]) => UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
5
  export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
6
- export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => any;
6
+ export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
@@ -1,14 +1,8 @@
1
1
  //#region src/components/inputs/Selection/shared/querySelect.utils.ts
2
- var isQueryItemsPage = (page) => {
3
- return !!page && typeof page === "object" && "items" in page && Array.isArray(page.items);
4
- };
5
2
  var getQueryItems = (data, queryMap) => {
6
3
  if (!data) return [];
7
4
  if (queryMap) return queryMap(data);
8
- if (Array.isArray(data)) {
9
- if (data.every(isQueryItemsPage)) return data.flatMap((page) => page.items);
10
- return data;
11
- }
5
+ if (Array.isArray(data)) return data;
12
6
  if (typeof data === "object" && data !== null) {
13
7
  if ("items" in data && Array.isArray(data.items)) return data.items;
14
8
  if ("pages" in data && Array.isArray(data.pages)) return data.pages.flatMap((page) => page && typeof page === "object" && "items" in page && Array.isArray(page.items) ? page.items : []);
@@ -7,27 +7,15 @@ var useStaticInputHandoff = (t0) => {
7
7
  const [shouldFocus, setShouldFocus] = useState(false);
8
8
  const pendingStaticChangeRef = useRef(null);
9
9
  const shouldReplayStaticPressRef = useRef(false);
10
- const shouldReplayStaticHoverRef = useRef(false);
11
10
  let t1;
12
11
  let t2;
13
12
  if ($[0] !== getFocusTarget || $[1] !== inputRef || $[2] !== renderInput || $[3] !== shouldFocus) {
14
13
  t1 = () => {
15
- if (!renderInput) return;
16
- const getInteractionTarget = () => {
17
- const input = inputRef.current;
18
- return input ? getFocusTarget?.(input) ?? input : null;
19
- };
20
- if (shouldReplayStaticHoverRef.current) {
21
- shouldReplayStaticHoverRef.current = false;
22
- const target = getInteractionTarget();
23
- target?.dispatchEvent(new PointerEvent("pointerover", { bubbles: true }));
24
- target?.dispatchEvent(new MouseEvent("mouseover", { bubbles: true }));
25
- target?.dispatchEvent(new MouseEvent("mouseenter"));
26
- }
27
- if (!shouldFocus) return;
14
+ if (!renderInput || !shouldFocus) return;
28
15
  const focusRealInput = (replayPendingInteraction) => {
16
+ const input = inputRef.current;
29
17
  const pendingValue = pendingStaticChangeRef.current;
30
- const focusTarget = getInteractionTarget();
18
+ const focusTarget = input ? getFocusTarget?.(input) ?? input : null;
31
19
  if (replayPendingInteraction && focusTarget instanceof HTMLInputElement && pendingValue != null) {
32
20
  (Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set)?.call(focusTarget, pendingValue);
33
21
  focusTarget.dispatchEvent(new Event("input", { bubbles: true }));
@@ -71,17 +59,14 @@ var useStaticInputHandoff = (t0) => {
71
59
  if ($[6] !== setRenderInput) {
72
60
  t3 = (focus) => {
73
61
  setShouldFocus(focus);
74
- shouldReplayStaticHoverRef.current = !focus;
75
62
  setRenderInput(true);
76
63
  };
77
64
  t4 = (value) => {
78
- shouldReplayStaticHoverRef.current = false;
79
65
  pendingStaticChangeRef.current = value;
80
66
  setShouldFocus(true);
81
67
  setRenderInput(true);
82
68
  };
83
69
  t5 = () => {
84
- shouldReplayStaticHoverRef.current = false;
85
70
  shouldReplayStaticPressRef.current = true;
86
71
  setShouldFocus(true);
87
72
  setRenderInput(true);
@@ -35,7 +35,7 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
35
35
  const totalItems = infiniteQueryResult?.data?.pages?.[0]?.totalItems;
36
36
  const items = useMemo(() => {
37
37
  if (!data) return [];
38
- return mapItems(isInfiniteQuery ? data.pages : data);
38
+ return mapItems(isInfiniteQuery ? data.pages?.flatMap((page) => page?.items ?? []) : data);
39
39
  }, [
40
40
  data,
41
41
  isInfiniteQuery,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.3.0-rc.7",
3
+ "version": "2.3.0-rc.8",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",