xdc-ui-lib 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,6 +32,13 @@ app.mount('#app')
32
32
  - [BaseForm 动态表单组件](#baseform-动态表单组件)
33
33
  - [BaseModal 模态框组件](#basemodal-模态框组件)
34
34
  - [FileUpload 文件上传组件](#fileupload-文件上传组件)
35
+ - [FullScreenContainer 全屏容器组件](#fullscreencontainer-全屏容器组件)
36
+
37
+ - [Hooks / 工具](#hooks--工具)
38
+ - [useModalManager 模态框管理](#usemodalmanager-模态框管理)
39
+ - [useColumnSetting 表格列设置 Hook](#usecolumnsetting-表格列设置-hook)
40
+ - [useFilterTypeDisplay 筛选项显示设置 Hook](#usefiltertypedisplay-筛选项显示设置-hook)
41
+ - [国际化(i18n)](#国际化i18n)
35
42
 
36
43
  ---
37
44
 
@@ -1074,6 +1081,207 @@ function onExceed(file) {
1074
1081
 
1075
1082
  ---
1076
1083
 
1084
+ ## FullScreenContainer 全屏容器组件
1085
+
1086
+ 用于页面/区域的“全屏展示”容器组件,常见于:大屏、表格/图表全屏查看、需要在不改路由的情况下临时全屏等场景。
1087
+
1088
+ > 说明:该组件为库内注册组件,可直接从 `xdc-ui-lib` 引入使用。
1089
+
1090
+ ### 基本用法
1091
+
1092
+ ```vue
1093
+ <template>
1094
+ <FullScreenContainer>
1095
+ <div style="height: 300px; background: #f5f5f5">内容区域</div>
1096
+ </FullScreenContainer>
1097
+ </template>
1098
+
1099
+ <script setup lang="ts">
1100
+ import { FullScreenContainer } from 'xdc-ui-lib'
1101
+ </script>
1102
+ ```
1103
+
1104
+ ### 常见用法(配合工具栏按钮)
1105
+
1106
+ ```vue
1107
+ <template>
1108
+ <a-button @click="toggle">切换全屏</a-button>
1109
+
1110
+ <FullScreenContainer ref="fsRef">
1111
+ <BaseTable :columns="columns" :data-source="dataSource" />
1112
+ </FullScreenContainer>
1113
+ </template>
1114
+
1115
+ <script setup lang="ts">
1116
+ import { ref } from 'vue'
1117
+ import { FullScreenContainer, BaseTable } from 'xdc-ui-lib'
1118
+
1119
+ const fsRef = ref<any>()
1120
+
1121
+ function toggle() {
1122
+ // 若组件内部 expose 了方法,可在此调用(以实际实现为准)
1123
+ // fsRef.value?.toggle?.()
1124
+ }
1125
+ </script>
1126
+ ```
1127
+
1128
+ ### Props
1129
+
1130
+ | 参数 | 说明 | 类型 | 默认值 |
1131
+ |------|------|------|--------|
1132
+ | noScroll | 是否隐藏内层白色容器滚动条;`false` 时内层 `overflow:auto`,`true` 时内层 `overflow:hidden` | `boolean` | `true` |
1133
+ | fill | 是否填满父容器;`true` 外层 `width/height:100%` 且内层绝对定位铺满;`false` 外层高度随内容(`height:auto`) | `boolean` | `true` |
1134
+ | flex | 外层是否采用 `flex(column)`;用于“上面标题/筛选区 + 下面表格自适应吃满剩余高度” | `boolean` | `true` |
1135
+ | gutter | 外层 padding(外层与内层之间间隙) | `number \| string` | `16` |
1136
+ | padding | 内层白色容器 padding(内容与白色容器边缘间距) | `number \| string` | `16` |
1137
+ | background | 内层白色容器背景色 | `string` | `'#fff'` |
1138
+ | maxHeight | 外层最大高度;用于“外层不滚、内层滚”的场景 | `number \| string` | `'100vh'` |
1139
+ | style | 透传给内层白色容器(`.fsc-content`)的 style(对象或字符串) | `Record<string, any> \| string` | `-` |
1140
+
1141
+ ### Slots
1142
+
1143
+ | 插槽名 | 说明 |
1144
+ |------|------|
1145
+ | default | 容器内容 |
1146
+
1147
+ ### Events
1148
+
1149
+ 当前组件未定义/抛出自定义事件。
1150
+
1151
+ ---
1152
+
1153
+ ## Hooks / 工具
1154
+
1155
+ ### useModalManager 模态框管理
1156
+
1157
+ 用于对多个 BaseModal 进行注册/注销,并支持“一键关闭全部弹窗”。
1158
+
1159
+ ```ts
1160
+ import { useModalManager } from 'xdc-ui-lib'
1161
+
1162
+ const { registerModal, unregisterModal, closeAllModals } = useModalManager()
1163
+ ```
1164
+
1165
+ **API:**
1166
+
1167
+ - `registerModal(id: string, ref: { close?: () => void })`
1168
+ - `unregisterModal(id: string)`
1169
+ - `closeAllModals()`
1170
+
1171
+ > 提示:`BaseModal` 内部会用到这个能力(如果你在业务里需要自行管理多个弹窗,也可以直接使用该 hook)。
1172
+
1173
+ ### useColumnSetting 表格列设置 Hook
1174
+
1175
+ 用于在业务侧**以 hook 方式**接入列设置(显隐/排序/固定/持久化),底层复用 `useColumnSettingStore` 的缓存逻辑。
1176
+
1177
+ ```ts
1178
+ import { computed } from 'vue'
1179
+ import { useColumnSetting, type ColumnSettingColumn } from 'xdc-ui-lib'
1180
+
1181
+ const baseColumns: ColumnSettingColumn[] = [
1182
+ { title: 'ID', dataIndex: 'id', key: 'id' },
1183
+ { title: '名称', dataIndex: 'name', key: 'name' },
1184
+ ]
1185
+
1186
+ const {
1187
+ tableRef,
1188
+ selectedColumns,
1189
+ currentSize,
1190
+ initColumns,
1191
+ getDisplayColumnsData,
1192
+ handleColumnChange,
1193
+ persist,
1194
+ } = useColumnSetting({
1195
+ columns: () => baseColumns,
1196
+ storageKey: 'user-list-columns',
1197
+ disabledColumns: ['id'],
1198
+ // hiddenColumns: ['action'],
1199
+ // size: 'middle',
1200
+ // persistOnChange: true,
1201
+ })
1202
+
1203
+ initColumns()
1204
+
1205
+ const displayColumns = computed(() => {
1206
+ // 仅示例:你也可以直接用 selectedColumns 过滤 checked
1207
+ return getDisplayColumnsData().filter((c) => c.checked)
1208
+ })
1209
+ ```
1210
+
1211
+ **核心入参(UseColumnSettingOptions):**
1212
+
1213
+ - `columns`:列定义(支持 ref/computed/function)
1214
+ - `storageKey`:本地缓存 key(建议业务传,避免 hash 变更影响)
1215
+ - `disabledColumns?`:禁止操作的列
1216
+ - `hiddenColumns?`:完全隐藏且不可操作的列
1217
+ - `size?`:表格密度(可选,参与缓存)
1218
+ - `persistOnChange?`:列变更时是否自动写缓存(默认 true;needConfirm 场景可设 false,最后手动 `persist()`)
1219
+
1220
+ ### useFilterTypeDisplay 筛选项显示设置 Hook
1221
+
1222
+ 用于 SearchPanel 的“筛选项显示/隐藏/排序”配置管理(存储与 ColumnSetting 类似)。
1223
+
1224
+ ```ts
1225
+ import { ref } from 'vue'
1226
+ import { useFilterTypeDisplay } from 'xdc-ui-lib'
1227
+
1228
+ const storageKey = ref('search-panel:user-list')
1229
+ const filterTypes = ref<any[]>([
1230
+ { id: 'name', label: '名称', type: 'input' },
1231
+ { id: 'status', label: '状态', type: 'select' },
1232
+ ])
1233
+
1234
+ const {
1235
+ selectedItems,
1236
+ init,
1237
+ toggleVisibility,
1238
+ onCheckAllChange,
1239
+ reset,
1240
+ } = useFilterTypeDisplay({
1241
+ storageKey,
1242
+ filterTypes,
1243
+ disabledIds: ref(['name']),
1244
+ })
1245
+
1246
+ init()
1247
+ ```
1248
+
1249
+ ### 国际化(i18n)
1250
+
1251
+ 组件库内置了基础国际化能力(默认 `zh-CN`),并支持切换语言、以及由业务侧传入自定义语言包。
1252
+
1253
+ ```ts
1254
+ import { initI18n, setLocale, getLocale, setMessages, getMessages, zhCN, enUS } from 'xdc-ui-lib'
1255
+
1256
+ // 1) 在 app.use(组件库) 前/后都可以初始化(组件库 install 内部也会默认 initI18n)
1257
+ initI18n({
1258
+ locale: 'zh-CN',
1259
+ // messages: 自定义语言包(可选)
1260
+ })
1261
+
1262
+ // 2) 运行时切换语言
1263
+ setLocale('en-US')
1264
+ console.log(getLocale())
1265
+
1266
+ // 3) 覆盖内置语言包(可选)
1267
+ setMessages({
1268
+ ...zhCN,
1269
+ // 按 LocaleMessages 结构补齐/覆盖字段
1270
+ } as any)
1271
+
1272
+ console.log(getMessages())
1273
+ ```
1274
+
1275
+ **可用导出:**
1276
+
1277
+ - `initI18n(options?)`
1278
+ - `setLocale(locale)` / `getLocale()`
1279
+ - `setMessages(messages)` / `getMessages()`
1280
+ - `zhCN` / `enUS` / `messages`
1281
+ - `useI18n()`:组件内部/业务侧均可使用(返回 `t(key)` 等)
1282
+
1283
+ ---
1284
+
1077
1285
  ## 开发
1078
1286
 
1079
1287
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xdc-ui-lib",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "常用组件库",
5
5
  "main": "xdc-ui-lib.js",
6
6
  "module": "xdc-ui-lib.js",