@pisell/materials 6.11.239 → 6.11.240

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.
@@ -5,6 +5,8 @@ export declare type PisellTabbarTemplate1Direction = 'horizontal' | 'vertical';
5
5
  export interface PisellTabbarTemplate1Props extends PisellTabbarProps {
6
6
  /** Tab 排列方向;默认保持现有横向布局。 */
7
7
  direction?: PisellTabbarTemplate1Direction;
8
+ /** 是否在每个层级展示自动生成的 All 分类;默认保持展示。 */
9
+ showAllItem?: boolean;
8
10
  }
9
11
  declare const _default: React.ForwardRefExoticComponent<PisellTabbarTemplate1Props & React.RefAttributes<unknown>>;
10
12
  export default _default;
@@ -16,7 +16,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
16
16
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  import classNames from 'classnames';
19
- import React, { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
19
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
20
20
  import PisellCards from "../../../PisellCards";
21
21
  import SuperTabs from "../../../PisellSuperTabs";
22
22
  import Iconfont from "../../../iconfont";
@@ -26,6 +26,11 @@ import { useActiveKey, useExpand } from "../../hooks";
26
26
  import mock from "../../mock";
27
27
  import { DEFAULT_LEVEL_CONFIG, LEVEL_ADD_ITEMS, getExpandConfig } from "./constants";
28
28
  import { addDataSourceItemsByKey, getDefaultActiveKey } from "./utils";
29
+ var tabbarInstanceSequence = 0;
30
+ function createTabbarInstanceId() {
31
+ tabbarInstanceSequence += 1;
32
+ return "sku-list-tabbar-temp1-".concat(tabbarInstanceSequence);
33
+ }
29
34
  function renderCategoryIcon(icon, size) {
30
35
  if (/^(?:https?:\/\/|data:|blob:|\/)/i.test(icon)) {
31
36
  return /*#__PURE__*/React.createElement("img", {
@@ -63,6 +68,7 @@ function renderCategoryIcon(icon, size) {
63
68
  * ```
64
69
  */
65
70
  var PisellTabbar = function PisellTabbar(props, ref) {
71
+ var _dataSource$0$id, _dataSource$, _dataSource$2;
66
72
  var _props$dataSource = props.dataSource,
67
73
  dataSource = _props$dataSource === void 0 ? props !== null && props !== void 0 && props.__designMode ? mock : mock : _props$dataSource,
68
74
  value = props.value,
@@ -77,10 +83,14 @@ var PisellTabbar = function PisellTabbar(props, ref) {
77
83
  searchProps = props.searchProps,
78
84
  level1Actions = props.level1Actions,
79
85
  _props$direction = props.direction,
80
- direction = _props$direction === void 0 ? 'horizontal' : _props$direction;
86
+ direction = _props$direction === void 0 ? 'horizontal' : _props$direction,
87
+ _props$showAllItem = props.showAllItem,
88
+ showAllItem = _props$showAllItem === void 0 ? true : _props$showAllItem;
81
89
  var isVertical = direction === 'vertical';
82
90
  var containerRef = useRef(null);
83
91
  var searchRef = useRef(null);
92
+ var firstCategoryKey = (_dataSource$0$id = (_dataSource$ = dataSource[0]) === null || _dataSource$ === void 0 ? void 0 : _dataSource$.id) !== null && _dataSource$0$id !== void 0 ? _dataSource$0$id : (_dataSource$2 = dataSource[0]) === null || _dataSource$2 === void 0 ? void 0 : _dataSource$2.key;
93
+ var initialActiveKey = value !== null && value !== void 0 ? value : showAllItem ? getDefaultActiveKey(dataSource, 'id') : firstCategoryKey !== undefined ? [firstCategoryKey] : [];
84
94
 
85
95
  /**
86
96
  * 每个 PisellTabbarTemplate1 实例使用独立的 DOM id(保留历史前缀),
@@ -89,17 +99,18 @@ var PisellTabbar = function PisellTabbar(props, ref) {
89
99
  * 命中错误那一个:PisellFind 的搜索弹窗 portal 会挂到隐藏节点 → 看似"无反应",
90
100
  * 二级 panel 的 portalContainer 也会渲染到错误位置。
91
101
  *
92
- * 使用 `useId()` 保证 SSR 一致并避免 hydration 失配;冒号在 id selector 里
93
- * 不合法,统一替换。
102
+ * Kiosk 低代码渲染只需要客户端实例唯一性;用 ref 保持挂载周期内稳定,
103
+ * 同时兼容 React 17(没有 `useId`)。
94
104
  */
95
- var reactId = useId();
96
- var tabbarId = useMemo(function () {
97
- return "sku-list-tabbar-temp1-".concat(reactId.replace(/:/g, ''));
98
- }, [reactId]);
105
+ var tabbarIdRef = useRef();
106
+ if (!tabbarIdRef.current) {
107
+ tabbarIdRef.current = createTabbarInstanceId();
108
+ }
109
+ var tabbarId = tabbarIdRef.current;
99
110
 
100
111
  // 激活的 key 管理
101
112
  var _useActiveKey = useActiveKey({
102
- initialActiveKey: value || getDefaultActiveKey(dataSource, 'id'),
113
+ initialActiveKey: initialActiveKey,
103
114
  onChange: onChange
104
115
  }),
105
116
  setActiveKey = _useActiveKey.setActiveKey,
@@ -188,16 +199,16 @@ var PisellTabbar = function PisellTabbar(props, ref) {
188
199
  */
189
200
  var handleLevel1Change = useCallback(function (key, item) {
190
201
  var _item$children;
191
- setActiveKey(0, key, item !== null && item !== void 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length ? 0 : undefined);
192
- }, [setActiveKey, activeKey]);
202
+ setActiveKey(0, key, showAllItem && item !== null && item !== void 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length ? 0 : undefined);
203
+ }, [setActiveKey, activeKey, showAllItem]);
193
204
 
194
205
  /**
195
206
  * 处理二级 Tab 切换
196
207
  */
197
208
  var handleLevel2Change = useCallback(function (key, item) {
198
209
  var _item$children2;
199
- setActiveKey(1, key, item !== null && item !== void 0 && (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length ? 0 : undefined);
200
- }, [setActiveKey, activeKey]);
210
+ setActiveKey(1, key, showAllItem && item !== null && item !== void 0 && (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length ? 0 : undefined);
211
+ }, [setActiveKey, activeKey, showAllItem]);
201
212
 
202
213
  /**
203
214
  * 处理三级 Tab 切换
@@ -304,7 +315,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
304
315
  * 渲染 level2/level3 普通卡片
305
316
  */
306
317
  var renderNormalCard = useCallback(function (cardProps, level) {
307
- var _levelCfg$textAlign, _levelCfg$iconSize, _levelCfg$borderRadiu, _cardProps$active2;
318
+ var _levelCfg$textAlign, _levelCfg$iconSize, _levelCfg$borderRadiu, _levelCfg$cardBackgro, _cardProps$active2, _levelCfg$activeBackg;
308
319
  var itemData = cardProps.dataSource;
309
320
  var levelCfg = getLevelConfig(level);
310
321
  var textAlign = isVertical ? (_levelCfg$textAlign = levelCfg.textAlign) !== null && _levelCfg$textAlign !== void 0 ? _levelCfg$textAlign : 'center' : 'center';
@@ -327,7 +338,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
327
338
  height: levelCfg.cardHeight
328
339
  }), {}, {
329
340
  borderRadius: isVertical ? (_levelCfg$borderRadiu = levelCfg.borderRadius) !== null && _levelCfg$borderRadiu !== void 0 ? _levelCfg$borderRadiu : '999px' : '20px',
330
- background: '#ffffff',
341
+ background: (_levelCfg$cardBackgro = levelCfg.cardBackground) !== null && _levelCfg$cardBackgro !== void 0 ? _levelCfg$cardBackgro : '#ffffff',
331
342
  minWidth: isVertical ? 0 : 100,
332
343
  justifyContent: isVertical && textAlign === 'left' ? 'flex-start' : 'center'
333
344
  }),
@@ -335,7 +346,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
335
346
  active: _objectSpread(_objectSpread({}, cardProps.active), {}, {
336
347
  style: _objectSpread(_objectSpread({}, (_cardProps$active2 = cardProps.active) === null || _cardProps$active2 === void 0 ? void 0 : _cardProps$active2.style), {}, {
337
348
  color: '#fff',
338
- background: '#7f56d9'
349
+ background: (_levelCfg$activeBackg = levelCfg.activeBackground) !== null && _levelCfg$activeBackg !== void 0 ? _levelCfg$activeBackg : '#7f56d9'
339
350
  })
340
351
  })
341
352
  }));
@@ -345,7 +356,9 @@ var PisellTabbar = function PisellTabbar(props, ref) {
345
356
  * 一级 Tabbar 数据源
346
357
  */
347
358
  var level1DataSource = useMemo(function () {
348
- var categoryItems = dataSource.length ? addDataSourceItemsByKey(dataSource, LEVEL_ADD_ITEMS.level1) : [];
359
+ var categoryItems = dataSource.length ? addDataSourceItemsByKey(dataSource, LEVEL_ADD_ITEMS.level1.filter(function (itemKey) {
360
+ return showAllItem || itemKey !== 'all';
361
+ })) : [];
349
362
  var actionItems = (level1Actions || []).map(function (action, index) {
350
363
  return {
351
364
  id: "__level1-action-".concat(String(action.key), "-").concat(index),
@@ -365,12 +378,13 @@ var PisellTabbar = function PisellTabbar(props, ref) {
365
378
  return isVertical ? full.filter(function (item) {
366
379
  return (item === null || item === void 0 ? void 0 : item.key) !== 'expand';
367
380
  }) : full;
368
- }, [dataSource, isSearchOpen, isVertical, level1Actions]);
381
+ }, [dataSource, isSearchOpen, isVertical, level1Actions, showAllItem]);
369
382
 
370
383
  /**
371
384
  * 渲染一级 Tab Item
372
385
  */
373
386
  var renderLevel1Item = useCallback(function (itemProps) {
387
+ var _itemData$children;
374
388
  var itemData = itemProps.dataSource;
375
389
  var isExpanded = getExpand('level1');
376
390
  var action = itemData === null || itemData === void 0 ? void 0 : itemData.__action;
@@ -405,6 +419,9 @@ var PisellTabbar = function PisellTabbar(props, ref) {
405
419
 
406
420
  // 普通项
407
421
  return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
422
+ className: classNames(itemProps.className, {
423
+ 'pisell-tabbar__category-group--level1': isVertical && (itemData === null || itemData === void 0 || (_itemData$children = itemData.children) === null || _itemData$children === void 0 ? void 0 : _itemData$children.length)
424
+ }),
408
425
  card: function card(cardProps) {
409
426
  return renderNormalCard(cardProps, 'level1');
410
427
  },
@@ -429,7 +446,9 @@ var PisellTabbar = function PisellTabbar(props, ref) {
429
446
  if (maxLevel < 2) return null;
430
447
  var _dataSource = panelProps.dataSource.children || [];
431
448
  if (_dataSource.length) {
432
- _dataSource = addDataSourceItemsByKey(_dataSource, LEVEL_ADD_ITEMS.level2);
449
+ _dataSource = addDataSourceItemsByKey(_dataSource, LEVEL_ADD_ITEMS.level2.filter(function (itemKey) {
450
+ return showAllItem || itemKey !== 'all';
451
+ }));
433
452
  if (isVertical) {
434
453
  _dataSource = _dataSource.filter(function (item) {
435
454
  return item.key !== 'expand';
@@ -486,6 +505,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
486
505
  }
487
506
  },
488
507
  renderItem: function renderItem(itemProps) {
508
+ var _itemData$children2;
489
509
  var itemData = itemProps.dataSource;
490
510
 
491
511
  // 处理展开按钮
@@ -502,6 +522,9 @@ var PisellTabbar = function PisellTabbar(props, ref) {
502
522
 
503
523
  // 普通项
504
524
  return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
525
+ className: classNames(itemProps.className, {
526
+ 'pisell-tabbar__category-group--level2': isVertical && (itemData === null || itemData === void 0 || (_itemData$children2 = itemData.children) === null || _itemData$children2 === void 0 ? void 0 : _itemData$children2.length)
527
+ }),
505
528
  card: function card(cardProps) {
506
529
  return renderNormalCard(cardProps, 'level2');
507
530
  },
@@ -519,7 +542,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
519
542
  }));
520
543
  }
521
544
  });
522
- }, [level2Value, maxLevel, activeKey, getActiveKey, handleLevel2Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard, direction, isVertical]);
545
+ }, [level2Value, maxLevel, activeKey, getActiveKey, handleLevel2Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard, showAllItem, direction, isVertical]);
523
546
 
524
547
  /**
525
548
  * 渲染三级 Tabbar 面板
@@ -528,7 +551,9 @@ var PisellTabbar = function PisellTabbar(props, ref) {
528
551
  if (maxLevel < 3) return null;
529
552
  var _dataSource2 = panelProps2.dataSource.children || [];
530
553
  if (_dataSource2.length) {
531
- _dataSource2 = addDataSourceItemsByKey(_dataSource2, LEVEL_ADD_ITEMS.level3);
554
+ _dataSource2 = addDataSourceItemsByKey(_dataSource2, LEVEL_ADD_ITEMS.level3.filter(function (itemKey) {
555
+ return showAllItem || itemKey !== 'all';
556
+ }));
532
557
  if (isVertical) {
533
558
  _dataSource2 = _dataSource2.filter(function (item) {
534
559
  return item.key !== 'expand';
@@ -607,7 +632,7 @@ var PisellTabbar = function PisellTabbar(props, ref) {
607
632
  }));
608
633
  }
609
634
  });
610
- }, [level3Value, maxLevel, activeKey, getActiveKey, handleLevel3Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard, direction, isVertical]);
635
+ }, [level3Value, maxLevel, activeKey, getActiveKey, handleLevel3Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard, showAllItem, direction, isVertical]);
611
636
 
612
637
  /**
613
638
  * 渲染一级 Tabbar
@@ -49,6 +49,10 @@ export interface TabbarLevelConfig {
49
49
  cardWidth: number;
50
50
  /** 卡片高度 */
51
51
  cardHeight: number;
52
+ /** 卡片背景色;未传时使用模板默认白色 */
53
+ cardBackground?: string;
54
+ /** 卡片选中背景色;未传时使用模板默认紫色 */
55
+ activeBackground?: string;
52
56
  /** 左侧缩进 */
53
57
  paddingLeft?: number;
54
58
  /** 卡片圆角;未传时使用模板默认值 */
@@ -5,6 +5,8 @@ export declare type PisellTabbarTemplate1Direction = 'horizontal' | 'vertical';
5
5
  export interface PisellTabbarTemplate1Props extends PisellTabbarProps {
6
6
  /** Tab 排列方向;默认保持现有横向布局。 */
7
7
  direction?: PisellTabbarTemplate1Direction;
8
+ /** 是否在每个层级展示自动生成的 All 分类;默认保持展示。 */
9
+ showAllItem?: boolean;
8
10
  }
9
11
  declare const _default: React.ForwardRefExoticComponent<PisellTabbarTemplate1Props & React.RefAttributes<unknown>>;
10
12
  export default _default;
@@ -43,6 +43,11 @@ var import_hooks = require("../../hooks");
43
43
  var import_mock = __toESM(require("../../mock"));
44
44
  var import_constants = require("./constants");
45
45
  var import_utils = require("./utils");
46
+ var tabbarInstanceSequence = 0;
47
+ function createTabbarInstanceId() {
48
+ tabbarInstanceSequence += 1;
49
+ return `sku-list-tabbar-temp1-${tabbarInstanceSequence}`;
50
+ }
46
51
  function renderCategoryIcon(icon, size) {
47
52
  if (/^(?:https?:\/\/|data:|blob:|\/)/i.test(icon)) {
48
53
  return /* @__PURE__ */ import_react.default.createElement(
@@ -62,6 +67,7 @@ function renderCategoryIcon(icon, size) {
62
67
  return /* @__PURE__ */ import_react.default.createElement(import_iconfont.default, { type: icon, style: { fontSize: size } });
63
68
  }
64
69
  var PisellTabbar = (props, ref) => {
70
+ var _a, _b;
65
71
  const {
66
72
  dataSource = (props == null ? void 0 : props.__designMode) ? import_mock.default : import_mock.default,
67
73
  value,
@@ -74,16 +80,19 @@ var PisellTabbar = (props, ref) => {
74
80
  onSearch,
75
81
  searchProps,
76
82
  level1Actions,
77
- direction = "horizontal"
83
+ direction = "horizontal",
84
+ showAllItem = true
78
85
  } = props;
79
86
  const isVertical = direction === "vertical";
80
87
  const containerRef = (0, import_react.useRef)(null);
81
88
  const searchRef = (0, import_react.useRef)(null);
82
- const reactId = (0, import_react.useId)();
83
- const tabbarId = (0, import_react.useMemo)(
84
- () => `sku-list-tabbar-temp1-${reactId.replace(/:/g, "")}`,
85
- [reactId]
86
- );
89
+ const firstCategoryKey = ((_a = dataSource[0]) == null ? void 0 : _a.id) ?? ((_b = dataSource[0]) == null ? void 0 : _b.key);
90
+ const initialActiveKey = value ?? (showAllItem ? (0, import_utils.getDefaultActiveKey)(dataSource, "id") : firstCategoryKey !== void 0 ? [firstCategoryKey] : []);
91
+ const tabbarIdRef = (0, import_react.useRef)();
92
+ if (!tabbarIdRef.current) {
93
+ tabbarIdRef.current = createTabbarInstanceId();
94
+ }
95
+ const tabbarId = tabbarIdRef.current;
87
96
  const {
88
97
  setActiveKey,
89
98
  getActiveKey,
@@ -92,7 +101,7 @@ var PisellTabbar = (props, ref) => {
92
101
  setCacheActiveKey,
93
102
  resetActiveKey
94
103
  } = (0, import_hooks.useActiveKey)({
95
- initialActiveKey: value || (0, import_utils.getDefaultActiveKey)(dataSource, "id"),
104
+ initialActiveKey,
96
105
  onChange
97
106
  });
98
107
  const { expand, toggleExpand, getExpand } = (0, import_hooks.useExpand)();
@@ -124,8 +133,8 @@ var PisellTabbar = (props, ref) => {
124
133
  }
125
134
  return {
126
135
  closeSearchMode: () => {
127
- var _a;
128
- return (_a = searchRef.current) == null ? void 0 : _a.close();
136
+ var _a2;
137
+ return (_a2 = searchRef.current) == null ? void 0 : _a2.close();
129
138
  }
130
139
  };
131
140
  });
@@ -145,17 +154,25 @@ var PisellTabbar = (props, ref) => {
145
154
  );
146
155
  const handleLevel1Change = (0, import_react.useCallback)(
147
156
  (key, item) => {
148
- var _a;
149
- setActiveKey(0, key, ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) ? 0 : void 0);
157
+ var _a2;
158
+ setActiveKey(
159
+ 0,
160
+ key,
161
+ showAllItem && ((_a2 = item == null ? void 0 : item.children) == null ? void 0 : _a2.length) ? 0 : void 0
162
+ );
150
163
  },
151
- [setActiveKey, activeKey]
164
+ [setActiveKey, activeKey, showAllItem]
152
165
  );
153
166
  const handleLevel2Change = (0, import_react.useCallback)(
154
167
  (key, item) => {
155
- var _a;
156
- setActiveKey(1, key, ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) ? 0 : void 0);
168
+ var _a2;
169
+ setActiveKey(
170
+ 1,
171
+ key,
172
+ showAllItem && ((_a2 = item == null ? void 0 : item.children) == null ? void 0 : _a2.length) ? 0 : void 0
173
+ );
157
174
  },
158
- [setActiveKey, activeKey]
175
+ [setActiveKey, activeKey, showAllItem]
159
176
  );
160
177
  const handleLevel3Change = (0, import_react.useCallback)(
161
178
  (key) => {
@@ -165,7 +182,7 @@ var PisellTabbar = (props, ref) => {
165
182
  );
166
183
  const renderExpandCard = (0, import_react.useCallback)(
167
184
  (cardProps, level, isExpanded) => {
168
- var _a;
185
+ var _a2;
169
186
  const config = expandConfig[isExpanded ? "active" : "inactive"];
170
187
  const levelCfg = getLevelConfig(level);
171
188
  return /* @__PURE__ */ import_react.default.createElement(
@@ -200,7 +217,7 @@ var PisellTabbar = (props, ref) => {
200
217
  active: {
201
218
  ...cardProps.active,
202
219
  style: {
203
- ...(_a = cardProps.active) == null ? void 0 : _a.style,
220
+ ...(_a2 = cardProps.active) == null ? void 0 : _a2.style,
204
221
  color: "#ffffff",
205
222
  background: "#7f56d9"
206
223
  }
@@ -225,22 +242,22 @@ var PisellTabbar = (props, ref) => {
225
242
  onSearch == null ? void 0 : onSearch(e);
226
243
  },
227
244
  getContainer: () => {
228
- var _a;
229
- const customContainer = (_a = searchProps == null ? void 0 : searchProps.getContainer) == null ? void 0 : _a.call(searchProps);
245
+ var _a2;
246
+ const customContainer = (_a2 = searchProps == null ? void 0 : searchProps.getContainer) == null ? void 0 : _a2.call(searchProps);
230
247
  return customContainer || document.querySelector(`#${tabbarId}`) || document.body;
231
248
  },
232
249
  modalStyle: {
233
250
  width: "100%"
234
251
  },
235
252
  onOpen: () => {
236
- var _a;
253
+ var _a2;
237
254
  openSearchMode();
238
- (_a = searchProps == null ? void 0 : searchProps.onOpen) == null ? void 0 : _a.call(searchProps);
255
+ (_a2 = searchProps == null ? void 0 : searchProps.onOpen) == null ? void 0 : _a2.call(searchProps);
239
256
  },
240
257
  onClose: () => {
241
- var _a;
258
+ var _a2;
242
259
  closeSearchMode();
243
- (_a = searchProps == null ? void 0 : searchProps.onClose) == null ? void 0 : _a.call(searchProps);
260
+ (_a2 = searchProps == null ? void 0 : searchProps.onClose) == null ? void 0 : _a2.call(searchProps);
244
261
  },
245
262
  trigger: /* @__PURE__ */ import_react.default.createElement(
246
263
  import_PisellCards.default.MultilevelCard,
@@ -278,7 +295,7 @@ var PisellTabbar = (props, ref) => {
278
295
  );
279
296
  const renderNormalCard = (0, import_react.useCallback)(
280
297
  (cardProps, level) => {
281
- var _a;
298
+ var _a2;
282
299
  const { dataSource: itemData } = cardProps;
283
300
  const levelCfg = getLevelConfig(level);
284
301
  const textAlign = isVertical ? levelCfg.textAlign ?? "center" : "center";
@@ -300,7 +317,7 @@ var PisellTabbar = (props, ref) => {
300
317
  style: {
301
318
  ...isVertical ? { minHeight: levelCfg.cardHeight } : { height: levelCfg.cardHeight },
302
319
  borderRadius: isVertical ? levelCfg.borderRadius ?? "999px" : "20px",
303
- background: "#ffffff",
320
+ background: levelCfg.cardBackground ?? "#ffffff",
304
321
  minWidth: isVertical ? 0 : 100,
305
322
  justifyContent: isVertical && textAlign === "left" ? "flex-start" : "center"
306
323
  },
@@ -308,9 +325,9 @@ var PisellTabbar = (props, ref) => {
308
325
  active: {
309
326
  ...cardProps.active,
310
327
  style: {
311
- ...(_a = cardProps.active) == null ? void 0 : _a.style,
328
+ ...(_a2 = cardProps.active) == null ? void 0 : _a2.style,
312
329
  color: "#fff",
313
- background: "#7f56d9"
330
+ background: levelCfg.activeBackground ?? "#7f56d9"
314
331
  }
315
332
  }
316
333
  }
@@ -320,7 +337,12 @@ var PisellTabbar = (props, ref) => {
320
337
  );
321
338
  const level1DataSource = (0, import_react.useMemo)(
322
339
  () => {
323
- const categoryItems = dataSource.length ? (0, import_utils.addDataSourceItemsByKey)(dataSource, import_constants.LEVEL_ADD_ITEMS.level1) : [];
340
+ const categoryItems = dataSource.length ? (0, import_utils.addDataSourceItemsByKey)(
341
+ dataSource,
342
+ import_constants.LEVEL_ADD_ITEMS.level1.filter(
343
+ (itemKey) => showAllItem || itemKey !== "all"
344
+ )
345
+ ) : [];
324
346
  const actionItems = (level1Actions || []).map((action, index) => ({
325
347
  id: `__level1-action-${String(action.key)}-${index}`,
326
348
  key: `__level1-action-${String(action.key)}-${index}`,
@@ -334,10 +356,11 @@ var PisellTabbar = (props, ref) => {
334
356
  }
335
357
  return isVertical ? full.filter((item) => (item == null ? void 0 : item.key) !== "expand") : full;
336
358
  },
337
- [dataSource, isSearchOpen, isVertical, level1Actions]
359
+ [dataSource, isSearchOpen, isVertical, level1Actions, showAllItem]
338
360
  );
339
361
  const renderLevel1Item = (0, import_react.useCallback)(
340
362
  (itemProps) => {
363
+ var _a2;
341
364
  const { dataSource: itemData } = itemProps;
342
365
  const isExpanded = getExpand("level1");
343
366
  const action = itemData == null ? void 0 : itemData.__action;
@@ -378,10 +401,13 @@ var PisellTabbar = (props, ref) => {
378
401
  import_PisellCards.default.MultilevelCard,
379
402
  {
380
403
  ...itemProps,
404
+ className: (0, import_classnames.default)(itemProps.className, {
405
+ "pisell-tabbar__category-group--level1": isVertical && ((_a2 = itemData == null ? void 0 : itemData.children) == null ? void 0 : _a2.length)
406
+ }),
381
407
  card: (cardProps) => renderNormalCard(cardProps, "level1"),
382
408
  panel: (panelProps) => {
383
- var _a, _b;
384
- if (((_b = (_a = panelProps == null ? void 0 : panelProps.dataSource) == null ? void 0 : _a.children) == null ? void 0 : _b.length) && maxLevel >= 2) {
409
+ var _a3, _b2;
410
+ if (((_b2 = (_a3 = panelProps == null ? void 0 : panelProps.dataSource) == null ? void 0 : _a3.children) == null ? void 0 : _b2.length) && maxLevel >= 2) {
385
411
  return renderLevel2Panel(panelProps);
386
412
  }
387
413
  return null;
@@ -410,7 +436,9 @@ var PisellTabbar = (props, ref) => {
410
436
  if (_dataSource.length) {
411
437
  _dataSource = (0, import_utils.addDataSourceItemsByKey)(
412
438
  _dataSource,
413
- import_constants.LEVEL_ADD_ITEMS.level2
439
+ import_constants.LEVEL_ADD_ITEMS.level2.filter(
440
+ (itemKey) => showAllItem || itemKey !== "all"
441
+ )
414
442
  );
415
443
  if (isVertical) {
416
444
  _dataSource = _dataSource.filter((item) => item.key !== "expand");
@@ -463,6 +491,7 @@ var PisellTabbar = (props, ref) => {
463
491
  }
464
492
  },
465
493
  renderItem: (itemProps) => {
494
+ var _a2;
466
495
  const { dataSource: itemData } = itemProps;
467
496
  if (itemData == null ? void 0 : itemData.customClick) {
468
497
  return /* @__PURE__ */ import_react.default.createElement(
@@ -478,10 +507,13 @@ var PisellTabbar = (props, ref) => {
478
507
  import_PisellCards.default.MultilevelCard,
479
508
  {
480
509
  ...itemProps,
510
+ className: (0, import_classnames.default)(itemProps.className, {
511
+ "pisell-tabbar__category-group--level2": isVertical && ((_a2 = itemData == null ? void 0 : itemData.children) == null ? void 0 : _a2.length)
512
+ }),
481
513
  card: (cardProps) => renderNormalCard(cardProps, "level2"),
482
514
  panel: (panelProps2) => {
483
- var _a, _b;
484
- if (((_b = (_a = panelProps2 == null ? void 0 : panelProps2.dataSource) == null ? void 0 : _a.children) == null ? void 0 : _b.length) && maxLevel >= 3) {
515
+ var _a3, _b2;
516
+ if (((_b2 = (_a3 = panelProps2 == null ? void 0 : panelProps2.dataSource) == null ? void 0 : _a3.children) == null ? void 0 : _b2.length) && maxLevel >= 3) {
485
517
  return renderLevel3Panel(panelProps2);
486
518
  }
487
519
  return null;
@@ -507,6 +539,7 @@ var PisellTabbar = (props, ref) => {
507
539
  getLevelConfig,
508
540
  renderExpandCard,
509
541
  renderNormalCard,
542
+ showAllItem,
510
543
  direction,
511
544
  isVertical
512
545
  ]
@@ -518,7 +551,9 @@ var PisellTabbar = (props, ref) => {
518
551
  if (_dataSource2.length) {
519
552
  _dataSource2 = (0, import_utils.addDataSourceItemsByKey)(
520
553
  _dataSource2,
521
- import_constants.LEVEL_ADD_ITEMS.level3
554
+ import_constants.LEVEL_ADD_ITEMS.level3.filter(
555
+ (itemKey) => showAllItem || itemKey !== "all"
556
+ )
522
557
  );
523
558
  if (isVertical) {
524
559
  _dataSource2 = _dataSource2.filter((item) => item.key !== "expand");
@@ -604,6 +639,7 @@ var PisellTabbar = (props, ref) => {
604
639
  getLevelConfig,
605
640
  renderExpandCard,
606
641
  renderNormalCard,
642
+ showAllItem,
607
643
  direction,
608
644
  isVertical
609
645
  ]
@@ -49,6 +49,10 @@ export interface TabbarLevelConfig {
49
49
  cardWidth: number;
50
50
  /** 卡片高度 */
51
51
  cardHeight: number;
52
+ /** 卡片背景色;未传时使用模板默认白色 */
53
+ cardBackground?: string;
54
+ /** 卡片选中背景色;未传时使用模板默认紫色 */
55
+ activeBackground?: string;
52
56
  /** 左侧缩进 */
53
57
  paddingLeft?: number;
54
58
  /** 卡片圆角;未传时使用模板默认值 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "6.11.239",
3
+ "version": "6.11.240",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",