@hi-ui/check-select 4.0.0-alpha.2 → 4.0.0-alpha.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.
@@ -1,15 +1,50 @@
1
1
  import React from 'react';
2
- export interface CheckSelectItem {
2
+ export interface CheckSelectDataItem {
3
3
  /**
4
- * 树节点唯一 id
4
+ * 节点唯一 id
5
5
  */
6
6
  id: React.ReactText;
7
7
  /**
8
- * 树节点标题
8
+ * 节点标题
9
9
  */
10
- title: React.ReactNode;
10
+ title?: React.ReactNode;
11
11
  /**
12
- * 是否禁用该节点(将禁用级联点击,展开,如果开启 checkbox,也将被禁用)
12
+ * 是否禁用该节点
13
13
  */
14
14
  disabled?: boolean;
15
15
  }
16
+ export interface CheckSelectDataGroupItem {
17
+ /**
18
+ * 节点组标题
19
+ */
20
+ groupTitle?: React.ReactNode;
21
+ /**
22
+ * 是否禁用该节点
23
+ */
24
+ children?: CheckSelectDataItem[];
25
+ }
26
+ export declare type CheckSelectItem = CheckSelectDataItem & CheckSelectDataGroupItem;
27
+ export interface CheckSelectRequiredProps {
28
+ checked: boolean;
29
+ focused: boolean;
30
+ }
31
+ export interface FlattedCheckSelectDataItem extends CheckSelectDataItem {
32
+ /**
33
+ * 该节点的子节点列表
34
+ */
35
+ children?: FlattedCheckSelectDataItem[];
36
+ /**
37
+ * 关联用户传入的原始节点
38
+ */
39
+ raw: CheckSelectDataItem;
40
+ /**
41
+ * 该节点的层级,从 0(顶层)开始
42
+ */
43
+ depth: number;
44
+ /**
45
+ * 该节点的父节点
46
+ */
47
+ parent?: FlattedCheckSelectDataItem;
48
+ }
49
+ export interface CheckSelectEventData extends FlattedCheckSelectDataItem, CheckSelectRequiredProps {
50
+ }
@@ -1,287 +1,76 @@
1
1
  import React from 'react';
2
- import { CheckSelectProps } from './CheckSelect';
3
- import { CheckSelectItem } from './types';
4
- export declare const useCheckSelect: ({ data: dataProp, children, disabled, value: valueProp, defaultValue, onChange: onChangeProp, onSelect, emptyContent, searchPlaceholder, titleRender, ...rest }: UseSelectProps) => {
2
+ import { CheckSelectDataItem, CheckSelectEventData } from './types';
3
+ export declare const useCheckSelect: ({ data: dataProp, children, disabled, value: valueProp, defaultValue, onChange: onChangeProp, onSelect, emptyContent, searchPlaceholder, filter, fieldNames, ...rest }: UseCheckSelectProps) => {
5
4
  rootProps: {
6
- searchable?: boolean | undefined;
7
- clearable?: boolean | undefined;
8
- displayRender?: ((option: CheckSelectItem) => React.ReactNode) | undefined;
5
+ /**
6
+ * 自定义选择后触发器所展示的内容,只在 title 为字符串时有效
7
+ */
8
+ displayRender?: ((option: CheckSelectEventData) => React.ReactNode) | undefined;
9
+ /**
10
+ * 触发器输入框占位符
11
+ */
9
12
  placeholder?: string | undefined;
10
- popper?: import("packages/ui/popper/lib/types").PopperProps | undefined;
11
- onSearch?: ((item: CheckSelectItem) => void | Promise<void | CheckSelectItem[]>) | undefined;
12
- slot?: string | undefined;
13
- style?: React.CSSProperties | undefined;
14
- title?: string | undefined;
15
- key?: React.Key | null | undefined;
16
- defaultChecked?: boolean | undefined;
17
- suppressContentEditableWarning?: boolean | undefined;
18
- suppressHydrationWarning?: boolean | undefined;
19
- accessKey?: string | undefined;
20
- className?: string | undefined;
21
- contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
22
- contextMenu?: string | undefined;
23
- dir?: string | undefined;
24
- draggable?: (boolean | "true" | "false") | undefined;
25
- hidden?: boolean | undefined;
26
- id?: string | undefined;
27
- lang?: string | undefined;
28
- spellCheck?: (boolean | "true" | "false") | undefined;
29
- tabIndex?: number | undefined;
30
- translate?: "yes" | "no" | undefined;
31
- radioGroup?: string | undefined;
32
- role?: (React.AriaRole & string) | undefined;
33
- about?: string | undefined;
34
- datatype?: string | undefined;
35
- inlist?: any;
36
- prefix?: string | undefined;
37
- property?: string | undefined;
38
- resource?: string | undefined;
39
- typeof?: string | undefined;
40
- vocab?: string | undefined;
41
- autoCapitalize?: string | undefined;
42
- autoCorrect?: string | undefined;
43
- autoSave?: string | undefined;
44
- color?: string | undefined;
45
- itemProp?: string | undefined;
46
- itemScope?: boolean | undefined;
47
- itemType?: string | undefined;
48
- itemID?: string | undefined;
49
- itemRef?: string | undefined;
50
- results?: number | undefined;
51
- security?: string | undefined;
52
- unselectable?: "on" | "off" | undefined;
53
- inputMode?: "text" | "none" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
54
- is?: string | undefined;
55
- 'aria-activedescendant'?: string | undefined;
56
- 'aria-atomic'?: boolean | "true" | "false" | undefined;
57
- 'aria-autocomplete'?: "list" | "none" | "inline" | "both" | undefined;
58
- 'aria-busy'?: boolean | "true" | "false" | undefined;
59
- 'aria-checked'?: boolean | "true" | "false" | "mixed" | undefined;
60
- 'aria-colcount'?: number | undefined;
61
- 'aria-colindex'?: number | undefined;
62
- 'aria-colspan'?: number | undefined;
63
- 'aria-controls'?: string | undefined;
64
- 'aria-current'?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined;
65
- 'aria-describedby'?: string | undefined;
66
- 'aria-details'?: string | undefined;
67
- 'aria-disabled'?: boolean | "true" | "false" | undefined;
68
- 'aria-dropeffect'?: "link" | "none" | "copy" | "execute" | "move" | "popup" | undefined;
69
- 'aria-errormessage'?: string | undefined;
70
- 'aria-expanded'?: boolean | "true" | "false" | undefined;
71
- 'aria-flowto'?: string | undefined;
72
- 'aria-grabbed'?: boolean | "true" | "false" | undefined;
73
- 'aria-haspopup'?: boolean | "dialog" | "menu" | "grid" | "listbox" | "tree" | "true" | "false" | undefined;
74
- 'aria-hidden'?: boolean | "true" | "false" | undefined;
75
- 'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
76
- 'aria-keyshortcuts'?: string | undefined;
77
- 'aria-label'?: string | undefined;
78
- 'aria-labelledby'?: string | undefined;
79
- 'aria-level'?: number | undefined;
80
- 'aria-live'?: "off" | "assertive" | "polite" | undefined;
81
- 'aria-modal'?: boolean | "true" | "false" | undefined;
82
- 'aria-multiline'?: boolean | "true" | "false" | undefined;
83
- 'aria-multiselectable'?: boolean | "true" | "false" | undefined;
84
- 'aria-orientation'?: "horizontal" | "vertical" | undefined;
85
- 'aria-owns'?: string | undefined;
86
- 'aria-placeholder'?: string | undefined;
87
- 'aria-posinset'?: number | undefined;
88
- 'aria-pressed'?: boolean | "true" | "false" | "mixed" | undefined;
89
- 'aria-readonly'?: boolean | "true" | "false" | undefined;
90
- 'aria-relevant'?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
91
- 'aria-required'?: boolean | "true" | "false" | undefined;
92
- 'aria-roledescription'?: string | undefined;
93
- 'aria-rowcount'?: number | undefined;
94
- 'aria-rowindex'?: number | undefined;
95
- 'aria-rowspan'?: number | undefined;
96
- 'aria-selected'?: boolean | "true" | "false" | undefined;
97
- 'aria-setsize'?: number | undefined;
98
- 'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
99
- 'aria-valuemax'?: number | undefined;
100
- 'aria-valuemin'?: number | undefined;
101
- 'aria-valuenow'?: number | undefined;
102
- 'aria-valuetext'?: string | undefined;
103
- dangerouslySetInnerHTML?: {
104
- __html: string;
105
- } | undefined;
106
- onCopy?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
107
- onCopyCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
108
- onCut?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
109
- onCutCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
110
- onPaste?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
111
- onPasteCapture?: React.ClipboardEventHandler<HTMLDivElement> | undefined;
112
- onCompositionEnd?: React.CompositionEventHandler<HTMLDivElement> | undefined;
113
- onCompositionEndCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
114
- onCompositionStart?: React.CompositionEventHandler<HTMLDivElement> | undefined;
115
- onCompositionStartCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
116
- onCompositionUpdate?: React.CompositionEventHandler<HTMLDivElement> | undefined;
117
- onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLDivElement> | undefined;
118
- onFocus?: React.FocusEventHandler<HTMLDivElement> | undefined;
119
- onFocusCapture?: React.FocusEventHandler<HTMLDivElement> | undefined;
120
- onBlur?: React.FocusEventHandler<HTMLDivElement> | undefined;
121
- onBlurCapture?: React.FocusEventHandler<HTMLDivElement> | undefined;
122
- onChangeCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
123
- onBeforeInput?: React.FormEventHandler<HTMLDivElement> | undefined;
124
- onBeforeInputCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
125
- onInput?: React.FormEventHandler<HTMLDivElement> | undefined;
126
- onInputCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
127
- onReset?: React.FormEventHandler<HTMLDivElement> | undefined;
128
- onResetCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
129
- onSubmit?: React.FormEventHandler<HTMLDivElement> | undefined;
130
- onSubmitCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
131
- onInvalid?: React.FormEventHandler<HTMLDivElement> | undefined;
132
- onInvalidCapture?: React.FormEventHandler<HTMLDivElement> | undefined;
133
- onLoad?: React.ReactEventHandler<HTMLDivElement> | undefined;
134
- onLoadCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
135
- onError?: React.ReactEventHandler<HTMLDivElement> | undefined;
136
- onErrorCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
137
- onKeyDown?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
138
- onKeyDownCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
139
- onKeyPress?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
140
- onKeyPressCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
141
- onKeyUp?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
142
- onKeyUpCapture?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
143
- onAbort?: React.ReactEventHandler<HTMLDivElement> | undefined;
144
- onAbortCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
145
- onCanPlay?: React.ReactEventHandler<HTMLDivElement> | undefined;
146
- onCanPlayCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
147
- onCanPlayThrough?: React.ReactEventHandler<HTMLDivElement> | undefined;
148
- onCanPlayThroughCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
149
- onDurationChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
150
- onDurationChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
151
- onEmptied?: React.ReactEventHandler<HTMLDivElement> | undefined;
152
- onEmptiedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
153
- onEncrypted?: React.ReactEventHandler<HTMLDivElement> | undefined;
154
- onEncryptedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
155
- onEnded?: React.ReactEventHandler<HTMLDivElement> | undefined;
156
- onEndedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
157
- onLoadedData?: React.ReactEventHandler<HTMLDivElement> | undefined;
158
- onLoadedDataCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
159
- onLoadedMetadata?: React.ReactEventHandler<HTMLDivElement> | undefined;
160
- onLoadedMetadataCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
161
- onLoadStart?: React.ReactEventHandler<HTMLDivElement> | undefined;
162
- onLoadStartCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
163
- onPause?: React.ReactEventHandler<HTMLDivElement> | undefined;
164
- onPauseCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
165
- onPlay?: React.ReactEventHandler<HTMLDivElement> | undefined;
166
- onPlayCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
167
- onPlaying?: React.ReactEventHandler<HTMLDivElement> | undefined;
168
- onPlayingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
169
- onProgress?: React.ReactEventHandler<HTMLDivElement> | undefined;
170
- onProgressCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
171
- onRateChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
172
- onRateChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
173
- onSeeked?: React.ReactEventHandler<HTMLDivElement> | undefined;
174
- onSeekedCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
175
- onSeeking?: React.ReactEventHandler<HTMLDivElement> | undefined;
176
- onSeekingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
177
- onStalled?: React.ReactEventHandler<HTMLDivElement> | undefined;
178
- onStalledCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
179
- onSuspend?: React.ReactEventHandler<HTMLDivElement> | undefined;
180
- onSuspendCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
181
- onTimeUpdate?: React.ReactEventHandler<HTMLDivElement> | undefined;
182
- onTimeUpdateCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
183
- onVolumeChange?: React.ReactEventHandler<HTMLDivElement> | undefined;
184
- onVolumeChangeCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
185
- onWaiting?: React.ReactEventHandler<HTMLDivElement> | undefined;
186
- onWaitingCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
187
- onAuxClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
188
- onAuxClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
189
- onClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
190
- onClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
191
- onContextMenu?: React.MouseEventHandler<HTMLDivElement> | undefined;
192
- onContextMenuCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
193
- onDoubleClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
194
- onDoubleClickCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
195
- onDrag?: React.DragEventHandler<HTMLDivElement> | undefined;
196
- onDragCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
197
- onDragEnd?: React.DragEventHandler<HTMLDivElement> | undefined;
198
- onDragEndCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
199
- onDragEnter?: React.DragEventHandler<HTMLDivElement> | undefined;
200
- onDragEnterCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
201
- onDragExit?: React.DragEventHandler<HTMLDivElement> | undefined;
202
- onDragExitCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
203
- onDragLeave?: React.DragEventHandler<HTMLDivElement> | undefined;
204
- onDragLeaveCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
205
- onDragOver?: React.DragEventHandler<HTMLDivElement> | undefined;
206
- onDragOverCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
207
- onDragStart?: React.DragEventHandler<HTMLDivElement> | undefined;
208
- onDragStartCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
209
- onDrop?: React.DragEventHandler<HTMLDivElement> | undefined;
210
- onDropCapture?: React.DragEventHandler<HTMLDivElement> | undefined;
211
- onMouseDown?: React.MouseEventHandler<HTMLDivElement> | undefined;
212
- onMouseDownCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
213
- onMouseEnter?: React.MouseEventHandler<HTMLDivElement> | undefined;
214
- onMouseLeave?: React.MouseEventHandler<HTMLDivElement> | undefined;
215
- onMouseMove?: React.MouseEventHandler<HTMLDivElement> | undefined;
216
- onMouseMoveCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
217
- onMouseOut?: React.MouseEventHandler<HTMLDivElement> | undefined;
218
- onMouseOutCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
219
- onMouseOver?: React.MouseEventHandler<HTMLDivElement> | undefined;
220
- onMouseOverCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
221
- onMouseUp?: React.MouseEventHandler<HTMLDivElement> | undefined;
222
- onMouseUpCapture?: React.MouseEventHandler<HTMLDivElement> | undefined;
223
- onSelectCapture?: React.ReactEventHandler<HTMLDivElement> | undefined;
224
- onTouchCancel?: React.TouchEventHandler<HTMLDivElement> | undefined;
225
- onTouchCancelCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
226
- onTouchEnd?: React.TouchEventHandler<HTMLDivElement> | undefined;
227
- onTouchEndCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
228
- onTouchMove?: React.TouchEventHandler<HTMLDivElement> | undefined;
229
- onTouchMoveCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
230
- onTouchStart?: React.TouchEventHandler<HTMLDivElement> | undefined;
231
- onTouchStartCapture?: React.TouchEventHandler<HTMLDivElement> | undefined;
232
- onPointerDown?: React.PointerEventHandler<HTMLDivElement> | undefined;
233
- onPointerDownCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
234
- onPointerMove?: React.PointerEventHandler<HTMLDivElement> | undefined;
235
- onPointerMoveCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
236
- onPointerUp?: React.PointerEventHandler<HTMLDivElement> | undefined;
237
- onPointerUpCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
238
- onPointerCancel?: React.PointerEventHandler<HTMLDivElement> | undefined;
239
- onPointerCancelCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
240
- onPointerEnter?: React.PointerEventHandler<HTMLDivElement> | undefined;
241
- onPointerEnterCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
242
- onPointerLeave?: React.PointerEventHandler<HTMLDivElement> | undefined;
243
- onPointerLeaveCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
244
- onPointerOver?: React.PointerEventHandler<HTMLDivElement> | undefined;
245
- onPointerOverCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
246
- onPointerOut?: React.PointerEventHandler<HTMLDivElement> | undefined;
247
- onPointerOutCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
248
- onGotPointerCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
249
- onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
250
- onLostPointerCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
251
- onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLDivElement> | undefined;
252
- onScroll?: React.UIEventHandler<HTMLDivElement> | undefined;
253
- onScrollCapture?: React.UIEventHandler<HTMLDivElement> | undefined;
254
- onWheel?: React.WheelEventHandler<HTMLDivElement> | undefined;
255
- onWheelCapture?: React.WheelEventHandler<HTMLDivElement> | undefined;
256
- onAnimationStart?: React.AnimationEventHandler<HTMLDivElement> | undefined;
257
- onAnimationStartCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
258
- onAnimationEnd?: React.AnimationEventHandler<HTMLDivElement> | undefined;
259
- onAnimationEndCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
260
- onAnimationIteration?: React.AnimationEventHandler<HTMLDivElement> | undefined;
261
- onAnimationIterationCapture?: React.AnimationEventHandler<HTMLDivElement> | undefined;
262
- onTransitionEnd?: React.TransitionEventHandler<HTMLDivElement> | undefined;
263
- onTransitionEndCapture?: React.TransitionEventHandler<HTMLDivElement> | undefined;
264
- prefixCls?: string | undefined;
265
13
  };
266
- data: CheckSelectItem[] | {
267
- id: any;
268
- title: any;
269
- disabled: any;
270
- }[];
14
+ data: any[];
15
+ flattedData: import("packages/utils/tree-utils/lib/types/types").BaseFlattedTreeNodeData<any, any>[];
271
16
  value: React.ReactText[];
17
+ tryChangeValue: (stateOrFunction: React.SetStateAction<React.ReactText[]>, ...args: any[]) => void;
272
18
  onSelect: (targetItem: import("@hi-ui/use-check").UseCheckItem, shouldChecked: boolean) => void;
273
19
  isSelectedId: (id: React.ReactText) => boolean;
274
20
  emptyContent: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal | null;
275
- getSearchInputProps: () => {
276
- placeholder: string | undefined;
277
- value: string;
278
- onChange: (evt: React.ChangeEvent<HTMLInputElement>) => void;
279
- };
280
- tryChangeValue: (newState: React.ReactText[], ...args: any[]) => void;
281
- isEmpty: boolean;
282
- resetSearch: () => void;
283
- titleRender: ((item: CheckSelectItem) => React.ReactNode) | undefined;
284
21
  };
285
- export interface UseSelectProps extends CheckSelectProps {
22
+ export interface UseCheckSelectProps {
23
+ /**
24
+ * 设置当前选中值
25
+ */
26
+ value?: React.ReactText[];
27
+ /**
28
+ * 设置当前选中值默认值
29
+ */
30
+ defaultValue?: React.ReactText[];
31
+ /**
32
+ * 选中值改变时的回调
33
+ */
34
+ onChange?: (value: React.ReactText[], targetOption?: CheckSelectEventData, shouldChecked?: boolean) => void;
35
+ /**
36
+ * 选中值时回调
37
+ */
38
+ onSelect?: (value: React.ReactText[], targetOption: CheckSelectEventData, shouldChecked: boolean) => void;
39
+ /**
40
+ * 是否禁止使用
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * 设置选项为空时展示的内容
45
+ */
46
+ emptyContent?: React.ReactNode;
47
+ /**
48
+ * 自定义选择后触发器所展示的内容,只在 title 为字符串时有效
49
+ */
50
+ displayRender?: (option: CheckSelectEventData) => React.ReactNode;
51
+ /**
52
+ * 触发器输入框占位符
53
+ */
54
+ placeholder?: string;
55
+ /**
56
+ * 搜索输入框占位符
57
+ */
58
+ searchPlaceholder?: string;
59
+ /**
60
+ * 启用自定义过滤函数实现根据搜索框内容,自定义搜索
61
+ */
62
+ filter?: (keyword: string, option: CheckSelectEventData) => boolean;
63
+ /**
64
+ * 选项数据
65
+ */
66
+ data?: CheckSelectDataItem[];
67
+ /**
68
+ * JSX 子节点
69
+ */
70
+ children?: React.ReactNode;
71
+ /**
72
+ * 设置 data 中 id, title, disabled, children 对应的 key
73
+ */
74
+ fieldNames?: Record<string, string>;
286
75
  }
287
76
  export declare type UseSelectReturn = ReturnType<typeof useCheckSelect>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/check-select",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.20",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HIUI <mi-hiui@xiaomi.com>",
@@ -43,29 +43,38 @@
43
43
  "url": "https://github.com/XiaoMi/hiui/issues"
44
44
  },
45
45
  "dependencies": {
46
- "@hi-ui/checkbox": "^4.0.0-alpha.9",
47
- "@hi-ui/classname": "^4.0.0-alpha.0",
48
- "@hi-ui/core": "^4.0.0-alpha.2",
49
- "@hi-ui/core-css": "^4.0.0-alpha.0",
50
- "@hi-ui/env": "^4.0.0-alpha.0",
51
- "@hi-ui/icons": "^4.0.0-alpha.8",
52
- "@hi-ui/input": "^4.0.0-alpha.10",
53
- "@hi-ui/popper": "^4.0.0-alpha.4",
54
- "@hi-ui/tag-input": "^4.0.0-alpha.1",
55
- "@hi-ui/use-check": "^4.0.0-alpha.5",
56
- "@hi-ui/use-children": "^4.0.0-alpha.1",
57
- "@hi-ui/use-latest": "^4.0.0-alpha.2",
58
- "@hi-ui/use-toggle": "^4.0.0-alpha.4",
59
- "@hi-ui/use-uncontrolled-state": "^4.0.0-alpha.5"
46
+ "@hi-ui/checkbox": "^4.0.0-alpha.21",
47
+ "@hi-ui/classname": "^4.0.0-alpha.3",
48
+ "@hi-ui/core": "^4.0.0-alpha.14",
49
+ "@hi-ui/core-css": "^4.0.0-alpha.10",
50
+ "@hi-ui/env": "^4.0.0-alpha.5",
51
+ "@hi-ui/highlighter": "^4.0.0-alpha.6",
52
+ "@hi-ui/icons": "^4.0.0-alpha.20",
53
+ "@hi-ui/input": "^4.0.0-alpha.24",
54
+ "@hi-ui/picker": "^4.0.0-alpha.8",
55
+ "@hi-ui/popper": "^4.0.0-alpha.17",
56
+ "@hi-ui/tag-input": "^4.0.0-alpha.15",
57
+ "@hi-ui/times": "^4.0.0-alpha.4",
58
+ "@hi-ui/tree-utils": "^4.0.0-alpha.8",
59
+ "@hi-ui/type-assertion": "^4.0.0-alpha.13",
60
+ "@hi-ui/use-check": "^4.0.0-alpha.14",
61
+ "@hi-ui/use-children": "^4.0.0-alpha.3",
62
+ "@hi-ui/use-data-source": "^4.0.0-alpha.5",
63
+ "@hi-ui/use-latest": "^4.0.0-alpha.4",
64
+ "@hi-ui/use-search-mode": "^4.0.0-alpha.6",
65
+ "@hi-ui/use-toggle": "^4.0.0-alpha.10",
66
+ "@hi-ui/use-uncontrolled-state": "^4.0.0-alpha.12",
67
+ "lodash": "^4.17.21",
68
+ "rc-virtual-list": "^3.4.1"
60
69
  },
61
70
  "peerDependencies": {
62
71
  "react": "^17.0.1",
63
72
  "react-dom": "^17.0.1"
64
73
  },
65
74
  "devDependencies": {
66
- "@hi-ui/hi-build": "^4.0.0-alpha.0",
75
+ "@hi-ui/hi-build": "^4.0.0-alpha.4",
67
76
  "react": "^17.0.1",
68
77
  "react-dom": "^17.0.1"
69
78
  },
70
- "gitHead": "0e89a6d183d2f2c5901a9c2bb7f88b30d5e2b193"
79
+ "gitHead": "dbe7ec19bc067527f0cfcf8c71100619fc98cc72"
71
80
  }
@@ -1,81 +0,0 @@
1
- /** @LICENSE
2
- * @hi-ui/check-select
3
- * https://github.com/XiaoMi/hiui/tree/master/packages/ui/check-select#readme
4
- *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, '__esModule', {
13
- value: true
14
- });
15
-
16
- var React = require('react');
17
-
18
- var useLatest = require('@hi-ui/use-latest');
19
-
20
- var env = require('@hi-ui/env');
21
- /**
22
- * 支持搜索功能的 hook
23
- */
24
-
25
-
26
- var useSearch = function useSearch(flattedData, filter) {
27
- var _useState = React.useState(''),
28
- searchValue = _useState[0],
29
- setSearchValue = _useState[1];
30
-
31
- var _useState2 = React.useState([]),
32
- matchedNodes = _useState2[0],
33
- setMatchedNodes = _useState2[1];
34
-
35
- var flattedDataRef = useLatest.useLatestRef(flattedData);
36
- var handleChange = React.useCallback(function (evt) {
37
- var nextSearchValue = evt.target.value;
38
- setSearchValue(nextSearchValue); // 匹配到搜索的节点,将这些节点进行展开显示,其它均隐藏
39
-
40
- var matchedNodes = getMatchedNodes(flattedDataRef.current, nextSearchValue, filter);
41
- setMatchedNodes(matchedNodes);
42
- }, [flattedDataRef]);
43
- var inputProps = React.useMemo(function () {
44
- return {
45
- value: searchValue,
46
- onChange: handleChange
47
- };
48
- }, [searchValue, handleChange]);
49
- var resetSearch = React.useCallback(function () {
50
- setSearchValue('');
51
- }, []);
52
- var isSearch = !!searchValue;
53
- var isEmpty = isSearch && matchedNodes.length === 0;
54
- return [isSearch, matchedNodes, inputProps, isEmpty, resetSearch];
55
- };
56
- /**
57
- * 从 value 中 找到指定的 options(逐层查找)
58
- */
59
-
60
-
61
- var getMatchedNodes = function getMatchedNodes(flattedData, searchValue, filter) {
62
- if (!searchValue) return [];
63
- return flattedData.filter(function (node) {
64
- var _a, _b;
65
-
66
- if (typeof node.title !== 'string') {
67
- if (env.__DEV__) {
68
- console.info('WARNING: The `option.title` should be `string` when searchable is enabled.');
69
- }
70
-
71
- return false;
72
- }
73
-
74
- if (filter && filter(node)) return false; // 匹配策略:`String.include`
75
-
76
- return (_b = (_a = node.title).includes) === null || _b === void 0 ? void 0 : _b.call(_a, searchValue);
77
- });
78
- };
79
-
80
- exports.useSearch = useSearch;
81
- //# sourceMappingURL=use-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-search.js","sources":["../../../src/hooks/use-search.ts"],"sourcesContent":[null],"names":["useSearch","flattedData","filter","useState","searchValue","setSearchValue","matchedNodes","setMatchedNodes","flattedDataRef","useLatestRef","handleChange","useCallback","evt","nextSearchValue","target","value","getMatchedNodes","current","inputProps","useMemo","onChange","resetSearch","isSearch","isEmpty","length","node","title","__DEV__","console","info","includes"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA;;;;;IAGaA,SAAS,GAAG,SAAZA,SAAY,CACvBC,WADuB,EAEvBC,MAFuB;kBAIeC,cAAAA,CAAS,EAATA;MAA/BC,WAAP;MAAoBC,cAApB;;mBACwCF,cAAAA,CAA4B,EAA5BA;MAAjCG,YAAP;MAAqBC,eAArB;;MAEMC,cAAc,GAAGC,sBAAAA,CAAaR,WAAbQ;MAEjBC,YAAY,GAAGC,iBAAAA,CACnB,UAACC,GAAD;QACQC,eAAe,GAAGD,GAAG,CAACE,MAAJF,CAAWG;AAEnCV,IAAAA,cAAc,CAACQ,eAAD,CAAdR;;QAGMC,YAAY,GAAGU,eAAe,CAACR,cAAc,CAACS,OAAhB,EAAyBJ,eAAzB,EAA0CX,MAA1C;AAEpCK,IAAAA,eAAe,CAACD,YAAD,CAAfC;AAT4B,GAAXI,EAWnB,CAACH,cAAD,CAXmBG;MAcfO,UAAU,GAAGC,aAAAA,CACjB;WAAO;AACLJ,MAAAA,KAAK,EAAEX,WADF;AAELgB,MAAAA,QAAQ,EAAEV;AAFL;AADiB,GAAPS,EAKjB,CAACf,WAAD,EAAcM,YAAd,CALiBS;MAQbE,WAAW,GAAGV,iBAAAA,CAAY;AAC9BN,IAAAA,cAAc,CAAC,EAAD,CAAdA;AAD6B,GAAXM,EAEjB,EAFiBA;MAIdW,QAAQ,GAAG,CAAC,CAAClB;MACbmB,OAAO,GAAGD,QAAQ,IAAIhB,YAAY,CAACkB,MAAblB,KAAwB;SAE7C,CAACgB,QAAD,EAAWhB,YAAX,EAAyBY,UAAzB,EAAqCK,OAArC,EAA8CF,WAA9C;;AAGT;;;;;AAGA,IAAML,eAAe,GAAG,SAAlBA,eAAkB,CACtBf,WADsB,EAEtBG,WAFsB,EAGtBF,MAHsB;MAKlB,CAACE,aAAa,OAAO,EAAP;SAEXH,WAAW,CAACC,MAAZD,CAAmB,UAACwB,IAAD;;;QACpB,OAAOA,IAAI,CAACC,KAAZ,KAAsB,UAAU;UAC9BC,aAAS;AACXC,QAAAA,OAAO,CAACC,IAARD,CAAa,4EAAbA;;;aAEK;;;QAGL1B,MAAM,IAAIA,MAAM,CAACuB,IAAD,GAAQ,OAAO,KAAP;;WAGrB,MAAA,MAAAA,IAAI,CAACC,KAAL,EAAWI,QAAX,UAAA,iBAAA,SAAA,eAAsB1B;AAXxB,GAAAH;AAPT,CAAA;;"}
@@ -1,72 +0,0 @@
1
- /** @LICENSE
2
- * @hi-ui/check-select
3
- * https://github.com/XiaoMi/hiui/tree/master/packages/ui/check-select#readme
4
- *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- import { useState, useCallback, useMemo } from 'react';
11
- import { useLatestRef } from '@hi-ui/use-latest';
12
- import { __DEV__ } from '@hi-ui/env';
13
- /**
14
- * 支持搜索功能的 hook
15
- */
16
-
17
- var useSearch = function useSearch(flattedData, filter) {
18
- var _useState = useState(''),
19
- searchValue = _useState[0],
20
- setSearchValue = _useState[1];
21
-
22
- var _useState2 = useState([]),
23
- matchedNodes = _useState2[0],
24
- setMatchedNodes = _useState2[1];
25
-
26
- var flattedDataRef = useLatestRef(flattedData);
27
- var handleChange = useCallback(function (evt) {
28
- var nextSearchValue = evt.target.value;
29
- setSearchValue(nextSearchValue); // 匹配到搜索的节点,将这些节点进行展开显示,其它均隐藏
30
-
31
- var matchedNodes = getMatchedNodes(flattedDataRef.current, nextSearchValue, filter);
32
- setMatchedNodes(matchedNodes);
33
- }, [flattedDataRef]);
34
- var inputProps = useMemo(function () {
35
- return {
36
- value: searchValue,
37
- onChange: handleChange
38
- };
39
- }, [searchValue, handleChange]);
40
- var resetSearch = useCallback(function () {
41
- setSearchValue('');
42
- }, []);
43
- var isSearch = !!searchValue;
44
- var isEmpty = isSearch && matchedNodes.length === 0;
45
- return [isSearch, matchedNodes, inputProps, isEmpty, resetSearch];
46
- };
47
- /**
48
- * 从 value 中 找到指定的 options(逐层查找)
49
- */
50
-
51
-
52
- var getMatchedNodes = function getMatchedNodes(flattedData, searchValue, filter) {
53
- if (!searchValue) return [];
54
- return flattedData.filter(function (node) {
55
- var _a, _b;
56
-
57
- if (typeof node.title !== 'string') {
58
- if (__DEV__) {
59
- console.info('WARNING: The `option.title` should be `string` when searchable is enabled.');
60
- }
61
-
62
- return false;
63
- }
64
-
65
- if (filter && filter(node)) return false; // 匹配策略:`String.include`
66
-
67
- return (_b = (_a = node.title).includes) === null || _b === void 0 ? void 0 : _b.call(_a, searchValue);
68
- });
69
- };
70
-
71
- export { useSearch };
72
- //# sourceMappingURL=use-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-search.js","sources":["../../../src/hooks/use-search.ts"],"sourcesContent":[null],"names":["useSearch","flattedData","filter","useState","searchValue","setSearchValue","matchedNodes","setMatchedNodes","flattedDataRef","useLatestRef","handleChange","useCallback","evt","nextSearchValue","target","value","getMatchedNodes","current","inputProps","useMemo","onChange","resetSearch","isSearch","isEmpty","length","node","title","__DEV__","console","info","includes"],"mappings":";;;;;;;;;;;;AAKA;;;;IAGaA,SAAS,GAAG,SAAZA,SAAY,CACvBC,WADuB,EAEvBC,MAFuB;kBAIeC,QAAQ,CAAC,EAAD;MAAvCC,WAAP;MAAoBC,cAApB;;mBACwCF,QAAQ,CAAoB,EAApB;MAAzCG,YAAP;MAAqBC,eAArB;;MAEMC,cAAc,GAAGC,YAAY,CAACR,WAAD;MAE7BS,YAAY,GAAGC,WAAW,CAC9B,UAACC,GAAD;QACQC,eAAe,GAAGD,GAAG,CAACE,MAAJF,CAAWG;AAEnCV,IAAAA,cAAc,CAACQ,eAAD,CAAdR;;QAGMC,YAAY,GAAGU,eAAe,CAACR,cAAc,CAACS,OAAhB,EAAyBJ,eAAzB,EAA0CX,MAA1C;AAEpCK,IAAAA,eAAe,CAACD,YAAD,CAAfC;AAT4B,GAAA,EAW9B,CAACC,cAAD,CAX8B;MAc1BU,UAAU,GAAGC,OAAO,CACxB;WAAO;AACLJ,MAAAA,KAAK,EAAEX,WADF;AAELgB,MAAAA,QAAQ,EAAEV;AAFL;AADiB,GAAA,EAKxB,CAACN,WAAD,EAAcM,YAAd,CALwB;MAQpBW,WAAW,GAAGV,WAAW,CAAC;AAC9BN,IAAAA,cAAc,CAAC,EAAD,CAAdA;AAD6B,GAAA,EAE5B,EAF4B;MAIzBiB,QAAQ,GAAG,CAAC,CAAClB;MACbmB,OAAO,GAAGD,QAAQ,IAAIhB,YAAY,CAACkB,MAAblB,KAAwB;SAE7C,CAACgB,QAAD,EAAWhB,YAAX,EAAyBY,UAAzB,EAAqCK,OAArC,EAA8CF,WAA9C;;AAGT;;;;;AAGA,IAAML,eAAe,GAAG,SAAlBA,eAAkB,CACtBf,WADsB,EAEtBG,WAFsB,EAGtBF,MAHsB;MAKlB,CAACE,aAAa,OAAO,EAAP;SAEXH,WAAW,CAACC,MAAZD,CAAmB,UAACwB,IAAD;;;QACpB,OAAOA,IAAI,CAACC,KAAZ,KAAsB,UAAU;UAC9BC,SAAS;AACXC,QAAAA,OAAO,CAACC,IAARD,CAAa,4EAAbA;;;aAEK;;;QAGL1B,MAAM,IAAIA,MAAM,CAACuB,IAAD,GAAQ,OAAO,KAAP;;WAGrB,MAAA,MAAAA,IAAI,CAACC,KAAL,EAAWI,QAAX,UAAA,iBAAA,SAAA,eAAsB1B;AAXxB,GAAAH;AAPT,CAAA;;"}
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * 一个缓存数据的 hook
4
- *
5
- * @param data
6
- * @returns
7
- */
8
- export declare const useCache: <T>(data: T) => readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>];