@fbkworks/adapter-element-plus 0.0.0-stage → 0.2.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 +35 -2
- package/dist/dark.css +1 -0
- package/dist/feedback.d.ts +2 -0
- package/dist/feedback.mjs +34 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.mjs +76 -0
- package/dist/index.mjs.map +1 -0
- package/dist/primitives/Button.d.ts +53 -0
- package/dist/primitives/Button.mjs +74 -0
- package/dist/primitives/Button.mjs.map +1 -0
- package/dist/primitives/Checkbox.d.ts +32 -0
- package/dist/primitives/Checkbox.mjs +40 -0
- package/dist/primitives/Checkbox.mjs.map +1 -0
- package/dist/primitives/DataGrid.d.ts +93 -0
- package/dist/primitives/DataGrid.mjs +107 -0
- package/dist/primitives/DataGrid.mjs.map +1 -0
- package/dist/primitives/DatePicker.d.ts +66 -0
- package/dist/primitives/DatePicker.mjs +69 -0
- package/dist/primitives/DatePicker.mjs.map +1 -0
- package/dist/primitives/Dialog.d.ts +58 -0
- package/dist/primitives/Dialog.mjs +60 -0
- package/dist/primitives/Dialog.mjs.map +1 -0
- package/dist/primitives/Drawer.d.ts +61 -0
- package/dist/primitives/Drawer.mjs +57 -0
- package/dist/primitives/Drawer.mjs.map +1 -0
- package/dist/primitives/Empty.d.ts +13 -0
- package/dist/primitives/Empty.mjs +26 -0
- package/dist/primitives/Empty.mjs.map +1 -0
- package/dist/primitives/Form.d.ts +95 -0
- package/dist/primitives/Form.mjs +127 -0
- package/dist/primitives/Form.mjs.map +1 -0
- package/dist/primitives/Input.d.ts +57 -0
- package/dist/primitives/Input.mjs +55 -0
- package/dist/primitives/Input.mjs.map +1 -0
- package/dist/primitives/Pagination.d.ts +63 -0
- package/dist/primitives/Pagination.mjs +56 -0
- package/dist/primitives/Pagination.mjs.map +1 -0
- package/dist/primitives/Radio.d.ts +40 -0
- package/dist/primitives/Radio.mjs +56 -0
- package/dist/primitives/Radio.mjs.map +1 -0
- package/dist/primitives/Select.d.ts +61 -0
- package/dist/primitives/Select.mjs +66 -0
- package/dist/primitives/Select.mjs.map +1 -0
- package/dist/primitives/Spin.d.ts +21 -0
- package/dist/primitives/Spin.mjs +32 -0
- package/dist/primitives/Spin.mjs.map +1 -0
- package/dist/primitives/Tag.d.ts +32 -0
- package/dist/primitives/Tag.mjs +48 -0
- package/dist/primitives/Tag.mjs.map +1 -0
- package/dist/root-provider.d.ts +50 -0
- package/dist/root-provider.mjs +45 -0
- package/dist/root-provider.mjs.map +1 -0
- package/dist/size.d.ts +2 -0
- package/dist/size.mjs +9 -0
- package/dist/size.mjs.map +1 -0
- package/dist/style.css +326 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.mjs +77 -0
- package/dist/theme.mjs.map +1 -0
- package/package.json +56 -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,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fbkworks/adapter-element-plus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
FBK 业务组件库的 Element Plus 适配器(桌面端,DataGrid 渲染为表格)。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add @fbkworks/components @fbkworks/adapter-element-plus
|
|
7
|
+
pnpm add -D element-plus
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## 使用
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { createBusinessKit } from '@fbkworks/adapter-core'
|
|
14
|
+
import { elementPlusAdapter } from '@fbkworks/adapter-element-plus'
|
|
15
|
+
|
|
16
|
+
import '@fbkworks/tokens/css'
|
|
17
|
+
import '@fbkworks/adapter-element-plus/style.css'
|
|
18
|
+
import '@fbkworks/components/style.css'
|
|
19
|
+
import 'element-plus/dist/index.css'
|
|
20
|
+
|
|
21
|
+
createApp(App).use(createBusinessKit({ adapter: elementPlusAdapter }))
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
暗色模式额外引入:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import '@fbkworks/adapter-element-plus/dark.css'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 能力
|
|
31
|
+
|
|
32
|
+
`dataGrid.presentation: 'table'`、`pagination.mode: 'pages'`、`theme.cssVariables: true`。
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
package/dist/dark.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'element-plus/theme-chalk/dark/css-vars.css';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ElMessageBox, ElMessage } from "element-plus";
|
|
2
|
+
const show = (type, content, options) => {
|
|
3
|
+
const instance = ElMessage({
|
|
4
|
+
type: type === "error" ? "error" : type,
|
|
5
|
+
message: content,
|
|
6
|
+
duration: options?.duration ?? 3e3,
|
|
7
|
+
showClose: options?.closable ?? false
|
|
8
|
+
});
|
|
9
|
+
return () => instance.close();
|
|
10
|
+
};
|
|
11
|
+
const message = ((type, content, options) => show(type, content, options));
|
|
12
|
+
message.success = (content, options) => show("success", content, options);
|
|
13
|
+
message.warning = (content, options) => show("warning", content, options);
|
|
14
|
+
message.error = (content, options) => show("error", content, options);
|
|
15
|
+
message.info = (content, options) => show("info", content, options);
|
|
16
|
+
const confirm = async (content, options = {}) => {
|
|
17
|
+
try {
|
|
18
|
+
await ElMessageBox.confirm(content, options.title ?? "提示", {
|
|
19
|
+
confirmButtonText: options.confirmText ?? "确定",
|
|
20
|
+
cancelButtonText: options.cancelText ?? "取消",
|
|
21
|
+
type: options.danger ? "warning" : options.type ?? "warning",
|
|
22
|
+
// 危险操作给确认按钮上危险色
|
|
23
|
+
confirmButtonClass: options.danger ? "el-button--danger" : void 0
|
|
24
|
+
});
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const feedback = { message, confirm };
|
|
31
|
+
export {
|
|
32
|
+
feedback
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=feedback.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.mjs","sources":["../src/feedback.ts"],"sourcesContent":["import { ElMessage, ElMessageBox } from 'element-plus'\nimport type { ConfirmOptions, FeedbackApi, MessageApi, MessageOptions, MessageType } from '@fbkworks/adapter-core'\n\n/**\n * element-plus 的命令式反馈。\n *\n * 注意 `confirm` 在用户取消时是 **reject**(ElMessageBox 的既有行为),\n * 而契约要求 resolve(false) —— 不转的话业务侧每处都要写 try/catch。\n */\nconst show = (type: MessageType, content: string, options?: MessageOptions) => {\n const instance = ElMessage({\n type: type === 'error' ? 'error' : type,\n message: content,\n duration: options?.duration ?? 3000,\n showClose: options?.closable ?? false,\n })\n return () => instance.close()\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 ElMessageBox.confirm(content, options.title ?? '提示', {\n confirmButtonText: options.confirmText ?? '确定',\n cancelButtonText: options.cancelText ?? '取消',\n type: options.danger ? 'warning' : (options.type ?? 'warning'),\n // 危险操作给确认按钮上危险色\n confirmButtonClass: options.danger ? 'el-button--danger' : undefined,\n })\n return true\n } catch {\n // 「用户取消」不是错误,契约要求 resolve(false)\n return false\n }\n}\n\nexport const feedback: FeedbackApi = { message, confirm }\n"],"names":[],"mappings":";AASA,MAAM,OAAO,CAAC,MAAmB,SAAiB,YAA6B;AAC7E,QAAM,WAAW,UAAU;AAAA,IACzB,MAAM,SAAS,UAAU,UAAU;AAAA,IACnC,SAAS;AAAA,IACT,UAAU,SAAS,YAAY;AAAA,IAC/B,WAAW,SAAS,YAAY;AAAA,EAAA,CACjC;AACD,SAAO,MAAM,SAAS,MAAA;AACxB;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,aAAa,QAAQ,SAAS,QAAQ,SAAS,MAAM;AAAA,MACzD,mBAAmB,QAAQ,eAAe;AAAA,MAC1C,kBAAkB,QAAQ,cAAc;AAAA,MACxC,MAAM,QAAQ,SAAS,YAAa,QAAQ,QAAQ;AAAA;AAAA,MAEpD,oBAAoB,QAAQ,SAAS,sBAAsB;AAAA,IAAA,CAC5D;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,21 @@
|
|
|
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 { Empty } from './primitives/Empty.js';
|
|
15
|
+
import { Spin } from './primitives/Spin.js';
|
|
16
|
+
import { elementTheme } from './theme.js';
|
|
17
|
+
import { RootProvider } from './root-provider.js';
|
|
18
|
+
export declare const elementPlusCapabilities: Capabilities;
|
|
19
|
+
export declare const elementPlusAdapter: UiAdapter;
|
|
20
|
+
export { elementTheme, RootProvider };
|
|
21
|
+
export { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Empty, Spin };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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 { Empty } from "./primitives/Empty.mjs";
|
|
15
|
+
import { Spin } from "./primitives/Spin.mjs";
|
|
16
|
+
import { elementTheme } from "./theme.mjs";
|
|
17
|
+
import { RootProvider } from "./root-provider.mjs";
|
|
18
|
+
const elementPlusCapabilities = {
|
|
19
|
+
dataGrid: {
|
|
20
|
+
presentation: "table",
|
|
21
|
+
selection: true,
|
|
22
|
+
sort: "custom",
|
|
23
|
+
expandable: true,
|
|
24
|
+
tree: true,
|
|
25
|
+
virtualScroll: false,
|
|
26
|
+
stickyHeader: true
|
|
27
|
+
},
|
|
28
|
+
form: {
|
|
29
|
+
layout: "horizontal",
|
|
30
|
+
labelWidth: true,
|
|
31
|
+
validateOn: ["change", "blur", "submit"],
|
|
32
|
+
asyncValidator: true
|
|
33
|
+
},
|
|
34
|
+
overlay: { kind: "dialog", supportsDrawer: true, supportsTeleport: true },
|
|
35
|
+
pagination: { mode: "pages", pageSizes: true, jumper: true },
|
|
36
|
+
// 只有契约里真实存在的两个 API;notification / loading 没有对应实现,不声明
|
|
37
|
+
feedback: { message: true, notification: false, confirm: true, loading: false },
|
|
38
|
+
theme: { darkMode: true, cssVariables: true, provider: false },
|
|
39
|
+
features: { "table.fixedColumns": true, "table.summary": true, "form.inline": true }
|
|
40
|
+
};
|
|
41
|
+
const elementPlusAdapter = {
|
|
42
|
+
meta: {
|
|
43
|
+
apiVersion: 3,
|
|
44
|
+
name: "element-plus",
|
|
45
|
+
version: "0.1.0",
|
|
46
|
+
uiLibrary: { name: "element-plus", version: "^2.8.0" },
|
|
47
|
+
platform: "desktop"
|
|
48
|
+
},
|
|
49
|
+
capabilities: elementPlusCapabilities,
|
|
50
|
+
primitives: { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Empty, Spin },
|
|
51
|
+
feedback,
|
|
52
|
+
RootProvider,
|
|
53
|
+
theme: elementTheme
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
Button,
|
|
57
|
+
Checkbox,
|
|
58
|
+
DataGrid,
|
|
59
|
+
DatePicker,
|
|
60
|
+
Dialog,
|
|
61
|
+
Drawer,
|
|
62
|
+
Empty,
|
|
63
|
+
Form,
|
|
64
|
+
FormItem,
|
|
65
|
+
Input,
|
|
66
|
+
Pagination,
|
|
67
|
+
Radio,
|
|
68
|
+
RootProvider,
|
|
69
|
+
Select,
|
|
70
|
+
Spin,
|
|
71
|
+
Tag,
|
|
72
|
+
elementPlusAdapter,
|
|
73
|
+
elementPlusCapabilities,
|
|
74
|
+
elementTheme
|
|
75
|
+
};
|
|
76
|
+
//# 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 { Empty } from './primitives/Empty'\nimport { Spin } from './primitives/Spin'\nimport { elementTheme } from './theme'\nimport { RootProvider } from './root-provider'\n\nexport const elementPlusCapabilities: Capabilities = {\n dataGrid: {\n presentation: 'table',\n selection: true,\n sort: 'custom',\n expandable: true,\n tree: true,\n virtualScroll: false,\n stickyHeader: true,\n },\n form: {\n layout: 'horizontal',\n labelWidth: true,\n validateOn: ['change', 'blur', 'submit'],\n asyncValidator: true,\n },\n overlay: { kind: 'dialog', supportsDrawer: true, supportsTeleport: true },\n pagination: { mode: 'pages', pageSizes: true, jumper: true },\n // 只有契约里真实存在的两个 API;notification / loading 没有对应实现,不声明\n feedback: { message: true, notification: false, confirm: true, loading: false },\n theme: { darkMode: true, cssVariables: true, provider: false },\n features: { 'table.fixedColumns': true, 'table.summary': true, 'form.inline': true },\n}\n\nexport const elementPlusAdapter: UiAdapter = {\n meta: {\n apiVersion: 3,\n name: 'element-plus',\n version: '0.1.0',\n uiLibrary: { name: 'element-plus', version: '^2.8.0' },\n platform: 'desktop',\n },\n capabilities: elementPlusCapabilities,\n primitives: { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Empty, Spin },\n feedback,\n RootProvider,\n theme: elementTheme,\n}\n\nexport { elementTheme, RootProvider }\nexport { Button, Input, Select, Checkbox, DatePicker, Radio, Form, FormItem, DataGrid, Pagination, Dialog, Drawer, Tag, Empty, Spin }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,0BAAwC;AAAA,EACnD,UAAU;AAAA,IACR,cAAc;AAAA,IACd,WAAW;AAAA,IACX,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,EAElB,SAAS,EAAE,MAAM,UAAU,gBAAgB,MAAM,kBAAkB,KAAA;AAAA,EACnE,YAAY,EAAE,MAAM,SAAS,WAAW,MAAM,QAAQ,KAAA;AAAA;AAAA,EAEtD,UAAU,EAAE,SAAS,MAAM,cAAc,OAAO,SAAS,MAAM,SAAS,MAAA;AAAA,EACxE,OAAO,EAAE,UAAU,MAAM,cAAc,MAAM,UAAU,MAAA;AAAA,EACvD,UAAU,EAAE,sBAAsB,MAAM,iBAAiB,MAAM,eAAe,KAAA;AAChF;AAEO,MAAM,qBAAgC;AAAA,EAC3C,MAAM;AAAA,IACJ,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,EAAE,MAAM,gBAAgB,SAAS,SAAA;AAAA,IAC5C,UAAU;AAAA,EAAA;AAAA,EAEZ,cAAc;AAAA,EACd,YAAY,EAAE,QAAQ,OAAO,QAAQ,UAAU,YAAY,OAAO,MAAM,UAAU,UAAU,YAAY,QAAQ,QAAQ,KAAK,OAAO,KAAA;AAAA,EACpI;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,74 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElButton } from "element-plus";
|
|
3
|
+
import { toElementSize } from "../size.mjs";
|
|
4
|
+
const variantType = {
|
|
5
|
+
primary: "primary",
|
|
6
|
+
default: "",
|
|
7
|
+
dashed: "primary",
|
|
8
|
+
text: "primary",
|
|
9
|
+
link: "primary"
|
|
10
|
+
};
|
|
11
|
+
const statusType = {
|
|
12
|
+
primary: "primary",
|
|
13
|
+
success: "success",
|
|
14
|
+
warning: "warning",
|
|
15
|
+
danger: "danger",
|
|
16
|
+
info: "info",
|
|
17
|
+
default: ""
|
|
18
|
+
};
|
|
19
|
+
const Button = /* @__PURE__ */ defineComponent({
|
|
20
|
+
name: "FbkElButton",
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
props: {
|
|
23
|
+
variant: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "default"
|
|
26
|
+
},
|
|
27
|
+
status: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "md"
|
|
34
|
+
},
|
|
35
|
+
disabled: Boolean,
|
|
36
|
+
loading: Boolean,
|
|
37
|
+
block: Boolean,
|
|
38
|
+
nativeType: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "button"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
emits: ["click"],
|
|
44
|
+
setup(props, {
|
|
45
|
+
attrs,
|
|
46
|
+
emit,
|
|
47
|
+
slots
|
|
48
|
+
}) {
|
|
49
|
+
const type = computed(() => props.status ? statusType[props.status] : variantType[props.variant ?? "default"]);
|
|
50
|
+
const plain = computed(() => props.variant === "dashed");
|
|
51
|
+
const text = computed(() => props.variant === "text");
|
|
52
|
+
const link = computed(() => props.variant === "link");
|
|
53
|
+
return () => createVNode(ElButton, mergeProps(attrs, {
|
|
54
|
+
"class": [text.value || link.value ? "fbk-button--text" : null, attrs.class],
|
|
55
|
+
"type": type.value,
|
|
56
|
+
"size": toElementSize(props.size),
|
|
57
|
+
"disabled": props.disabled,
|
|
58
|
+
"loading": props.loading,
|
|
59
|
+
"plain": plain.value,
|
|
60
|
+
"text": text.value,
|
|
61
|
+
"link": link.value,
|
|
62
|
+
"nativeType": props.nativeType,
|
|
63
|
+
"style": props.block ? {
|
|
64
|
+
width: "100%",
|
|
65
|
+
...attrs.style ?? {}
|
|
66
|
+
} : attrs.style,
|
|
67
|
+
"onClick": (event) => emit("click", event)
|
|
68
|
+
}), slots);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
Button
|
|
73
|
+
};
|
|
74
|
+
//# 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 { ElButton } from 'element-plus'\nimport type { ButtonProps, Size, Status } from '@fbkworks/adapter-core'\nimport { toElementSize } from '../size'\n\nconst variantType: Record<string, 'primary' | 'success' | 'warning' | 'danger' | 'info' | ''> = {\n primary: 'primary',\n default: '',\n dashed: 'primary',\n text: 'primary',\n link: 'primary',\n}\n\nconst statusType = {\n primary: 'primary',\n success: 'success',\n warning: 'warning',\n danger: 'danger',\n info: 'info',\n default: '',\n} as const\n\nexport const Button = defineComponent({\n name: 'FbkElButton',\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] : variantType[props.variant ?? 'default']))\n const plain = computed(() => props.variant === 'dashed')\n const text = computed(() => props.variant === 'text')\n const link = computed(() => props.variant === 'link')\n\n return () => (\n <ElButton\n {...attrs}\n /* 与 naive 适配器对齐的标记类。\n naive 的 text 模式不输出任何类名,样式层只能靠这个标记补控件高度;\n element-plus 本来会输出 .el-button--text,但如果只有一侧有标记类,\n style.css 里针对 .fbk-button--text 的规则就只在一个适配器生效 ——\n 两边按钮高度会分叉。所以两个适配器都必须打同一个标记。 */\n class={[text.value || link.value ? 'fbk-button--text' : null, attrs.class]}\n type={type.value}\n size={toElementSize(props.size)}\n disabled={props.disabled}\n loading={props.loading}\n plain={plain.value}\n text={text.value}\n link={link.value}\n nativeType={props.nativeType}\n style={props.block ? { width: '100%', ...((attrs.style as object) ?? {}) } : attrs.style}\n onClick={(event: MouseEvent) => emit('click', event)}\n v-slots={slots}\n />\n )\n },\n})\n"],"names":["variantType","primary","default","dashed","text","link","statusType","success","warning","danger","info","Button","defineComponent","name","inheritAttrs","props","variant","type","String","status","undefined","size","disabled","Boolean","loading","block","nativeType","emits","setup","attrs","emit","slots","computed","plain","_createVNode","ElButton","_mergeProps","value","class","toElementSize","width","style","event"],"mappings":";;;AAKA,MAAMA,cAA0F;AAAA,EAC9FC,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,QAAQ;AAAA,EACRC,MAAM;AAAA,EACNC,MAAM;AACR;AAEA,MAAMC,aAAa;AAAA,EACjBL,SAAS;AAAA,EACTM,SAAS;AAAA,EACTC,SAAS;AAAA,EACTC,QAAQ;AAAA,EACRC,MAAM;AAAA,EACNR,SAAS;AACX;AAEO,MAAMS,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,SAAS;AAAA,MAAEC,MAAMC;AAAAA,MAA4ChB,SAAS;AAAA;IACtEiB,QAAQ;AAAA,MAAEF,MAAMC;AAAAA,MAA4BhB,SAASkB;AAAAA;IACrDC,MAAM;AAAA,MAAEJ,MAAMC;AAAAA,MAA0BhB,SAAS;AAAA;IACjDoB,UAAUC;AAAAA,IACVC,SAASD;AAAAA,IACTE,OAAOF;AAAAA,IACPG,YAAY;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选框右侧,正好是业务表单要的顺序,
|
|
7
|
+
* 所以不需要额外包一层插槽。
|
|
8
|
+
*/
|
|
9
|
+
export declare const Checkbox: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
10
|
+
modelValue: BooleanConstructor;
|
|
11
|
+
label: StringConstructor;
|
|
12
|
+
disabled: BooleanConstructor;
|
|
13
|
+
size: {
|
|
14
|
+
type: PropType<Size>;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
}>, () => 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<{
|
|
18
|
+
modelValue: BooleanConstructor;
|
|
19
|
+
label: StringConstructor;
|
|
20
|
+
disabled: BooleanConstructor;
|
|
21
|
+
size: {
|
|
22
|
+
type: PropType<Size>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
}>> & Readonly<{
|
|
26
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
27
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
size: Size;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
modelValue: boolean;
|
|
32
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElCheckbox } from "element-plus";
|
|
3
|
+
import { toElementSize } from "../size.mjs";
|
|
4
|
+
const Checkbox = /* @__PURE__ */ defineComponent({
|
|
5
|
+
name: "FbkElCheckbox",
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: Boolean,
|
|
9
|
+
label: String,
|
|
10
|
+
disabled: Boolean,
|
|
11
|
+
size: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: "md"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
emits: ["update:modelValue", "change"],
|
|
17
|
+
setup(props, {
|
|
18
|
+
attrs,
|
|
19
|
+
emit,
|
|
20
|
+
slots
|
|
21
|
+
}) {
|
|
22
|
+
return () => createVNode(ElCheckbox, mergeProps(attrs, {
|
|
23
|
+
"modelValue": props.modelValue,
|
|
24
|
+
"disabled": props.disabled,
|
|
25
|
+
"size": toElementSize(props.size),
|
|
26
|
+
"label": props.label,
|
|
27
|
+
"onChange": (value) => {
|
|
28
|
+
const next = Boolean(value);
|
|
29
|
+
emit("update:modelValue", next);
|
|
30
|
+
emit("change", next);
|
|
31
|
+
}
|
|
32
|
+
}), {
|
|
33
|
+
default: () => [slots.default?.()]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
Checkbox
|
|
39
|
+
};
|
|
40
|
+
//# 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 { ElCheckbox } from 'element-plus'\nimport type { Size } from '@fbkworks/adapter-core'\nimport { toElementSize } from '../size'\n\n/**\n * 布尔开关。\n *\n * element-plus 的 ElCheckbox 把 label 放在勾选框右侧,正好是业务表单要的顺序,\n * 所以不需要额外包一层插槽。\n */\nexport const Checkbox = defineComponent({\n name: 'FbkElCheckbox',\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 <ElCheckbox\n {...attrs}\n modelValue={props.modelValue}\n disabled={props.disabled}\n size={toElementSize(props.size)}\n label={props.label}\n onChange={(value: unknown) => {\n const next = Boolean(value)\n emit('update:modelValue', next)\n emit('change', next)\n }}\n >\n {slots.default?.()}\n </ElCheckbox>\n )\n },\n})\n"],"names":["Checkbox","defineComponent","name","inheritAttrs","props","modelValue","Boolean","label","String","disabled","size","type","default","emits","setup","attrs","emit","slots","_createVNode","ElCheckbox","_mergeProps","toElementSize","value","next"],"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,QAClBY,cAAcjB,MAAMM,IAAI;AAAA,MAAC,SACxBN,MAAMG;AAAAA,MAAK,YACPe,WAAmB;AAC5B,cAAMC,OAAOjB,QAAQgB,KAAK;AAC1BN,aAAK,qBAAqBO,IAAI;AAC9BP,aAAK,UAAUO,IAAI;AAAA,MACrB;AAAA,IAAC,CAAA,GAAA;AAAA,MAAAX,SAAAA,MAAA,CAEAK,MAAML,UAAO,CAAI;AAAA,KAAA;AAAA,EAGxB;AACF,CAAC;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { DataGridColumn, DataGridProps, SortState } from '@fbkworks/adapter-core';
|
|
3
|
+
export declare const DataGrid: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
columns: {
|
|
5
|
+
type: PropType<DataGridColumn<any>[]>;
|
|
6
|
+
default: () => never[];
|
|
7
|
+
};
|
|
8
|
+
data: {
|
|
9
|
+
type: PropType<any[]>;
|
|
10
|
+
default: () => never[];
|
|
11
|
+
};
|
|
12
|
+
rowKey: {
|
|
13
|
+
type: PropType<DataGridProps["rowKey"]>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
loading: BooleanConstructor;
|
|
17
|
+
presentation: {
|
|
18
|
+
type: PropType<DataGridProps["presentation"]>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
selectionEnabled: BooleanConstructor;
|
|
22
|
+
selectionWidth: {
|
|
23
|
+
type: NumberConstructor;
|
|
24
|
+
default: number;
|
|
25
|
+
};
|
|
26
|
+
selectedKeys: {
|
|
27
|
+
type: PropType<Array<string | number>>;
|
|
28
|
+
default: () => never[];
|
|
29
|
+
};
|
|
30
|
+
sort: {
|
|
31
|
+
type: PropType<SortState | null>;
|
|
32
|
+
default: null;
|
|
33
|
+
};
|
|
34
|
+
emptyText: StringConstructor;
|
|
35
|
+
rowClickable: BooleanConstructor;
|
|
36
|
+
size: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("update:selectedKeys" | "update:sort" | "row-click")[], "update:selectedKeys" | "update:sort" | "row-click", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
41
|
+
columns: {
|
|
42
|
+
type: PropType<DataGridColumn<any>[]>;
|
|
43
|
+
default: () => never[];
|
|
44
|
+
};
|
|
45
|
+
data: {
|
|
46
|
+
type: PropType<any[]>;
|
|
47
|
+
default: () => never[];
|
|
48
|
+
};
|
|
49
|
+
rowKey: {
|
|
50
|
+
type: PropType<DataGridProps["rowKey"]>;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
loading: BooleanConstructor;
|
|
54
|
+
presentation: {
|
|
55
|
+
type: PropType<DataGridProps["presentation"]>;
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
selectionEnabled: BooleanConstructor;
|
|
59
|
+
selectionWidth: {
|
|
60
|
+
type: NumberConstructor;
|
|
61
|
+
default: number;
|
|
62
|
+
};
|
|
63
|
+
selectedKeys: {
|
|
64
|
+
type: PropType<Array<string | number>>;
|
|
65
|
+
default: () => never[];
|
|
66
|
+
};
|
|
67
|
+
sort: {
|
|
68
|
+
type: PropType<SortState | null>;
|
|
69
|
+
default: null;
|
|
70
|
+
};
|
|
71
|
+
emptyText: StringConstructor;
|
|
72
|
+
rowClickable: BooleanConstructor;
|
|
73
|
+
size: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
}>> & Readonly<{
|
|
78
|
+
"onUpdate:selectedKeys"?: ((...args: any[]) => any) | undefined;
|
|
79
|
+
"onUpdate:sort"?: ((...args: any[]) => any) | undefined;
|
|
80
|
+
"onRow-click"?: ((...args: any[]) => any) | undefined;
|
|
81
|
+
}>, {
|
|
82
|
+
size: string;
|
|
83
|
+
sort: SortState | null;
|
|
84
|
+
data: any[];
|
|
85
|
+
loading: boolean;
|
|
86
|
+
rowKey: string | ((row: any) => string | number) | undefined;
|
|
87
|
+
presentation: import('@fbkworks/adapter-core').DataGridPresentation | undefined;
|
|
88
|
+
selectionEnabled: boolean;
|
|
89
|
+
rowClickable: boolean;
|
|
90
|
+
columns: DataGridColumn<any>[];
|
|
91
|
+
selectionWidth: number;
|
|
92
|
+
selectedKeys: (string | number)[];
|
|
93
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { defineComponent, computed, withDirectives, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElTable, ElTableColumn, vLoading } from "element-plus";
|
|
3
|
+
import { renderCell } from "@fbkworks/adapter-core";
|
|
4
|
+
import { getRowKey } from "@fbkworks/shared";
|
|
5
|
+
const DataGrid = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "FbkElDataGrid",
|
|
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
|
+
size: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "md"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
emits: ["update:selectedKeys", "update:sort", "row-click"],
|
|
47
|
+
setup(props, {
|
|
48
|
+
attrs,
|
|
49
|
+
emit,
|
|
50
|
+
slots
|
|
51
|
+
}) {
|
|
52
|
+
const rowKeyOf = (row, index) => getRowKey(row, index, props.rowKey);
|
|
53
|
+
const elementSize = computed(() => props.size === "sm" ? "small" : props.size === "lg" ? "large" : "default");
|
|
54
|
+
return () => withDirectives(createVNode(ElTable, mergeProps(attrs, {
|
|
55
|
+
"data": props.data,
|
|
56
|
+
"rowKey": props.rowKey,
|
|
57
|
+
"size": elementSize.value,
|
|
58
|
+
"emptyText": props.emptyText ?? "暂无数据",
|
|
59
|
+
"defaultSort": props.sort ? {
|
|
60
|
+
prop: props.sort.field,
|
|
61
|
+
order: props.sort.order === "asc" ? "ascending" : "descending"
|
|
62
|
+
} : void 0,
|
|
63
|
+
"onSelection-change": (rows) => emit("update:selectedKeys", rows.map((row) => rowKeyOf(row, props.data.indexOf(row)))),
|
|
64
|
+
"onSort-change": ({
|
|
65
|
+
prop,
|
|
66
|
+
order
|
|
67
|
+
}) => emit("update:sort", order && prop ? {
|
|
68
|
+
field: prop,
|
|
69
|
+
order: order === "ascending" ? "asc" : "desc"
|
|
70
|
+
} : null),
|
|
71
|
+
"onRow-click": (row, _column, event) => {
|
|
72
|
+
if (!props.rowClickable) return;
|
|
73
|
+
emit("row-click", row, props.data.indexOf(row), event);
|
|
74
|
+
}
|
|
75
|
+
}), {
|
|
76
|
+
default: () => [props.selectionEnabled ? createVNode(ElTableColumn, {
|
|
77
|
+
"type": "selection",
|
|
78
|
+
"width": props.selectionWidth,
|
|
79
|
+
"reserveSelection": true
|
|
80
|
+
}, null) : null, props.columns.map((column) => createVNode(ElTableColumn, {
|
|
81
|
+
"key": column.key,
|
|
82
|
+
"prop": column.dataIndex ?? column.key,
|
|
83
|
+
"label": column.title,
|
|
84
|
+
"width": column.width,
|
|
85
|
+
"minWidth": column.minWidth,
|
|
86
|
+
"fixed": column.fixed,
|
|
87
|
+
"align": column.align,
|
|
88
|
+
"sortable": column.sortable ? "custom" : false,
|
|
89
|
+
"showOverflowTooltip": column.ellipsis,
|
|
90
|
+
"className": column.numeric ? "fbk-numeric" : void 0
|
|
91
|
+
}, {
|
|
92
|
+
default: ({
|
|
93
|
+
row,
|
|
94
|
+
$index
|
|
95
|
+
}) => slots[`cell-${column.key}`]?.({
|
|
96
|
+
row,
|
|
97
|
+
index: $index,
|
|
98
|
+
value: renderCell(column, row, $index)
|
|
99
|
+
}) ?? renderCell(column, row, $index)
|
|
100
|
+
}))]
|
|
101
|
+
}), [[vLoading, props.loading]]);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
export {
|
|
105
|
+
DataGrid
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=DataGrid.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataGrid.mjs","sources":["../../src/primitives/DataGrid.tsx"],"sourcesContent":["import { computed, defineComponent, withDirectives, type PropType } from 'vue'\nimport { ElTable, ElTableColumn, vLoading } from 'element-plus'\nimport {\n renderCell,\n type DataGridColumn,\n type DataGridProps,\n type SortState,\n} from '@fbkworks/adapter-core'\nimport { getRowKey } from '@fbkworks/shared'\n\nexport const DataGrid = defineComponent({\n name: 'FbkElDataGrid',\n inheritAttrs: false,\n props: {\n columns: { type: Array as PropType<DataGridColumn<any>[]>, default: () => [] },\n data: { type: Array as PropType<any[]>, default: () => [] },\n rowKey: { type: [String, Function] as PropType<DataGridProps['rowKey']>, default: 'id' },\n loading: Boolean,\n presentation: { type: String as PropType<DataGridProps['presentation']>, default: 'auto' },\n selectionEnabled: Boolean,\n selectionWidth: { type: Number, default: 48 },\n selectedKeys: { type: Array as PropType<Array<string | number>>, default: () => [] },\n sort: { type: Object as PropType<SortState | null>, default: null },\n emptyText: String,\n rowClickable: Boolean,\n size: { type: String, default: 'md' },\n },\n emits: ['update:selectedKeys', 'update:sort', 'row-click'],\n setup(props, { attrs, emit, slots }) {\n const rowKeyOf = (row: any, index: number) => getRowKey(row, index, props.rowKey)\n\n const elementSize = computed(() =>\n props.size === 'sm' ? 'small' : props.size === 'lg' ? 'large' : 'default',\n )\n\n /* element-plus 没有独立 Spin,loading 只能靠 v-loading 指令挂遮罩;\n 这里用 withDirectives 直接绑指令对象,不要求业务侧全局注册 v-loading。 */\n return () => withDirectives(\n <ElTable\n {...attrs}\n data={props.data}\n rowKey={props.rowKey as any}\n size={elementSize.value}\n emptyText={props.emptyText ?? '暂无数据'}\n defaultSort={props.sort ? { prop: props.sort.field, order: props.sort.order === 'asc' ? 'ascending' : 'descending' } : undefined}\n onSelection-change={(rows: any[]) =>\n emit('update:selectedKeys', rows.map((row) => rowKeyOf(row, props.data.indexOf(row))))\n }\n onSort-change={({ prop, order }: { prop: string | null; order: string | null }) =>\n emit(\n 'update:sort',\n order && prop ? { field: prop, order: order === 'ascending' ? 'asc' : 'desc' } : null,\n )\n }\n onRow-click={(row: any, _column: any, event: Event) => {\n if (!props.rowClickable) return\n emit('row-click', row, props.data.indexOf(row), event)\n }}\n >\n {props.selectionEnabled ? (\n <ElTableColumn type=\"selection\" width={props.selectionWidth} reserveSelection />\n ) : null}\n {props.columns.map((column) => (\n <ElTableColumn\n key={column.key}\n /* prop 同时是 sort-change 回传的字段名:dataIndex 可选,\n 缺省时回退 key,否则点击排序只会发出 null。 */\n prop={(column.dataIndex ?? column.key) as string}\n label={column.title}\n width={column.width}\n minWidth={column.minWidth}\n fixed={column.fixed}\n align={column.align}\n sortable={column.sortable ? 'custom' : false}\n showOverflowTooltip={column.ellipsis}\n /* 数值列加 .fbk-numeric,由适配器样式给等宽数字。\n className 是 el-table-column 的官方 prop(落在 <td> 上),\n 比自己拼 class 稳。 */\n className={column.numeric ? 'fbk-numeric' : undefined}\n v-slots={{\n default: ({ row, $index }: { row: any; $index: number }) =>\n slots[`cell-${column.key}`]?.({ row, index: $index, value: renderCell(column, row, $index) }) ??\n renderCell(column, row, $index),\n }}\n />\n ))}\n </ElTable>,\n [[vLoading, props.loading]],\n )\n },\n})\n"],"names":["DataGrid","defineComponent","name","inheritAttrs","props","columns","type","Array","default","data","rowKey","String","Function","loading","Boolean","presentation","selectionEnabled","selectionWidth","Number","selectedKeys","sort","Object","emptyText","rowClickable","size","emits","setup","attrs","emit","slots","rowKeyOf","row","index","getRowKey","elementSize","computed","withDirectives","_createVNode","ElTable","_mergeProps","value","prop","field","order","undefined","rows","map","indexOf","onSort-change","onRow-click","_column","event","ElTableColumn","column","key","dataIndex","title","width","minWidth","fixed","align","sortable","ellipsis","numeric","$index","renderCell","vLoading"],"mappings":";;;;AAUO,MAAMA,WAAWC,gCAAgB;AAAA,EACtCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC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