@povio/ui 2.2.9-rc.1 → 2.2.9-rc.10
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/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +7 -3
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +19 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -3
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +13 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +7 -3
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +12 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +13 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +13 -7
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -1
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +3 -0
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/TextInput/TextInput.js +2 -0
- package/dist/components/inputs/Inputs/InputItem.d.ts +9 -15
- package/dist/components/inputs/Inputs/InputItem.js +4 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +6 -1
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +2 -2
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +23 -7
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +30 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +56 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +4 -2
- package/dist/components/inputs/Selection/Select/Select.js +2 -2
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +6 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +2 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +5 -1
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +11 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -1
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +22 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +2 -2
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +3 -4
- package/dist/config/uiConfig.context.d.ts +7 -1
- package/dist/config/uiConfig.context.js +5 -1
- package/dist/config/uiStyle.context.d.ts +6 -1
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useQueryAutocomplete.d.ts +25 -0
- package/dist/hooks/useQueryAutocomplete.js +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -3
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ComponentProps, JSXElementConstructor, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { Control, UseFormReturn } from 'react-hook-form';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { Autocomplete } from '../Selection/Autocomplete/Autocomplete';
|
|
5
|
+
import { Select } from '../Selection/Select/Select';
|
|
4
6
|
import { HasRequiredProperty } from '../../../types/common';
|
|
5
7
|
declare const componentRegistry: {
|
|
6
8
|
readonly toggle: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Toggle/Toggle').ControlledToggleProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,24 +12,16 @@ declare const componentRegistry: {
|
|
|
10
12
|
readonly textInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextInput/TextInput').ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
readonly select:
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
|
|
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;
|
|
24
|
-
queryOptions?: Parameters<TQueryFn>[1] | undefined;
|
|
25
|
-
})) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
readonly select: typeof Select;
|
|
16
|
+
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('../Selection/Select/QuerySelect.js').QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
readonly autocomplete: typeof Autocomplete;
|
|
18
|
+
readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../../..').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
19
|
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
20
|
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
21
|
readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
29
22
|
readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
30
23
|
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;
|
|
24
|
+
readonly textEditor: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../../../text-editor.js').ControlledTextEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
31
25
|
readonly unknown: null;
|
|
32
26
|
};
|
|
33
27
|
export type InputComponentRegistry = typeof componentRegistry;
|
|
@@ -56,8 +50,8 @@ type TypeBasedInputDef<TSchemaType extends Record<string, any>, T extends InputC
|
|
|
56
50
|
interface RenderBasedInputDef<TSchemaType extends Record<string, any>, K extends keyof TSchemaType> {
|
|
57
51
|
type?: never;
|
|
58
52
|
name: K;
|
|
59
|
-
label?:
|
|
60
|
-
placeholder?:
|
|
53
|
+
label?: string;
|
|
54
|
+
placeholder?: string;
|
|
61
55
|
props?: never;
|
|
62
56
|
inputWrapper?: never;
|
|
63
57
|
render: (formControl: {
|
|
@@ -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 }) {
|
|
@@ -2,7 +2,7 @@ import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
3
|
import { CheckContent } from "../shared/CheckContent.js";
|
|
4
4
|
import { FormField } from "../FormField/FormField.js";
|
|
5
|
-
import { radio, radioIndicatorClass, radioTypography } from "./radio.cva.js";
|
|
5
|
+
import { radio, radioContentClassName, radioIndicatorClass, radioTypography } from "./radio.cva.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { Radio, RadioGroup } from "react-aria-components";
|
|
@@ -13,6 +13,7 @@ var RadioGroupBase = (props) => {
|
|
|
13
13
|
const ui = UIConfig.useConfig();
|
|
14
14
|
const radioCva = UIStyle.useCva("radio.cva", radio);
|
|
15
15
|
const radioTypographyMap = UIStyle.useMapper("radio.typography", radioTypography);
|
|
16
|
+
const radioContentClassNameMap = UIStyle.useMapper("radio.contentClassName", radioContentClassName);
|
|
16
17
|
const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, variant = ui.radioGroup.variant, hideLabel = ui.radioGroup.hideLabel, ...rest } = props;
|
|
17
18
|
const formFieldProps = {
|
|
18
19
|
className,
|
|
@@ -49,6 +50,10 @@ var RadioGroupBase = (props) => {
|
|
|
49
50
|
variant,
|
|
50
51
|
...rest
|
|
51
52
|
}),
|
|
53
|
+
contentClassName: radioContentClassNameMap({
|
|
54
|
+
variant,
|
|
55
|
+
...rest
|
|
56
|
+
}),
|
|
52
57
|
className: labelClassName,
|
|
53
58
|
children: option.label
|
|
54
59
|
})]
|
|
@@ -9,3 +9,6 @@ export declare const radioIndicatorClass = "group flex items-center gap-2";
|
|
|
9
9
|
export declare const radioTypography: (props: {
|
|
10
10
|
variant?: "default" | null | undefined;
|
|
11
11
|
}) => TypographyVariantProps | undefined;
|
|
12
|
+
export declare const radioContentClassName: (props: {
|
|
13
|
+
variant?: "default" | null | undefined;
|
|
14
|
+
}) => string | undefined;
|
|
@@ -31,5 +31,6 @@ var radioTypography = compoundMapper({ default: {
|
|
|
31
31
|
sizeMobile: "label-1",
|
|
32
32
|
variant: "default"
|
|
33
33
|
} });
|
|
34
|
+
var radioContentClassName = compoundMapper({ default: "text-text-default-2" });
|
|
34
35
|
//#endregion
|
|
35
|
-
export { radio, radioIndicatorClass, radioTypography };
|
|
36
|
+
export { radio, radioContentClassName, radioIndicatorClass, radioTypography };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
1
2
|
import { Key } from 'react-aria-components';
|
|
2
3
|
import { FieldValues } from 'react-hook-form';
|
|
3
4
|
import { SelectBaseProps } from '../shared/SelectBase';
|
|
@@ -5,4 +6,5 @@ import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps
|
|
|
5
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
6
7
|
export type AutocompleteProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "isSearchable">;
|
|
7
8
|
export type ControlledAutocompleteProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<AutocompleteProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
8
|
-
export declare
|
|
9
|
+
export declare function Autocomplete<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: AutocompleteProps<TKey, TInitialSelectItem>): ReactElement;
|
|
10
|
+
export declare function Autocomplete<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|
|
@@ -3,7 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
4
|
import { Controller } from "react-hook-form";
|
|
5
5
|
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
6
|
-
|
|
6
|
+
function Autocomplete(props) {
|
|
7
7
|
if ("formControl" in props && props.formControl) {
|
|
8
8
|
const { formControl, ref, ...innerProps } = props;
|
|
9
9
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -26,6 +26,6 @@ var Autocomplete = (props) => {
|
|
|
26
26
|
...props,
|
|
27
27
|
isSearchable: true
|
|
28
28
|
});
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
30
|
//#endregion
|
|
31
31
|
export { Autocomplete };
|
|
@@ -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 {
|
|
5
|
-
import {
|
|
6
|
-
|
|
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
|
|
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
|
-
|
|
10
|
-
}
|
|
20
|
+
initialQueryState: props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
|
|
21
|
+
});
|
|
22
|
+
const { isInitialQueryDisabled: _, ...restProps } = props;
|
|
11
23
|
return /* @__PURE__ */ jsx(Autocomplete, {
|
|
12
|
-
...
|
|
13
|
-
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,14 @@
|
|
|
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
|
+
export 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;
|
|
@@ -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,8 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
1
2
|
import { Key } from 'react-aria-components';
|
|
2
3
|
import { FieldValues } from 'react-hook-form';
|
|
3
4
|
import { SelectBaseProps } from '../shared/SelectBase';
|
|
4
5
|
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectAsyncProps } from '../shared/select.types';
|
|
5
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
6
7
|
export type SelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "initialSelection" | "mapInitialToSelectItem" | keyof SelectAsyncProps>;
|
|
7
|
-
export type ControlledSelectProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<SelectProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey>;
|
|
8
|
-
export declare
|
|
8
|
+
export type ControlledSelectProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<SelectProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
9
|
+
export declare function Select<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: SelectProps<TKey, TInitialSelectItem>): ReactElement;
|
|
10
|
+
export declare function Select<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|
|
@@ -3,7 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
4
|
import { Controller } from "react-hook-form";
|
|
5
5
|
//#region src/components/inputs/Selection/Select/Select.tsx
|
|
6
|
-
|
|
6
|
+
function Select(props) {
|
|
7
7
|
if ("formControl" in props && props.formControl) {
|
|
8
8
|
const { formControl, ref, ...innerProps } = props;
|
|
9
9
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -22,6 +22,6 @@ var Select = (props) => {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
//#endregion
|
|
27
27
|
export { Select };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, Ref } from 'react';
|
|
1
|
+
import { FocusEventHandler, MouseEventHandler, ReactElement, ReactNode, 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';
|
|
@@ -14,10 +14,13 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
|
|
|
14
14
|
isSearchable?: boolean;
|
|
15
15
|
isClearable?: boolean;
|
|
16
16
|
isClientSearchDisabled?: boolean;
|
|
17
|
+
ignoreInputValueFiltering?: boolean;
|
|
17
18
|
ignoreTriggerWidth?: boolean;
|
|
18
19
|
items: SelectItem<TKey>[];
|
|
19
20
|
inputClassName?: string;
|
|
20
21
|
containerClassName?: string;
|
|
22
|
+
leadingContent?: ReactNode;
|
|
23
|
+
trailingContent?: ReactNode;
|
|
21
24
|
customTrigger?: ReactElement;
|
|
22
25
|
selectedTagsType?: "tags" | "list";
|
|
23
26
|
collapseAfter?: number;
|
|
@@ -25,5 +28,7 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
|
|
|
25
28
|
onInputChange?: (value: string) => void;
|
|
26
29
|
onSearchChange?: (value: string) => void;
|
|
27
30
|
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
31
|
+
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
32
|
+
onFocusCapture?: FocusEventHandler<HTMLDivElement>;
|
|
28
33
|
};
|
|
29
34
|
export declare const SelectBase: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(dProps: SelectBaseProps<TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,8 @@ var SelectBase = (dProps) => {
|
|
|
20
20
|
ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
|
|
21
21
|
collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
|
|
22
22
|
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
|
|
23
|
-
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange
|
|
23
|
+
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
|
|
24
|
+
isClientSearchDisabled: dProps.ignoreInputValueFiltering ?? dProps.isClientSearchDisabled
|
|
24
25
|
};
|
|
25
26
|
const isDesktop = useBreakpoint("md");
|
|
26
27
|
return /* @__PURE__ */ jsx(SelectContext.Provider, {
|
|
@@ -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, leadingContent, trailingContent, 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, leadingContent, trailingContent, 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, {
|
|
@@ -135,6 +137,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
|
|
|
135
137
|
isClearable,
|
|
136
138
|
showSelectionContent,
|
|
137
139
|
inputClassName,
|
|
140
|
+
leadingContent,
|
|
141
|
+
trailingContent,
|
|
138
142
|
collapseAfter,
|
|
139
143
|
selectedTagsType,
|
|
140
144
|
isRequired,
|
|
@@ -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" | "leadingContent" | "trailingContent" | "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, leadingContent, trailingContent, 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, leadingContent, trailingContent, 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: [
|
|
@@ -99,6 +101,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
99
101
|
...headerProps,
|
|
100
102
|
labelProps
|
|
101
103
|
}),
|
|
104
|
+
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
105
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
106
|
+
children: leadingContent
|
|
107
|
+
}),
|
|
102
108
|
(showTags || isSearchable) && /* @__PURE__ */ jsxs("div", {
|
|
103
109
|
className: clsx("flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate", !isSearchable && "pointer-events-none z-1"),
|
|
104
110
|
children: [showTags && /* @__PURE__ */ jsx(SelectInputTags, {
|
|
@@ -131,6 +137,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
131
137
|
})
|
|
132
138
|
]
|
|
133
139
|
}),
|
|
140
|
+
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: "flex shrink-0 items-center",
|
|
142
|
+
children: trailingContent
|
|
143
|
+
}),
|
|
134
144
|
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
135
145
|
onClear: () => {
|
|
136
146
|
onClear();
|
|
@@ -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, leadingContent, trailingContent, 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, leadingContent, trailingContent, 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,
|
|
@@ -79,6 +81,8 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
|
|
|
79
81
|
onBlur: void 0,
|
|
80
82
|
fieldProps,
|
|
81
83
|
headerProps,
|
|
84
|
+
leadingContent,
|
|
85
|
+
trailingContent,
|
|
82
86
|
collapseAfter,
|
|
83
87
|
selectedTagsType,
|
|
84
88
|
isRequired,
|
|
@@ -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 };
|
|
@@ -17,14 +17,15 @@ export declare namespace SelectContext {
|
|
|
17
17
|
onClear: () => void;
|
|
18
18
|
onSelectAll: () => void;
|
|
19
19
|
onRemove: (val: Key) => void;
|
|
20
|
+
onBlur: () => void;
|
|
20
21
|
listItems: ExtendedSelectItem[];
|
|
21
22
|
selectableListItems: SelectItem[];
|
|
22
23
|
selectedItems: SelectItem[];
|
|
23
24
|
selectedIds: Key[];
|
|
24
25
|
isMultiple: boolean;
|
|
25
26
|
} & Pick<SelectBaseProps, "onInputChange" | "isLoading" | "hasLoadMore">;
|
|
26
|
-
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled">;
|
|
27
|
-
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled" | "ignoreInputValueFiltering">;
|
|
28
|
+
export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
export const useSelect: () => Type;
|
|
29
30
|
export {};
|
|
30
31
|
}
|