@manohub/ui 0.6.0
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/README.md +141 -0
- package/dist/components/avatar/index.d.ts +283 -0
- package/dist/components/avatar/index.js +167 -0
- package/dist/components/badge/index.d.ts +132 -0
- package/dist/components/badge/index.js +99 -0
- package/dist/components/button/index.d.ts +578 -0
- package/dist/components/button/index.js +191 -0
- package/dist/components/capsule/index.d.ts +161 -0
- package/dist/components/capsule/index.js +101 -0
- package/dist/components/card/index.d.ts +456 -0
- package/dist/components/card/index.js +231 -0
- package/dist/components/checkbox/index.d.ts +331 -0
- package/dist/components/checkbox/index.js +165 -0
- package/dist/components/code/index.d.ts +134 -0
- package/dist/components/code/index.js +117 -0
- package/dist/components/code-editor/index.d.ts +163 -0
- package/dist/components/code-editor/index.js +98 -0
- package/dist/components/collapse/index.d.ts +125 -0
- package/dist/components/collapse/index.js +95 -0
- package/dist/components/control-size.d.ts +8 -0
- package/dist/components/dialog/index.d.ts +224 -0
- package/dist/components/dialog/index.js +194 -0
- package/dist/components/divider/index.d.ts +64 -0
- package/dist/components/divider/index.js +62 -0
- package/dist/components/drawer/index.d.ts +226 -0
- package/dist/components/drawer/index.js +190 -0
- package/dist/components/filter/index.d.ts +391 -0
- package/dist/components/filter/index.js +203 -0
- package/dist/components/form/index.d.ts +704 -0
- package/dist/components/form/index.js +329 -0
- package/dist/components/input/index.d.ts +980 -0
- package/dist/components/input/index.js +334 -0
- package/dist/components/layout/index.d.ts +162 -0
- package/dist/components/layout/index.js +100 -0
- package/dist/components/list-view/index.d.ts +563 -0
- package/dist/components/list-view/index.js +221 -0
- package/dist/components/loading/index.d.ts +77 -0
- package/dist/components/loading/index.js +40 -0
- package/dist/components/nav/index.d.ts +293 -0
- package/dist/components/nav/index.js +164 -0
- package/dist/components/notice/index.d.ts +137 -0
- package/dist/components/notice/index.js +101 -0
- package/dist/components/notification/index.d.ts +118 -0
- package/dist/components/notification/index.js +99 -0
- package/dist/components/page/index.d.ts +276 -0
- package/dist/components/page/index.js +351 -0
- package/dist/components/page/split-resize.d.ts +42 -0
- package/dist/components/page/split-resize.js +36 -0
- package/dist/components/pagination/index.d.ts +171 -0
- package/dist/components/pagination/index.js +226 -0
- package/dist/components/panel/index.d.ts +401 -0
- package/dist/components/panel/index.js +193 -0
- package/dist/components/part-padding.d.ts +27 -0
- package/dist/components/part-padding.js +23 -0
- package/dist/components/query-state/index.d.ts +207 -0
- package/dist/components/query-state/index.js +181 -0
- package/dist/components/radio/index.d.ts +473 -0
- package/dist/components/radio/index.js +250 -0
- package/dist/components/search/index.d.ts +167 -0
- package/dist/components/search/index.js +105 -0
- package/dist/components/select/index.d.ts +252 -0
- package/dist/components/select/index.js +281 -0
- package/dist/components/skeleton/index.d.ts +88 -0
- package/dist/components/skeleton/index.js +56 -0
- package/dist/components/steps/index.d.ts +199 -0
- package/dist/components/steps/index.js +117 -0
- package/dist/components/switch/index.d.ts +150 -0
- package/dist/components/switch/index.js +103 -0
- package/dist/components/table/index.d.ts +351 -0
- package/dist/components/table/index.js +286 -0
- package/dist/components/tabs/index.d.ts +179 -0
- package/dist/components/tabs/index.js +153 -0
- package/dist/components/tabset/index.d.ts +105 -0
- package/dist/components/tabset/index.js +68 -0
- package/dist/components/tag/index.d.ts +203 -0
- package/dist/components/tag/index.js +144 -0
- package/dist/components/toast/index.d.ts +271 -0
- package/dist/components/toast/index.js +116 -0
- package/dist/components/tooltip/index.d.ts +126 -0
- package/dist/components/tooltip/index.js +97 -0
- package/dist/components/tree/index.d.ts +317 -0
- package/dist/components/tree/index.js +251 -0
- package/dist/components/upload/index.d.ts +384 -0
- package/dist/components/upload/index.js +172 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +102 -0
- package/dist/services/base.d.ts +21 -0
- package/dist/services/base.js +42 -0
- package/dist/services/dialog.d.ts +41 -0
- package/dist/services/dialog.js +83 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/loading.d.ts +21 -0
- package/dist/services/loading.js +41 -0
- package/dist/services/toast.d.ts +40 -0
- package/dist/services/toast.js +74 -0
- package/dist/styles/components/avatar.css +128 -0
- package/dist/styles/components/avatar.tokens.css +24 -0
- package/dist/styles/components/badge.css +237 -0
- package/dist/styles/components/button.css +454 -0
- package/dist/styles/components/button.tokens.css +56 -0
- package/dist/styles/components/capsule.css +120 -0
- package/dist/styles/components/capsule.tokens.css +27 -0
- package/dist/styles/components/card.css +192 -0
- package/dist/styles/components/checkbox.css +145 -0
- package/dist/styles/components/checkbox.tokens.css +26 -0
- package/dist/styles/components/code-editor.css +91 -0
- package/dist/styles/components/code-editor.tokens.css +24 -0
- package/dist/styles/components/code.css +153 -0
- package/dist/styles/components/code.tokens.css +29 -0
- package/dist/styles/components/collapse.css +62 -0
- package/dist/styles/components/collapse.tokens.css +20 -0
- package/dist/styles/components/dialog.css +106 -0
- package/dist/styles/components/dialog.tokens.css +24 -0
- package/dist/styles/components/divider.css +71 -0
- package/dist/styles/components/divider.tokens.css +21 -0
- package/dist/styles/components/drawer.css +143 -0
- package/dist/styles/components/drawer.tokens.css +22 -0
- package/dist/styles/components/filter.css +41 -0
- package/dist/styles/components/filter.tokens.css +14 -0
- package/dist/styles/components/form.css +220 -0
- package/dist/styles/components/form.tokens.css +15 -0
- package/dist/styles/components/input.css +445 -0
- package/dist/styles/components/input.tokens.css +41 -0
- package/dist/styles/components/layout.css +198 -0
- package/dist/styles/components/list-view.css +244 -0
- package/dist/styles/components/loading.css +76 -0
- package/dist/styles/components/loading.tokens.css +23 -0
- package/dist/styles/components/nav.css +48 -0
- package/dist/styles/components/notice.css +153 -0
- package/dist/styles/components/notice.tokens.css +17 -0
- package/dist/styles/components/notification.css +159 -0
- package/dist/styles/components/notification.tokens.css +37 -0
- package/dist/styles/components/page.css +473 -0
- package/dist/styles/components/pagination.css +297 -0
- package/dist/styles/components/pagination.tokens.css +32 -0
- package/dist/styles/components/panel.css +77 -0
- package/dist/styles/components/query-state.css +88 -0
- package/dist/styles/components/radio.css +271 -0
- package/dist/styles/components/radio.tokens.css +26 -0
- package/dist/styles/components/search.css +30 -0
- package/dist/styles/components/select.css +242 -0
- package/dist/styles/components/select.tokens.css +33 -0
- package/dist/styles/components/skeleton.css +60 -0
- package/dist/styles/components/skeleton.tokens.css +27 -0
- package/dist/styles/components/steps.css +157 -0
- package/dist/styles/components/steps.tokens.css +42 -0
- package/dist/styles/components/switch.css +165 -0
- package/dist/styles/components/switch.tokens.css +26 -0
- package/dist/styles/components/table.css +439 -0
- package/dist/styles/components/table.tokens.css +41 -0
- package/dist/styles/components/tabs.css +234 -0
- package/dist/styles/components/tabs.tokens.css +30 -0
- package/dist/styles/components/tag.css +200 -0
- package/dist/styles/components/tag.tokens.css +30 -0
- package/dist/styles/components/toast.css +150 -0
- package/dist/styles/components/toast.tokens.css +26 -0
- package/dist/styles/components/tooltip.css +89 -0
- package/dist/styles/components/tooltip.tokens.css +25 -0
- package/dist/styles/components/tree.css +139 -0
- package/dist/styles/components/tree.tokens.css +20 -0
- package/dist/styles/components/upload.css +150 -0
- package/dist/styles/components/upload.tokens.css +27 -0
- package/dist/styles/index.css +149 -0
- package/dist/styles/operations/collapse.css +84 -0
- package/dist/styles/operations/popup.css +189 -0
- package/dist/styles/operations/tabset.css +57 -0
- package/dist/utils/state-illustration.d.ts +31 -0
- package/dist/utils/state-illustration.js +156 -0
- package/package.json +62 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { type PropType, type SlotsType, type VNodeChild } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 条件值:单值(文本 / 单选)或数组(多选)。数字与字符串同等对待(取值原样透传)。
|
|
4
|
+
*/
|
|
5
|
+
export type FilterValue = string | number | Array<string | number>;
|
|
6
|
+
/** 条件快照:`条件名 → 值`(未选条件的值为空串,语义是「不过滤」) */
|
|
7
|
+
export type FilterValues = Record<string, FilterValue>;
|
|
8
|
+
/**
|
|
9
|
+
* 「全部」哨兵:选项值等于它即「不过滤」。
|
|
10
|
+
*
|
|
11
|
+
* 与既有查询方案(骨架层的筛选适配件)同词,便于迁移时**选项表原样搬运**;
|
|
12
|
+
* 自绘场景更推荐直接用 `placeholder="全部"` 表达未选(本包 `Select` 把空串视为未选中,
|
|
13
|
+
* 会显示占位文案)—— 两条路子的最终视觉一致,见 `docs/components/filter.md`。
|
|
14
|
+
*/
|
|
15
|
+
export declare const FILTER_ALL = "all";
|
|
16
|
+
/**
|
|
17
|
+
* 筛选字段的作用域插槽:控件由消费方渲染,本件交出**归一后**的当前值。
|
|
18
|
+
*
|
|
19
|
+
* 与 `Form.Item` 的作用域同形,差别只在归一:筛选语义里「未选」一律是空串
|
|
20
|
+
* (`'all'` 哨兵 / `null` / 空数组都归到空串),于是消费方直接把 `value` 绑给控件即可,
|
|
21
|
+
* 不必自己处理哨兵——这是 `Filter.Item` 相对 `Form.Item` 唯一的增量。
|
|
22
|
+
*/
|
|
23
|
+
export interface FilterItemSlotScope {
|
|
24
|
+
/** 当前条件值(已归一:空串 = 未选) */
|
|
25
|
+
value: FilterValue;
|
|
26
|
+
/** 写入该条件(写入前归一) */
|
|
27
|
+
setValue: (value: FilterValue | undefined | null) => void;
|
|
28
|
+
/** 清空该条件(等价于 `setValue('')`) */
|
|
29
|
+
clear: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 归一(读与写**同一份实现**,两处不各写一套):
|
|
33
|
+
* - `'all'`(哨兵)/ `''` / `null` / `undefined` → `''`(= 不过滤);
|
|
34
|
+
* - 数组逐项归一后去空,全空 → `''`;**只剩一项仍是数组**(多选值的类型不降级成标量);
|
|
35
|
+
* - 数字原样(`0` 是有效值,不是「空」);
|
|
36
|
+
* - 其余原样(不做 trim:归一不负责改写用户输入)。
|
|
37
|
+
*/
|
|
38
|
+
export declare function normalizeFilterValue(value: FilterValue | null | undefined): FilterValue;
|
|
39
|
+
export interface FilterProps {
|
|
40
|
+
/** 筛选条标题(透传给 `Form.Header`) */
|
|
41
|
+
title?: string;
|
|
42
|
+
/** 标题下的说明小字(透传给 `Form.Header`) */
|
|
43
|
+
description?: string;
|
|
44
|
+
/** label 列宽(px);缺省 `56`(见 `FILTER_LABEL_WIDTH`),透传给 `Form` */
|
|
45
|
+
labelWidth?: number;
|
|
46
|
+
/** 受控条件快照(`条件名 → 值`);不传即非受控(由 `defaultValue` 起) */
|
|
47
|
+
modelValue?: FilterValues;
|
|
48
|
+
/** 非受控初值;其中的键会一并成为快照的键 */
|
|
49
|
+
defaultValue?: FilterValues;
|
|
50
|
+
/** 「筛选」按钮文案 */
|
|
51
|
+
queryText?: string;
|
|
52
|
+
/** 「重置」按钮文案 */
|
|
53
|
+
resetText?: string;
|
|
54
|
+
/** 是否渲染「重置」按钮(缺省渲染) */
|
|
55
|
+
showReset?: boolean;
|
|
56
|
+
/** 条件值变化(快照已归一) */
|
|
57
|
+
onChange?: (values: FilterValues) => void;
|
|
58
|
+
/** 「筛选」按钮 / 字段区回车(回车只作用于输入框,且不认浮层里的输入) */
|
|
59
|
+
onQuery?: (values: FilterValues) => void;
|
|
60
|
+
/** 「重置」按钮:全部条件清空(**不再触发 `onChange`**,避免与重置回调双触发) */
|
|
61
|
+
onReset?: (values: FilterValues) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface FilterItemProps {
|
|
64
|
+
/** 条件名(必填):快照的键,也是后端查询参数的键(就是 `Form.Item` 的 `name`) */
|
|
65
|
+
code: string;
|
|
66
|
+
/** 字段名(渲染在控件左侧的 label) */
|
|
67
|
+
label?: string;
|
|
68
|
+
/** 必填标记(透传 `Form.Item`,星号画在 label 文字**之后**) */
|
|
69
|
+
required?: boolean;
|
|
70
|
+
/** 校验错误文案(透传 `Form.Item`:非空即进 invalid 态,排在控件下方) */
|
|
71
|
+
error?: string;
|
|
72
|
+
/** 控件下方提示(透传 `Form.Item`) */
|
|
73
|
+
hint?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 筛选字段(`Filter` 的子件):**`Form.Item` 的薄包装**。
|
|
77
|
+
*
|
|
78
|
+
* 一字段一个子件,`code` 就是 `Form.Item` 的 `name`(值仍然存在 `Form` 里,本件不另起一套存储);
|
|
79
|
+
* 增量只有一处 —— **读写的值都是归一后的**(`'all'` / 空数组 / 空值 → 空串),
|
|
80
|
+
* 于是消费方直接把 `value` 绑给控件,不必自己处理哨兵。
|
|
81
|
+
*
|
|
82
|
+
* 字段宽**自适应**:容器够宽一行排下,窄了整体换行(列距 24 / 行距 16)。
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* <Filter.Item code="status" label="授权状态">
|
|
86
|
+
* {{ default: ({ value, setValue }) => (
|
|
87
|
+
* <Select options={statusOptions} modelValue={String(value)} placeholder="全部" onChange={setValue} />
|
|
88
|
+
* ) }}
|
|
89
|
+
* </Filter.Item>
|
|
90
|
+
*/
|
|
91
|
+
export declare const FilterItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
92
|
+
code: {
|
|
93
|
+
type: StringConstructor;
|
|
94
|
+
required: true;
|
|
95
|
+
};
|
|
96
|
+
label: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: undefined;
|
|
99
|
+
};
|
|
100
|
+
required: {
|
|
101
|
+
type: BooleanConstructor;
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
104
|
+
error: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
hint: {
|
|
109
|
+
type: StringConstructor;
|
|
110
|
+
default: string;
|
|
111
|
+
};
|
|
112
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
113
|
+
code: {
|
|
114
|
+
type: StringConstructor;
|
|
115
|
+
required: true;
|
|
116
|
+
};
|
|
117
|
+
label: {
|
|
118
|
+
type: StringConstructor;
|
|
119
|
+
default: undefined;
|
|
120
|
+
};
|
|
121
|
+
required: {
|
|
122
|
+
type: BooleanConstructor;
|
|
123
|
+
default: boolean;
|
|
124
|
+
};
|
|
125
|
+
error: {
|
|
126
|
+
type: StringConstructor;
|
|
127
|
+
default: string;
|
|
128
|
+
};
|
|
129
|
+
hint: {
|
|
130
|
+
type: StringConstructor;
|
|
131
|
+
default: string;
|
|
132
|
+
};
|
|
133
|
+
}>> & Readonly<{}>, {
|
|
134
|
+
label: string;
|
|
135
|
+
error: string;
|
|
136
|
+
required: boolean;
|
|
137
|
+
hint: string;
|
|
138
|
+
}, SlotsType<{
|
|
139
|
+
default?: (scope: FilterItemSlotScope) => VNodeChild;
|
|
140
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
141
|
+
/** 复合件入口:`Filter` + `Filter.Item`(与 `Form` / `Page` 同款 Object.assign 写法,成员不平级导出) */
|
|
142
|
+
export declare const Filter: {
|
|
143
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
144
|
+
title: {
|
|
145
|
+
type: StringConstructor;
|
|
146
|
+
default: undefined;
|
|
147
|
+
};
|
|
148
|
+
description: {
|
|
149
|
+
type: StringConstructor;
|
|
150
|
+
default: undefined;
|
|
151
|
+
};
|
|
152
|
+
labelWidth: {
|
|
153
|
+
type: NumberConstructor;
|
|
154
|
+
default: undefined;
|
|
155
|
+
};
|
|
156
|
+
modelValue: {
|
|
157
|
+
type: PropType<FilterValues>;
|
|
158
|
+
default: undefined;
|
|
159
|
+
};
|
|
160
|
+
defaultValue: {
|
|
161
|
+
type: PropType<FilterValues>;
|
|
162
|
+
default: undefined;
|
|
163
|
+
};
|
|
164
|
+
queryText: {
|
|
165
|
+
type: StringConstructor;
|
|
166
|
+
default: string;
|
|
167
|
+
};
|
|
168
|
+
resetText: {
|
|
169
|
+
type: StringConstructor;
|
|
170
|
+
default: string;
|
|
171
|
+
};
|
|
172
|
+
showReset: {
|
|
173
|
+
type: BooleanConstructor;
|
|
174
|
+
default: boolean;
|
|
175
|
+
};
|
|
176
|
+
onChange: {
|
|
177
|
+
type: PropType<(values: FilterValues) => void>;
|
|
178
|
+
default: undefined;
|
|
179
|
+
};
|
|
180
|
+
onQuery: {
|
|
181
|
+
type: PropType<(values: FilterValues) => void>;
|
|
182
|
+
default: undefined;
|
|
183
|
+
};
|
|
184
|
+
onReset: {
|
|
185
|
+
type: PropType<(values: FilterValues) => void>;
|
|
186
|
+
default: undefined;
|
|
187
|
+
};
|
|
188
|
+
}>> & Readonly<{
|
|
189
|
+
"onUpdate:modelValue"?: ((values: FilterValues) => any) | undefined;
|
|
190
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
191
|
+
'update:modelValue': (values: FilterValues) => true;
|
|
192
|
+
}, import("vue").PublicProps, {
|
|
193
|
+
title: string;
|
|
194
|
+
onChange: (values: FilterValues) => void;
|
|
195
|
+
onReset: (values: FilterValues) => void;
|
|
196
|
+
defaultValue: FilterValues;
|
|
197
|
+
modelValue: FilterValues;
|
|
198
|
+
description: string;
|
|
199
|
+
labelWidth: number;
|
|
200
|
+
queryText: string;
|
|
201
|
+
resetText: string;
|
|
202
|
+
showReset: boolean;
|
|
203
|
+
onQuery: (values: FilterValues) => void;
|
|
204
|
+
}, true, {}, SlotsType<{
|
|
205
|
+
default?: () => VNodeChild;
|
|
206
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
207
|
+
P: {};
|
|
208
|
+
B: {};
|
|
209
|
+
D: {};
|
|
210
|
+
C: {};
|
|
211
|
+
M: {};
|
|
212
|
+
Defaults: {};
|
|
213
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
214
|
+
title: {
|
|
215
|
+
type: StringConstructor;
|
|
216
|
+
default: undefined;
|
|
217
|
+
};
|
|
218
|
+
description: {
|
|
219
|
+
type: StringConstructor;
|
|
220
|
+
default: undefined;
|
|
221
|
+
};
|
|
222
|
+
labelWidth: {
|
|
223
|
+
type: NumberConstructor;
|
|
224
|
+
default: undefined;
|
|
225
|
+
};
|
|
226
|
+
modelValue: {
|
|
227
|
+
type: PropType<FilterValues>;
|
|
228
|
+
default: undefined;
|
|
229
|
+
};
|
|
230
|
+
defaultValue: {
|
|
231
|
+
type: PropType<FilterValues>;
|
|
232
|
+
default: undefined;
|
|
233
|
+
};
|
|
234
|
+
queryText: {
|
|
235
|
+
type: StringConstructor;
|
|
236
|
+
default: string;
|
|
237
|
+
};
|
|
238
|
+
resetText: {
|
|
239
|
+
type: StringConstructor;
|
|
240
|
+
default: string;
|
|
241
|
+
};
|
|
242
|
+
showReset: {
|
|
243
|
+
type: BooleanConstructor;
|
|
244
|
+
default: boolean;
|
|
245
|
+
};
|
|
246
|
+
onChange: {
|
|
247
|
+
type: PropType<(values: FilterValues) => void>;
|
|
248
|
+
default: undefined;
|
|
249
|
+
};
|
|
250
|
+
onQuery: {
|
|
251
|
+
type: PropType<(values: FilterValues) => void>;
|
|
252
|
+
default: undefined;
|
|
253
|
+
};
|
|
254
|
+
onReset: {
|
|
255
|
+
type: PropType<(values: FilterValues) => void>;
|
|
256
|
+
default: undefined;
|
|
257
|
+
};
|
|
258
|
+
}>> & Readonly<{
|
|
259
|
+
"onUpdate:modelValue"?: ((values: FilterValues) => any) | undefined;
|
|
260
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
|
|
261
|
+
title: string;
|
|
262
|
+
onChange: (values: FilterValues) => void;
|
|
263
|
+
onReset: (values: FilterValues) => void;
|
|
264
|
+
defaultValue: FilterValues;
|
|
265
|
+
modelValue: FilterValues;
|
|
266
|
+
description: string;
|
|
267
|
+
labelWidth: number;
|
|
268
|
+
queryText: string;
|
|
269
|
+
resetText: string;
|
|
270
|
+
showReset: boolean;
|
|
271
|
+
onQuery: (values: FilterValues) => void;
|
|
272
|
+
}>;
|
|
273
|
+
__isFragment?: never;
|
|
274
|
+
__isTeleport?: never;
|
|
275
|
+
__isSuspense?: never;
|
|
276
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
277
|
+
title: {
|
|
278
|
+
type: StringConstructor;
|
|
279
|
+
default: undefined;
|
|
280
|
+
};
|
|
281
|
+
description: {
|
|
282
|
+
type: StringConstructor;
|
|
283
|
+
default: undefined;
|
|
284
|
+
};
|
|
285
|
+
labelWidth: {
|
|
286
|
+
type: NumberConstructor;
|
|
287
|
+
default: undefined;
|
|
288
|
+
};
|
|
289
|
+
modelValue: {
|
|
290
|
+
type: PropType<FilterValues>;
|
|
291
|
+
default: undefined;
|
|
292
|
+
};
|
|
293
|
+
defaultValue: {
|
|
294
|
+
type: PropType<FilterValues>;
|
|
295
|
+
default: undefined;
|
|
296
|
+
};
|
|
297
|
+
queryText: {
|
|
298
|
+
type: StringConstructor;
|
|
299
|
+
default: string;
|
|
300
|
+
};
|
|
301
|
+
resetText: {
|
|
302
|
+
type: StringConstructor;
|
|
303
|
+
default: string;
|
|
304
|
+
};
|
|
305
|
+
showReset: {
|
|
306
|
+
type: BooleanConstructor;
|
|
307
|
+
default: boolean;
|
|
308
|
+
};
|
|
309
|
+
onChange: {
|
|
310
|
+
type: PropType<(values: FilterValues) => void>;
|
|
311
|
+
default: undefined;
|
|
312
|
+
};
|
|
313
|
+
onQuery: {
|
|
314
|
+
type: PropType<(values: FilterValues) => void>;
|
|
315
|
+
default: undefined;
|
|
316
|
+
};
|
|
317
|
+
onReset: {
|
|
318
|
+
type: PropType<(values: FilterValues) => void>;
|
|
319
|
+
default: undefined;
|
|
320
|
+
};
|
|
321
|
+
}>> & Readonly<{
|
|
322
|
+
"onUpdate:modelValue"?: ((values: FilterValues) => any) | undefined;
|
|
323
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
324
|
+
'update:modelValue': (values: FilterValues) => true;
|
|
325
|
+
}, string, {
|
|
326
|
+
title: string;
|
|
327
|
+
onChange: (values: FilterValues) => void;
|
|
328
|
+
onReset: (values: FilterValues) => void;
|
|
329
|
+
defaultValue: FilterValues;
|
|
330
|
+
modelValue: FilterValues;
|
|
331
|
+
description: string;
|
|
332
|
+
labelWidth: number;
|
|
333
|
+
queryText: string;
|
|
334
|
+
resetText: string;
|
|
335
|
+
showReset: boolean;
|
|
336
|
+
onQuery: (values: FilterValues) => void;
|
|
337
|
+
}, {}, string, SlotsType<{
|
|
338
|
+
default?: () => VNodeChild;
|
|
339
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
340
|
+
Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
341
|
+
code: {
|
|
342
|
+
type: StringConstructor;
|
|
343
|
+
required: true;
|
|
344
|
+
};
|
|
345
|
+
label: {
|
|
346
|
+
type: StringConstructor;
|
|
347
|
+
default: undefined;
|
|
348
|
+
};
|
|
349
|
+
required: {
|
|
350
|
+
type: BooleanConstructor;
|
|
351
|
+
default: boolean;
|
|
352
|
+
};
|
|
353
|
+
error: {
|
|
354
|
+
type: StringConstructor;
|
|
355
|
+
default: string;
|
|
356
|
+
};
|
|
357
|
+
hint: {
|
|
358
|
+
type: StringConstructor;
|
|
359
|
+
default: string;
|
|
360
|
+
};
|
|
361
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
362
|
+
code: {
|
|
363
|
+
type: StringConstructor;
|
|
364
|
+
required: true;
|
|
365
|
+
};
|
|
366
|
+
label: {
|
|
367
|
+
type: StringConstructor;
|
|
368
|
+
default: undefined;
|
|
369
|
+
};
|
|
370
|
+
required: {
|
|
371
|
+
type: BooleanConstructor;
|
|
372
|
+
default: boolean;
|
|
373
|
+
};
|
|
374
|
+
error: {
|
|
375
|
+
type: StringConstructor;
|
|
376
|
+
default: string;
|
|
377
|
+
};
|
|
378
|
+
hint: {
|
|
379
|
+
type: StringConstructor;
|
|
380
|
+
default: string;
|
|
381
|
+
};
|
|
382
|
+
}>> & Readonly<{}>, {
|
|
383
|
+
label: string;
|
|
384
|
+
error: string;
|
|
385
|
+
required: boolean;
|
|
386
|
+
hint: string;
|
|
387
|
+
}, SlotsType<{
|
|
388
|
+
default?: (scope: FilterItemSlotScope) => VNodeChild;
|
|
389
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
390
|
+
};
|
|
391
|
+
export type FilterCompound = typeof Filter;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { defineComponent, createVNode, ref, h, Fragment } from "vue";
|
|
2
|
+
import { Button } from "../button/index.js";
|
|
3
|
+
import { FormItem, Form } from "../form/index.js";
|
|
4
|
+
const FILTER_ALL = "all";
|
|
5
|
+
const FILTER_LABEL_WIDTH = 68;
|
|
6
|
+
const FILTER_GAP = 16;
|
|
7
|
+
function normalizeFilterValue(value) {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
const kept = value.map((item) => normalizeFilterValue(item)).filter((item) => item !== "");
|
|
10
|
+
return kept.length ? kept : "";
|
|
11
|
+
}
|
|
12
|
+
if (value === void 0 || value === null) return "";
|
|
13
|
+
if (typeof value === "number") return value;
|
|
14
|
+
return value === "" || value === FILTER_ALL ? "" : value;
|
|
15
|
+
}
|
|
16
|
+
function normalizeValues(values) {
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const [code, value] of Object.entries(values ?? {})) {
|
|
19
|
+
out[code] = normalizeFilterValue(value);
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
const FilterRoot = /* @__PURE__ */ defineComponent({
|
|
24
|
+
name: "Filter",
|
|
25
|
+
inheritAttrs: false,
|
|
26
|
+
props: {
|
|
27
|
+
title: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
labelWidth: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
modelValue: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
defaultValue: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
queryText: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "筛选"
|
|
50
|
+
},
|
|
51
|
+
resetText: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: "重置"
|
|
54
|
+
},
|
|
55
|
+
showReset: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
onChange: {
|
|
60
|
+
type: Function,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
onQuery: {
|
|
64
|
+
type: Function,
|
|
65
|
+
default: void 0
|
|
66
|
+
},
|
|
67
|
+
onReset: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: void 0
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
emits: {
|
|
73
|
+
"update:modelValue": (values) => true
|
|
74
|
+
},
|
|
75
|
+
slots: Object,
|
|
76
|
+
setup(props, {
|
|
77
|
+
slots,
|
|
78
|
+
attrs,
|
|
79
|
+
emit
|
|
80
|
+
}) {
|
|
81
|
+
const formRef = ref(null);
|
|
82
|
+
let clearing = false;
|
|
83
|
+
const onFormChange = (values) => {
|
|
84
|
+
if (clearing) return;
|
|
85
|
+
const snapshot2 = normalizeValues(values);
|
|
86
|
+
emit("update:modelValue", snapshot2);
|
|
87
|
+
props.onChange?.(snapshot2);
|
|
88
|
+
};
|
|
89
|
+
const snapshot = () => normalizeValues(formRef.value?.getValues());
|
|
90
|
+
const query = () => props.onQuery?.(snapshot());
|
|
91
|
+
const reset = () => {
|
|
92
|
+
clearing = true;
|
|
93
|
+
const cleared = formRef.value?.clear() ?? {};
|
|
94
|
+
clearing = false;
|
|
95
|
+
const next = normalizeValues(cleared);
|
|
96
|
+
emit("update:modelValue", next);
|
|
97
|
+
props.onReset?.(next);
|
|
98
|
+
};
|
|
99
|
+
const onFieldsKeydown = (event) => {
|
|
100
|
+
if (event.key !== "Enter" || event.isComposing) return;
|
|
101
|
+
const target = event.target;
|
|
102
|
+
if (target?.tagName !== "INPUT" || target.closest("[popover]")) return;
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
query();
|
|
105
|
+
};
|
|
106
|
+
const renderActions = () => createVNode(Fragment, null, [createVNode(Button, {
|
|
107
|
+
"variant": "primary",
|
|
108
|
+
"onClick": query
|
|
109
|
+
}, {
|
|
110
|
+
default: () => props.queryText
|
|
111
|
+
}), props.showReset ? createVNode(Button, {
|
|
112
|
+
"variant": "secondary",
|
|
113
|
+
"onClick": reset
|
|
114
|
+
}, {
|
|
115
|
+
default: () => props.resetText
|
|
116
|
+
}) : null]);
|
|
117
|
+
return () => createVNode(Form, {
|
|
118
|
+
"ref": formRef,
|
|
119
|
+
"class": ["mh-filter__form", attrs.class].filter(Boolean).join(" "),
|
|
120
|
+
"style": attrs.style,
|
|
121
|
+
"labelWidth": props.labelWidth ?? FILTER_LABEL_WIDTH,
|
|
122
|
+
"gap": FILTER_GAP,
|
|
123
|
+
"modelValue": props.modelValue,
|
|
124
|
+
"defaultValue": props.defaultValue,
|
|
125
|
+
"onChange": onFormChange
|
|
126
|
+
}, {
|
|
127
|
+
default: () => [
|
|
128
|
+
/* 插槽一律走对象形态:TSX 的 `v-slots={{…}}` 会被当**普通属性**丢掉
|
|
129
|
+
(见 `list-view/index.tsx` 同款记录),而多子节点直传会触发
|
|
130
|
+
「Non-function value encountered for default slot」告警(同 `page/index.tsx`)。 */
|
|
131
|
+
h(Form.Header, {
|
|
132
|
+
title: props.title,
|
|
133
|
+
description: props.description
|
|
134
|
+
}, {
|
|
135
|
+
extra: renderActions
|
|
136
|
+
}),
|
|
137
|
+
// 字段区也用插槽对象形态传子节点:`h()` 的第三参不收 `null`(`slots.default?.()` 的返回可能是 null)
|
|
138
|
+
h("div", {
|
|
139
|
+
class: "mh-filter__fields",
|
|
140
|
+
onKeydown: onFieldsKeydown
|
|
141
|
+
}, {
|
|
142
|
+
default: () => slots.default?.()
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const FilterItem = /* @__PURE__ */ defineComponent({
|
|
149
|
+
name: "FilterItem",
|
|
150
|
+
inheritAttrs: false,
|
|
151
|
+
props: {
|
|
152
|
+
code: {
|
|
153
|
+
type: String,
|
|
154
|
+
required: true
|
|
155
|
+
},
|
|
156
|
+
label: {
|
|
157
|
+
type: String,
|
|
158
|
+
default: void 0
|
|
159
|
+
},
|
|
160
|
+
required: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
default: false
|
|
163
|
+
},
|
|
164
|
+
error: {
|
|
165
|
+
type: String,
|
|
166
|
+
default: ""
|
|
167
|
+
},
|
|
168
|
+
hint: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: ""
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
slots: Object,
|
|
174
|
+
setup(props, {
|
|
175
|
+
slots,
|
|
176
|
+
attrs
|
|
177
|
+
}) {
|
|
178
|
+
return () => createVNode(FormItem, {
|
|
179
|
+
"name": props.code,
|
|
180
|
+
"label": props.label,
|
|
181
|
+
"required": props.required,
|
|
182
|
+
"error": props.error,
|
|
183
|
+
"hint": props.hint,
|
|
184
|
+
"class": ["mh-filter__item", attrs.class].filter(Boolean).join(" "),
|
|
185
|
+
"style": attrs.style
|
|
186
|
+
}, {
|
|
187
|
+
default: (scope) => slots.default?.({
|
|
188
|
+
value: normalizeFilterValue(scope.value),
|
|
189
|
+
setValue: (value) => scope.setValue(normalizeFilterValue(value)),
|
|
190
|
+
clear: () => scope.setValue("")
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const Filter = Object.assign(FilterRoot, {
|
|
196
|
+
Item: FilterItem
|
|
197
|
+
});
|
|
198
|
+
export {
|
|
199
|
+
FILTER_ALL,
|
|
200
|
+
Filter,
|
|
201
|
+
FilterItem,
|
|
202
|
+
normalizeFilterValue
|
|
203
|
+
};
|