@kne/table-page 0.1.22 → 0.1.23
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 +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +13 -2
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3895,7 +3895,7 @@ render(<BaseExample />);
|
|
|
3895
3895
|
| defaultValue | array | `[]` | 非受控初始筛选值,会合并进首次请求参数 |
|
|
3896
3896
|
| onChange | function | - | 筛选值变化回调 `(value) => void` |
|
|
3897
3897
|
| mapFilterValue | function | - | 自定义参数转换,默认 `getFilterValue` |
|
|
3898
|
-
| searchParamsValue | object | - | 与 `@kne/react-filter` 的 `useSearchParamsValue` **同参** `{ searchParams, setSearchParams?, fields }
|
|
3898
|
+
| searchParamsValue | object | - | 与 `@kne/react-filter` 的 `useSearchParamsValue` **同参** `{ searchParams, setSearchParams?, fields }`。`fields` 项为 `{ name, label, labelKey? }`,可选 `labelKey` 为选中值展示文案的 URL key。同步解析 URL 作初始筛选种子:非受控时 `mergeByName(defaultValue, fromUrl)`(同名 URL 覆盖)并写入 `defaultValue` + 首包参数;受控时不改写 `value`/`onChange`,首包用 `mergeByName(value, fromUrl)`。有 `setSearchParams` 时清理已消费 key(含 labelKey)。勿与外层 `useSearchParamsValue` 同时使用 |
|
|
3899
3899
|
|
|
3900
3900
|
#### search
|
|
3901
3901
|
|
package/dist/index.js
CHANGED
|
@@ -2717,9 +2717,11 @@ const TableToolbar = ({
|
|
|
2717
2717
|
/**
|
|
2718
2718
|
* 与 @kne/react-filter useSearchParamsValue 内部解析保持一致(不从该包导出)。
|
|
2719
2719
|
*
|
|
2720
|
+
* fields 项:`name` 为 URL key;`label` 为筛选项标题;可选 `labelKey` 为选中值展示文案的 URL key。
|
|
2721
|
+
*
|
|
2720
2722
|
* @param {Object} [options]
|
|
2721
2723
|
* @param {URLSearchParams} [options.searchParams]
|
|
2722
|
-
* @param {Array<{ name: string, label?: string }>} [options.fields]
|
|
2724
|
+
* @param {Array<{ name: string, label?: string, labelKey?: string }>} [options.fields]
|
|
2723
2725
|
* @returns {{ items: Array, consumedKeys: string[] }}
|
|
2724
2726
|
*/
|
|
2725
2727
|
const parseSearchParamsValue = ({
|
|
@@ -2744,12 +2746,21 @@ const parseSearchParamsValue = ({
|
|
|
2744
2746
|
return;
|
|
2745
2747
|
}
|
|
2746
2748
|
consumedKeys.push(name);
|
|
2749
|
+
let valueText = raw;
|
|
2750
|
+
const labelKey = field.labelKey;
|
|
2751
|
+
if (labelKey && searchParams.has(labelKey)) {
|
|
2752
|
+
const fromLabelKey = searchParams.get(labelKey);
|
|
2753
|
+
if (fromLabelKey != null && fromLabelKey !== '') {
|
|
2754
|
+
valueText = fromLabelKey;
|
|
2755
|
+
consumedKeys.push(labelKey);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2747
2758
|
const label = field.label != null ? field.label : name;
|
|
2748
2759
|
items.push({
|
|
2749
2760
|
name,
|
|
2750
2761
|
label,
|
|
2751
2762
|
value: {
|
|
2752
|
-
label:
|
|
2763
|
+
label: valueText,
|
|
2753
2764
|
value: raw
|
|
2754
2765
|
}
|
|
2755
2766
|
});
|