@amaoaaaaa/search-table 0.2.2 → 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/README.md CHANGED
@@ -135,11 +135,74 @@ const columns = [{ label: '姓名', prop: 'name' }];
135
135
  | `getSelectionRows` | `() => TableRow[]` | 获取已勾选的行 |
136
136
  | `selectRows` | `(rows: TableRow[]) => void` | 勾选指定行 |
137
137
 
138
+ ### SearchTable 样式定制
139
+
140
+ 组件内部按 BEM 规范预留了类名,块名为 `search-table`,可在外层通过 `:deep()` 覆盖样式:
141
+
142
+ ```vue
143
+ <template>
144
+ <SearchTable class="my-search-table" :columns="columns" :fetch-fn="fetchData" />
145
+ </template>
146
+
147
+ <style scoped>
148
+ .my-search-table :deep(.search-table__search-button) {
149
+ border-radius: 9999px;
150
+ }
151
+ </style>
152
+ ```
153
+
154
+ | 类名 | 说明 |
155
+ | -------------------------------------- | ------------------------------------------ |
156
+ | `search-table` | 根容器 |
157
+ | `search-table__toolbar` | 顶部区域(搜索区 + 操作区) |
158
+ | `search-table__search` | 左侧搜索组(搜索框 + 搜索表单 + 搜索按钮) |
159
+ | `search-table__search-input` | 搜索输入框 |
160
+ | `search-table__search-button` | 搜索按钮 |
161
+ | `search-table__actions` | 右侧操作按钮组(新增 / 批量删除 / 插槽) |
162
+ | `search-table__add-button` | 新增按钮 |
163
+ | `search-table__batch-delete-button` | 批量删除按钮 |
164
+ | `search-table__body` | 表格区域(ProTable 根节点) |
165
+ | `search-table__footer` | 底部分页区域 |
166
+ | `search-table__selection` | 已选条数提示区域 |
167
+ | `search-table__clear-selection-button` | 清空勾选按钮 |
168
+ | `search-table__pagination` | 分页组件 |
169
+ | `search-table__footer-spacer` | 分页区域右侧占位(用于保持分页居中) |
170
+
171
+ ### SearchTableConfigProvider 全局配置
172
+
173
+ 组件默认按 element-plus 表格的默认尺寸(表头 40px、每行 40px)计算每页条数。
174
+ 如果业务中修改了表格样式,可用 `SearchTableConfigProvider` 统一覆盖,避免分页行数计算错误。
175
+ 该组件只提供配置、不渲染额外 DOM,用法类似 `ElConfigProvider`:
176
+
177
+ ```vue
178
+ <template>
179
+ <SearchTableConfigProvider row-height="48" header-height="56px">
180
+ <SearchTable :columns="columns" :fetch-fn="fetchData" />
181
+ </SearchTableConfigProvider>
182
+ </template>
183
+
184
+ <script setup lang="ts">
185
+ import { SearchTable, SearchTableConfigProvider } from '@amaoaaaaa/search-table';
186
+ </script>
187
+ ```
188
+
189
+ | 属性 | 类型 | 默认值 | 说明 |
190
+ | -------------- | ------------------ | ------ | -------------------------------- |
191
+ | `rowHeight` | `number \| string` | `40` | 表格行高(px),用于计算每页条数 |
192
+ | `headerHeight` | `number \| string` | `40` | 表头高度(px),用于计算每页条数 |
193
+
194
+ 取值规则:
195
+
196
+ - 支持数字或字符串,字符串只提取前导数字并忽略单位:`48`、`'48'`、`'48px'`、`' 48.5px '` 均可用,`'3rem'` 会被当成 `3`(不做单位换算)。
197
+ - 解析结果四舍五入为整数:`'48.5px'` 为 `49`,`'48.4'` 为 `48`。
198
+ - 无法解析或非正数(如 `'abc'`、`''`、`0`、`Infinity`)会回退默认值 `40`。
199
+ - 只影响未显式传入 `pageSize` 的实例;配置在实例挂载时读取一次,运行中修改 props 不会让已挂载实例重新计算。
200
+
138
201
  ## 导出清单
139
202
 
