@pisell/private-materials 6.11.16 → 6.11.18

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.
@@ -550,6 +550,7 @@ export var useWalletPass = function useWalletPass(props) {
550
550
  title: 'useWalletPass_onOrderCreated onSelectChange 开始调用',
551
551
  metadata: {}
552
552
  });
553
+
553
554
  // 设置默认选中钱包
554
555
  onSelectChange === null || onSelectChange === void 0 || onSelectChange(_select);
555
556
  } else {
@@ -699,6 +700,8 @@ export var useWalletPass = function useWalletPass(props) {
699
700
  wallet_pass_usage_unit: item.wallet_pass_usage_unit,
700
701
  wallet_pass_use_value: item.wallet_pass_use_value
701
702
  };
703
+ }).filter(function (item) {
704
+ return !!item.amount;
702
705
  });
703
706
  logger === null || logger === void 0 || logger.addLog({
704
707
  type: 'info',
@@ -15,7 +15,7 @@ import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, u
15
15
  import ProductSelect from "../../../../plus/productSelect";
16
16
  import List from "../../../list/List";
17
17
  import SkuCard from "../../../../plus/productSelect/ProductCard/SkuCard";
18
- import { formatSkuDataSource, generateProductTabs } from "./utils";
18
+ import { formatSkuDataSource, generateProductTabs, sortProductsByTabOrder } from "./utils";
19
19
  import "./index.less";
20
20
  import { locales } from "@pisell/utils";
21
21
  /**
@@ -135,6 +135,11 @@ var ProductDisplayAdapter = function ProductDisplayAdapter(props, ref) {
135
135
  })) || []
136
136
  });
137
137
  });
138
+
139
+ // 当 isTreeTab 为 false 时,按 tabData 分类顺序排序,再按商品 sort 降序
140
+ if (!isTreeTab && tabData && Array.isArray(tabData)) {
141
+ sortProductsByTabOrder(filteredData, tabData);
142
+ }
138
143
  var emptyText = emptyDescription;
139
144
  if (Array.isArray(activeTab) && activeTab.length === 0 && keyword === '') {
140
145
  emptyText = locales.getText('pisell2.ticket-booking.input-search-to-show-data');
@@ -82,4 +82,13 @@ export interface CategoryTreeNode {
82
82
  * @returns Switch 模式返回 CategoryTreeNode[],Anchor 模式返回 TabItem[]
83
83
  */
84
84
  export declare const generateProductTabs: (products: Product[], tabStyle?: 'switch' | 'anchor', isTreeTab?: boolean) => CategoryTreeNode[] | TabItem[];
85
+ /**
86
+ * 按 tabData 分类顺序对商品列表排序,同分类内按商品 sort 降序
87
+ * 仅在 isTreeTab 为 false 时使用
88
+ *
89
+ * @param data 商品列表(category 已转为 string[] 格式)
90
+ * @param tabData 分类 tab 列表(CategoryTreeNode[])
91
+ * @returns 排序后的商品列表(原地排序)
92
+ */
93
+ export declare const sortProductsByTabOrder: (data: any[], tabData: CategoryTreeNode[]) => any[];
85
94
  export {};
@@ -342,4 +342,36 @@ var buildCategoryTree = function buildCategoryTree(products) {
342
342
  return _toConsumableArray(rootNodes);
343
343
  }
344
344
  return rootNodes;
345
+ };
346
+
347
+ /**
348
+ * 按 tabData 分类顺序对商品列表排序,同分类内按商品 sort 降序
349
+ * 仅在 isTreeTab 为 false 时使用
350
+ *
351
+ * @param data 商品列表(category 已转为 string[] 格式)
352
+ * @param tabData 分类 tab 列表(CategoryTreeNode[])
353
+ * @returns 排序后的商品列表(原地排序)
354
+ */
355
+ export var sortProductsByTabOrder = function sortProductsByTabOrder(data, tabData) {
356
+ var categoryOrderMap = new Map();
357
+ tabData.forEach(function (tab, index) {
358
+ categoryOrderMap.set(String(tab.id), index);
359
+ });
360
+ return data.sort(function (a, b) {
361
+ var _a$category, _b$category, _categoryOrderMap$get, _categoryOrderMap$get2;
362
+ var aIndex = Math.max(Array.isArray(a.category) ? a.category.length - 1 : 0, 0);
363
+ var bIndex = Math.max(Array.isArray(b.category) ? b.category.length - 1 : 0, 0);
364
+ var aCategoryId = (_a$category = a.category) === null || _a$category === void 0 ? void 0 : _a$category[aIndex];
365
+ var bCategoryId = (_b$category = b.category) === null || _b$category === void 0 ? void 0 : _b$category[bIndex];
366
+
367
+ // 按 tabData 分类顺序排序(无分类的排到最后)
368
+ var aOrder = aCategoryId !== undefined ? (_categoryOrderMap$get = categoryOrderMap.get(String(aCategoryId))) !== null && _categoryOrderMap$get !== void 0 ? _categoryOrderMap$get : Infinity : Infinity;
369
+ var bOrder = bCategoryId !== undefined ? (_categoryOrderMap$get2 = categoryOrderMap.get(String(bCategoryId))) !== null && _categoryOrderMap$get2 !== void 0 ? _categoryOrderMap$get2 : Infinity : Infinity;
370
+ if (aOrder !== bOrder) {
371
+ return aOrder - bOrder;
372
+ }
373
+
374
+ // 同分类内按商品 sort 降序(越大越前)
375
+ return (b.sort || 0) - (a.sort || 0);
376
+ });
345
377
  };
@@ -494,7 +494,7 @@ var useWalletPass = (props) => {
494
494
  code: item.tag,
495
495
  wallet_pass_usage_unit: item.wallet_pass_usage_unit,
496
496
  wallet_pass_use_value: item.wallet_pass_use_value
497
- }));
497
+ })).filter((item) => !!item.amount);
498
498
  logger == null ? void 0 : logger.addLog({
499
499
  type: "info",
500
500
  title: "useWalletPass_notifySelectChange 通知外部选择变化",
@@ -135,6 +135,9 @@ var ProductDisplayAdapter = (props, ref) => {
135
135
  category: ((_b = (_a = item.category) == null ? void 0 : _a.map) == null ? void 0 : _b.call(_a, (category) => `${category.id}`)) || []
136
136
  };
137
137
  });
