@fbkworks/adapter-element-plus 0.4.0 → 0.5.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.
|
@@ -97,7 +97,10 @@ const DataGrid = /* @__PURE__ */ defineComponent({
|
|
|
97
97
|
index: $index,
|
|
98
98
|
value: renderCell(column, row, $index)
|
|
99
99
|
}) ?? renderCell(column, row, $index)
|
|
100
|
-
}))]
|
|
100
|
+
}))],
|
|
101
|
+
...slots.empty ? {
|
|
102
|
+
empty: () => slots.empty()
|
|
103
|
+
} : void 0
|
|
101
104
|
}), [[vLoading, props.loading]]);
|
|
102
105
|
}
|
|
103
106
|
});
|
|
@@ -1 +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,WAAWA,CAACC,KAAUC,UAAkBC,UAAUF,KAAKC,OAAO5B,MAAMM,MAAM;AAEhF,UAAMwB,cAAcC,SAAS,MAC3B/B,MAAMoB,SAAS,OAAO,UAAUpB,MAAMoB,SAAS,OAAO,UAAU,SAClE;AAIA,WAAO,MAAMY,eAAcC,YAAAC,SAAAC,WAEnBZ,OAAK;AAAA,MAAA,
|
|
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 v-slots={slots.empty ? { empty: () => slots.empty!() } : undefined}\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","empty","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,WAAWA,CAACC,KAAUC,UAAkBC,UAAUF,KAAKC,OAAO5B,MAAMM,MAAM;AAEhF,UAAMwB,cAAcC,SAAS,MAC3B/B,MAAMoB,SAAS,OAAO,UAAUpB,MAAMoB,SAAS,OAAO,UAAU,SAClE;AAIA,WAAO,MAAMY,eAAcC,YAAAC,SAAAC,WAEnBZ,OAAK;AAAA,MAAA,QAEHvB,MAAMK;AAAA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AAQ,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,MAAA,GA9COnC,MAAMqC,QAAQ;AAAA,QAAEA,OAAOA,MAAMrC,MAAMqC,MAAK;AAAA,MAAI,IAAItB;AAAAA,KAAS,GAgDpE,CAAC,CAACuB,UAAU/D,MAAMS,OAAO,CAAC,CAC5B;AAAA,EACF;AACF,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fbkworks/adapter-element-plus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@fbkworks/adapter-core": "^0.
|
|
24
|
+
"@fbkworks/adapter-core": "^0.5.0",
|
|
25
25
|
"@fbkworks/shared": "^0.3.0",
|
|
26
26
|
"@fbkworks/tokens": "^0.3.0"
|
|
27
27
|
},
|