@povio/ui 2.2.8 → 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 +16 -4
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +14 -7
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +7 -2
- 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/NumberInput/NumberInput.js +1 -0
- package/dist/components/inputs/Input/TextInput/TextInput.js +3 -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 +4 -3
- 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 +4 -3
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -2
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +23 -3
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +9 -3
- 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/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +7 -3
- 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 +8 -2
- package/dist/config/uiConfig.context.js +7 -2
- 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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
export declare const formFieldHeader: (props?: ({
|
|
3
|
+
visible?: boolean | null | undefined;
|
|
4
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
5
|
+
export interface FormFieldHeaderVariantProps extends VariantProps<typeof formFieldHeader> {
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
//#region src/components/inputs/FormField/formFieldHeader.cva.ts
|
|
3
|
+
var formFieldHeader = cva("", {
|
|
4
|
+
variants: { visible: {
|
|
5
|
+
true: "mb-1",
|
|
6
|
+
false: "sr-only"
|
|
7
|
+
} },
|
|
8
|
+
defaultVariants: { visible: true }
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { formFieldHeader };
|
|
@@ -101,6 +101,7 @@ var NumberInputBase = (props) => {
|
|
|
101
101
|
"data-is-dirty": isDirty || void 0,
|
|
102
102
|
"data-is-required": isRequired || void 0,
|
|
103
103
|
"data-is-empty": value === null || value === void 0 || void 0,
|
|
104
|
+
"data-is-filled": !("" + value === "" || value === null || value === void 0) || void 0,
|
|
104
105
|
placeholder: as === "floating" ? "\xA0" : inputProps.placeholder,
|
|
105
106
|
className: "w-full outline-none",
|
|
106
107
|
onFocus: (e) => {
|
|
@@ -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,
|
|
@@ -91,6 +93,7 @@ var TextInputBase = (props) => {
|
|
|
91
93
|
...inputProps,
|
|
92
94
|
ref: mergeRefs(ref, inputRef),
|
|
93
95
|
"data-is-empty": value === "" || value === null || value === void 0 || void 0,
|
|
96
|
+
"data-is-filled": !(value === "" || value === null || value === void 0) || void 0,
|
|
94
97
|
"data-is-dirty": isDirty || void 0,
|
|
95
98
|
"data-is-required": isRequired || void 0,
|
|
96
99
|
"data-is-disabled": isDisabled || void 0,
|
|
@@ -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,18 +3,19 @@ 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, {
|
|
10
10
|
control: formControl.control,
|
|
11
11
|
name: formControl.name,
|
|
12
|
-
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
12
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
13
13
|
...innerProps,
|
|
14
14
|
ref: mergeRefs(ref, field.ref),
|
|
15
15
|
value: field.value,
|
|
16
16
|
onChange: field.onChange,
|
|
17
17
|
onBlur: field.onBlur,
|
|
18
|
+
isDirty,
|
|
18
19
|
isDisabled: field.disabled || props.isDisabled,
|
|
19
20
|
error: props.error ?? error?.message,
|
|
20
21
|
isSearchable: true
|
|
@@ -25,6 +26,6 @@ var Autocomplete = (props) => {
|
|
|
25
26
|
...props,
|
|
26
27
|
isSearchable: true
|
|
27
28
|
});
|
|
28
|
-
}
|
|
29
|
+
}
|
|
29
30
|
//#endregion
|
|
30
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,24 +3,25 @@ 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, {
|
|
10
10
|
control: formControl.control,
|
|
11
11
|
name: formControl.name,
|
|
12
|
-
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
12
|
+
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
13
13
|
...innerProps,
|
|
14
14
|
ref: mergeRefs(ref, field.ref),
|
|
15
15
|
value: field.value,
|
|
16
16
|
onChange: field.onChange,
|
|
17
17
|
onBlur: field.onBlur,
|
|
18
|
+
isDirty,
|
|
18
19
|
isDisabled: field.disabled || props.isDisabled,
|
|
19
20
|
error: props.error ?? error?.message
|
|
20
21
|
})
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
24
|
-
}
|
|
25
|
+
}
|
|
25
26
|
//#endregion
|
|
26
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';
|
|
@@ -7,21 +7,28 @@ import { InputVariantProps } from '../../shared/input.cva';
|
|
|
7
7
|
export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = FormFieldProps & GroupedSelectProps<TKey, TInitialSelectItem> & SelectNewItemProps & SelectAsyncProps & SelectVirtualizationProps & InputVariantProps & Pick<AriaButtonProps, "onBlur"> & {
|
|
8
8
|
ref?: Ref<HTMLDivElement>;
|
|
9
9
|
className?: string;
|
|
10
|
+
isDirty?: boolean;
|
|
10
11
|
placeholder?: string;
|
|
11
12
|
hideDropdownIcon?: boolean;
|
|
12
13
|
hideSearchIcon?: boolean;
|
|
13
14
|
isSearchable?: boolean;
|
|
14
15
|
isClearable?: boolean;
|
|
15
16
|
isClientSearchDisabled?: boolean;
|
|
17
|
+
ignoreInputValueFiltering?: boolean;
|
|
16
18
|
ignoreTriggerWidth?: boolean;
|
|
17
19
|
items: SelectItem<TKey>[];
|
|
18
20
|
inputClassName?: string;
|
|
19
21
|
containerClassName?: string;
|
|
22
|
+
leadingContent?: ReactNode;
|
|
23
|
+
trailingContent?: ReactNode;
|
|
20
24
|
customTrigger?: ReactElement;
|
|
21
25
|
selectedTagsType?: "tags" | "list";
|
|
22
26
|
collapseAfter?: number;
|
|
27
|
+
fireBlurOnChange?: boolean;
|
|
23
28
|
onInputChange?: (value: string) => void;
|
|
24
29
|
onSearchChange?: (value: string) => void;
|
|
25
30
|
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
31
|
+
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
32
|
+
onFocusCapture?: FocusEventHandler<HTMLDivElement>;
|
|
26
33
|
};
|
|
27
34
|
export declare const SelectBase: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(dProps: SelectBaseProps<TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,9 @@ var SelectBase = (dProps) => {
|
|
|
19
19
|
selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
|
|
20
20
|
ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
|
|
21
21
|
collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
|
|
22
|
-
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon
|
|
22
|
+
hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
|
|
23
|
+
fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
|
|
24
|
+
isClientSearchDisabled: dProps.ignoreInputValueFiltering ?? dProps.isClientSearchDisabled
|
|
23
25
|
};
|
|
24
26
|
const isDesktop = useBreakpoint("md");
|
|
25
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,8 +13,8 @@ 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 }) => {
|
|
17
|
-
const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
|
|
16
|
+
var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
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 = {
|
|
20
20
|
error,
|
|
@@ -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,8 +137,12 @@ 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,
|
|
144
|
+
isRequired,
|
|
145
|
+
isDirty,
|
|
140
146
|
onBlur,
|
|
141
147
|
onCloseComboBox: (state) => {
|
|
142
148
|
if (isSearchable) closeComboBoxRef.current = state;
|
|
@@ -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"> {
|
|
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, onCloseComboBox, onBlur, ...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, onCloseComboBox, onBlur, ...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");
|
|
@@ -44,9 +44,13 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
44
44
|
if (e.key === "Enter" && !isMultiple && !isLoading && listItems.length === 1 && !listItems[0].isDisabled) {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
onChange(listItems[0].id);
|
|
47
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
47
48
|
onCloseComboBox?.(state);
|
|
48
49
|
}
|
|
49
|
-
if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0)
|
|
50
|
+
if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0) {
|
|
51
|
+
onChange(fieldState.value.slice(0, -1));
|
|
52
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
53
|
+
}
|
|
50
54
|
};
|
|
51
55
|
const onClick = () => {
|
|
52
56
|
if (isDisabled) return;
|
|
@@ -75,7 +79,12 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
75
79
|
"data-has-search": fieldState.searchValue !== "" || void 0,
|
|
76
80
|
"data-invalid": isInvalid || void 0,
|
|
77
81
|
"data-is-empty": isEmpty || void 0,
|
|
82
|
+
"data-is-filled": !isEmpty || void 0,
|
|
83
|
+
"data-is-required": isRequired || void 0,
|
|
84
|
+
"data-is-dirty": isDirty || void 0,
|
|
78
85
|
"data-select-input": "",
|
|
86
|
+
onMouseEnter,
|
|
87
|
+
onFocusCapture,
|
|
79
88
|
...hoverProps,
|
|
80
89
|
...focusWithinProps,
|
|
81
90
|
children: [
|
|
@@ -92,6 +101,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
92
101
|
...headerProps,
|
|
93
102
|
labelProps
|
|
94
103
|
}),
|
|
104
|
+
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
105
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
106
|
+
children: leadingContent
|
|
107
|
+
}),
|
|
95
108
|
(showTags || isSearchable) && /* @__PURE__ */ jsxs("div", {
|
|
96
109
|
className: clsx("flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate", !isSearchable && "pointer-events-none z-1"),
|
|
97
110
|
children: [showTags && /* @__PURE__ */ jsx(SelectInputTags, {
|
|
@@ -124,8 +137,15 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
124
137
|
})
|
|
125
138
|
]
|
|
126
139
|
}),
|
|
140
|
+
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: "flex shrink-0 items-center",
|
|
142
|
+
children: trailingContent
|
|
143
|
+
}),
|
|
127
144
|
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
128
|
-
onClear
|
|
145
|
+
onClear: () => {
|
|
146
|
+
onClear();
|
|
147
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
148
|
+
},
|
|
129
149
|
show: showClearButton
|
|
130
150
|
}),
|
|
131
151
|
!hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
|
|
@@ -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 {};
|