138
+ if (!isTreeTab && tabData && Array.isArray(tabData)) {
139
+ (0, import_utils.sortProductsByTabOrder)(filteredData, tabData);
140
+ }
138
141
  let emptyText = emptyDescription;
139
142
  if (Array.isArray(activeTab) && activeTab.length === 0 && keyword === "") {
140
143
  emptyText = import_utils2.locales.getText("pisell2.ticket-booking.input-search-to-show-data");
@@ -82,4 +82,13 @@ export interface CategoryTreeNode {
82
82
  * @returns Switch 模式返回 CategoryTreeNode[],Anchor 模式返回 TabItem[]
83
83
  */
84
84
  export declare const generateProductTabs: (products: Product[], tabStyle?: 'switch' | 'anchor', isTreeTab?: boolean) => CategoryTreeNode[] | TabItem[];
85
+ /**
86
+ * 按 tabData 分类顺序对商品列表排序,同分类内按商品 sort 降序
87
+ * 仅在 isTreeTab 为 false 时使用
88
+ *
89
+ * @param data 商品列表(category 已转为 string[] 格式)
90
+ * @param tabData 分类 tab 列表(CategoryTreeNode[])
91
+ * @returns 排序后的商品列表(原地排序)
92
+ */
93
+ export declare const sortProductsByTabOrder: (data: any[], tabData: CategoryTreeNode[]) => any[];
85
94
  export {};
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
32
  formatSkuDataSource: () => formatSkuDataSource,
33
- generateProductTabs: () => generateProductTabs
33
+ generateProductTabs: () => generateProductTabs,
34
+ sortProductsByTabOrder: () => sortProductsByTabOrder
34
35
  });
35
36
  module.exports = __toCommonJS(utils_exports);
36
37
  var import_utils = require("@pisell/utils");
@@ -245,8 +246,28 @@ var buildCategoryTree = (products) => {
245
246
  }
246
247
  return rootNodes;
247
248
  };
249
+ var sortProductsByTabOrder = (data, tabData) => {
250
+ const categoryOrderMap = /* @__PURE__ */ new Map();
251
+ tabData.forEach((tab, index) => {
252
+ categoryOrderMap.set(String(tab.id), index);
253
+ });
254
+ return data.sort((a, b) => {
255
+ var _a, _b;
256
+ const aIndex = Math.max(Array.isArray(a.category) ? a.category.length - 1 : 0, 0);
257
+ const bIndex = Math.max(Array.isArray(b.category) ? b.category.length - 1 : 0, 0);
258
+ const aCategoryId = (_a = a.category) == null ? void 0 : _a[aIndex];
259
+ const bCategoryId = (_b = b.category) == null ? void 0 : _b[bIndex];
260
+ const aOrder = aCategoryId !== void 0 ? categoryOrderMap.get(String(aCategoryId)) ?? Infinity : Infinity;
261
+ const bOrder = bCategoryId !== void 0 ? categoryOrderMap.get(String(bCategoryId)) ?? Infinity : Infinity;
262
+ if (aOrder !== bOrder) {
263
+ return aOrder - bOrder;
264
+ }
265
+ return (b.sort || 0) - (a.sort || 0);
266
+ });
267
+ };
248
268
  // Annotate the CommonJS export names for ESM import in node:
249
269
  0 && (module.exports = {
250
270
  formatSkuDataSource,
251
- generateProductTabs
271
+ generateProductTabs,
272
+ sortProductsByTabOrder
252
273
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.11.16",
3
+ "version": "6.11.18",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -68,8 +68,8 @@
68
68
  "react-resizable": "^3.0.5",
69
69
  "styled-components": "^6.0.0-rc.3",
70
70
  "@pisell/utils": "3.0.2",
71
- "@pisell/icon": "0.0.11",
72
71
  "@pisell/materials": "6.11.6",
72
+ "@pisell/icon": "0.0.11",
73
73
  "@pisell/date-picker": "3.0.8"
74
74
  },
75
75
  "peerDependencies": {