@povio/ui 2.2.9-rc.1 → 2.2.9-rc.2

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.
Files changed (23) hide show
  1. package/dist/components/inputs/Input/TextInput/TextInput.js +2 -0
  2. package/dist/components/inputs/Inputs/InputItem.d.ts +8 -10
  3. package/dist/components/inputs/Inputs/InputItem.js +4 -0
  4. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
  5. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +23 -7
  6. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +30 -0
  7. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +15 -0
  8. package/dist/components/inputs/Selection/Select/QuerySelect.js +56 -0
  9. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +3 -1
  10. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  11. package/dist/components/inputs/Selection/shared/SelectDesktop.js +3 -1
  12. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  13. package/dist/components/inputs/Selection/shared/SelectInput.js +3 -1
  14. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  15. package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -1
  16. package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
  17. package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
  18. package/dist/config/uiConfig.context.d.ts +6 -0
  19. package/dist/config/uiConfig.context.js +2 -0
  20. package/dist/hooks/useQueryAutocomplete.d.ts +25 -0
  21. package/dist/hooks/useQueryAutocomplete.js +41 -0
  22. package/dist/index.js +1 -1
  23. package/package.json +1 -1
@@ -75,6 +75,8 @@ var TextInputBase = (props) => {
75
75
  labelProps,
76
76
  className: clsx("group w-full", as === "inline" && "h-full", className),
77
77
  tabIndex: as === "inline" ? -1 : void 0,
78
+ "data-is-empty": value === "" || value === null || value === void 0 || void 0,
79
+ "data-is-required": isRequired || void 0,
78
80
  children: /* @__PURE__ */ jsx("div", {
79
81
  className: clsx("relative flex cursor-text has-disabled:cursor-default", inputBaseCva({
80
82
  variant,
@@ -11,23 +11,21 @@ declare const componentRegistry: {
11
11
  readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
12
12
  readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
13
13
  readonly select: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Select/Select').ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
14
- readonly autocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Autocomplete/Autocomplete').ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
15
- readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../Selection/shared/select.types').SelectItem<any>, TQueryFn extends (...args: any) => import('@tanstack/react-query').UseQueryResult<TSelectItem[]>>({ query, queryParams, queryOptions, ...props }: import('../../../types/common').OmitDiscriminatedUnion<import('../Selection/Autocomplete/Autocomplete').AutocompleteProps<Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
16
- id: infer InferredKey extends import('react-aria').Key;
17
- } ? InferredKey : never>, "onChange" | "value" | "items" | "selectionMode" | "isLoading" | "showSelectionBar" | "showSelectAllOption" | "initialSelection" | "showSelectionContent" | "onSearchChange"> & (import('../Selection/shared/select.types').GroupedSelectControlProps<TFieldValues, Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
18
- id: infer InferredKey extends import('react-aria').Key;
19
- } ? InferredKey : never> & {
20
- query: Parameters<TQueryFn>[0] extends {
21
- search?: string;
22
- } ? TQueryFn : never;
23
- queryParams?: Omit<Parameters<TQueryFn>[0], "search"> | undefined;
14
+ readonly querySelect: <TFieldValues extends import('react-hook-form').FieldValues, TQueryFn extends import('../Selection/shared/querySelect.utils').QueryFn, TKey extends import('react-aria').Key = import('react-aria').Key>({ query, queryParams, queryOptions, queryMap, ...props }: import('../../../types/common').OmitDiscriminatedUnion<import('../Selection/shared/SelectBase').SelectBaseProps<TKey>, "onChange" | "value" | "items" | "selectionMode" | "isLoading" | "showSelectionBar" | "showSelectAllOption" | "initialSelection" | "showSelectionContent"> & (import('../Selection/shared/select.types').GroupedSelectControlProps<TFieldValues, TKey> & {
15
+ query: TQueryFn;
16
+ queryParams?: Parameters<TQueryFn>[0] | undefined;
24
17
  queryOptions?: Parameters<TQueryFn>[1] | undefined;
18
+ queryMap?: ((data: Exclude<ReturnType<TQueryFn>["data"], undefined>) => import('../Selection/shared/select.types').SelectItem<TKey>[]) | undefined;
19
+ isInitialQueryDisabled?: boolean;
25
20
  })) => import("react/jsx-runtime").JSX.Element;
21
+ readonly autocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Autocomplete/Autocomplete').ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
22
+ readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../Selection/shared/select.types').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn<TSelectItem>>({ query, queryParams, queryOptions, queryMap, ...props }: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
26
23
  readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
27
24
  readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
28
25
  readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
29
26
  readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
30
27
  readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
28
+ readonly textEditor: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../../../text-editor.js').ControlledTextEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
31
29
  readonly unknown: null;
32
30
  };
33
31
  export type InputComponentRegistry = typeof componentRegistry;
@@ -13,6 +13,8 @@ import { QueryAutocomplete } from "../Selection/Autocomplete/QueryAutocomplete.j
13
13
  import { Slider } from "../Slider/Slider.js";
14
14
  import { Toggle } from "../Toggle/Toggle.js";
15
15
  import { Segment } from "../../segment/Segment.js";
16
+ import { QuerySelect } from "../Selection/Select/QuerySelect.js";
17
+ import { TextEditor } from "../TextEditor/TextEditor.js";
16
18
  import { jsx } from "react/jsx-runtime";
17
19
  //#region src/components/inputs/Inputs/InputItem.tsx
18
20
  var componentRegistry = {
@@ -24,6 +26,7 @@ var componentRegistry = {
24
26
  passwordInput: PasswordInput,
25
27
  textArea: TextArea,
26
28
  select: Select,
29
+ querySelect: QuerySelect,
27
30
  autocomplete: Autocomplete,
28
31
  queryAutocomplete: QueryAutocomplete,
29
32
  segment: Segment,
@@ -31,6 +34,7 @@ var componentRegistry = {
31
34
  dateTimePicker: DateTimePicker,
32
35
  timePicker: TimePicker,
33
36
  dateRangePicker: DateRangePicker,
37
+ textEditor: TextEditor,
34
38
  unknown: null
35
39
  };
36
40
  function InputItem({ form, inputDef }) {
@@ -1,19 +1,4 @@
1
- import { UseQueryResult } from '@tanstack/react-query';
2
- import { Key } from 'react-aria-components';
3
1
  import { FieldValues } from 'react-hook-form';
4
- import { AutocompleteProps } from './Autocomplete';
5
- import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
6
- import { OmitDiscriminatedUnion } from '../../../../types/common';
7
- type QueryFn<TSelectItem extends SelectItem = SelectItem> = (...args: any) => UseQueryResult<Array<TSelectItem>>;
8
- type TKey<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
9
- id: infer InferredKey extends Key;
10
- } ? InferredKey : never;
11
- type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>> = OmitDiscriminatedUnion<AutocompleteProps<TKey<TQueryFn>>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey<TQueryFn>> & {
12
- query: Parameters<TQueryFn>[0] extends {
13
- search?: string;
14
- } ? TQueryFn : never;
15
- queryParams?: Omit<Parameters<TQueryFn>[0], "search">;
16
- queryOptions?: Parameters<TQueryFn>[1];
17
- };
18
- export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>>({ query, queryParams, queryOptions, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
19
- export {};
2
+ import { QueryAutocompleteProps, QueryFn } from './queryAutocomplete.types';
3
+ import { SelectItem } from '../shared/select.types';
4
+ export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>>({ query, queryParams, queryOptions, queryMap, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
@@ -1,19 +1,35 @@
1
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
1
2
  import { Autocomplete } from "./Autocomplete.js";
3
+ import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
2
4
  import { jsx } from "react/jsx-runtime";
3
5
  import { useState } from "react";
4
6
  //#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
5
- var QueryAutocomplete = ({ query, queryParams, queryOptions, ...props }) => {
7
+ var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
8
+ const ui = UIConfig.useConfig();
6
9
  const [search, setSearch] = useState("");
7
- const { data: items, isLoading } = query({
10
+ const mapItems = (data) => {
11
+ const extractedData = Array.isArray(data) ? data : data.pages.flatMap((page) => page.items ?? []);
12
+ return queryMap?.(extractedData) ?? extractedData;
13
+ };
14
+ const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
15
+ query,
16
+ queryParams,
17
+ queryOptions,
18
+ mapItems: (data) => mapItems(data),
8
19
  search,
9
- ...queryParams
10
- }, queryOptions);
20
+ initialQueryState: props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
21
+ });
22
+ const { isInitialQueryDisabled: _, ...restProps } = props;
11
23
  return /* @__PURE__ */ jsx(Autocomplete, {
12
- ...props,
13
- items: items ?? [],
24
+ ...restProps,
25
+ items,
14
26
  onSearchChange: setSearch,
15
27
  isClientSearchDisabled: true,
16
- isLoading
28
+ isLoading,
29
+ onMouseEnter: handleEnableQuery,
30
+ onFocusCapture: handleEnableQuery,
31
+ hasLoadMore: hasNextPage,
32
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0
17
33
  });
18
34
  };
19
35
  //#endregion
@@ -0,0 +1,30 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { FieldValues } from 'react-hook-form';
4
+ import { AutocompleteProps } from './Autocomplete';
5
+ import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
6
+ import { OmitDiscriminatedUnion } from '../../../../types/common';
7
+ export interface QueryAutocompleteInfinitePage<TSelectItem extends SelectItem = SelectItem> {
8
+ items: Array<TSelectItem>;
9
+ totalItems?: number;
10
+ }
11
+ export type QueryResult<TSelectItem extends SelectItem = SelectItem> = UseQueryResult<Array<TSelectItem>> | UseInfiniteQueryResult<QueryAutocompleteInfinitePage<TSelectItem>>;
12
+ export type QueryFn<TSelectItem extends SelectItem = SelectItem> = (...args: any[]) => QueryResult<TSelectItem>;
13
+ export type QueryAutocompleteExtractedData<TSelectItem extends SelectItem = SelectItem> = Array<TSelectItem>;
14
+ export type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>> = OmitDiscriminatedUnion<AutocompleteProps<TSelectItem["id"]>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TSelectItem["id"]> & {
15
+ query: Parameters<TQueryFn>[0] extends {
16
+ search?: string;
17
+ } ? TQueryFn : never;
18
+ queryParams?: Omit<Parameters<TQueryFn>[0], "search">;
19
+ queryOptions?: Parameters<TQueryFn>[1];
20
+ queryMap?: (data: QueryAutocompleteExtractedData<TSelectItem>) => SelectItem<TSelectItem["id"]>[];
21
+ isInitialQueryDisabled?: boolean;
22
+ };
23
+ export interface UseQueryAutocompleteOptions<TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>, TKey extends Key = QueryAutocompleteExtractedData<TSelectItem>[number]["id"]> {
24
+ query: TQueryFn;
25
+ queryParams?: Parameters<TQueryFn>[0];
26
+ queryOptions?: Parameters<TQueryFn>[1];
27
+ queryMap?: (data: QueryAutocompleteExtractedData<TSelectItem>) => SelectItem<TKey>[];
28
+ initialQueryState?: boolean;
29
+ search: string;
30
+ }
@@ -0,0 +1,15 @@
1
+ import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
2
+ import { SelectBaseProps } from '../shared/SelectBase';
3
+ import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
4
+ import { OmitDiscriminatedUnion } from '../../../../types/common';
5
+ import { Key } from 'react-aria-components';
6
+ import { FieldValues } from 'react-hook-form';
7
+ type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key> = OmitDiscriminatedUnion<SelectBaseProps<TKey>, "items" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey> & {
8
+ query: TQueryFn;
9
+ queryParams?: Parameters<TQueryFn>[0];
10
+ queryOptions?: Parameters<TQueryFn>[1];
11
+ queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
12
+ isInitialQueryDisabled?: boolean;
13
+ };
14
+ export declare const QuerySelect: <TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, queryMap, ...props }: QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,56 @@
1
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
2
+ import { SelectBase } from "../shared/SelectBase.js";
3
+ import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
4
+ import { getQueryItems } from "../shared/querySelect.utils.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { mergeRefs } from "@react-aria/utils";
7
+ import { Controller } from "react-hook-form";
8
+ //#region src/components/inputs/Selection/Select/QuerySelect.tsx
9
+ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
10
+ const ui = UIConfig.useConfig();
11
+ const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
12
+ query,
13
+ queryParams,
14
+ queryOptions,
15
+ mapItems: (data) => getQueryItems(data, queryMap),
16
+ initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
17
+ });
18
+ if ("formControl" in props && props.formControl) {
19
+ const { formControl, ref, isInitialQueryDisabled: _, ...innerProps } = props;
20
+ return /* @__PURE__ */ jsx(Controller, {
21
+ control: formControl.control,
22
+ name: formControl.name,
23
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
24
+ ...innerProps,
25
+ ref: mergeRefs(ref, field.ref),
26
+ items,
27
+ isLoading,
28
+ hasLoadMore: hasNextPage,
29
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
30
+ value: field.value,
31
+ onChange: (value) => {
32
+ field.onChange(value);
33
+ field.onBlur?.();
34
+ },
35
+ onBlur: field.onBlur,
36
+ isDirty,
37
+ isDisabled: field.disabled || props.isDisabled,
38
+ error: props.error ?? error?.message,
39
+ onMouseEnter: handleEnableQuery,
40
+ onFocusCapture: handleEnableQuery
41
+ })
42
+ });
43
+ }
44
+ const { isInitialQueryDisabled: _, ...restProps } = props;
45
+ return /* @__PURE__ */ jsx(SelectBase, {
46
+ ...restProps,
47
+ items,
48
+ isLoading,
49
+ hasLoadMore: hasNextPage,
50
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
51
+ onMouseEnter: handleEnableQuery,
52
+ onFocusCapture: handleEnableQuery
53
+ });
54
+ };
55
+ //#endregion
56
+ export { QuerySelect };
@@ -1,4 +1,4 @@
1
- import { ReactElement, Ref } from 'react';
1
+ import { FocusEventHandler, MouseEventHandler, ReactElement, Ref } from 'react';
2
2
  import { AriaButtonProps } from 'react-aria';
3
3
  import { Key } from 'react-aria-components';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
@@ -25,5 +25,7 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
25
25
  onInputChange?: (value: string) => void;
26
26
  onSearchChange?: (value: string) => void;
27
27
  mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
28
+ onMouseEnter?: MouseEventHandler<HTMLDivElement>;
29
+ onFocusCapture?: FocusEventHandler<HTMLDivElement>;
28
30
  };
29
31
  export declare const SelectBase: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(dProps: SelectBaseProps<TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectDesktopProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -13,7 +13,7 @@ import { ComboBox, DialogTrigger, Popover } from "react-aria-components";
13
13
  import { useLabel, usePreventScroll } from "react-aria";
14
14
  import { mergeRefs } from "@react-aria/utils";
15
15
  //#region src/components/inputs/Selection/shared/SelectDesktop.tsx
16
- var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
16
+ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
17
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
18
18
  const popoverCva = UIStyle.useCva("popover.cva", popover);
19
19
  const formFieldProps = {
@@ -119,6 +119,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
119
119
  children: /* @__PURE__ */ jsx("div", {
120
120
  ...fieldProps,
121
121
  ref: mergeRefs(ref, triggerRef),
122
+ onMouseEnter,
123
+ onFocusCapture,
122
124
  children: customTrigger
123
125
  })
124
126
  }) : /* @__PURE__ */ jsx(SelectInput, {
@@ -4,12 +4,12 @@ import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
4
4
  import { SelectBaseProps } from './SelectBase';
5
5
  import { SelectItem } from './select.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
7
- interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange"> {
7
+ interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange" | "onMouseEnter" | "onFocusCapture"> {
8
8
  isInvalid?: boolean;
9
9
  className?: string;
10
10
  fieldProps?: AriaFieldProps;
11
11
  headerProps?: FormFieldHeaderProps;
12
12
  onCloseComboBox?: (state: ComboBoxState<SelectItem> | null) => void;
13
13
  }
14
- export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
15
15
  export {};
@@ -14,7 +14,7 @@ import { Button, ComboBoxStateContext, Input } from "react-aria-components";
14
14
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
15
15
  import { useTranslation } from "react-i18next";
16
16
  //#region src/components/inputs/Selection/shared/SelectInput.tsx
17
- var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, ...props }) => {
17
+ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }) => {
18
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
19
19
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
20
  const { t } = useTranslation("ui");
@@ -83,6 +83,8 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
83
83
  "data-is-required": isRequired || void 0,
84
84
  "data-is-dirty": isDirty || void 0,
85
85
  "data-select-input": "",
86
+ onMouseEnter,
87
+ onFocusCapture,
86
88
  ...hoverProps,
87
89
  ...focusWithinProps,
88
90
  children: [
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectMobileProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -13,7 +13,7 @@ import { useRef } from "react";
13
13
  import { DialogTrigger } from "react-aria-components";
14
14
  import { useLabel } from "react-aria";
15
15
  //#region src/components/inputs/Selection/shared/SelectMobile.tsx
16
- var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
16
+ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
17
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, size, collapseAfter, selectedTagsType } = props;
18
18
  const formFieldProps = {
19
19
  error,
@@ -62,6 +62,8 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
62
62
  children: [customTrigger ? /* @__PURE__ */ jsx("div", {
63
63
  ...fieldProps,
64
64
  ref,
65
+ onMouseEnter,
66
+ onFocusCapture,
65
67
  children: customTrigger
66
68
  }) : /* @__PURE__ */ jsx(SelectInput, {
67
69
  ref,
@@ -0,0 +1,6 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { SelectItem } from './select.types';
4
+ export type QueryFn<TData = any> = (...args: any[]) => UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
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>[]) => SelectItem<TKey>[];
@@ -0,0 +1,13 @@
1
+ //#region src/components/inputs/Selection/shared/querySelect.utils.ts
2
+ var getQueryItems = (data, queryMap) => {
3
+ if (!data) return [];
4
+ if (queryMap) return queryMap(data);
5
+ if (Array.isArray(data)) return data;
6
+ if (typeof data === "object" && data !== null) {
7
+ if ("items" in data && Array.isArray(data.items)) return data.items;
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 : []);
9
+ }
10
+ return [];
11
+ };
12
+ //#endregion
13
+ export { getQueryItems };
@@ -25,6 +25,12 @@ export declare namespace UIConfig {
25
25
  radioGroup: Pick<RadioGroupProps, "variant" | "hideLabel">;
26
26
  checkbox: Pick<CheckboxProps, "variant">;
27
27
  select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon" | "fireBlurOnChange">;
28
+ queryAutocomplete: {
29
+ isInitialQueryDisabled?: boolean;
30
+ };
31
+ querySelect: {
32
+ isInitialQueryDisabled?: boolean;
33
+ };
28
34
  toggle: Pick<ToggleProps, "variant">;
29
35
  slider: Pick<SliderProps, "minValue" | "maxValue">;
30
36
  dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry">;
@@ -34,6 +34,8 @@ var UIConfig;
34
34
  hideSearchIcon: false,
35
35
  fireBlurOnChange: false
36
36
  },
37
+ queryAutocomplete: { isInitialQueryDisabled: false },
38
+ querySelect: { isInitialQueryDisabled: false },
37
39
  toggle: { variant: "default" },
38
40
  slider: {
39
41
  minValue: 0,
@@ -0,0 +1,25 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { SelectItem } from '../components/inputs/Selection/shared/select.types';
4
+ type QueryResult<TData = any> = UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
+ type QueryFn<TData = any> = (...args: any[]) => QueryResult<TData>;
6
+ type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
7
+ interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
8
+ query: TQueryFn;
9
+ queryParams?: Parameters<TQueryFn>[0];
10
+ queryOptions?: Parameters<TQueryFn>[1];
11
+ mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
12
+ initialQueryState?: boolean;
13
+ search?: string;
14
+ }
15
+ export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
16
+ data: any;
17
+ isLoading: boolean;
18
+ isQueryEnabled: boolean;
19
+ handleEnableQuery: () => void;
20
+ items: SelectItem<TKey>[];
21
+ hasNextPage: boolean;
22
+ fetchNextPage: (() => Promise<unknown>) | ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<any, Error>>) | undefined;
23
+ isFetchingNextPage: boolean;
24
+ };
25
+ export {};
@@ -0,0 +1,41 @@
1
+ import { useMemo, useState } from "react";
2
+ //#region src/hooks/useQueryAutocomplete.ts
3
+ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search }) => {
4
+ const [isQueryEnabled, setIsQueryEnabled] = useState(!initialQueryState);
5
+ const queryResult = query(search === void 0 ? queryParams : {
6
+ search,
7
+ ...queryParams
8
+ }, {
9
+ ...queryOptions,
10
+ enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
11
+ });
12
+ const data = queryResult.data;
13
+ const isLoading = queryResult.isLoading;
14
+ const isInfiniteQueryResult = (result) => {
15
+ return "hasNextPage" in result && "fetchNextPage" in result;
16
+ };
17
+ const isInfiniteQuery = isInfiniteQueryResult(queryResult);
18
+ const handleEnableQuery = () => {
19
+ setIsQueryEnabled(true);
20
+ };
21
+ const infiniteQueryResult = isInfiniteQuery ? queryResult : void 0;
22
+ const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
23
+ const fetchNextPage = infiniteQueryResult?.fetchNextPage;
24
+ const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
25
+ const items = useMemo(() => {
26
+ if (!data) return [];
27
+ return mapItems(data);
28
+ }, [data, mapItems]);
29
+ return {
30
+ data,
31
+ isLoading: isLoading || isFetchingNextPage,
32
+ isQueryEnabled,
33
+ handleEnableQuery,
34
+ items,
35
+ hasNextPage,
36
+ fetchNextPage,
37
+ isFetchingNextPage
38
+ };
39
+ };
40
+ //#endregion
41
+ export { useQueryAutocomplete };
package/dist/index.js CHANGED
@@ -92,6 +92,7 @@ import { QueryAutocomplete } from "./components/inputs/Selection/Autocomplete/Qu
92
92
  import { Slider } from "./components/inputs/Slider/Slider.js";
93
93
  import { Toggle } from "./components/inputs/Toggle/Toggle.js";
94
94
  import { Segment } from "./components/segment/Segment.js";
95
+ import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
95
96
  import { StringUtils } from "./utils/string.utils.js";
96
97
  import { dynamicInputs } from "./helpers/dynamicInputs.js";
97
98
  import { Form } from "./components/inputs/Inputs/Form.js";
@@ -102,7 +103,6 @@ import { Stepper } from "./components/navigation/Stepper/Stepper.js";
102
103
  import { Modal } from "./components/overlays/Modal/Modal.js";
103
104
  import { ActionModal } from "./components/overlays/ActionModal/ActionModal.js";
104
105
  import { Drawer } from "./components/overlays/Drawer/Drawer.js";
105
- import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
106
106
  import { TooltipEllipsis } from "./components/overlays/Tooltip/TooltipEllipsis.js";
107
107
  import { PaginationList } from "./components/shared/pagination/PaginationList.js";
108
108
  import { Pagination } from "./components/shared/pagination/Pagination.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.1",
3
+ "version": "2.2.9-rc.2",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",