zzz-pc-view 0.0.89 → 0.0.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zzz-pc-view",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "main": "src/index.umd.js",
5
5
  "module": "src/index.es.js",
6
6
  "types": "src/index.d.ts",
package/src/index.es.js CHANGED
@@ -1926,20 +1926,28 @@ const selectCtrlByAll = (param) => {
1926
1926
  };
1927
1927
  const selectCtrlByInvert = (param) => {
1928
1928
  const { keyProp, selected, defaultBoolean } = param;
1929
- return param.toMap ? param.list.reduce(
1930
- (map2, item) => {
1931
- const key2 = item[keyProp];
1932
- map2[key2] = Object.prototype.hasOwnProperty.call(selected, key2) ? !selected[key2] : defaultBoolean;
1933
- return map2;
1934
- },
1935
- {}
1936
- ) : param.list.reduce((list2, item) => {
1937
- const key2 = item[keyProp];
1938
- if (Object.prototype.hasOwnProperty.call(selected, key2) ? !selected[key2] : defaultBoolean) {
1939
- list2.push(key2);
1940
- }
1941
- return list2;
1942
- }, []);
1929
+ return (
1930
+ // 根据 toMap 的值选择不同的处理方式
1931
+ param.toMap ? param.list.reduce(
1932
+ // 将列表转换为映射对象,反转每个元素的选择状态
1933
+ (map2, item) => {
1934
+ const key2 = item[keyProp];
1935
+ map2[key2] = Object.prototype.hasOwnProperty.call(selected, key2) ? !selected[key2] : defaultBoolean;
1936
+ return map2;
1937
+ },
1938
+ {}
1939
+ ) : param.list.reduce(
1940
+ // 将列表转换为数组,只包含反转后选择状态为 true 的元素
1941
+ (list2, item) => {
1942
+ const key2 = item[keyProp];
1943
+ if (Object.prototype.hasOwnProperty.call(selected, key2) ? !selected[key2] : defaultBoolean) {
1944
+ list2.push(key2);
1945
+ }
1946
+ return list2;
1947
+ },
1948
+ []
1949
+ )
1950
+ );
1943
1951
  };
1944
1952
  const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1945
1953
  __proto__: null,
@@ -1,10 +1,44 @@
1
1
  import { KeyMatch, KeyValType } from '../DeclareType';
2
+ /**
3
+ * 定义 `selectCtrl` 系列函数的返回类型。
4
+ * 根据泛型参数 `M` 的值,决定返回一个映射对象或者一个值数组。
5
+ *
6
+ * @template M - 可选的布尔类型,用于指示是否将结果转换为映射对象,可为 `undefined`。
7
+ * @returns 如果 `M` 为 `true`,返回以 `KeyValType` 为键、布尔值为值的映射对象;
8
+ * 否则,返回 `KeyValType` 类型的数组。
9
+ */
2
10
  export type SelectCtrlResponse<M extends undefined | boolean> = M extends true ? Record<KeyValType, boolean> : KeyValType[];
11
+ /**
12
+ * 根据给定列表,选择所有元素并根据配置返回结果。
13
+ * 可以选择将列表元素的特定属性提取出来,也可以将结果转换为映射对象。
14
+ *
15
+ * @template T - 输入列表中元素的类型。
16
+ * @template M - 可选的布尔类型,用于指示是否将结果转换为映射对象,可为 `undefined`。
17
+ * @param param - 包含操作所需参数的对象。
18
+ * @param param.list - 输入的元素列表。
19
+ * @param param.keyProp - 用于从列表元素中提取特定属性的键。
20
+ * @param param.toMap - 可选的布尔值,指示是否将结果转换为映射对象。
21
+ * @returns 根据 `M` 的值,返回 `KeyValType` 类型的数组或者以 `KeyValType` 为键、布尔值为值的映射对象。
22
+ */
3
23
  export declare const selectCtrlByAll: <T, M extends undefined | boolean>(param: {
4
24
  list: T[];
5
25
  keyProp: KeyMatch<T, KeyValType>;
6
26
  toMap?: M;
7
27
  }) => SelectCtrlResponse<M>;
28
+ /**
29
+ * 根据给定列表和已选状态,反转选择状态并根据配置返回结果。
30
+ * 可以选择将列表元素的特定属性提取出来,也可以将结果转换为映射对象。
31
+ *
32
+ * @template T - 输入列表中元素的类型。
33
+ * @template M - 可选的布尔类型,用于指示是否将结果转换为映射对象,可为 `undefined`。
34
+ * @param param - 包含操作所需参数的对象。
35
+ * @param param.list - 输入的元素列表。
36
+ * @param param.keyProp - 用于从列表元素中提取特定属性的键。
37
+ * @param param.toMap - 可选的布尔值,指示是否将结果转换为映射对象。
38
+ * @param param.selected - 已选状态的映射对象,键为 `KeyValType`,值为布尔值。
39
+ * @param param.defaultBoolean - 当元素不在 `selected` 中时的默认选择状态。
40
+ * @returns 根据 `M` 的值,返回 `KeyValType` 类型的数组或者以 `KeyValType` 为键、布尔值为值的映射对象。
41
+ */
8
42
  export declare const selectCtrlByInvert: <T, M extends undefined | boolean>(param: {
9
43
  list: T[];
10
44
  keyProp: KeyMatch<T, KeyValType>;