@fbkworks/adapter-vant 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +33 -2
- package/dist/dark.css +4 -0
- package/dist/feedback.d.ts +2 -0
- package/dist/feedback.mjs +37 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.mjs +77 -0
- package/dist/index.mjs.map +1 -0
- package/dist/primitives/Button.d.ts +53 -0
- package/dist/primitives/Button.mjs +58 -0
- package/dist/primitives/Button.mjs.map +1 -0
- package/dist/primitives/Checkbox.d.ts +33 -0
- package/dist/primitives/Checkbox.mjs +39 -0
- package/dist/primitives/Checkbox.mjs.map +1 -0
- package/dist/primitives/DataGrid.d.ts +100 -0
- package/dist/primitives/DataGrid.mjs +129 -0
- package/dist/primitives/DataGrid.mjs.map +1 -0
- package/dist/primitives/DatePicker.d.ts +66 -0
- package/dist/primitives/DatePicker.mjs +114 -0
- package/dist/primitives/DatePicker.mjs.map +1 -0
- package/dist/primitives/Dialog.d.ts +51 -0
- package/dist/primitives/Dialog.mjs +59 -0
- package/dist/primitives/Dialog.mjs.map +1 -0
- package/dist/primitives/Drawer.d.ts +57 -0
- package/dist/primitives/Drawer.mjs +72 -0
- package/dist/primitives/Drawer.mjs.map +1 -0
- package/dist/primitives/Form.d.ts +86 -0
- package/dist/primitives/Form.mjs +119 -0
- package/dist/primitives/Form.mjs.map +1 -0
- package/dist/primitives/Input.d.ts +50 -0
- package/dist/primitives/Input.mjs +49 -0
- package/dist/primitives/Input.mjs.map +1 -0
- package/dist/primitives/Pagination.d.ts +65 -0
- package/dist/primitives/Pagination.mjs +57 -0
- package/dist/primitives/Pagination.mjs.map +1 -0
- package/dist/primitives/Radio.d.ts +40 -0
- package/dist/primitives/Radio.mjs +54 -0
- package/dist/primitives/Radio.mjs.map +1 -0
- package/dist/primitives/Select.d.ts +58 -0
- package/dist/primitives/Select.mjs +118 -0
- package/dist/primitives/Select.mjs.map +1 -0
- package/dist/primitives/Spin.d.ts +15 -0
- package/dist/primitives/Spin.mjs +29 -0
- package/dist/primitives/Spin.mjs.map +1 -0
- package/dist/primitives/Tag.d.ts +25 -0
- package/dist/primitives/Tag.mjs +44 -0
- package/dist/primitives/Tag.mjs.map +1 -0
- package/dist/root-provider.d.ts +47 -0
- package/dist/root-provider.mjs +53 -0
- package/dist/root-provider.mjs.map +1 -0
- package/dist/style.css +246 -0
- package/dist/theme.d.ts +7 -0
- package/dist/theme.mjs +54 -0
- package/dist/theme.mjs.map +1 -0
- package/package.json +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 54356
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fbkworks/adapter-vant
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
FBK 业务组件库的 Vant 4 适配器(移动端)。DataGrid 没有对应的 Vant 组件,
|
|
4
|
+
因此渲染为卡片列表:`column.mobile.primary` 成为标题,其余字段按 `mobile.order` 排列,
|
|
5
|
+
分页走 `van-list` 触底加载。
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @fbkworks/components @fbkworks/adapter-vant
|
|
9
|
+
pnpm add -D vant
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 使用
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createBusinessKit } from '@fbkworks/adapter-core'
|
|
16
|
+
import { vantAdapter } from '@fbkworks/adapter-vant'
|
|
17
|
+
|
|
18
|
+
import '@fbkworks/tokens/css'
|
|
19
|
+
import '@fbkworks/adapter-vant/style.css'
|
|
20
|
+
import '@fbkworks/components/style.css'
|
|
21
|
+
import 'vant/lib/index.css'
|
|
22
|
+
|
|
23
|
+
createApp(App).use(createBusinessKit({ adapter: vantAdapter }))
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 适配要点
|
|
27
|
+
|
|
28
|
+
- `Select` = `van-field` 只读展示 + `van-popup` + `van-picker`(多选为 `van-checkbox-group`)
|
|
29
|
+
- `Form.validate()` 用 `@submit` / `@failed` 事件桥接成 `Promise<true>`
|
|
30
|
+
- `pagination.mode: 'infinite'`
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/dist/dark.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { showConfirmDialog, showSuccessToast, showFailToast, showToast } from "vant";
|
|
2
|
+
const show = (type, content, options) => {
|
|
3
|
+
const duration = options?.duration ?? 2e3;
|
|
4
|
+
if (type === "success") {
|
|
5
|
+
showSuccessToast({ message: content, duration });
|
|
6
|
+
} else if (type === "error") {
|
|
7
|
+
showFailToast({ message: content, duration });
|
|
8
|
+
} else {
|
|
9
|
+
showToast({ message: content, duration });
|
|
10
|
+
}
|
|
11
|
+
return () => {
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const message = ((type, content, options) => show(type, content, options));
|
|
15
|
+
message.success = (content, options) => show("success", content, options);
|
|
16
|
+
message.warning = (content, options) => show("warning", content, options);
|
|
17
|
+
message.error = (content, options) => show("error", content, options);
|
|
18
|
+
message.info = (content, options) => show("info", content, options);
|
|
19
|
+
const confirm = async (content, options = {}) => {
|
|
20
|
+
try {
|
|
21
|
+
await showConfirmDialog({
|
|
22
|
+
title: options.title ?? "提示",
|
|
23
|
+
message: content,
|
|
24
|
+
confirmButtonText: options.confirmText ?? "确定",
|
|
25
|
+
cancelButtonText: options.cancelText ?? "取消",
|
|
26
|
+
confirmButtonColor: options.danger ? "var(--fbk-color-danger)" : void 0
|
|
27
|
+
});
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const feedback = { message, confirm };
|
|
34
|
+
export {
|
|
35
|
+
feedback
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=feedback.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.mjs","sources":["../src/feedback.ts"],"sourcesContent":["import { showToast, showSuccessToast, showFailToast, showConfirmDialog } from 'vant'\nimport type { ConfirmOptions, FeedbackApi, MessageApi, MessageOptions, MessageType } from '@fbkworks/adapter-core'\n\n/**\n * vant 的命令式反馈(移动端)。\n *\n * vant 的 toast 只有 success / fail / loading 三种语义,\n * 没有 warning / info —— 映射到普通 toast 并在文案上不做额外加工,\n * 避免\"warning 显示成红色失败\"这种误导。\n */\nconst show = (type: MessageType, content: string, options?: MessageOptions) => {\n const duration = options?.duration ?? 2000\n if (type === 'success') {\n showSuccessToast({ message: content, duration })\n } else if (type === 'error') {\n showFailToast({ message: content, duration })\n } else {\n showToast({ message: content, duration })\n }\n // vant 的 toast 不支持手动关闭,返回空句柄保持契约一致\n return () => {}\n}\n\nconst message = ((type: MessageType, content: string, options?: MessageOptions) =>\n show(type, content, options)) as MessageApi\n\nmessage.success = (content, options) => show('success', content, options)\nmessage.warning = (content, options) => show('warning', content, options)\nmessage.error = (content, options) => show('error', content, options)\nmessage.info = (content, options) => show('info', content, options)\n\nconst confirm = async (content: string, options: ConfirmOptions = {}) => {\n try {\n await showConfirmDialog({\n title: options.title ?? '提示',\n message: content,\n confirmButtonText: options.confirmText ?? '确定',\n cancelButtonText: options.cancelText ?? '取消',\n confirmButtonColor: options.danger ? 'var(--fbk-color-danger)' : undefined,\n })\n return true\n } catch {\n // vant 在取消时 reject,契约要求 resolve(false)\n return false\n }\n}\n\nexport const feedback: FeedbackApi = { message, confirm }\n"],"names":[],"mappings":";AAUA,MAAM,OAAO,CAAC,MAAmB,SAAiB,YAA6B;AAC7E,QAAM,WAAW,SAAS,YAAY;AACtC,MAAI,SAAS,WAAW;AACtB,qBAAiB,EAAE,SAAS,SAAS,SAAA,CAAU;AAAA,EACjD,WAAW,SAAS,SAAS;AAC3B,kBAAc,EAAE,SAAS,SAAS,SAAA,CAAU;AAAA,EAC9C,OAAO;AACL,cAAU,EAAE,SAAS,SAAS,SAAA,CAAU;AAAA,EAC1C;AAEA,SAAO,MAAM;AAAA,EAAC;AAChB;AAEA,MAAM,WAAW,CAAC,MAAmB,SAAiB,YACpD,KAAK,MAAM,SAAS,OAAO;AAE7B,QAAQ,UAAU,CAAC,SAAS,YAAY,KAAK,WAAW,SAAS,OAAO;AACxE,QAAQ,UAAU,CAAC,SAAS,YAAY,KAAK,WAAW,SAAS,OAAO;AACxE,QAAQ,QAAQ,CAAC,SAAS,YAAY,KAAK,SAAS,SAAS,OAAO;AACpE,QAAQ,OAAO,CAAC,SAAS,YAAY,KAAK,QAAQ,SAAS,OAAO;AAElE,MAAM,UAAU,OAAO,SAAiB,UAA0B,OAAO;AACvE,MAAI;AACF,UAAM,kBAAkB;AAAA,MACtB,OAAO,QAAQ,SAAS;AAAA,MACxB,SAAS;AAAA,MACT,mBAAmB,QAAQ,eAAe;AAAA,MAC1C,kBAAkB,QAAQ,cAAc;AAAA,MACxC,oBAAoB,QAAQ,SAAS,4BAA4B;AAAA,IAAA,CAClE;AACD,WAAO;AAAA,EACT,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAEO,MAAM,WAAwB,EAAE,SAAS,QAAA;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Capabilities, UiAdapter } from '@fbkworks/adapter-core';
|
|
2
|
+
import { Button } from './primitives/Button.js';
|
|
3
|
+
import { Input } from './primitives/Input.js';
|
|
4
|
+
import { Select } from './primitives/Select.js';
|
|
5
|
+
import { Checkbox } from './primitives/Checkbox.js';
|
|
6
|
+
import { DatePicker } from './primitives/DatePicker.js';
|
|
7
|
+
import { Radio } from './primitives/Radio.js';
|
|
8
|
+
import { Form, FormItem } from './primitives/Form.js';
|
|
9
|
+
import { DataGrid } from './primitives/DataGrid.js';
|
|
10
|
+
import { Pagination } from './primitives/Pagination.js';
|
|
11
|
+
import { Dialog } from './primitives/Dialog.js';
|
|
12
|
+
import { Drawer } from './primitives/Drawer.js';
|
|
13
|
+
import { Tag } from './primitives/Tag.js';
|
|
14
|
+
import { Spin } from './primitives/Spin.js';
|
|
15
|
+
import { vantTheme } from './theme.js';
|
|
16
|
+
import { RootProvider } from './root-provider.js';
|
|
17
|
+
export declare const vantCapabilities: Capabilities;
|
|
18
|
+
export declare const vantAdapter: UiAdapter;
|
|
19
|
+
export { vantTheme, RootProvider };
|
|
20
|
+
export { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Spin };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Button } from "./primitives/Button.mjs";
|
|
2
|
+
import { Input } from "./primitives/Input.mjs";
|
|
3
|
+
import { Select } from "./primitives/Select.mjs";
|
|
4
|
+
import { Checkbox } from "./primitives/Checkbox.mjs";
|
|
5
|
+
import { DatePicker } from "./primitives/DatePicker.mjs";
|
|
6
|
+
import { Radio } from "./primitives/Radio.mjs";
|
|
7
|
+
import { feedback } from "./feedback.mjs";
|
|
8
|
+
import { FormItem, Form } from "./primitives/Form.mjs";
|
|
9
|
+
import { DataGrid } from "./primitives/DataGrid.mjs";
|
|
10
|
+
import { Pagination } from "./primitives/Pagination.mjs";
|
|
11
|
+
import { Dialog } from "./primitives/Dialog.mjs";
|
|
12
|
+
import { Drawer } from "./primitives/Drawer.mjs";
|
|
13
|
+
import { Tag } from "./primitives/Tag.mjs";
|
|
14
|
+
import { Spin } from "./primitives/Spin.mjs";
|
|
15
|
+
import { vantTheme } from "./theme.mjs";
|
|
16
|
+
import { RootProvider } from "./root-provider.mjs";
|
|
17
|
+
const vantCapabilities = {
|
|
18
|
+
dataGrid: {
|
|
19
|
+
presentation: "cards",
|
|
20
|
+
selection: true,
|
|
21
|
+
/* 卡片列表没有表头,全文也没有一处 emit('update:sort');
|
|
22
|
+
补齐移动端排序入口(下拉 / 筛选栏 / 顶栏菜单)需要产品方案,故声明为 none。 */
|
|
23
|
+
sort: "none",
|
|
24
|
+
expandable: false,
|
|
25
|
+
tree: false,
|
|
26
|
+
virtualScroll: false,
|
|
27
|
+
stickyHeader: false
|
|
28
|
+
},
|
|
29
|
+
form: {
|
|
30
|
+
layout: "vertical",
|
|
31
|
+
labelWidth: false,
|
|
32
|
+
validateOn: ["change", "blur", "submit"],
|
|
33
|
+
asyncValidator: true
|
|
34
|
+
},
|
|
35
|
+
// van-popup 的 position 就是抽屉:Drawer 原语已实现,能力声明必须跟上
|
|
36
|
+
overlay: { kind: "popup", supportsDrawer: true, supportsTeleport: true },
|
|
37
|
+
pagination: { mode: "infinite", pageSizes: false, jumper: false },
|
|
38
|
+
// 只有契约里真实存在的两个 API;notification / loading 没有对应实现,不声明
|
|
39
|
+
feedback: { message: true, notification: false, confirm: true, loading: false },
|
|
40
|
+
theme: { darkMode: true, cssVariables: true, provider: true },
|
|
41
|
+
features: { "table.fixedColumns": false, "table.summary": false, "form.inline": false }
|
|
42
|
+
};
|
|
43
|
+
const vantAdapter = {
|
|
44
|
+
meta: {
|
|
45
|
+
apiVersion: 3,
|
|
46
|
+
name: "vant",
|
|
47
|
+
version: "0.1.0",
|
|
48
|
+
uiLibrary: { name: "vant", version: "^4.9.0" },
|
|
49
|
+
platform: "mobile"
|
|
50
|
+
},
|
|
51
|
+
capabilities: vantCapabilities,
|
|
52
|
+
primitives: { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Spin },
|
|
53
|
+
feedback,
|
|
54
|
+
RootProvider,
|
|
55
|
+
theme: vantTheme
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
Button,
|
|
59
|
+
Checkbox,
|
|
60
|
+
DataGrid,
|
|
61
|
+
DatePicker,
|
|
62
|
+
Dialog,
|
|
63
|
+
Drawer,
|
|
64
|
+
Form,
|
|
65
|
+
FormItem,
|
|
66
|
+
Input,
|
|
67
|
+
Pagination,
|
|
68
|
+
Radio,
|
|
69
|
+
RootProvider,
|
|
70
|
+
Select,
|
|
71
|
+
Spin,
|
|
72
|
+
Tag,
|
|
73
|
+
vantAdapter,
|
|
74
|
+
vantCapabilities,
|
|
75
|
+
vantTheme
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { Capabilities, UiAdapter } from '@fbkworks/adapter-core'\nimport { Button } from './primitives/Button'\nimport { Input } from './primitives/Input'\nimport { Select } from './primitives/Select'\nimport { Checkbox } from './primitives/Checkbox'\nimport { DatePicker } from './primitives/DatePicker'\nimport { Radio } from './primitives/Radio'\nimport { feedback } from './feedback'\nimport { Form, FormItem } from './primitives/Form'\nimport { DataGrid } from './primitives/DataGrid'\nimport { Pagination } from './primitives/Pagination'\nimport { Dialog } from './primitives/Dialog'\nimport { Drawer } from './primitives/Drawer'\nimport { Tag } from './primitives/Tag'\nimport { Spin } from './primitives/Spin'\nimport { vantTheme } from './theme'\nimport { RootProvider } from './root-provider'\n\nexport const vantCapabilities: Capabilities = {\n dataGrid: {\n presentation: 'cards',\n selection: true,\n /* 卡片列表没有表头,全文也没有一处 emit('update:sort');\n 补齐移动端排序入口(下拉 / 筛选栏 / 顶栏菜单)需要产品方案,故声明为 none。 */\n sort: 'none',\n expandable: false,\n tree: false,\n virtualScroll: false,\n stickyHeader: false,\n },\n form: {\n layout: 'vertical',\n labelWidth: false,\n validateOn: ['change', 'blur', 'submit'],\n asyncValidator: true,\n },\n // van-popup 的 position 就是抽屉:Drawer 原语已实现,能力声明必须跟上\n overlay: { kind: 'popup', supportsDrawer: true, supportsTeleport: true },\n pagination: { mode: 'infinite', pageSizes: false, jumper: false },\n // 只有契约里真实存在的两个 API;notification / loading 没有对应实现,不声明\n feedback: { message: true, notification: false, confirm: true, loading: false },\n theme: { darkMode: true, cssVariables: true, provider: true },\n features: { 'table.fixedColumns': false, 'table.summary': false, 'form.inline': false },\n}\n\nexport const vantAdapter: UiAdapter = {\n meta: {\n apiVersion: 3,\n name: 'vant',\n version: '0.1.0',\n uiLibrary: { name: 'vant', version: '^4.9.0' },\n platform: 'mobile',\n },\n capabilities: vantCapabilities,\n primitives: { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Spin },\n feedback,\n RootProvider,\n theme: vantTheme,\n}\n\nexport { vantTheme, RootProvider }\nexport { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Spin }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAkBO,MAAM,mBAAiC;AAAA,EAC5C,UAAU;AAAA,IACR,cAAc;AAAA,IACd,WAAW;AAAA;AAAA;AAAA,IAGX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,eAAe;AAAA,IACf,cAAc;AAAA,EAAA;AAAA,EAEhB,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,YAAY,CAAC,UAAU,QAAQ,QAAQ;AAAA,IACvC,gBAAgB;AAAA,EAAA;AAAA;AAAA,EAGlB,SAAS,EAAE,MAAM,SAAS,gBAAgB,MAAM,kBAAkB,KAAA;AAAA,EAClE,YAAY,EAAE,MAAM,YAAY,WAAW,OAAO,QAAQ,MAAA;AAAA;AAAA,EAE1D,UAAU,EAAE,SAAS,MAAM,cAAc,OAAO,SAAS,MAAM,SAAS,MAAA;AAAA,EACxE,OAAO,EAAE,UAAU,MAAM,cAAc,MAAM,UAAU,KAAA;AAAA,EACvD,UAAU,EAAE,sBAAsB,OAAO,iBAAiB,OAAO,eAAe,MAAA;AAClF;AAEO,MAAM,cAAyB;AAAA,EACpC,MAAM;AAAA,IACJ,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,EAAE,MAAM,QAAQ,SAAS,SAAA;AAAA,IACpC,UAAU;AAAA,EAAA;AAAA,EAEZ,cAAc;AAAA,EACd,YAAY,EAAE,QAAQ,OAAO,QAAQ,UAAU,YAAY,OAAO,MAAM,UAAU,UAAU,YAAY,QAAQ,QAAQ,KAAK,KAAA;AAAA,EAC7H;AAAA,EACA;AAAA,EACA,OAAO;AACT;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { ButtonProps, Size, Status } from '@fbkworks/adapter-core';
|
|
3
|
+
export declare const Button: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
variant: {
|
|
5
|
+
type: PropType<ButtonProps["variant"]>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
status: {
|
|
9
|
+
type: PropType<Status>;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
type: PropType<Size>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
disabled: BooleanConstructor;
|
|
17
|
+
loading: BooleanConstructor;
|
|
18
|
+
block: BooleanConstructor;
|
|
19
|
+
nativeType: {
|
|
20
|
+
type: PropType<ButtonProps["nativeType"]>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "click"[], "click", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
24
|
+
variant: {
|
|
25
|
+
type: PropType<ButtonProps["variant"]>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
status: {
|
|
29
|
+
type: PropType<Status>;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
size: {
|
|
33
|
+
type: PropType<Size>;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
disabled: BooleanConstructor;
|
|
37
|
+
loading: BooleanConstructor;
|
|
38
|
+
block: BooleanConstructor;
|
|
39
|
+
nativeType: {
|
|
40
|
+
type: PropType<ButtonProps["nativeType"]>;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
}>> & Readonly<{
|
|
44
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
}>, {
|
|
46
|
+
size: Size;
|
|
47
|
+
variant: import('@fbkworks/adapter-core').ButtonVariant | undefined;
|
|
48
|
+
nativeType: "submit" | "button" | "reset" | undefined;
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
loading: boolean;
|
|
51
|
+
block: boolean;
|
|
52
|
+
status: Status;
|
|
53
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { Button as Button$1 } from "vant";
|
|
3
|
+
const statusType = {
|
|
4
|
+
primary: "primary",
|
|
5
|
+
success: "success",
|
|
6
|
+
warning: "warning",
|
|
7
|
+
danger: "danger",
|
|
8
|
+
info: "primary",
|
|
9
|
+
default: "default"
|
|
10
|
+
};
|
|
11
|
+
const Button = /* @__PURE__ */ defineComponent({
|
|
12
|
+
name: "FbkVantButton",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
variant: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "default"
|
|
18
|
+
},
|
|
19
|
+
status: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "md"
|
|
26
|
+
},
|
|
27
|
+
disabled: Boolean,
|
|
28
|
+
loading: Boolean,
|
|
29
|
+
block: Boolean,
|
|
30
|
+
nativeType: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "button"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
emits: ["click"],
|
|
36
|
+
setup(props, {
|
|
37
|
+
attrs,
|
|
38
|
+
emit,
|
|
39
|
+
slots
|
|
40
|
+
}) {
|
|
41
|
+
const type = computed(() => props.status ? statusType[props.status] : props.variant === "primary" ? "primary" : "default");
|
|
42
|
+
const size = computed(() => props.size === "sm" ? "small" : props.size === "lg" ? "large" : "normal");
|
|
43
|
+
return () => createVNode(Button$1, mergeProps(attrs, {
|
|
44
|
+
"type": type.value,
|
|
45
|
+
"size": size.value,
|
|
46
|
+
"disabled": props.disabled,
|
|
47
|
+
"loading": props.loading,
|
|
48
|
+
"block": props.block,
|
|
49
|
+
"nativeType": props.nativeType,
|
|
50
|
+
"plain": props.variant === "dashed",
|
|
51
|
+
"onClick": (event) => emit("click", event)
|
|
52
|
+
}), slots);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export {
|
|
56
|
+
Button
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=Button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../src/primitives/Button.tsx"],"sourcesContent":["import { computed, defineComponent, type PropType } from 'vue'\nimport { Button as VanButton } from 'vant'\nimport type { ButtonProps, Size, Status } from '@fbkworks/adapter-core'\n\nconst statusType = {\n primary: 'primary',\n success: 'success',\n warning: 'warning',\n danger: 'danger',\n info: 'primary',\n default: 'default',\n} as const\n\nexport const Button = defineComponent({\n name: 'FbkVantButton',\n inheritAttrs: false,\n props: {\n variant: { type: String as PropType<ButtonProps['variant']>, default: 'default' },\n status: { type: String as PropType<Status>, default: undefined },\n size: { type: String as PropType<Size>, default: 'md' },\n disabled: Boolean,\n loading: Boolean,\n block: Boolean,\n nativeType: { type: String as PropType<ButtonProps['nativeType']>, default: 'button' },\n },\n emits: ['click'],\n setup(props, { attrs, emit, slots }) {\n const type = computed(() => (props.status ? statusType[props.status] : props.variant === 'primary' ? 'primary' : 'default'))\n const size = computed(() => (props.size === 'sm' ? 'small' : props.size === 'lg' ? 'large' : 'normal'))\n return () => (\n <VanButton\n {...attrs}\n type={type.value}\n size={size.value}\n disabled={props.disabled}\n loading={props.loading}\n block={props.block}\n nativeType={props.nativeType}\n plain={props.variant === 'dashed'}\n onClick={(event: MouseEvent) => emit('click', event)}\n v-slots={slots}\n />\n )\n },\n})\n"],"names":["statusType","primary","success","warning","danger","info","default","Button","defineComponent","name","inheritAttrs","props","variant","type","String","status","undefined","size","disabled","Boolean","loading","block","nativeType","emits","setup","attrs","emit","slots","computed","_createVNode","VanButton","_mergeProps","value","event"],"mappings":";;AAIA,MAAMA,aAAa;AAAA,EACjBC,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,QAAQ;AAAA,EACRC,MAAM;AAAA,EACNC,SAAS;AACX;AAEO,MAAMC,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,SAAS;AAAA,MAAEC,MAAMC;AAAAA,MAA4CR,SAAS;AAAA;IACtES,QAAQ;AAAA,MAAEF,MAAMC;AAAAA,MAA4BR,SAASU;AAAAA;IACrDC,MAAM;AAAA,MAAEJ,MAAMC;AAAAA,MAA0BR,SAAS;AAAA;IACjDY,UAAUC;AAAAA,IACVC,SAASD;AAAAA,IACTE,OAAOF;AAAAA,IACPG,YAAY;AAAA,MAAET,MAAMC;AAAAA,MAA+CR,SAAS;AAAA,IAAS;AAAA;EAEvFiB,OAAO,CAAC,OAAO;AAAA,EACfC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,UAAMd,OAAOe,SAAS,MAAOjB,MAAMI,SAASf,WAAWW,MAAMI,MAAM,IAAIJ,MAAMC,YAAY,YAAY,YAAY,SAAU;AAC3H,UAAMK,OAAOW,SAAS,MAAOjB,MAAMM,SAAS,OAAO,UAAUN,MAAMM,SAAS,OAAO,UAAU,QAAS;AACtG,WAAO,MAAAY,YAAAC,UAAAC,WAECN,OAAK;AAAA,MAAA,QACHZ,KAAKmB;AAAAA,MAAK,QACVf,KAAKe;AAAAA,MAAK,YACNrB,MAAMO;AAAAA,MAAQ,WACfP,MAAMS;AAAAA,MAAO,SACfT,MAAMU;AAAAA,MAAK,cACNV,MAAMW;AAAAA,MAAU,SACrBX,MAAMC,YAAY;AAAA,MAAQ,WACvBqB,WAAsBP,KAAK,SAASO,KAAK;AAAA,IAAC,CAAA,GAC3CN,KAAK;AAAA,EAGpB;AACF,CAAC;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { Size } from '@fbkworks/adapter-core';
|
|
3
|
+
/**
|
|
4
|
+
* 布尔开关。
|
|
5
|
+
*
|
|
6
|
+
* vant 的 Checkbox 是 `modelValue` 双向的,但它的 label 位置固定在勾选框左侧,
|
|
7
|
+
* 而业务表单里开关文案通常在右侧 —— 这里用插槽显式包一层 <span>,
|
|
8
|
+
* 保证三个适配器下「勾选框在左、文字在右」的顺序一致。
|
|
9
|
+
*/
|
|
10
|
+
export declare const Checkbox: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
11
|
+
modelValue: BooleanConstructor;
|
|
12
|
+
label: StringConstructor;
|
|
13
|
+
disabled: BooleanConstructor;
|
|
14
|
+
size: {
|
|
15
|
+
type: PropType<Size>;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
+
modelValue: BooleanConstructor;
|
|
20
|
+
label: StringConstructor;
|
|
21
|
+
disabled: BooleanConstructor;
|
|
22
|
+
size: {
|
|
23
|
+
type: PropType<Size>;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
}>> & Readonly<{
|
|
27
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
28
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
size: Size;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
modelValue: boolean;
|
|
33
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { Checkbox as Checkbox$1 } from "vant";
|
|
3
|
+
const Checkbox = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "FbkVantCheckbox",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: Boolean,
|
|
8
|
+
label: String,
|
|
9
|
+
disabled: Boolean,
|
|
10
|
+
size: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "md"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
emits: ["update:modelValue", "change"],
|
|
16
|
+
setup(props, {
|
|
17
|
+
attrs,
|
|
18
|
+
emit,
|
|
19
|
+
slots
|
|
20
|
+
}) {
|
|
21
|
+
return () => createVNode(Checkbox$1, mergeProps(attrs, {
|
|
22
|
+
"modelValue": props.modelValue,
|
|
23
|
+
"disabled": props.disabled,
|
|
24
|
+
"iconSize": props.size === "sm" ? 16 : props.size === "lg" ? 22 : 18,
|
|
25
|
+
"onUpdate:modelValue": (value) => {
|
|
26
|
+
emit("update:modelValue", value);
|
|
27
|
+
emit("change", value);
|
|
28
|
+
}
|
|
29
|
+
}), {
|
|
30
|
+
default: () => slots.default?.() ?? (props.label ? createVNode("span", {
|
|
31
|
+
"class": "fbk-checkbox__label"
|
|
32
|
+
}, [props.label]) : null)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export {
|
|
37
|
+
Checkbox
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=Checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.mjs","sources":["../../src/primitives/Checkbox.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { Checkbox as VanCheckbox } from 'vant'\nimport type { Size } from '@fbkworks/adapter-core'\n\n/**\n * 布尔开关。\n *\n * vant 的 Checkbox 是 `modelValue` 双向的,但它的 label 位置固定在勾选框左侧,\n * 而业务表单里开关文案通常在右侧 —— 这里用插槽显式包一层 <span>,\n * 保证三个适配器下「勾选框在左、文字在右」的顺序一致。\n */\nexport const Checkbox = defineComponent({\n name: 'FbkVantCheckbox',\n inheritAttrs: false,\n props: {\n modelValue: Boolean,\n label: String,\n disabled: Boolean,\n size: { type: String as PropType<Size>, default: 'md' },\n },\n emits: ['update:modelValue', 'change'],\n setup(props, { attrs, emit, slots }) {\n return () => (\n <VanCheckbox\n {...attrs}\n modelValue={props.modelValue}\n disabled={props.disabled}\n iconSize={props.size === 'sm' ? 16 : props.size === 'lg' ? 22 : 18}\n onUpdate:modelValue={(value: boolean) => {\n emit('update:modelValue', value)\n emit('change', value)\n }}\n v-slots={{\n default: () =>\n slots.default?.() ?? (props.label ? <span class=\"fbk-checkbox__label\">{props.label}</span> : null),\n }}\n />\n )\n },\n})\n"],"names":["Checkbox","defineComponent","name","inheritAttrs","props","modelValue","Boolean","label","String","disabled","size","type","default","emits","setup","attrs","emit","slots","_createVNode","VanCheckbox","_mergeProps","value"],"mappings":";;AAWO,MAAMA,WAAWC,gCAAgB;AAAA,EACtCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAYC;AAAAA,IACZC,OAAOC;AAAAA,IACPC,UAAUH;AAAAA,IACVI,MAAM;AAAA,MAAEC,MAAMH;AAAAA,MAA0BI,SAAS;AAAA,IAAK;AAAA;EAExDC,OAAO,CAAC,qBAAqB,QAAQ;AAAA,EACrCC,MAAMV,OAAO;AAAA,IAAEW;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAAC,YAAAC,YAAAC,WAECL,OAAK;AAAA,MAAA,cACGX,MAAMC;AAAAA,MAAU,YAClBD,MAAMK;AAAAA,MAAQ,YACdL,MAAMM,SAAS,OAAO,KAAKN,MAAMM,SAAS,OAAO,KAAK;AAAA,MAAE,uBAC5CW,WAAmB;AACvCL,aAAK,qBAAqBK,KAAK;AAC/BL,aAAK,UAAUK,KAAK;AAAA,MACtB;AAAA,KAAC,GACQ;AAAA,MACPT,SAASA,MACPK,MAAML,UAAO,MAASR,MAAMG,QAAKW,YAAA,QAAA;AAAA,QAAA,SAAA;AAAA,MAAA,GAAA,CAAsCd,MAAMG,KAAK,CAAA,IAAW;AAAA,IACjG,CAAC;AAAA,EAGP;AACF,CAAC;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { DataGridColumn, DataGridProps, SortState } from '@fbkworks/adapter-core';
|
|
3
|
+
/**
|
|
4
|
+
* vant 没有 Table。这里把同一份列描述渲染成卡片列表:
|
|
5
|
+
* - column.mobile.primary 决定卡片主标题
|
|
6
|
+
* - 其余列按 column.mobile.order 排列成 dt/dd
|
|
7
|
+
* - column.mobile.hidden 的列不渲染
|
|
8
|
+
* - loadMore 时接 van-list 触发 load-more
|
|
9
|
+
*/
|
|
10
|
+
export declare const DataGrid: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
11
|
+
columns: {
|
|
12
|
+
type: PropType<DataGridColumn<any>[]>;
|
|
13
|
+
default: () => never[];
|
|
14
|
+
};
|
|
15
|
+
data: {
|
|
16
|
+
type: PropType<any[]>;
|
|
17
|
+
default: () => never[];
|
|
18
|
+
};
|
|
19
|
+
rowKey: {
|
|
20
|
+
type: PropType<DataGridProps["rowKey"]>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
loading: BooleanConstructor;
|
|
24
|
+
presentation: {
|
|
25
|
+
type: PropType<DataGridProps["presentation"]>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
selectionEnabled: BooleanConstructor;
|
|
29
|
+
selectionWidth: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
selectedKeys: {
|
|
34
|
+
type: PropType<Array<string | number>>;
|
|
35
|
+
default: () => never[];
|
|
36
|
+
};
|
|
37
|
+
sort: {
|
|
38
|
+
type: PropType<SortState | null>;
|
|
39
|
+
default: null;
|
|
40
|
+
};
|
|
41
|
+
emptyText: StringConstructor;
|
|
42
|
+
rowClickable: BooleanConstructor;
|
|
43
|
+
loadMore: BooleanConstructor;
|
|
44
|
+
finished: BooleanConstructor;
|
|
45
|
+
size: StringConstructor;
|
|
46
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("update:selectedKeys" | "update:sort" | "row-click" | "load-more")[], "update:selectedKeys" | "update:sort" | "row-click" | "load-more", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
47
|
+
columns: {
|
|
48
|
+
type: PropType<DataGridColumn<any>[]>;
|
|
49
|
+
default: () => never[];
|
|
50
|
+
};
|
|
51
|
+
data: {
|
|
52
|
+
type: PropType<any[]>;
|
|
53
|
+
default: () => never[];
|
|
54
|
+
};
|
|
55
|
+
rowKey: {
|
|
56
|
+
type: PropType<DataGridProps["rowKey"]>;
|
|
57
|
+
default: string;
|
|
58
|
+
};
|
|
59
|
+
loading: BooleanConstructor;
|
|
60
|
+
presentation: {
|
|
61
|
+
type: PropType<DataGridProps["presentation"]>;
|
|
62
|
+
default: string;
|
|
63
|
+
};
|
|
64
|
+
selectionEnabled: BooleanConstructor;
|
|
65
|
+
selectionWidth: {
|
|
66
|
+
type: NumberConstructor;
|
|
67
|
+
default: number;
|
|
68
|
+
};
|
|
69
|
+
selectedKeys: {
|
|
70
|
+
type: PropType<Array<string | number>>;
|
|
71
|
+
default: () => never[];
|
|
72
|
+
};
|
|
73
|
+
sort: {
|
|
74
|
+
type: PropType<SortState | null>;
|
|
75
|
+
default: null;
|
|
76
|
+
};
|
|
77
|
+
emptyText: StringConstructor;
|
|
78
|
+
rowClickable: BooleanConstructor;
|
|
79
|
+
loadMore: BooleanConstructor;
|
|
80
|
+
finished: BooleanConstructor;
|
|
81
|
+
size: StringConstructor;
|
|
82
|
+
}>> & Readonly<{
|
|
83
|
+
"onUpdate:selectedKeys"?: ((...args: any[]) => any) | undefined;
|
|
84
|
+
"onUpdate:sort"?: ((...args: any[]) => any) | undefined;
|
|
85
|
+
"onRow-click"?: ((...args: any[]) => any) | undefined;
|
|
86
|
+
"onLoad-more"?: ((...args: any[]) => any) | undefined;
|
|
87
|
+
}>, {
|
|
88
|
+
sort: SortState | null;
|
|
89
|
+
data: any[];
|
|
90
|
+
loading: boolean;
|
|
91
|
+
columns: DataGridColumn<any>[];
|
|
92
|
+
rowKey: string | ((row: any) => string | number) | undefined;
|
|
93
|
+
presentation: import('@fbkworks/adapter-core').DataGridPresentation | undefined;
|
|
94
|
+
selectionEnabled: boolean;
|
|
95
|
+
rowClickable: boolean;
|
|
96
|
+
loadMore: boolean;
|
|
97
|
+
finished: boolean;
|
|
98
|
+
selectionWidth: number;
|
|
99
|
+
selectedKeys: (string | number)[];
|
|
100
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps, createTextVNode } from "vue";
|
|
2
|
+
import { Empty, Checkbox, List, Loading } from "vant";
|
|
3
|
+
import { renderCell } from "@fbkworks/adapter-core";
|
|
4
|
+
import { getRowKey } from "@fbkworks/shared";
|
|
5
|
+
const DataGrid = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "FbkVantDataGrid",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
columns: {
|
|
10
|
+
type: Array,
|
|
11
|
+
default: () => []
|
|
12
|
+
},
|
|
13
|
+
data: {
|
|
14
|
+
type: Array,
|
|
15
|
+
default: () => []
|
|
16
|
+
},
|
|
17
|
+
rowKey: {
|
|
18
|
+
type: [String, Function],
|
|
19
|
+
default: "id"
|
|
20
|
+
},
|
|
21
|
+
loading: Boolean,
|
|
22
|
+
presentation: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "auto"
|
|
25
|
+
},
|
|
26
|
+
selectionEnabled: Boolean,
|
|
27
|
+
selectionWidth: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 48
|
|
30
|
+
},
|
|
31
|
+
selectedKeys: {
|
|
32
|
+
type: Array,
|
|
33
|
+
default: () => []
|
|
34
|
+
},
|
|
35
|
+
sort: {
|
|
36
|
+
type: Object,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
39
|
+
emptyText: String,
|
|
40
|
+
rowClickable: Boolean,
|
|
41
|
+
loadMore: Boolean,
|
|
42
|
+
finished: Boolean,
|
|
43
|
+
size: String
|
|
44
|
+
},
|
|
45
|
+
emits: ["update:selectedKeys", "update:sort", "row-click", "load-more"],
|
|
46
|
+
setup(props, {
|
|
47
|
+
attrs,
|
|
48
|
+
emit,
|
|
49
|
+
slots
|
|
50
|
+
}) {
|
|
51
|
+
const keyOf = (row, index) => getRowKey(row, index, props.rowKey);
|
|
52
|
+
const visibleColumns = computed(() => props.columns.filter((column) => !column.mobile?.hidden));
|
|
53
|
+
const primaryColumn = computed(() => visibleColumns.value.find((column) => column.mobile?.primary) ?? visibleColumns.value[0]);
|
|
54
|
+
const restColumns = computed(() => visibleColumns.value.filter((column) => column !== primaryColumn.value).sort((a, b) => (a.mobile?.order ?? 99) - (b.mobile?.order ?? 99)));
|
|
55
|
+
const toggle = (row, index, checked) => {
|
|
56
|
+
const key = keyOf(row, index);
|
|
57
|
+
const next = new Set(props.selectedKeys);
|
|
58
|
+
if (checked) next.add(key);
|
|
59
|
+
else next.delete(key);
|
|
60
|
+
emit("update:selectedKeys", [...next]);
|
|
61
|
+
};
|
|
62
|
+
return () => createVNode("div", mergeProps({
|
|
63
|
+
"class": "fbk-vant-grid",
|
|
64
|
+
"data-fbk-part": "data-grid"
|
|
65
|
+
}, attrs), [props.data.length === 0 && !props.loading ? createVNode(Empty, {
|
|
66
|
+
"description": props.emptyText ?? "暂无数据"
|
|
67
|
+
}, null) : null, props.data.map((row, index) => {
|
|
68
|
+
const key = keyOf(row, index);
|
|
69
|
+
return createVNode("div", {
|
|
70
|
+
"key": String(key),
|
|
71
|
+
"class": "fbk-vant-grid__card",
|
|
72
|
+
"data-fbk-part": "grid-row",
|
|
73
|
+
"data-row-key": String(key),
|
|
74
|
+
"tabindex": props.rowClickable ? 0 : void 0,
|
|
75
|
+
"onClick": (event) => props.rowClickable && emit("row-click", row, index, event),
|
|
76
|
+
"onKeydown": (event) => {
|
|
77
|
+
if (!props.rowClickable) return;
|
|
78
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
emit("row-click", row, index, event);
|
|
81
|
+
}
|
|
82
|
+
}, [props.selectionEnabled ? createVNode(Checkbox, {
|
|
83
|
+
"class": "fbk-vant-grid__check",
|
|
84
|
+
"iconSize": Math.min(Math.max(props.selectionWidth - 28, 16), 28),
|
|
85
|
+
"modelValue": props.selectedKeys.includes(key),
|
|
86
|
+
"onClick": (event) => event.stopPropagation(),
|
|
87
|
+
"onUpdate:modelValue": (checked) => toggle(row, index, checked)
|
|
88
|
+
}, null) : null, primaryColumn.value ? createVNode("div", {
|
|
89
|
+
"class": "fbk-vant-grid__title"
|
|
90
|
+
}, [slots[`cell-${primaryColumn.value.key}`]?.({
|
|
91
|
+
row,
|
|
92
|
+
index,
|
|
93
|
+
value: renderCell(primaryColumn.value, row, index)
|
|
94
|
+
}) ?? renderCell(primaryColumn.value, row, index)]) : null, createVNode("dl", {
|
|
95
|
+
"class": "fbk-vant-grid__fields"
|
|
96
|
+
}, [restColumns.value.map((column) => (
|
|
97
|
+
/* data-numeric 供样式给等宽数字 —— 卡片里没有 <td>,
|
|
98
|
+
用属性选择器比再发明一个类名省事。 */
|
|
99
|
+
createVNode("div", {
|
|
100
|
+
"class": "fbk-vant-grid__field",
|
|
101
|
+
"key": column.key,
|
|
102
|
+
"data-numeric": column.numeric || void 0
|
|
103
|
+
}, [createVNode("dt", null, [column.mobile?.label ?? column.title]), createVNode("dd", null, [slots[`cell-${column.key}`]?.({
|
|
104
|
+
row,
|
|
105
|
+
index,
|
|
106
|
+
value: renderCell(column, row, index)
|
|
107
|
+
}) ?? renderCell(column, row, index)])])
|
|
108
|
+
))]), slots["card-footer"]?.({
|
|
109
|
+
row,
|
|
110
|
+
index
|
|
111
|
+
})]);
|
|
112
|
+
}), props.loadMore ? createVNode(List, {
|
|
113
|
+
"loading": props.loading,
|
|
114
|
+
"finished": props.finished,
|
|
115
|
+
"finishedText": "没有更多了",
|
|
116
|
+
"onLoad": () => emit("load-more")
|
|
117
|
+
}, null) : null, props.loading && !props.loadMore ? createVNode("div", {
|
|
118
|
+
"class": "fbk-vant-grid__loading"
|
|
119
|
+
}, [createVNode(Loading, {
|
|
120
|
+
"size": "20"
|
|
121
|
+
}, {
|
|
122
|
+
default: () => [createTextVNode("加载中...")]
|
|
123
|
+
})]) : null]);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
export {
|
|
127
|
+
DataGrid
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=DataGrid.mjs.map
|