1
1
import { Composite } from "@floating-ui/react" ;
2
- import { useState , type KeyboardEvent } from "react" ;
2
+ import { type KeyboardEvent , useState } from "react" ;
3
3
import { useControllableState } from "../../hooks" ;
4
4
import type { PrimitiveProps } from "../../primitives" ;
5
5
import { CompositeContext , type CompositeContextValue } from "../../primitives/composite/composite-context" ;
6
+ import type { MultipleValueProps , SingleValueProps } from "../../shared/types" ;
6
7
import { tx } from "../../utils" ;
7
- import { AccordionContext , type AccordionBaseProps , type AccordionContextValue } from "./accordion-context" ;
8
+ import { type AccordionBaseProps , AccordionContext , type AccordionContextValue } from "./accordion-context" ;
8
9
9
10
type AccordionSingleProps = {
10
11
/**
11
12
* 同时打开多个项目
12
13
*/
13
14
multiple : false ;
14
15
15
- /**
16
- * 受控值
17
- */
18
- value ?: string | number | null ;
19
-
20
- /**
21
- * 默认值
22
- */
23
- defaultValue ?: string | number | null ;
24
-
25
- /**
26
- * onChange 回调
27
- */
28
- onChange ?: ( value : string | number | null ) => void ;
29
-
30
16
/**
31
17
* 允许关闭内容, 当 `multiple` 为 `false` 时有效
32
18
* @default false
33
19
*/
34
20
collapsible ?: boolean ;
35
- } ;
21
+ } & Omit < SingleValueProps , "multiple" > ;
36
22
37
23
type AccordionMultipleProps = {
38
24
/**
@@ -42,22 +28,7 @@ type AccordionMultipleProps = {
42
28
multiple ?: true ;
43
29
44
30
collapsible ?: never ;
45
-
46
- /**
47
- * 受控值
48
- */
49
- value ?: ( string | number ) [ ] ;
50
-
51
- /**
52
- * 默认值
53
- */
54
- defaultValue ?: ( string | number ) [ ] ;
55
-
56
- /**
57
- * onChange 回调
58
- */
59
- onChange ?: ( value : ( string | number ) [ ] ) => void ;
60
- } ;
31
+ } & Omit < MultipleValueProps , "multiple" > ;
61
32
62
33
export type AccordionRootProps = ( AccordionMultipleProps | AccordionSingleProps ) & AccordionBaseProps ;
63
34
0 commit comments