@fbkworks/adapter-element-plus 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 +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 +20 -0
- package/dist/index.mjs +78 -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/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
|
@@ -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,OAAO;AAAA,IACLC,SAAS;AAAA,MAAEC,MAAMC;AAAAA,MAA0CC,SAASA,MAAM,CAAA;AAAA;IAC1EC,MAAM;AAAA,MAAEH,MAAMC;AAAAA,MAA0BC,SAASA,MAAM,CAAA;AAAA;IACvDE,QAAQ;AAAA,MAAEJ,MAAM,CAACK,QAAQC,QAAQ;AAAA,MAAwCJ,SAAS;AAAA;IAClFK,SAASC;AAAAA,IACTC,cAAc;AAAA,MAAET,MAAMK;AAAAA,MAAmDH,SAAS;AAAA;IAClFQ,kBAAkBF;AAAAA,IAClBG,gBAAgB;AAAA,MAAEX,MAAMY;AAAAA,MAAQV,SAAS;AAAA;IACzCW,cAAc;AAAA,MAAEb,MAAMC;AAAAA,MAA2CC,SAASA,MAAM,CAAA;AAAA;IAChFY,MAAM;AAAA,MAAEd,MAAMe;AAAAA,MAAsCb,SAAS;AAAA;IAC7Dc,WAAWX;AAAAA,IACXY,cAAcT;AAAAA,IACdU,MAAM;AAAA,MAAElB,MAAMK;AAAAA,MAAQH,SAAS;AAAA,IAAK;AAAA;EAEtCiB,OAAO,CAAC,uBAAuB,eAAe,WAAW;AAAA,EACzDC,MAAMtB,OAAO;AAAA,IAAEuB;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,UAAMC,WA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,QAAG,QAGRD,OAAOE,aAAaF,OAAOC;AAAAA,QAAG,SAC9BD,OAAOG;AAAAA,QAAK,SACZH,OAAOI;AAAAA,QAAK,YACTJ,OAAOK;AAAAA,QAAQ,SAClBL,OAAOM;AAAAA,QAAK,SACZN,OAAOO;AAAAA,QAAK,YACTP,OAAOQ,WAAW,WAAW;AAAA,QAAK,uBACvBR,OAAOS;AAAAA,QAAQ,aAIzBT,OAAOU,UAAU,gBAAgBnB;AAAAA,SACnC;AAAA,QACPpC,SAASA,CAAC;AAAA,UAAEuB;AAAAA,UAAKiC;AAAAA,cACfnC,MAAM,QAAQwB,OAAOC,GAAG,EAAE,IAAI;AAAA,UAAEvB;AAAAA,UAAKC,OAAOgC;AAAAA,UAAQxB,OAAOyB,WAAWZ,QAAQtB,KAAKiC,MAAM;AAAA,SAAG,KAC5FC,WAAWZ,QAAQtB,KAAKiC,MAAM;AAAA,MAClC,CAAC,CAEJ,CAAC;AAAA,KAAA,GAEJ,CAAC,CAACE,UAAU9D,MAAMS,OAAO,CAAC,CAC5B;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { DatePickerProps, Size } from '@fbkworks/adapter-core';
|
|
3
|
+
export declare const DatePicker: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: PropType<string | string[] | null>;
|
|
6
|
+
default: undefined;
|
|
7
|
+
};
|
|
8
|
+
type: {
|
|
9
|
+
type: PropType<DatePickerProps["type"]>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
placeholder: {
|
|
13
|
+
type: PropType<string | [string, string]>;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
disabled: BooleanConstructor;
|
|
17
|
+
clearable: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
size: {
|
|
22
|
+
type: PropType<Size>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
uiProps: {
|
|
26
|
+
type: PropType<Record<string, any>>;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>, () => 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<{
|
|
30
|
+
modelValue: {
|
|
31
|
+
type: PropType<string | string[] | null>;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
type: {
|
|
35
|
+
type: PropType<DatePickerProps["type"]>;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
placeholder: {
|
|
39
|
+
type: PropType<string | [string, string]>;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
disabled: BooleanConstructor;
|
|
43
|
+
clearable: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
size: {
|
|
48
|
+
type: PropType<Size>;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
uiProps: {
|
|
52
|
+
type: PropType<Record<string, any>>;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
}>> & Readonly<{
|
|
56
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
57
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
58
|
+
}>, {
|
|
59
|
+
size: Size;
|
|
60
|
+
type: import('@fbkworks/adapter-core').DatePickerType | undefined;
|
|
61
|
+
disabled: boolean;
|
|
62
|
+
placeholder: string | [string, string];
|
|
63
|
+
modelValue: string | string[] | null;
|
|
64
|
+
clearable: boolean;
|
|
65
|
+
uiProps: Record<string, any>;
|
|
66
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElDatePicker } from "element-plus";
|
|
3
|
+
import { toElementSize } from "../size.mjs";
|
|
4
|
+
const VALUE_FORMAT = {
|
|
5
|
+
date: "YYYY-MM-DD",
|
|
6
|
+
datetime: "YYYY-MM-DD HH:mm:ss",
|
|
7
|
+
time: "HH:mm:ss",
|
|
8
|
+
daterange: "YYYY-MM-DD",
|
|
9
|
+
datetimerange: "YYYY-MM-DD HH:mm:ss"
|
|
10
|
+
};
|
|
11
|
+
const DatePicker = /* @__PURE__ */ defineComponent({
|
|
12
|
+
name: "FbkElDatePicker",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [String, Array],
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
type: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "date"
|
|
22
|
+
},
|
|
23
|
+
placeholder: {
|
|
24
|
+
type: [String, Array],
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
disabled: Boolean,
|
|
28
|
+
clearable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true
|
|
31
|
+
},
|
|
32
|
+
size: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: "md"
|
|
35
|
+
},
|
|
36
|
+
uiProps: {
|
|
37
|
+
type: Object,
|
|
38
|
+
default: void 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
emits: ["update:modelValue", "change"],
|
|
42
|
+
setup(props, {
|
|
43
|
+
attrs,
|
|
44
|
+
emit,
|
|
45
|
+
slots
|
|
46
|
+
}) {
|
|
47
|
+
const isRange = computed(() => props.type === "daterange" || props.type === "datetimerange");
|
|
48
|
+
return () => createVNode(ElDatePicker, mergeProps(attrs, props.uiProps ?? {}, {
|
|
49
|
+
"modelValue": props.modelValue ?? (isRange.value ? null : ""),
|
|
50
|
+
"type": props.type === "time" ? "datetime" : props.type,
|
|
51
|
+
"valueFormat": VALUE_FORMAT[props.type ?? "date"],
|
|
52
|
+
"placeholder": Array.isArray(props.placeholder) ? void 0 : props.placeholder,
|
|
53
|
+
"disabled": props.disabled,
|
|
54
|
+
"clearable": props.clearable,
|
|
55
|
+
"size": toElementSize(props.size),
|
|
56
|
+
"startPlaceholder": isRange.value ? "开始日期" : void 0,
|
|
57
|
+
"endPlaceholder": isRange.value ? "结束日期" : void 0,
|
|
58
|
+
"rangeSeparator": "至",
|
|
59
|
+
"onUpdate:modelValue": (value) => {
|
|
60
|
+
emit("update:modelValue", value);
|
|
61
|
+
emit("change", value);
|
|
62
|
+
}
|
|
63
|
+
}), slots);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export {
|
|
67
|
+
DatePicker
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=DatePicker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.mjs","sources":["../../src/primitives/DatePicker.tsx"],"sourcesContent":["import { computed, defineComponent, type PropType } from 'vue'\nimport { ElDatePicker } from 'element-plus'\nimport type { DatePickerProps, Size } from '@fbkworks/adapter-core'\nimport { toElementSize } from '../size'\n\n/**\n * 日期/时间选择。\n *\n * 值统一用字符串(YYYY-MM-DD / YYYY-MM-DD HH:mm:ss / HH:mm:ss),\n * element-plus 原生支持字符串 v-model,直接用 `value-format` 约束输出格式即可,\n * 不需要在适配器里做 Date 互转。\n */\nconst VALUE_FORMAT: Record<string, string> = {\n date: 'YYYY-MM-DD',\n datetime: 'YYYY-MM-DD HH:mm:ss',\n time: 'HH:mm:ss',\n daterange: 'YYYY-MM-DD',\n datetimerange: 'YYYY-MM-DD HH:mm:ss',\n}\n\nexport const DatePicker = defineComponent({\n name: 'FbkElDatePicker',\n inheritAttrs: false,\n props: {\n modelValue: { type: [String, Array] as PropType<string | string[] | null>, default: undefined },\n type: { type: String as PropType<DatePickerProps['type']>, default: 'date' },\n placeholder: { type: [String, Array] as PropType<string | [string, string]>, default: undefined },\n disabled: Boolean,\n clearable: { type: Boolean, default: true },\n size: { type: String as PropType<Size>, default: 'md' },\n uiProps: { type: Object as PropType<Record<string, any>>, default: undefined },\n },\n emits: ['update:modelValue', 'change'],\n setup(props, { attrs, emit, slots }) {\n const isRange = computed(() => props.type === 'daterange' || props.type === 'datetimerange')\n\n return () => (\n <ElDatePicker\n {...attrs}\n {...(props.uiProps ?? {})}\n modelValue={props.modelValue ?? (isRange.value ? null : '')}\n /* element-plus 的 type 枚举里没有 'time'(纯时间用 ElTimePicker)。\n 这里把 time 映射成 datetime 面板,并靠 format 只显示时分 —— \n 与 naive 适配器保持同一策略,三边行为一致。 */\n type={(props.type === 'time' ? 'datetime' : props.type) as any}\n valueFormat={VALUE_FORMAT[props.type ?? 'date']}\n placeholder={Array.isArray(props.placeholder) ? undefined : props.placeholder}\n disabled={props.disabled}\n clearable={props.clearable}\n size={toElementSize(props.size)}\n startPlaceholder={isRange.value ? '开始日期' : undefined}\n endPlaceholder={isRange.value ? '结束日期' : undefined}\n rangeSeparator=\"至\"\n onUpdate:modelValue={(value: string | string[] | null) => {\n emit('update:modelValue', value)\n emit('change', value)\n }}\n v-slots={slots}\n />\n )\n },\n})\n"],"names":["VALUE_FORMAT","date","datetime","time","daterange","datetimerange","DatePicker","defineComponent","name","inheritAttrs","props","modelValue","type","String","Array","default","undefined","placeholder","disabled","Boolean","clearable","size","uiProps","Object","emits","setup","attrs","emit","slots","isRange","computed","_createVNode","ElDatePicker","_mergeProps","value","isArray","toElementSize"],"mappings":";;;AAYA,MAAMA,eAAuC;AAAA,EAC3CC,MAAM;AAAA,EACNC,UAAU;AAAA,EACVC,MAAM;AAAA,EACNC,WAAW;AAAA,EACXC,eAAe;AACjB;AAEO,MAAMC,aAAaC,gCAAgB;AAAA,EACxCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAY;AAAA,MAAEC,MAAM,CAAC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AGpB;AACF,CAAC;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { DialogProps } from '@fbkworks/adapter-core';
|
|
3
|
+
/**
|
|
4
|
+
* placement 必须真的生效。element-plus 侧落在两处:
|
|
5
|
+
* center → align-center(它自己的居中实现 .el-dialog.is-align-center{margin:auto});
|
|
6
|
+
* bottom → fbk-dialog--bottom,由 style.css 把对话框推到视口底部(贴底弹层)。
|
|
7
|
+
*
|
|
8
|
+
* 此前这个适配器完全不读 placement,'center' 与 'bottom' 渲染出的 DOM 一模一样,
|
|
9
|
+
* 而契约里写着它有效 —— 属于声明与实现脱节(审查 B12)。
|
|
10
|
+
*/
|
|
11
|
+
export declare const Dialog: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
12
|
+
modelValue: BooleanConstructor;
|
|
13
|
+
title: StringConstructor;
|
|
14
|
+
width: {
|
|
15
|
+
type: PropType<string | number>;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
placement: {
|
|
19
|
+
type: PropType<DialogProps["placement"]>;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
closeOnClickModal: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
showClose: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
31
|
+
modelValue: BooleanConstructor;
|
|
32
|
+
title: StringConstructor;
|
|
33
|
+
width: {
|
|
34
|
+
type: PropType<string | number>;
|
|
35
|
+
default: string;
|
|
36
|
+
};
|
|
37
|
+
placement: {
|
|
38
|
+
type: PropType<DialogProps["placement"]>;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
closeOnClickModal: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
45
|
+
showClose: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{
|
|
50
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
51
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
52
|
+
}>, {
|
|
53
|
+
width: string | number;
|
|
54
|
+
modelValue: boolean;
|
|
55
|
+
placement: "center" | "bottom" | undefined;
|
|
56
|
+
showClose: boolean;
|
|
57
|
+
closeOnClickModal: boolean;
|
|
58
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElDialog } from "element-plus";
|
|
3
|
+
const Dialog = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "FbkElDialog",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: Boolean,
|
|
8
|
+
title: String,
|
|
9
|
+
width: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: "520px"
|
|
12
|
+
},
|
|
13
|
+
placement: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "center"
|
|
16
|
+
},
|
|
17
|
+
closeOnClickModal: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
},
|
|
21
|
+
showClose: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
emits: ["update:modelValue", "close"],
|
|
27
|
+
setup(props, {
|
|
28
|
+
attrs,
|
|
29
|
+
emit,
|
|
30
|
+
slots
|
|
31
|
+
}) {
|
|
32
|
+
return () => {
|
|
33
|
+
const bottom = props.placement === "bottom";
|
|
34
|
+
const {
|
|
35
|
+
class: attrsClass,
|
|
36
|
+
...rest
|
|
37
|
+
} = attrs;
|
|
38
|
+
return createVNode(ElDialog, mergeProps(rest, {
|
|
39
|
+
"modelValue": props.modelValue,
|
|
40
|
+
"title": props.title,
|
|
41
|
+
"width": bottom ? "100%" : props.width,
|
|
42
|
+
"alignCenter": !bottom,
|
|
43
|
+
"class": [attrsClass, bottom ? "fbk-dialog--bottom" : void 0],
|
|
44
|
+
"appendToBody": true,
|
|
45
|
+
"closeOnClickModal": props.closeOnClickModal,
|
|
46
|
+
"showClose": props.showClose,
|
|
47
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value),
|
|
48
|
+
"onClose": () => emit("close")
|
|
49
|
+
}), {
|
|
50
|
+
default: slots.default,
|
|
51
|
+
header: slots.header,
|
|
52
|
+
footer: slots.footer
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
Dialog
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Dialog.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.mjs","sources":["../../src/primitives/Dialog.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { ElDialog } from 'element-plus'\nimport type { DialogProps } from '@fbkworks/adapter-core'\n\n/**\n * placement 必须真的生效。element-plus 侧落在两处:\n * center → align-center(它自己的居中实现 .el-dialog.is-align-center{margin:auto});\n * bottom → fbk-dialog--bottom,由 style.css 把对话框推到视口底部(贴底弹层)。\n *\n * 此前这个适配器完全不读 placement,'center' 与 'bottom' 渲染出的 DOM 一模一样,\n * 而契约里写着它有效 —— 属于声明与实现脱节(审查 B12)。\n */\nexport const Dialog = defineComponent({\n name: 'FbkElDialog',\n inheritAttrs: false,\n props: {\n modelValue: Boolean,\n title: String,\n width: { type: [String, Number] as PropType<string | number>, default: '520px' },\n placement: { type: String as PropType<DialogProps['placement']>, default: 'center' },\n closeOnClickModal: { type: Boolean, default: true },\n showClose: { type: Boolean, default: true },\n },\n emits: ['update:modelValue', 'close'],\n setup(props, { attrs, emit, slots }) {\n return () => {\n const bottom = props.placement === 'bottom'\n /* class 要合并而不是覆盖:调用方传进来的 class 得留着,\n 贴底标记又是我们自己的语义,两者互不替代。 */\n const { class: attrsClass, ...rest } = attrs as Record<string, any>\n return (\n <ElDialog\n {...rest}\n modelValue={props.modelValue}\n title={props.title}\n width={bottom ? '100%' : props.width}\n alignCenter={!bottom}\n class={[attrsClass, bottom ? 'fbk-dialog--bottom' : undefined]}\n appendToBody\n closeOnClickModal={props.closeOnClickModal}\n showClose={props.showClose}\n onUpdate:modelValue={(value: boolean) => emit('update:modelValue', value)}\n onClose={() => emit('close')}\n v-slots={{\n default: slots.default,\n header: slots.header,\n footer: slots.footer,\n }}\n />\n )\n }\n },\n})\n"],"names":["Dialog","defineComponent","name","inheritAttrs","props","modelValue","Boolean","title","String","width","type","Number","default","placement","closeOnClickModal","showClose","emits","setup","attrs","emit","slots","bottom","class","attrsClass","rest","_createVNode","ElDialog","_mergeProps","undefined","value","onClose","header","footer"],"mappings":";;AAYO,MAAMA,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAYC;AAAAA,IACZC,OAAOC;AAAAA,IACPC,OAAO;AAAA,MAAEC,MAAM,CAACF,QAAQG,MAAM;AAAA,MAAgCC,SAAS;AAAA;IACvEC,WAAW;AAAA,MAAEH,MAAMF;AAAAA,MAA8CI,SAAS;AAAA;IAC1EE,mBAAmB;AAAA,MAAEJ,MAAMJ;AAAAA,MAASM,SAAS;AAAA;IAC7CG,WAAW;AAAA,MAAEL,MAAMJ;AAAAA,MAASM,SAAS;AAAA,IAAK;AAAA;EAE5CI,OAAO,CAAC,qBAAqB,OAAO;AAAA,EACpCC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAM;AACX,YAAMC,SAASjB,MAAMS,cAAc;AAGnC,YAAM;AAAA,QAAES,OAAOC;AAAAA,QAAY,GAAGC;AAAAA,MAAK,IAAIN;AACvC,aAAAO,YAAAC,UAAAC,WAEQH,MAAI;AAAA,QAAA,cACIpB,MAAMC;AAAAA,QAAU,SACrBD,MAAMG;AAAAA,QAAK,SACXc,SAAS,SAASjB,MAAMK;AAAAA,QAAK,eACvB,CAACY;AAAAA,QAAM,SACb,CAACE,YAAYF,SAAS,uBAAuBO,MAAS;AAAA,QAAC,gBAAA;AAAA,QAAA,qBAE3CxB,MAAMU;AAAAA,QAAiB,aAC/BV,MAAMW;AAAAA,QAAS,uBACJc,WAAmBV,KAAK,qBAAqBU,KAAK;AAAA,QAAC,WAChEC,MAAMX,KAAK,OAAO;AAAA,OAAC,GACnB;AAAA,QACPP,SAASQ,MAAMR;AAAAA,QACfmB,QAAQX,MAAMW;AAAAA,QACdC,QAAQZ,MAAMY;AAAAA,OACf;AAAA,IAGP;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { DrawerProps } from '@fbkworks/adapter-core';
|
|
3
|
+
/**
|
|
4
|
+
* 桌面抽屉:ElDrawer 用的是方向(direction)而不是位置语义。
|
|
5
|
+
* right → rtl(右侧滑入,宽度取 size),bottom → btt(底部滑入,高度取 size)。
|
|
6
|
+
* btt 方向本身铺满宽度,所以底部弹出时不再传固定宽度 —— 那正是移动端全屏。
|
|
7
|
+
*
|
|
8
|
+
* 关闭走 beforeClose 而不是等 ElDrawer 自己 emit update:modelValue:
|
|
9
|
+
* element-plus 是在**离场动画结束**(afterLeave)才发那个事件的,
|
|
10
|
+
* 动画被中断就永远不发;而在没有 transitionend 的环境里(jsdom / 关掉动画)
|
|
11
|
+
* 一次都不会发。把关闭意图同步翻译成 update:modelValue(false),
|
|
12
|
+
* 再让父级通过 modelValue 收回抽屉 —— 与 vant / naive 的行为一致(纯受控)。
|
|
13
|
+
*/
|
|
14
|
+
export declare const Drawer: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
15
|
+
modelValue: BooleanConstructor;
|
|
16
|
+
title: StringConstructor;
|
|
17
|
+
width: {
|
|
18
|
+
type: PropType<string | number>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
placement: {
|
|
22
|
+
type: PropType<DrawerProps["placement"]>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
closeOnClickModal: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
showClose: {
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
34
|
+
modelValue: BooleanConstructor;
|
|
35
|
+
title: StringConstructor;
|
|
36
|
+
width: {
|
|
37
|
+
type: PropType<string | number>;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
placement: {
|
|
41
|
+
type: PropType<DrawerProps["placement"]>;
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
44
|
+
closeOnClickModal: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
showClose: {
|
|
49
|
+
type: BooleanConstructor;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
52
|
+
}>> & Readonly<{
|
|
53
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
54
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
55
|
+
}>, {
|
|
56
|
+
width: string | number;
|
|
57
|
+
modelValue: boolean;
|
|
58
|
+
placement: "bottom" | "right" | undefined;
|
|
59
|
+
showClose: boolean;
|
|
60
|
+
closeOnClickModal: boolean;
|
|
61
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { ElDrawer } from "element-plus";
|
|
3
|
+
const Drawer = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "FbkElDrawer",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: Boolean,
|
|
8
|
+
title: String,
|
|
9
|
+
width: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: "480px"
|
|
12
|
+
},
|
|
13
|
+
placement: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "right"
|
|
16
|
+
},
|
|
17
|
+
closeOnClickModal: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
},
|
|
21
|
+
showClose: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
emits: ["update:modelValue", "close"],
|
|
27
|
+
setup(props, {
|
|
28
|
+
attrs,
|
|
29
|
+
emit,
|
|
30
|
+
slots
|
|
31
|
+
}) {
|
|
32
|
+
return () => {
|
|
33
|
+
const bottom = props.placement === "bottom";
|
|
34
|
+
return createVNode(ElDrawer, mergeProps(attrs, {
|
|
35
|
+
"modelValue": props.modelValue,
|
|
36
|
+
"title": props.title,
|
|
37
|
+
"direction": bottom ? "btt" : "rtl",
|
|
38
|
+
"size": bottom ? "100%" : props.width,
|
|
39
|
+
"appendToBody": true,
|
|
40
|
+
"closeOnClickModal": props.closeOnClickModal,
|
|
41
|
+
"showClose": props.showClose,
|
|
42
|
+
"beforeClose": () => emit("update:modelValue", false),
|
|
43
|
+
"onUpdate:modelValue": (value) => {
|
|
44
|
+
if (value) emit("update:modelValue", value);
|
|
45
|
+
},
|
|
46
|
+
"onClose": () => emit("close")
|
|
47
|
+
}), {
|
|
48
|
+
default: slots.default,
|
|
49
|
+
footer: slots.footer
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export {
|
|
55
|
+
Drawer
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=Drawer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.mjs","sources":["../../src/primitives/Drawer.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { ElDrawer } from 'element-plus'\nimport type { DrawerProps } from '@fbkworks/adapter-core'\n\n/**\n * 桌面抽屉:ElDrawer 用的是方向(direction)而不是位置语义。\n * right → rtl(右侧滑入,宽度取 size),bottom → btt(底部滑入,高度取 size)。\n * btt 方向本身铺满宽度,所以底部弹出时不再传固定宽度 —— 那正是移动端全屏。\n *\n * 关闭走 beforeClose 而不是等 ElDrawer 自己 emit update:modelValue:\n * element-plus 是在**离场动画结束**(afterLeave)才发那个事件的,\n * 动画被中断就永远不发;而在没有 transitionend 的环境里(jsdom / 关掉动画)\n * 一次都不会发。把关闭意图同步翻译成 update:modelValue(false),\n * 再让父级通过 modelValue 收回抽屉 —— 与 vant / naive 的行为一致(纯受控)。\n */\nexport const Drawer = defineComponent({\n name: 'FbkElDrawer',\n inheritAttrs: false,\n props: {\n modelValue: Boolean,\n title: String,\n width: { type: [String, Number] as PropType<string | number>, default: '480px' },\n placement: { type: String as PropType<DrawerProps['placement']>, default: 'right' },\n closeOnClickModal: { type: Boolean, default: true },\n showClose: { type: Boolean, default: true },\n },\n emits: ['update:modelValue', 'close'],\n setup(props, { attrs, emit, slots }) {\n return () => {\n const bottom = props.placement === 'bottom'\n return (\n <ElDrawer\n {...attrs}\n modelValue={props.modelValue}\n title={props.title}\n direction={bottom ? 'btt' : 'rtl'}\n size={bottom ? '100%' : props.width}\n appendToBody\n closeOnClickModal={props.closeOnClickModal}\n showClose={props.showClose}\n /* 关闭控件 / 点遮罩 / ESC 都汇到这里,同步发出关闭意图 */\n beforeClose={() => emit('update:modelValue', false)}\n onUpdate:modelValue={(value: boolean) => {\n /* ElDrawer 在离场后才补发的 false 已经晚了:父级早就收过上面的意图,\n 再发一次就是重复事件;只有 true 是我们没发过的新状态 */\n if (value) emit('update:modelValue', value)\n }}\n onClose={() => emit('close')}\n v-slots={{ default: slots.default, footer: slots.footer }}\n />\n )\n }\n },\n})\n"],"names":["Drawer","defineComponent","name","inheritAttrs","props","modelValue","Boolean","title","String","width","type","Number","default","placement","closeOnClickModal","showClose","emits","setup","attrs","emit","slots","bottom","_createVNode","ElDrawer","_mergeProps","beforeClose","value","onClose","footer"],"mappings":";;AAeO,MAAMA,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAYC;AAAAA,IACZC,OAAOC;AAAAA,IACPC,OAAO;AAAA,MAAEC,MAAM,CAACF,QAAQG,MAAM;AAAA,MAAgCC,SAAS;AAAA;IACvEC,WAAW;AAAA,MAAEH,MAAMF;AAAAA,MAA8CI,SAAS;AAAA;IAC1EE,mBAAmB;AAAA,MAAEJ,MAAMJ;AAAAA,MAASM,SAAS;AAAA;IAC7CG,WAAW;AAAA,MAAEL,MAAMJ;AAAAA,MAASM,SAAS;AAAA,IAAK;AAAA;EAE5CI,OAAO,CAAC,qBAAqB,OAAO;AAAA,EACpCC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAM;AACX,YAAMC,SAASjB,MAAMS,cAAc;AACnC,aAAAS,YAAAC,UAAAC,WAEQN,OAAK;AAAA,QAAA,cACGd,MAAMC;AAAAA,QAAU,SACrBD,MAAMG;AAAAA,QAAK,aACPc,SAAS,QAAQ;AAAA,QAAK,QAC3BA,SAAS,SAASjB,MAAMK;AAAAA,QAAK,gBAAA;AAAA,QAAA,qBAEhBL,MAAMU;AAAAA,QAAiB,aAC/BV,MAAMW;AAAAA,QAAS,eAEbU,MAAMN,KAAK,qBAAqB,KAAK;AAAA,QAAC,uBAC7BO,WAAmB;AAGvC,cAAIA,MAAOP,MAAK,qBAAqBO,KAAK;AAAA,QAC5C;AAAA,QAAC,WACQC,MAAMR,KAAK,OAAO;AAAA,OAAC,GACnB;AAAA,QAAEP,SAASQ,MAAMR;AAAAA,QAASgB,QAAQR,MAAMQ;AAAAA,OAAQ;AAAA,IAG/D;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { FormProps, FbkRule, Size } from '@fbkworks/adapter-core';
|
|
3
|
+
export declare const Form: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
model: {
|
|
5
|
+
type: PropType<Record<string, any>>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
rules: {
|
|
9
|
+
type: PropType<FormProps["rules"]>;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
|
+
labelWidth: {
|
|
13
|
+
type: PropType<string | number>;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
labelPosition: {
|
|
17
|
+
type: PropType<FormProps["labelPosition"]>;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
disabled: BooleanConstructor;
|
|
21
|
+
size: {
|
|
22
|
+
type: PropType<Size>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
scrollToError: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
30
|
+
model: {
|
|
31
|
+
type: PropType<Record<string, any>>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
rules: {
|
|
35
|
+
type: PropType<FormProps["rules"]>;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
labelWidth: {
|
|
39
|
+
type: PropType<string | number>;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
labelPosition: {
|
|
43
|
+
type: PropType<FormProps["labelPosition"]>;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
disabled: BooleanConstructor;
|
|
47
|
+
size: {
|
|
48
|
+
type: PropType<Size>;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
scrollToError: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
}>> & Readonly<{}>, {
|
|
56
|
+
size: Size;
|
|
57
|
+
disabled: boolean;
|
|
58
|
+
rules: Record<string, FbkRule[]> | undefined;
|
|
59
|
+
labelPosition: "right" | "left" | "top" | undefined;
|
|
60
|
+
labelWidth: string | number;
|
|
61
|
+
scrollToError: boolean;
|
|
62
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
63
|
+
export declare const FormItem: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
64
|
+
label: StringConstructor;
|
|
65
|
+
prop: StringConstructor;
|
|
66
|
+
required: BooleanConstructor;
|
|
67
|
+
rules: {
|
|
68
|
+
type: PropType<FbkRule[]>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
help: StringConstructor;
|
|
72
|
+
labelWidth: {
|
|
73
|
+
type: PropType<string | number>;
|
|
74
|
+
default: undefined;
|
|
75
|
+
};
|
|
76
|
+
span: NumberConstructor;
|
|
77
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
78
|
+
label: StringConstructor;
|
|
79
|
+
prop: StringConstructor;
|
|
80
|
+
required: BooleanConstructor;
|
|
81
|
+
rules: {
|
|
82
|
+
type: PropType<FbkRule[]>;
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
help: StringConstructor;
|
|
86
|
+
labelWidth: {
|
|
87
|
+
type: PropType<string | number>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
span: NumberConstructor;
|
|
91
|
+
}>> & Readonly<{}>, {
|
|
92
|
+
required: boolean;
|
|
93
|
+
rules: FbkRule[];
|
|
94
|
+
labelWidth: string | number;
|
|
95
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, createVNode } from "vue";
|
|
2
|
+
import { ElForm, ElFormItem } from "element-plus";
|
|
3
|
+
import { toElementSize } from "../size.mjs";
|
|
4
|
+
function toElementRules(rules) {
|
|
5
|
+
if (!rules?.length) return void 0;
|
|
6
|
+
return rules.map((rule) => ({
|
|
7
|
+
required: rule.required,
|
|
8
|
+
type: rule.type,
|
|
9
|
+
min: rule.min,
|
|
10
|
+
max: rule.max,
|
|
11
|
+
len: rule.len,
|
|
12
|
+
pattern: rule.pattern,
|
|
13
|
+
message: rule.message,
|
|
14
|
+
trigger: rule.trigger === "submit" ? void 0 : rule.trigger ?? "change",
|
|
15
|
+
validator: rule.validator && ((_r, value, callback) => {
|
|
16
|
+
const result = rule.validator(value, {});
|
|
17
|
+
if (result instanceof Promise) {
|
|
18
|
+
result.then((message) => message === true || !message ? callback() : callback(new Error(message)));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (result === true || result === void 0) callback();
|
|
22
|
+
else callback(new Error(result));
|
|
23
|
+
})
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
const Form = /* @__PURE__ */ defineComponent({
|
|
27
|
+
name: "FbkElForm",
|
|
28
|
+
props: {
|
|
29
|
+
model: {
|
|
30
|
+
type: Object,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
type: Object,
|
|
35
|
+
default: void 0
|
|
36
|
+
},
|
|
37
|
+
labelWidth: {
|
|
38
|
+
type: [String, Number],
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
41
|
+
labelPosition: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "right"
|
|
44
|
+
},
|
|
45
|
+
disabled: Boolean,
|
|
46
|
+
size: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "md"
|
|
49
|
+
},
|
|
50
|
+
scrollToError: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
setup(props, {
|
|
56
|
+
expose,
|
|
57
|
+
slots
|
|
58
|
+
}) {
|
|
59
|
+
const formRef = ref();
|
|
60
|
+
const elementRules = computed(() => {
|
|
61
|
+
if (!props.rules) return void 0;
|
|
62
|
+
return Object.fromEntries(Object.entries(props.rules).map(([key, rules]) => [key, toElementRules(rules)]));
|
|
63
|
+
});
|
|
64
|
+
expose({
|
|
65
|
+
validate: async () => {
|
|
66
|
+
const result = await formRef.value?.validate();
|
|
67
|
+
return result ?? true;
|
|
68
|
+
},
|
|
69
|
+
validateField: async (prop) => {
|
|
70
|
+
await formRef.value?.validateField(prop);
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
resetFields: () => formRef.value?.resetFields(),
|
|
74
|
+
clearValidate: (props2) => formRef.value?.clearValidate(props2)
|
|
75
|
+
});
|
|
76
|
+
return () => createVNode(ElForm, {
|
|
77
|
+
"ref": formRef,
|
|
78
|
+
"model": props.model,
|
|
79
|
+
"rules": elementRules.value,
|
|
80
|
+
"labelWidth": props.labelWidth,
|
|
81
|
+
"labelPosition": props.labelPosition,
|
|
82
|
+
"disabled": props.disabled,
|
|
83
|
+
"size": toElementSize(props.size),
|
|
84
|
+
"scrollToError": props.scrollToError
|
|
85
|
+
}, {
|
|
86
|
+
default: () => [slots.default?.()]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const FormItem = /* @__PURE__ */ defineComponent({
|
|
91
|
+
name: "FbkElFormItem",
|
|
92
|
+
props: {
|
|
93
|
+
label: String,
|
|
94
|
+
prop: String,
|
|
95
|
+
required: Boolean,
|
|
96
|
+
rules: {
|
|
97
|
+
type: Array,
|
|
98
|
+
default: void 0
|
|
99
|
+
},
|
|
100
|
+
help: String,
|
|
101
|
+
labelWidth: {
|
|
102
|
+
type: [String, Number],
|
|
103
|
+
default: void 0
|
|
104
|
+
},
|
|
105
|
+
span: Number
|
|
106
|
+
},
|
|
107
|
+
setup(props, {
|
|
108
|
+
slots
|
|
109
|
+
}) {
|
|
110
|
+
return () => createVNode(ElFormItem, {
|
|
111
|
+
"label": props.label,
|
|
112
|
+
"prop": props.prop,
|
|
113
|
+
"required": props.required,
|
|
114
|
+
"rules": toElementRules(props.rules),
|
|
115
|
+
"labelWidth": props.labelWidth
|
|
116
|
+
}, {
|
|
117
|
+
default: () => [slots.default?.(), props.help ? createVNode("div", {
|
|
118
|
+
"class": "fbk-form-item__help"
|
|
119
|
+
}, [props.help]) : null]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
export {
|
|
124
|
+
Form,
|
|
125
|
+
FormItem
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=Form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../src/primitives/Form.tsx"],"sourcesContent":["import { computed, defineComponent, ref, type PropType } from 'vue'\nimport { ElForm, ElFormItem, type FormInstance } from 'element-plus'\nimport type { FormProps, FbkRule, Size } from '@fbkworks/adapter-core'\nimport { toElementSize } from '../size'\n\nfunction toElementRules(rules: FbkRule[] | undefined) {\n if (!rules?.length) return undefined\n return rules.map((rule) => ({\n required: rule.required,\n type: rule.type,\n min: rule.min,\n max: rule.max,\n len: rule.len,\n pattern: rule.pattern,\n message: rule.message,\n trigger: rule.trigger === 'submit' ? undefined : (rule.trigger ?? 'change'),\n validator:\n rule.validator &&\n ((_r: unknown, value: unknown, callback: (error?: Error) => void) => {\n const result = rule.validator!(value, {})\n if (result instanceof Promise) {\n result.then((message) => (message === true || !message ? callback() : callback(new Error(message))))\n return\n }\n if (result === true || result === undefined) callback()\n else callback(new Error(result))\n }),\n }))\n}\n\nexport const Form = defineComponent({\n name: 'FbkElForm',\n props: {\n model: { type: Object as PropType<Record<string, any>>, required: true },\n rules: { type: Object as PropType<FormProps['rules']>, default: undefined },\n labelWidth: { type: [String, Number] as PropType<string | number>, default: undefined },\n labelPosition: { type: String as PropType<FormProps['labelPosition']>, default: 'right' },\n disabled: Boolean,\n size: { type: String as PropType<Size>, default: 'md' },\n scrollToError: { type: Boolean, default: true },\n },\n setup(props, { expose, slots }) {\n const formRef = ref<FormInstance>()\n const elementRules = computed(() => {\n if (!props.rules) return undefined\n return Object.fromEntries(\n Object.entries(props.rules).map(([key, rules]) => [key, toElementRules(rules)]),\n )\n })\n\n expose({\n validate: async () => {\n const result = await formRef.value?.validate()\n return (result ?? true) as true\n },\n validateField: async (prop: string | string[]) => {\n await formRef.value?.validateField(prop)\n return true as const\n },\n resetFields: () => formRef.value?.resetFields(),\n clearValidate: (props?: string | string[]) => formRef.value?.clearValidate(props),\n })\n\n return () => (\n <ElForm\n ref={formRef}\n model={props.model}\n rules={elementRules.value}\n labelWidth={props.labelWidth}\n labelPosition={props.labelPosition}\n disabled={props.disabled}\n size={toElementSize(props.size)}\n scrollToError={props.scrollToError}\n >\n {slots.default?.()}\n </ElForm>\n )\n },\n})\n\nexport const FormItem = defineComponent({\n name: 'FbkElFormItem',\n props: {\n label: String,\n prop: String,\n required: Boolean,\n rules: { type: Array as PropType<FbkRule[]>, default: undefined },\n help: String,\n labelWidth: { type: [String, Number] as PropType<string | number>, default: undefined },\n span: Number,\n },\n setup(props, { slots }) {\n return () => (\n <ElFormItem\n label={props.label}\n prop={props.prop}\n required={props.required}\n rules={toElementRules(props.rules)}\n labelWidth={props.labelWidth}\n >\n {slots.default?.()}\n {props.help ? <div class=\"fbk-form-item__help\">{props.help}</div> : null}\n </ElFormItem>\n )\n },\n})\n"],"names":["toElementRules","rules","length","undefined","map","rule","required","type","min","max","len","pattern","message","trigger","validator","_r","value","callback","result","Promise","then","Error","Form","defineComponent","name","props","model","Object","default","labelWidth","String","Number","labelPosition","disabled","Boolean","size","scrollToError","setup","expose","slots","formRef","ref","elementRules","computed","fromEntries","entries","key","validate","validateField","prop","resetFields","clearValidate","_createVNode","ElForm","toElementSize","FormItem","label","Array","help","span","ElFormItem"],"mappings":";;;AAKA,SAASA,eAAeC,OAA8B;AACpD,MAAI,CAACA,OAAOC,OAAQ,QAAOC;AAC3B,SAAOF,MAAMG,IAAKC,WAAU;AAAA,IAC1BC,UAAUD,KAAKC;AAAAA,IACfC,MAAMF,KAAKE;AAAAA,IACXC,KAAKH,KAAKG;AAAAA,IACVC,KAAKJ,KAAKI;AAAAA,IACVC,KAAKL,KAAKK;AAAAA,IACVC,SAASN,KAAKM;AAAAA,IACdC,SAASP,KAAKO;AAAAA,IACdC,SAASR,KAAKQ,YAAY,WAAWV,SAAaE,KAAKQ,WAAW;AAAA,IAClEC,WACET,KAAKS,cACJ,CAACC,IAAaC,OAAgBC,aAAsC;AACnE,YAAMC,SAASb,KAAKS,UAAWE,OAAO,CAAA,CAAE;AACxC,UAAIE,kBAAkBC,SAAS;AAC7BD,eAAOE,KAAMR,aAAaA,YAAY,QAAQ,CAACA,UAAUK,SAAQ,IAAKA,SAAS,IAAII,MAAMT,OAAO,CAAC,CAAE;AACnG;AAAA,MACF;AACA,UAAIM,WAAW,QAAQA,WAAWf,OAAWc;UACxCA,UAAS,IAAII,MAAMH,MAAM,CAAC;AAAA,IACjC;AAAA,EACJ,EAAE;AACJ;AAEO,MAAMI,OAAOC,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