140
- **组件:** `SearchTable`, `ProTable`
203
+ **组件:** `SearchTable`, `SearchTableConfigProvider`, `ProTable`
141
204
 
142
- **类型:** `SearchTableProps`, `SearchTableFetchFn`, `PageParams`, `PageResp`, `ProTableProps`, `ProTableColumn`, `ProTableAction`, `TableRow`, `ApplyFilterPayload`, `CellEditPayload`, `SortState`, `ProTableInstance`
205
+ **类型:** `SearchTableProps`, `SearchTableFetchFn`, `PageParams`, `PageResp`, `SearchTableConfigProviderProps`, `ProTableProps`, `ProTableColumn`, `ProTableAction`, `TableRow`, `ApplyFilterPayload`, `CellEditPayload`, `SortState`, `ProTableInstance`
143
206
 
144
207
  **工具:** `SelectionStore`, `useTableSort`, `useDelayedRef`, `parseErrorReason`
145
208
 
@@ -0,0 +1,21 @@
1
+ import { SearchTableConfigProviderProps } from './config';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ default?(_: {}): any;
6
+ };
7
+ refs: {};
8
+ rootEl: any;
9
+ };
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
+ declare const __VLS_component: import('vue').DefineComponent<SearchTableConfigProviderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SearchTableConfigProviderProps> & Readonly<{}>, {
12
+ rowHeight: number | string;
13
+ headerHeight: number | string;
14
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
+ export default _default;
17
+ type __VLS_WithTemplateSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -0,0 +1,46 @@
1
+ import { InjectionKey } from 'vue';
2
+ /**
3
+ * SearchTableConfigProvider 的配置项
4
+ */
5
+ export interface SearchTableConfigProviderProps {
6
+ /**
7
+ * 表格行高,用于计算每页条数
8
+ *
9
+ * 支持数字或字符串(如 `48`、`'48px'`),单位会被忽略
10
+ *
11
+ * @default 40
12
+ */
13
+ rowHeight?: number | string;
14
+ /**
15
+ * 表头高度,用于计算每页条数
16
+ *
17
+ * 支持数字或字符串(如 `48`、`'48px'`),单位会被忽略
18
+ *
19
+ * @default 40
20
+ */
21
+ headerHeight?: number | string;
22
+ }
23
+ /**
24
+ * 解析后的高度配置
25
+ */
26
+ export interface SearchTableHeightConfig {
27
+ /** 表格行高,正整数 */
28
+ rowHeight: number;
29
+ /** 表头高度,正整数 */
30
+ headerHeight: number;
31
+ }
32
+ /**
33
+ * 默认高度配置,与 element-plus 表格默认样式保持一致
34
+ */
35
+ export declare const DEFAULT_SEARCH_TABLE_HEIGHT_CONFIG: SearchTableHeightConfig;
36
+ /**
37
+ * 解析高度配置
38
+ *
39
+ * @param config 原始配置
40
+ * @returns 解析后的正整数高度配置
41
+ */
42
+ export declare function resolveHeightConfig(config?: SearchTableConfigProviderProps): SearchTableHeightConfig;
43
+ /**
44
+ * 高度配置的注入 key,由 SearchTableConfigProvider 提供、SearchTable 读取
45
+ */
46
+ export declare const searchTableConfigKey: InjectionKey<SearchTableHeightConfig>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as SearchTable } from './SearchTable/index.vue';
2
+ export { default as SearchTableConfigProvider } from './SearchTable/ConfigProvider.vue';
2
3
  export { default as ProTable } from './ProTable/index.vue';
3
4
  export type { ProTableInstance } from './ProTable';
4
5
  export type { SearchTableProps, SearchTableFetchFn, PageParams, PageResp, } from './SearchTable/types';
5
6
  export type { SearchTableInstance } from './SearchTable';
7
+ export type { SearchTableConfigProviderProps } from './SearchTable/config';
6
8
  export type { ProTableProps, ProTableColumn, ProTableAction, TableRow, FilterOption, FilterType, ActionButtonVisibility, ApplyFilterPayload, CellEditPayload, ProTableColumn as SearchTableColumn, ProTableAction as SearchTableAction, } from './ProTable/types';