soda-heroui 0.11.18 → 0.11.20
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/AutoRefresh.d.ts +1 -1
- package/dist/components/EnumSelect.cjs +42 -7
- package/dist/components/EnumSelect.d.ts +25 -8
- package/dist/components/EnumSelect.js +44 -9
- package/dist/components/FormAutocomplete.d.ts +1 -1
- package/dist/components/FormCalendar.cjs +1 -1
- package/dist/components/FormCalendar.d.ts +1 -1
- package/dist/components/FormCalendar.js +1 -1
- package/dist/components/FormCheckbox.d.ts +1 -1
- package/dist/components/FormCheckboxGroup.d.ts +1 -1
- package/dist/components/FormDateInput.cjs +1 -1
- package/dist/components/FormDateInput.d.ts +1 -1
- package/dist/components/FormDateInput.js +1 -1
- package/dist/components/FormDatePicker.cjs +1 -1
- package/dist/components/FormDatePicker.d.ts +1 -1
- package/dist/components/FormDatePicker.js +1 -1
- package/dist/components/FormDateRangePicker.cjs +1 -1
- package/dist/components/FormDateRangePicker.d.ts +1 -1
- package/dist/components/FormDateRangePicker.js +1 -1
- package/dist/components/FormInput.d.ts +1 -1
- package/dist/components/FormInputOtp.d.ts +1 -1
- package/dist/components/FormNumberInput.d.ts +1 -1
- package/dist/components/FormPagination.d.ts +1 -1
- package/dist/components/FormProvider.cjs +1 -1
- package/dist/components/FormProvider.js +1 -1
- package/dist/components/FormRadioGroup.d.ts +1 -1
- package/dist/components/FormRangeCalendar.cjs +1 -1
- package/dist/components/FormRangeCalendar.d.ts +1 -1
- package/dist/components/FormRangeCalendar.js +1 -1
- package/dist/components/FormSelect.cjs +1 -1
- package/dist/components/FormSelect.d.ts +1 -1
- package/dist/components/FormSelect.js +1 -1
- package/dist/components/FormSwitch.d.ts +1 -1
- package/dist/components/FormTextarea.d.ts +1 -1
- package/dist/components/FormTimeInput.cjs +1 -1
- package/dist/components/FormTimeInput.d.ts +1 -1
- package/dist/components/FormTimeInput.js +1 -1
- package/dist/utils/range.d.ts +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/AutoRefresh.tsx +1 -1
- package/src/components/EnumSelect.tsx +109 -31
- package/src/components/ErrorMessage.tsx +1 -1
- package/src/components/FormAutocomplete.tsx +1 -1
- package/src/components/FormCalendar.tsx +1 -1
- package/src/components/FormCheckbox.tsx +1 -1
- package/src/components/FormCheckboxGroup.tsx +1 -1
- package/src/components/FormDateInput.tsx +1 -1
- package/src/components/FormDatePicker.tsx +1 -1
- package/src/components/FormDateRangePicker.tsx +1 -1
- package/src/components/FormInput.tsx +1 -1
- package/src/components/FormInputOtp.tsx +1 -1
- package/src/components/FormNumberInput.tsx +1 -1
- package/src/components/FormPagination.tsx +1 -1
- package/src/components/FormProvider.tsx +1 -1
- package/src/components/FormRadioGroup.tsx +1 -1
- package/src/components/FormRangeCalendar.tsx +1 -1
- package/src/components/FormSelect.tsx +1 -1
- package/src/components/FormSwitch.tsx +1 -1
- package/src/components/FormTextarea.tsx +1 -1
- package/src/components/FormTimeInput.tsx +1 -1
- package/src/utils/range.ts +1 -1
- package/src/utils/time.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addToast } from "@heroui/react";
|
|
2
1
|
import { FC, ReactNode } from "react";
|
|
2
|
+
import { addToast } from "@heroui/react";
|
|
3
3
|
import { FirstParameter } from "soda-type";
|
|
4
4
|
export interface AutoRefreshProps extends FirstParameter<typeof addToast> {
|
|
5
5
|
onRefresh?: () => void;
|
|
@@ -29,16 +29,51 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
createEnumSelect: ()=>createEnumSelect
|
|
30
30
|
});
|
|
31
31
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
32
33
|
const react_namespaceObject = require("@heroui/react");
|
|
33
34
|
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const external_soda_hooks_namespaceObject = require("soda-hooks");
|
|
36
|
+
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
37
|
+
function render({ label, value }) {
|
|
38
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.SelectItem, {
|
|
39
|
+
children: label
|
|
40
|
+
}, value);
|
|
41
|
+
}
|
|
42
|
+
function EnumSelect({ enumObject, selectionMode, value: _value, onValueChange, emptyValue, ...rest }) {
|
|
43
|
+
const context = (0, external_react_namespaceObject.useContext)(external_FormProvider_cjs_namespaceObject.FormContext);
|
|
44
|
+
emptyValue ??= context.emptyValue;
|
|
45
|
+
const [value, setValue] = (0, external_soda_hooks_namespaceObject.useInputState)(_value);
|
|
46
|
+
const isNumberEnum = "object" == typeof enumObject && !Array.isArray(enumObject) && "number" == typeof Object.values(enumObject).at(0);
|
|
47
|
+
const selectedKeys = (0, external_react_namespaceObject.useMemo)(()=>(Array.isArray(value) ? value : (0, external_deepsea_tools_namespaceObject.isNonNullable)(value) ? [
|
|
48
|
+
value
|
|
49
|
+
] : []).map(String), [
|
|
50
|
+
value
|
|
51
|
+
]);
|
|
52
|
+
const onSelectionChange = (0, external_react_namespaceObject.useCallback)(function(selection) {
|
|
53
|
+
const keys = Array.from(selection).map((item)=>isNumberEnum ? (0, external_deepsea_tools_namespaceObject.intParser)(String(item)) : String(item));
|
|
54
|
+
const nextValue = "multiple" === selectionMode ? keys : keys.at(0) ?? (0, external_FormProvider_cjs_namespaceObject.getEmptyValue)(emptyValue);
|
|
55
|
+
setValue(nextValue);
|
|
56
|
+
null == onValueChange || onValueChange(nextValue);
|
|
57
|
+
}, [
|
|
58
|
+
selectionMode,
|
|
59
|
+
onValueChange,
|
|
60
|
+
setValue,
|
|
61
|
+
isNumberEnum,
|
|
62
|
+
emptyValue
|
|
63
|
+
]);
|
|
64
|
+
const items = (0, external_react_namespaceObject.useMemo)(()=>Array.isArray(enumObject) ? enumObject.map(([label, value])=>({
|
|
65
|
+
label,
|
|
66
|
+
value
|
|
67
|
+
})) : enumObject ? (0, external_deepsea_tools_namespaceObject.getEnumOptions)(enumObject) : [], [
|
|
68
|
+
enumObject
|
|
69
|
+
]);
|
|
70
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Select, {
|
|
71
|
+
items: items,
|
|
72
|
+
selectionMode: selectionMode,
|
|
73
|
+
selectedKeys: isNumberEnum ? selectedKeys.map(String) : selectedKeys,
|
|
74
|
+
onSelectionChange: onSelectionChange,
|
|
38
75
|
...rest,
|
|
39
|
-
children:
|
|
40
|
-
children: label
|
|
41
|
-
}, value)
|
|
76
|
+
children: render
|
|
42
77
|
});
|
|
43
78
|
}
|
|
44
79
|
function createEnumSelect(enumObject) {
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { Select } from "@heroui/react";
|
|
3
|
+
import { ValueOf } from "deepsea-tools";
|
|
4
|
+
import { EmptyValue, GetEmptyValue } from "./FormProvider";
|
|
5
|
+
import { SelectionMode } from "./FormSelect";
|
|
6
|
+
/** 获取枚举值的类型 */
|
|
7
|
+
export type EnumValue<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]> = Options extends any[] ? Options[number][1] : ValueOf<Options>;
|
|
8
|
+
/** 获取选择器的值的类型 */
|
|
9
|
+
export type SelectValue<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[], Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null"> = Mode extends "multiple" ? EnumValue<Options>[] : EnumValue<Options> | (DisallowEmptySelection extends true ? never : GetEmptyValue<Empty>);
|
|
10
|
+
export interface EnumOption<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]> {
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
value: EnumValue<Options>;
|
|
7
13
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
14
|
+
export interface EnumSelectPropsBase<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[], Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null", Value = SelectValue<Options, Mode, DisallowEmptySelection, Empty>> extends Omit<ComponentProps<typeof Select<EnumOption<Options>>>, "items" | "selectionMode" | "disallowEmptySelection" | "children" | "selectedKeys" | "onSelectionChange" | "value" | "onValueChange"> {
|
|
15
|
+
enumObject?: Options;
|
|
16
|
+
selectionMode?: Mode;
|
|
17
|
+
disallowEmptySelection?: DisallowEmptySelection;
|
|
18
|
+
value?: Value;
|
|
19
|
+
onValueChange?: (value: Value) => void;
|
|
20
|
+
emptyValue?: Empty;
|
|
21
|
+
}
|
|
22
|
+
export interface EnumSelectProps<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[], Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null"> extends EnumSelectPropsBase<Options, Mode, DisallowEmptySelection, Empty> {
|
|
23
|
+
}
|
|
24
|
+
export declare function EnumSelect<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[], Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null">({ enumObject, selectionMode, value: _value, onValueChange, emptyValue, ...rest }: EnumSelectProps<Options, Mode, DisallowEmptySelection, Empty>): ReactNode;
|
|
25
|
+
export declare function createEnumSelect<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]>(enumObject?: Options): EnumSelectComponent<EnumValue<Options>>;
|
|
26
|
+
export type EnumSelectComponent<Value extends string | number> = <Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null">(props: Omit<EnumSelectProps<[ReactNode, Value][], Mode, DisallowEmptySelection, Empty>, "enumObject">) => ReactNode;
|
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { useCallback, useContext, useMemo } from "react";
|
|
4
|
+
import { Select, SelectItem } from "@heroui/react";
|
|
5
|
+
import { getEnumOptions, intParser, isNonNullable } from "deepsea-tools";
|
|
6
|
+
import { useInputState } from "soda-hooks";
|
|
7
|
+
import { FormContext, getEmptyValue } from "./FormProvider.js";
|
|
8
|
+
function render({ label, value }) {
|
|
9
|
+
return /*#__PURE__*/ jsx(SelectItem, {
|
|
10
|
+
children: label
|
|
11
|
+
}, value);
|
|
12
|
+
}
|
|
13
|
+
function EnumSelect({ enumObject, selectionMode, value: _value, onValueChange, emptyValue, ...rest }) {
|
|
14
|
+
const context = useContext(FormContext);
|
|
15
|
+
emptyValue ??= context.emptyValue;
|
|
16
|
+
const [value, setValue] = useInputState(_value);
|
|
17
|
+
const isNumberEnum = "object" == typeof enumObject && !Array.isArray(enumObject) && "number" == typeof Object.values(enumObject).at(0);
|
|
18
|
+
const selectedKeys = useMemo(()=>(Array.isArray(value) ? value : isNonNullable(value) ? [
|
|
19
|
+
value
|
|
20
|
+
] : []).map(String), [
|
|
21
|
+
value
|
|
22
|
+
]);
|
|
23
|
+
const onSelectionChange = useCallback(function(selection) {
|
|
24
|
+
const keys = Array.from(selection).map((item)=>isNumberEnum ? intParser(String(item)) : String(item));
|
|
25
|
+
const nextValue = "multiple" === selectionMode ? keys : keys.at(0) ?? getEmptyValue(emptyValue);
|
|
26
|
+
setValue(nextValue);
|
|
27
|
+
null == onValueChange || onValueChange(nextValue);
|
|
28
|
+
}, [
|
|
29
|
+
selectionMode,
|
|
30
|
+
onValueChange,
|
|
31
|
+
setValue,
|
|
32
|
+
isNumberEnum,
|
|
33
|
+
emptyValue
|
|
34
|
+
]);
|
|
35
|
+
const items = useMemo(()=>Array.isArray(enumObject) ? enumObject.map(([label, value])=>({
|
|
36
|
+
label,
|
|
37
|
+
value
|
|
38
|
+
})) : enumObject ? getEnumOptions(enumObject) : [], [
|
|
39
|
+
enumObject
|
|
40
|
+
]);
|
|
41
|
+
return /*#__PURE__*/ jsx(Select, {
|
|
42
|
+
items: items,
|
|
43
|
+
selectionMode: selectionMode,
|
|
44
|
+
selectedKeys: isNumberEnum ? selectedKeys.map(String) : selectedKeys,
|
|
45
|
+
onSelectionChange: onSelectionChange,
|
|
9
46
|
...rest,
|
|
10
|
-
children:
|
|
11
|
-
children: label
|
|
12
|
-
}, value)
|
|
47
|
+
children: render
|
|
13
48
|
});
|
|
14
49
|
}
|
|
15
50
|
function createEnumSelect(enumObject) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Autocomplete, AutocompleteProps } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { Autocomplete, AutocompleteProps } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
export interface FormAutocompleteProps<FieldValue extends string | null | undefined = string | null | undefined, RenderItem extends object = object> extends FieldComponentProps<typeof Autocomplete<RenderItem>, FieldValue> {
|
|
5
5
|
component?: <T extends object>(props: AutocompleteProps<T>) => ReactNode;
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormCalendar: ()=>FormCalendar
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const time_cjs_namespaceObject = require("../utils/time.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Calendar, CalendarProps, DateValue } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { Calendar, CalendarProps, DateValue } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
import { StrictOmit } from "soda-type";
|
|
5
5
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Calendar } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { Calendar } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, CheckboxProps, MergeWithAs } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, CheckboxProps, MergeWithAs } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormCheckboxProps<FieldValue extends boolean | null | undefined = boolean | null | undefined, AsComponent extends As = "input"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, CheckboxProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, CheckboxGroupProps, MergeWithAs } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, CheckboxGroupProps, MergeWithAs } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormCheckboxGroupProps<FieldValue extends string[] | null | undefined = string[] | null | undefined, AsComponent extends As = "div"> = MergeWithAs<ComponentPropsWithoutRef<"div">, ComponentPropsWithoutRef<AsComponent>, CheckboxGroupProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormDateInput: ()=>FormDateInput
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const time_cjs_namespaceObject = require("../utils/time.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DateInput, DateInputProps, DateValue } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { DateInput, DateInputProps, DateValue } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
import { StrictOmit } from "soda-type";
|
|
5
5
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { DateInput } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { DateInput } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormDatePicker: ()=>FormDatePicker
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const time_cjs_namespaceObject = require("../utils/time.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatePicker, DatePickerProps, DateValue } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { DatePicker, DatePickerProps, DateValue } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
import { StrictOmit } from "soda-type";
|
|
5
5
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { DatePicker } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { DatePicker } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormDateRangePicker: ()=>FormDateRangePicker
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const range_cjs_namespaceObject = require("../utils/range.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DateRangePicker, DateRangePickerProps, DateValue } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { DateRangePicker, DateRangePickerProps, DateValue } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
import { StrictOmit } from "soda-type";
|
|
5
5
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { DateRangePicker } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { DateRangePicker } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldRangeValue, getOnRangeChange } from "../utils/range.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, InputProps, MergeWithAs } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, InputProps, MergeWithAs } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormInputProps<FieldValue extends string | null | undefined = string | null | undefined, AsComponent extends As = "input"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, InputProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, InputOtpProps, MergeWithAs } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, InputOtpProps, MergeWithAs } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormInputOtpProps<FieldValue extends string | null | undefined = string | null | undefined, AsComponent extends As = "input"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, InputOtpProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, MergeWithAs, NumberInputProps } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, MergeWithAs, NumberInputProps } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormNumberInputProps<FieldValue extends number | null | undefined = number | null | undefined, AsComponent extends As = "input"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, NumberInputProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, MergeWithAs, PaginationProps } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, MergeWithAs, PaginationProps } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormPaginationProps<FieldValue extends number | null | undefined = number | null | undefined, AsComponent extends As = "nav"> = MergeWithAs<ComponentPropsWithoutRef<"nav">, ComponentPropsWithoutRef<AsComponent>, PaginationProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -30,8 +30,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
30
30
|
getEmptyValue: ()=>getEmptyValue
|
|
31
31
|
});
|
|
32
32
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
|
-
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
34
33
|
const external_react_namespaceObject = require("react");
|
|
34
|
+
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
35
35
|
function getEmptyValue(value) {
|
|
36
36
|
return "undefined" === value ? void 0 : null;
|
|
37
37
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { assign as external_deepsea_tools_assign } from "deepsea-tools";
|
|
4
3
|
import { createContext, useContext } from "react";
|
|
4
|
+
import { assign as external_deepsea_tools_assign } from "deepsea-tools";
|
|
5
5
|
function getEmptyValue(value) {
|
|
6
6
|
return "undefined" === value ? void 0 : null;
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, MergeWithAs, RadioGroupProps } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, MergeWithAs, RadioGroupProps } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormRadioGroupProps<FieldValue extends string | null | undefined = string | null | undefined, AsComponent extends As = "div"> = MergeWithAs<ComponentPropsWithoutRef<"div">, ComponentPropsWithoutRef<AsComponent>, RadioGroupProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormRangeCalendar: ()=>FormRangeCalendar
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const range_cjs_namespaceObject = require("../utils/range.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DateValue, RangeCalendar, RangeCalendarProps } from "@heroui/react";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { DateValue, RangeCalendar, RangeCalendarProps } from "@heroui/react";
|
|
3
3
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
4
4
|
import { StrictOmit } from "soda-type";
|
|
5
5
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { RangeCalendar } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { RangeCalendar } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldRangeValue, getOnRangeChange } from "../utils/range.js";
|
|
@@ -28,9 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormSelect: ()=>FormSelect
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
31
32
|
const react_namespaceObject = require("@heroui/react");
|
|
32
33
|
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
33
|
-
const external_react_namespaceObject = require("react");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
36
36
|
function FormSelect({ field, emptyValue, component: Select2 = react_namespaceObject.Select, selectionMode, labelPlacement, classNames: { base, label, ...restClassNames } = {}, ...rest }) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { Select, SelectProps } from "@heroui/react";
|
|
2
3
|
import { Key } from "@react-types/shared";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
4
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
5
5
|
import { StrictOmit } from "soda-type";
|
|
6
6
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import { Select } from "@heroui/react";
|
|
4
5
|
import { clsx, isNonNullable } from "deepsea-tools";
|
|
5
|
-
import { useContext } from "react";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { FormContext, getEmptyValue } from "./FormProvider.js";
|
|
8
8
|
function FormSelect({ field, emptyValue, component: Select2 = Select, selectionMode, labelPlacement, classNames: { base, label, ...restClassNames } = {}, ...rest }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, MergeWithAs, SwitchProps } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, MergeWithAs, SwitchProps } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormSwitchProps<FieldValue extends boolean | null | undefined = boolean | null | undefined, AsComponent extends As = "input"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, SwitchProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { As, MergeWithAs, TextAreaProps } from "@heroui/react";
|
|
2
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { As, MergeWithAs, TextAreaProps } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
export type FormTextareaProps<FieldValue extends string | null | undefined = string | null | undefined, AsComponent extends As = "textarea"> = MergeWithAs<ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef<AsComponent>, TextAreaProps, AsComponent> & {
|
|
5
5
|
field: Field<FieldValue>;
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormTimeInput: ()=>FormTimeInput
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const react_namespaceObject = require("@heroui/react");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
34
34
|
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
35
|
const time_cjs_namespaceObject = require("../utils/time.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { TimeInput, TimeInputProps } from "@heroui/react";
|
|
2
3
|
import { CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
4
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
5
5
|
import { StrictOmit } from "soda-type";
|
|
6
6
|
import { EmptyValue } from "./FormProvider";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { TimeInput } from "@heroui/react";
|
|
4
3
|
import { useContext } from "react";
|
|
4
|
+
import { TimeInput } from "@heroui/react";
|
|
5
5
|
import { FormContext } from "./FormProvider.js";
|
|
6
6
|
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
7
|
import { getFieldValue, getOnChange } from "../utils/time.js";
|
package/dist/utils/range.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DateValue, RangeValue } from "@heroui/react";
|
|
2
1
|
import { SetStateAction } from "react";
|
|
2
|
+
import { DateValue, RangeValue } from "@heroui/react";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
import { EmptyValue } from "../components/FormProvider";
|
|
5
5
|
import { DefaultTime } from "./getTimeValue";
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date";
|
|
2
1
|
import { SetStateAction } from "react";
|
|
2
|
+
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date";
|
|
3
3
|
import { Field } from "soda-tanstack-form";
|
|
4
4
|
import { EmptyValue } from "../components/FormProvider";
|
|
5
5
|
import { DefaultTime } from "./getTimeValue";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-heroui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@internationalized/date": "^3.10.0",
|
|
39
39
|
"@tanstack/react-form": "^1.23.6",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"soda-hooks": "6.15.2",
|
|
41
|
+
"deepsea-tools": "5.42.4",
|
|
42
42
|
"soda-tanstack-form": "0.3.1",
|
|
43
43
|
"soda-type": "6.7.1"
|
|
44
44
|
},
|
|
@@ -1,46 +1,124 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { ComponentProps, ReactNode, useCallback, useContext, useMemo } from "react"
|
|
4
|
+
import { Select, SelectItem, SharedSelection } from "@heroui/react"
|
|
5
|
+
import { ValueOf, getEnumOptions, intParser, isNonNullable } from "deepsea-tools"
|
|
6
|
+
import { useInputState } from "soda-hooks"
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { EmptyValue, FormContext, GetEmptyValue, getEmptyValue } from "./FormProvider"
|
|
9
|
+
import { SelectionMode } from "./FormSelect"
|
|
10
|
+
|
|
11
|
+
/** 获取枚举值的类型 */
|
|
12
|
+
export type EnumValue<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]> =
|
|
13
|
+
Options extends any[] ? Options[number][1] : ValueOf<Options>
|
|
14
|
+
|
|
15
|
+
/** 获取选择器的值的类型 */
|
|
16
|
+
export type SelectValue<
|
|
17
|
+
Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[],
|
|
18
|
+
Mode extends SelectionMode = "single",
|
|
19
|
+
DisallowEmptySelection extends boolean = false,
|
|
20
|
+
Empty extends EmptyValue = "null",
|
|
21
|
+
> = Mode extends "multiple" ? EnumValue<Options>[] : EnumValue<Options> | (DisallowEmptySelection extends true ? never : GetEmptyValue<Empty>)
|
|
22
|
+
|
|
23
|
+
export interface EnumOption<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]> {
|
|
24
|
+
label: ReactNode
|
|
25
|
+
value: EnumValue<Options>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface EnumSelectPropsBase<
|
|
29
|
+
Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[],
|
|
30
|
+
Mode extends SelectionMode = "single",
|
|
31
|
+
DisallowEmptySelection extends boolean = false,
|
|
32
|
+
Empty extends EmptyValue = "null",
|
|
33
|
+
Value = SelectValue<Options, Mode, DisallowEmptySelection, Empty>,
|
|
34
|
+
> extends Omit<
|
|
35
|
+
ComponentProps<typeof Select<EnumOption<Options>>>,
|
|
36
|
+
"items" | "selectionMode" | "disallowEmptySelection" | "children" | "selectedKeys" | "onSelectionChange" | "value" | "onValueChange"
|
|
37
|
+
> {
|
|
38
|
+
enumObject?: Options
|
|
39
|
+
selectionMode?: Mode
|
|
40
|
+
disallowEmptySelection?: DisallowEmptySelection
|
|
41
|
+
value?: Value
|
|
42
|
+
onValueChange?: (value: Value) => void
|
|
43
|
+
emptyValue?: Empty
|
|
44
|
+
}
|
|
9
45
|
|
|
10
46
|
export interface EnumSelectProps<
|
|
11
|
-
|
|
47
|
+
Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[],
|
|
12
48
|
Mode extends SelectionMode = "single",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
DisallowEmptySelection extends boolean = false,
|
|
50
|
+
Empty extends EmptyValue = "null",
|
|
51
|
+
> extends EnumSelectPropsBase<Options, Mode, DisallowEmptySelection, Empty> {}
|
|
52
|
+
|
|
53
|
+
function render<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]>({
|
|
54
|
+
label,
|
|
55
|
+
value,
|
|
56
|
+
}: EnumOption<Options>) {
|
|
57
|
+
return <SelectItem key={value}>{label}</SelectItem>
|
|
19
58
|
}
|
|
20
59
|
|
|
21
60
|
export function EnumSelect<
|
|
22
|
-
|
|
61
|
+
Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[],
|
|
23
62
|
Mode extends SelectionMode = "single",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
63
|
+
DisallowEmptySelection extends boolean = false,
|
|
64
|
+
Empty extends EmptyValue = "null",
|
|
65
|
+
>({ enumObject, selectionMode, value: _value, onValueChange, emptyValue, ...rest }: EnumSelectProps<Options, Mode, DisallowEmptySelection, Empty>): ReactNode {
|
|
66
|
+
const context = useContext(FormContext)
|
|
67
|
+
emptyValue ??= context.emptyValue as Empty
|
|
68
|
+
|
|
69
|
+
type Value = SelectValue<Options, Mode, DisallowEmptySelection, Empty>
|
|
70
|
+
|
|
71
|
+
const [value, setValue] = useInputState(_value as Value)
|
|
72
|
+
const isNumberEnum = typeof enumObject === "object" && !Array.isArray(enumObject) && typeof Object.values(enumObject).at(0) === "number"
|
|
73
|
+
const selectedKeys = useMemo(() => (Array.isArray(value) ? value : isNonNullable(value) ? [value] : []).map(String), [value])
|
|
74
|
+
|
|
75
|
+
const onSelectionChange = useCallback(
|
|
76
|
+
function onSelectionChange(selection: SharedSelection) {
|
|
77
|
+
const keys = Array.from(selection).map(item => (isNumberEnum ? intParser(String(item)) : String(item)) as ValueOf<Options>)
|
|
78
|
+
const nextValue = (selectionMode === "multiple" ? keys : (keys.at(0) ?? getEmptyValue(emptyValue))) as Value
|
|
79
|
+
setValue(nextValue)
|
|
80
|
+
onValueChange?.(nextValue)
|
|
81
|
+
},
|
|
82
|
+
[selectionMode, onValueChange, setValue, isNumberEnum, emptyValue],
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const items = useMemo(
|
|
86
|
+
() =>
|
|
87
|
+
(Array.isArray(enumObject)
|
|
88
|
+
? enumObject.map(([label, value]) => ({ label, value }))
|
|
89
|
+
: enumObject
|
|
90
|
+
? getEnumOptions(enumObject)
|
|
91
|
+
: []) as EnumOption<Options>[],
|
|
92
|
+
[enumObject],
|
|
93
|
+
)
|
|
94
|
+
|
|
29
95
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
96
|
+
<Select
|
|
97
|
+
items={items}
|
|
98
|
+
selectionMode={selectionMode}
|
|
99
|
+
selectedKeys={isNumberEnum ? selectedKeys.map(String) : selectedKeys}
|
|
100
|
+
onSelectionChange={onSelectionChange}
|
|
101
|
+
{...rest}
|
|
102
|
+
>
|
|
103
|
+
{render}
|
|
104
|
+
</Select>
|
|
33
105
|
)
|
|
34
106
|
}
|
|
35
107
|
|
|
36
|
-
export function createEnumSelect<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return <EnumSelect enumObject={enumObject} {...props} />
|
|
45
|
-
}
|
|
108
|
+
export function createEnumSelect<Options extends Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]>(
|
|
109
|
+
enumObject?: Options,
|
|
110
|
+
): EnumSelectComponent<EnumValue<Options>> {
|
|
111
|
+
return function EnumSelect2<Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null">(
|
|
112
|
+
props: Omit<EnumSelectProps<Options, Mode, DisallowEmptySelection, Empty>, "enumObject">,
|
|
113
|
+
): ReactNode {
|
|
114
|
+
return <EnumSelect<Options, Mode, DisallowEmptySelection, Empty> enumObject={enumObject} {...props} />
|
|
115
|
+
} as EnumSelectComponent<EnumValue<Options>>
|
|
46
116
|
}
|
|
117
|
+
|
|
118
|
+
export type EnumSelectComponent<Value extends string | number> = <
|
|
119
|
+
Mode extends SelectionMode = "single",
|
|
120
|
+
DisallowEmptySelection extends boolean = false,
|
|
121
|
+
Empty extends EmptyValue = "null",
|
|
122
|
+
>(
|
|
123
|
+
props: Omit<EnumSelectProps<[ReactNode, Value][], Mode, DisallowEmptySelection, Empty>, "enumObject">,
|
|
124
|
+
) => ReactNode
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { Autocomplete, AutocompleteProps } from "@heroui/react"
|
|
4
3
|
import { Key, ReactNode } from "react"
|
|
4
|
+
import { Autocomplete, AutocompleteProps } from "@heroui/react"
|
|
5
5
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { Calendar, CalendarProps, DateValue } from "@heroui/react"
|
|
4
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
import { Calendar, CalendarProps, DateValue } from "@heroui/react"
|
|
5
5
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
import { StrictOmit } from "soda-type"
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, Checkbox, CheckboxProps, MergeWithAs } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, Checkbox, CheckboxProps, MergeWithAs } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, CheckboxGroup, CheckboxGroupProps, MergeWithAs } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, CheckboxGroup, CheckboxGroupProps, MergeWithAs } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { DateInput, DateInputProps, DateValue } from "@heroui/react"
|
|
4
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
import { DateInput, DateInputProps, DateValue } from "@heroui/react"
|
|
5
5
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
import { StrictOmit } from "soda-type"
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { DatePicker, DatePickerProps, DateValue } from "@heroui/react"
|
|
4
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
import { DatePicker, DatePickerProps, DateValue } from "@heroui/react"
|
|
5
5
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
import { StrictOmit } from "soda-type"
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { DateRangePicker, DateRangePickerProps, DateValue } from "@heroui/react"
|
|
4
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
import { DateRangePicker, DateRangePickerProps, DateValue } from "@heroui/react"
|
|
5
5
|
import { Field, FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
import { StrictOmit } from "soda-type"
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, Input, InputProps, MergeWithAs } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, Input, InputProps, MergeWithAs } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, InputOtp, InputOtpProps, MergeWithAs } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, InputOtp, InputOtpProps, MergeWithAs } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, MergeWithAs, NumberInput, NumberInputProps } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, MergeWithAs, NumberInput, NumberInputProps } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, MergeWithAs, Pagination, PaginationProps } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, MergeWithAs, Pagination, PaginationProps } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, MergeWithAs, RadioGroup, RadioGroupProps } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, MergeWithAs, RadioGroup, RadioGroupProps } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { DateValue, RangeCalendar, RangeCalendarProps } from "@heroui/react"
|
|
4
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
import { DateValue, RangeCalendar, RangeCalendarProps } from "@heroui/react"
|
|
5
5
|
import { Field, FieldComponentProps } from "soda-tanstack-form"
|
|
6
6
|
import { StrictOmit } from "soda-type"
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { ReactNode, useContext } from "react"
|
|
3
4
|
import { Select, SelectProps } from "@heroui/react"
|
|
4
5
|
import { Key } from "@react-types/shared"
|
|
5
6
|
import { clsx, isNonNullable } from "deepsea-tools"
|
|
6
|
-
import { ReactNode, useContext } from "react"
|
|
7
7
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
8
8
|
import { StrictOmit } from "soda-type"
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, MergeWithAs, Switch, SwitchProps } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, MergeWithAs, Switch, SwitchProps } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { As, MergeWithAs, TextAreaProps, Textarea } from "@heroui/react"
|
|
4
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
+
import { As, MergeWithAs, TextAreaProps, Textarea } from "@heroui/react"
|
|
5
5
|
import { Field } from "soda-tanstack-form"
|
|
6
6
|
|
|
7
7
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { ReactNode, useContext } from "react"
|
|
3
4
|
import { TimeInput, TimeInputProps } from "@heroui/react"
|
|
4
5
|
import { CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date"
|
|
5
|
-
import { ReactNode, useContext } from "react"
|
|
6
6
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
7
7
|
import { StrictOmit } from "soda-type"
|
|
8
8
|
|
package/src/utils/range.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { SetStateAction } from "react"
|
|
1
2
|
import { DateValue, RangeValue } from "@heroui/react"
|
|
2
3
|
import { isNonNullable } from "deepsea-tools"
|
|
3
|
-
import { SetStateAction } from "react"
|
|
4
4
|
import { Field } from "soda-tanstack-form"
|
|
5
5
|
|
|
6
6
|
import { EmptyValue, getEmptyValue } from "@/components/FormProvider"
|
package/src/utils/time.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { SetStateAction } from "react"
|
|
1
2
|
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date"
|
|
2
3
|
import { isNonNullable } from "deepsea-tools"
|
|
3
|
-
import { SetStateAction } from "react"
|
|
4
4
|
import { Field } from "soda-tanstack-form"
|
|
5
5
|
|
|
6
6
|
import { EmptyValue, getEmptyValue } from "@/components/FormProvider"
|