soda-heroui 0.11.20 → 0.11.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,15 +3,17 @@ import { Select } from "@heroui/react";
|
|
|
3
3
|
import { ValueOf } from "deepsea-tools";
|
|
4
4
|
import { EmptyValue, GetEmptyValue } from "./FormProvider";
|
|
5
5
|
import { SelectionMode } from "./FormSelect";
|
|
6
|
+
/** enumObject 的类型 */
|
|
7
|
+
export type SelectOptions = Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[];
|
|
6
8
|
/** 获取枚举值的类型 */
|
|
7
|
-
export type EnumValue<Options extends
|
|
9
|
+
export type EnumValue<Options extends SelectOptions> = Options extends any[] ? Options[number][1] : ValueOf<Options>;
|
|
8
10
|
/** 获取选择器的值的类型 */
|
|
9
|
-
export type SelectValue<Options extends
|
|
10
|
-
export interface EnumOption<Options extends
|
|
11
|
+
export type SelectValue<Options extends SelectOptions, 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>);
|
|
12
|
+
export interface EnumOption<Options extends SelectOptions> {
|
|
11
13
|
label: ReactNode;
|
|
12
14
|
value: EnumValue<Options>;
|
|
13
15
|
}
|
|
14
|
-
export interface EnumSelectPropsBase<Options extends
|
|
16
|
+
export interface EnumSelectPropsBase<Options extends SelectOptions, 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
17
|
enumObject?: Options;
|
|
16
18
|
selectionMode?: Mode;
|
|
17
19
|
disallowEmptySelection?: DisallowEmptySelection;
|
|
@@ -19,8 +21,8 @@ export interface EnumSelectPropsBase<Options extends Record<string, string | num
|
|
|
19
21
|
onValueChange?: (value: Value) => void;
|
|
20
22
|
emptyValue?: Empty;
|
|
21
23
|
}
|
|
22
|
-
export interface EnumSelectProps<Options extends
|
|
24
|
+
export interface EnumSelectProps<Options extends SelectOptions, Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null"> extends EnumSelectPropsBase<Options, Mode, DisallowEmptySelection, Empty> {
|
|
23
25
|
}
|
|
24
|
-
export declare function EnumSelect<Options extends
|
|
25
|
-
export declare function createEnumSelect<Options extends
|
|
26
|
+
export declare function EnumSelect<Options extends SelectOptions, 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;
|
|
27
|
+
export declare function createEnumSelect<Options extends SelectOptions>(enumObject?: Options): EnumSelectComponent<EnumValue<Options>>;
|
|
26
28
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-heroui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@internationalized/date": "^3.10.0",
|
|
39
39
|
"@tanstack/react-form": "^1.23.6",
|
|
40
|
-
"soda-
|
|
41
|
-
"deepsea-tools": "5.
|
|
40
|
+
"soda-type": "6.7.1",
|
|
41
|
+
"deepsea-tools": "5.43.0",
|
|
42
42
|
"soda-tanstack-form": "0.3.1",
|
|
43
|
-
"soda-
|
|
43
|
+
"soda-hooks": "6.15.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
|
@@ -8,25 +8,27 @@ import { useInputState } from "soda-hooks"
|
|
|
8
8
|
import { EmptyValue, FormContext, GetEmptyValue, getEmptyValue } from "./FormProvider"
|
|
9
9
|
import { SelectionMode } from "./FormSelect"
|
|
10
10
|
|
|
11
|
+
/** enumObject 的类型 */
|
|
12
|
+
export type SelectOptions = Record<string, string | number> | ([ReactNode, string | number] | readonly [ReactNode, string | number])[]
|
|
13
|
+
|
|
11
14
|
/** 获取枚举值的类型 */
|
|
12
|
-
export type EnumValue<Options extends
|
|
13
|
-
Options extends any[] ? Options[number][1] : ValueOf<Options>
|
|
15
|
+
export type EnumValue<Options extends SelectOptions> = Options extends any[] ? Options[number][1] : ValueOf<Options>
|
|
14
16
|
|
|
15
17
|
/** 获取选择器的值的类型 */
|
|
16
18
|
export type SelectValue<
|
|
17
|
-
Options extends
|
|
19
|
+
Options extends SelectOptions,
|
|
18
20
|
Mode extends SelectionMode = "single",
|
|
19
21
|
DisallowEmptySelection extends boolean = false,
|
|
20
22
|
Empty extends EmptyValue = "null",
|
|
21
23
|
> = Mode extends "multiple" ? EnumValue<Options>[] : EnumValue<Options> | (DisallowEmptySelection extends true ? never : GetEmptyValue<Empty>)
|
|
22
24
|
|
|
23
|
-
export interface EnumOption<Options extends
|
|
25
|
+
export interface EnumOption<Options extends SelectOptions> {
|
|
24
26
|
label: ReactNode
|
|
25
27
|
value: EnumValue<Options>
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export interface EnumSelectPropsBase<
|
|
29
|
-
Options extends
|
|
31
|
+
Options extends SelectOptions,
|
|
30
32
|
Mode extends SelectionMode = "single",
|
|
31
33
|
DisallowEmptySelection extends boolean = false,
|
|
32
34
|
Empty extends EmptyValue = "null",
|
|
@@ -44,7 +46,7 @@ export interface EnumSelectPropsBase<
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export interface EnumSelectProps<
|
|
47
|
-
Options extends
|
|
49
|
+
Options extends SelectOptions,
|
|
48
50
|
Mode extends SelectionMode = "single",
|
|
49
51
|
DisallowEmptySelection extends boolean = false,
|
|
50
52
|
Empty extends EmptyValue = "null",
|
|
@@ -58,7 +60,7 @@ function render<Options extends Record<string, string | number> | ([ReactNode, s
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
export function EnumSelect<
|
|
61
|
-
Options extends
|
|
63
|
+
Options extends SelectOptions,
|
|
62
64
|
Mode extends SelectionMode = "single",
|
|
63
65
|
DisallowEmptySelection extends boolean = false,
|
|
64
66
|
Empty extends EmptyValue = "null",
|
|
@@ -105,9 +107,7 @@ export function EnumSelect<
|
|
|
105
107
|
)
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
export function createEnumSelect<Options extends
|
|
109
|
-
enumObject?: Options,
|
|
110
|
-
): EnumSelectComponent<EnumValue<Options>> {
|
|
110
|
+
export function createEnumSelect<Options extends SelectOptions>(enumObject?: Options): EnumSelectComponent<EnumValue<Options>> {
|
|
111
111
|
return function EnumSelect2<Mode extends SelectionMode = "single", DisallowEmptySelection extends boolean = false, Empty extends EmptyValue = "null">(
|
|
112
112
|
props: Omit<EnumSelectProps<Options, Mode, DisallowEmptySelection, Empty>, "enumObject">,
|
|
113
113
|
): ReactNode {
|