@pisell/materials 6.8.8 → 6.8.10
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.js +16 -16
- package/build/lowcode/view.js +16 -16
- package/es/components/PisellProcedure/PisellProcedure.stories.d.ts +163 -0
- package/es/components/PisellProcedure/PisellProcedure.stories.js +1611 -0
- package/es/components/PisellScrollView/PisellScrollView.stories.d.ts +87 -0
- package/es/components/PisellScrollView/PisellScrollView.stories.js +772 -0
- package/es/components/PisellScrollView/hooks/useScrollEvents.js +18 -3
- package/es/components/PisellScrollView/index.d.ts +2 -1
- package/es/components/PisellScrollView/index.js +2 -1
- package/es/components/PisellSteps/PisellSteps.stories.d.ts +155 -0
- package/es/components/PisellSteps/PisellSteps.stories.js +851 -0
- package/es/components/PisellSuperTabs/PisellSuperTabs.d.ts +6 -10
- package/es/components/PisellSuperTabs/PisellSuperTabs.js +28 -8
- package/es/components/PisellSuperTabs/types.d.ts +1 -0
- package/es/components/PisellTabbar/PisellTabbar.d.ts +2 -19
- package/es/components/PisellTabbar/PisellTabbar.js +2 -1
- package/es/components/PisellTabbar/constants.d.ts +4 -4
- package/es/components/PisellTabbar/constants.js +5 -5
- package/es/components/PisellTabbar/index.d.ts +2 -0
- package/es/components/PisellTabbar/index.js +2 -0
- package/es/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +20 -0
- package/es/components/PisellTabbar/template/Template1/PisellTabbar.js +426 -0
- package/es/components/PisellTabbar/template/Template1/constants.d.ts +10 -0
- package/es/components/PisellTabbar/template/Template1/constants.js +33 -0
- package/es/components/PisellTabbar/template/Template1/index.d.ts +6 -0
- package/es/components/PisellTabbar/template/Template1/index.js +7 -0
- package/es/components/PisellTabbar/template/Template1/utils/index.d.ts +35 -0
- package/es/components/PisellTabbar/template/Template1/utils/index.js +96 -0
- package/es/components/PisellTabbar/utils/index.d.ts +33 -0
- package/es/components/PisellTabbar/utils/index.js +3 -2
- package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/es/components/productCard/components/Packages/utils.d.ts +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/lib/components/PisellProcedure/PisellProcedure.stories.d.ts +163 -0
- package/lib/components/PisellProcedure/PisellProcedure.stories.js +925 -0
- package/lib/components/PisellScrollView/PisellScrollView.stories.d.ts +87 -0
- package/lib/components/PisellScrollView/PisellScrollView.stories.js +535 -0
- package/lib/components/PisellScrollView/hooks/useScrollEvents.js +13 -3
- package/lib/components/PisellScrollView/index.d.ts +2 -1
- package/lib/components/PisellScrollView/index.js +2 -5
- package/lib/components/PisellSteps/PisellSteps.stories.d.ts +155 -0
- package/lib/components/PisellSteps/PisellSteps.stories.js +570 -0
- package/lib/components/PisellSuperTabs/PisellSuperTabs.d.ts +6 -10
- package/lib/components/PisellSuperTabs/PisellSuperTabs.js +25 -6
- package/lib/components/PisellSuperTabs/types.d.ts +1 -0
- package/lib/components/PisellTabbar/PisellTabbar.d.ts +2 -19
- package/lib/components/PisellTabbar/PisellTabbar.js +2 -1
- package/lib/components/PisellTabbar/constants.d.ts +4 -4
- package/lib/components/PisellTabbar/constants.js +5 -5
- package/lib/components/PisellTabbar/index.d.ts +2 -0
- package/lib/components/PisellTabbar/index.js +6 -0
- package/lib/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +20 -0
- package/lib/components/PisellTabbar/template/Template1/PisellTabbar.js +437 -0
- package/lib/components/PisellTabbar/template/Template1/constants.d.ts +10 -0
- package/lib/components/PisellTabbar/template/Template1/constants.js +60 -0
- package/lib/components/PisellTabbar/template/Template1/index.d.ts +6 -0
- package/lib/components/PisellTabbar/template/Template1/index.js +36 -0
- package/lib/components/PisellTabbar/template/Template1/utils/index.d.ts +35 -0
- package/lib/components/PisellTabbar/template/Template1/utils/index.js +68 -0
- package/lib/components/PisellTabbar/utils/index.d.ts +33 -0
- package/lib/components/PisellTabbar/utils/index.js +4 -1
- package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +5 -2
- package/package.json +23 -4
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { PisellSuperTabsProps } from './types';
|
|
2
3
|
import './PisellSuperTabs.less';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare const PisellSuperTabs: {
|
|
9
|
-
<T>(props: PisellSuperTabsProps<T>): JSX.Element;
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
12
|
-
export default PisellSuperTabs;
|
|
4
|
+
interface PisellSuperTabsRef {
|
|
5
|
+
scrollItemByRowKey: (key: string) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.ForwardRefExoticComponent<PisellSuperTabsProps<unknown> & React.RefAttributes<PisellSuperTabsRef>>;
|
|
8
|
+
export default _default;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useImperativeHandle, useRef, forwardRef } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useTabsState } from "./hooks";
|
|
5
5
|
import { getRowKey } from "./utils";
|
|
6
6
|
import PisellBasicGrid from "../PisellBasicGrid";
|
|
7
|
-
import
|
|
7
|
+
import PisellScrollView from "../PisellScrollView";
|
|
8
8
|
import "./PisellSuperTabs.less";
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* PisellSuperTabs 组件
|
|
12
11
|
* @description 通用导航框架封装的全能型 Tab 组件
|
|
13
12
|
* @template T - 数据源项的类型
|
|
14
13
|
*/
|
|
15
|
-
var PisellSuperTabs = function PisellSuperTabs(props) {
|
|
14
|
+
var PisellSuperTabs = function PisellSuperTabs(props, ref) {
|
|
16
15
|
var className = props.className,
|
|
17
16
|
style = props.style,
|
|
18
17
|
_props$dataSource = props.dataSource,
|
|
@@ -42,7 +41,9 @@ var PisellSuperTabs = function PisellSuperTabs(props) {
|
|
|
42
41
|
slotLeftStyle = props.slotLeftStyle,
|
|
43
42
|
slotRightStyle = props.slotRightStyle,
|
|
44
43
|
slotTopStyle = props.slotTopStyle,
|
|
45
|
-
slotBottomStyle = props.slotBottomStyle
|
|
44
|
+
slotBottomStyle = props.slotBottomStyle,
|
|
45
|
+
__designMode = props.__designMode;
|
|
46
|
+
var containerRef = useRef(null);
|
|
46
47
|
|
|
47
48
|
// 状态管理:处理受控/非受控模式
|
|
48
49
|
var _useTabsState = useTabsState({
|
|
@@ -52,10 +53,29 @@ var PisellSuperTabs = function PisellSuperTabs(props) {
|
|
|
52
53
|
}),
|
|
53
54
|
activeKey = _useTabsState.activeKey,
|
|
54
55
|
handleTabChange = _useTabsState.handleTabChange;
|
|
56
|
+
var scrollItemByRowKey = function scrollItemByRowKey(key) {
|
|
57
|
+
var item = document.querySelector(".pisell-super-tabs-item-".concat(id, "-").concat(key));
|
|
58
|
+
console.log(".pisell-super-tabs-item-".concat(id, "-").concat(key));
|
|
59
|
+
if (item) {
|
|
60
|
+
item.scrollIntoView({
|
|
61
|
+
behavior: 'smooth'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
useImperativeHandle(ref, function () {
|
|
66
|
+
if (__designMode) {
|
|
67
|
+
//@ts-ignore
|
|
68
|
+
return containerRef.current;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
scrollItemByRowKey: scrollItemByRowKey
|
|
72
|
+
};
|
|
73
|
+
});
|
|
55
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
56
75
|
className: classNames('pisell-super-tabs', className),
|
|
57
76
|
style: style,
|
|
58
|
-
id: id
|
|
77
|
+
id: id,
|
|
78
|
+
ref: containerRef
|
|
59
79
|
}, /*#__PURE__*/React.createElement("div", {
|
|
60
80
|
className: classNames('pisell-super-tabs-slot-top-' + id, slotTopClassName),
|
|
61
81
|
style: slotTopStyle
|
|
@@ -107,7 +127,7 @@ var PisellSuperTabs = function PisellSuperTabs(props) {
|
|
|
107
127
|
// 包裹点击事件处理
|
|
108
128
|
return /*#__PURE__*/React.createElement("div", {
|
|
109
129
|
key: key,
|
|
110
|
-
className: classNames('pisell-super-tabs-item', {
|
|
130
|
+
className: classNames('pisell-super-tabs-item', "pisell-super-tabs-item-".concat(id, "-").concat(key), {
|
|
111
131
|
'pisell-super-tabs-item--active': active
|
|
112
132
|
}, tabItemClassName),
|
|
113
133
|
style: tabItemStyle
|
|
@@ -124,4 +144,4 @@ var PisellSuperTabs = function PisellSuperTabs(props) {
|
|
|
124
144
|
}, slotBottom));
|
|
125
145
|
};
|
|
126
146
|
PisellSuperTabs.displayName = 'PisellSuperTabs';
|
|
127
|
-
export default PisellSuperTabs;
|
|
147
|
+
export default /*#__PURE__*/forwardRef(PisellSuperTabs);
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PisellTabbarProps } from './types';
|
|
1
|
+
import PisellTabbar4 from './template/Template1';
|
|
3
2
|
import './PisellTabbar.less';
|
|
4
|
-
|
|
5
|
-
* PisellTabbar - 多层级 Tabbar 组件
|
|
6
|
-
*
|
|
7
|
-
* 支持最多 3 层级的 Tab 导航,每层级可独立展开/收起
|
|
8
|
-
*
|
|
9
|
-
* @component
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <PisellTabbar
|
|
13
|
-
* dataSource={categoryData}
|
|
14
|
-
* value={[1, 10, 100]}
|
|
15
|
-
* onChange={(value) => console.log('当前选中:', value)}
|
|
16
|
-
* />
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare const PisellTabbar: React.FC<PisellTabbarProps>;
|
|
20
|
-
export default PisellTabbar;
|
|
3
|
+
export default PisellTabbar4;
|
|
@@ -11,6 +11,7 @@ import { useActiveKey, useExpand } from "./hooks";
|
|
|
11
11
|
import { addDataSourceItemsByKey, getDefaultActiveKey } from "./utils";
|
|
12
12
|
import { DEFAULT_LEVEL_CONFIG, LEVEL_ADD_ITEMS } from "./constants";
|
|
13
13
|
import mock from "./mock";
|
|
14
|
+
import PisellTabbar4 from "./template/Template1";
|
|
14
15
|
import "./PisellTabbar.less";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -171,4 +172,4 @@ PisellTabbar.displayName = 'PisellTabbar';
|
|
|
171
172
|
|
|
172
173
|
// PisellTabbar.Template1 = PisellTabbar2;
|
|
173
174
|
|
|
174
|
-
export default
|
|
175
|
+
export default PisellTabbar4;
|
|
@@ -12,15 +12,15 @@ export declare const getExpandConfig: () => ExpandConfig;
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const DEFAULT_ITEMS: {
|
|
14
14
|
all: {
|
|
15
|
-
id:
|
|
15
|
+
id: string;
|
|
16
16
|
shop_id: number;
|
|
17
17
|
parent_id: number;
|
|
18
|
-
name:
|
|
18
|
+
name: any;
|
|
19
19
|
slug: string;
|
|
20
20
|
icon: string;
|
|
21
21
|
};
|
|
22
22
|
search: {
|
|
23
|
-
id:
|
|
23
|
+
id: string;
|
|
24
24
|
shop_id: number;
|
|
25
25
|
parent_id: number;
|
|
26
26
|
name: string;
|
|
@@ -30,7 +30,7 @@ export declare const DEFAULT_ITEMS: {
|
|
|
30
30
|
customClick: boolean;
|
|
31
31
|
};
|
|
32
32
|
expand: {
|
|
33
|
-
id:
|
|
33
|
+
id: string;
|
|
34
34
|
shop_id: number;
|
|
35
35
|
parent_id: number;
|
|
36
36
|
key: string;
|
|
@@ -45,15 +45,15 @@ export var getExpandConfig = function getExpandConfig() {
|
|
|
45
45
|
*/
|
|
46
46
|
export var DEFAULT_ITEMS = {
|
|
47
47
|
all: {
|
|
48
|
-
id: 0,
|
|
48
|
+
id: '0',
|
|
49
49
|
shop_id: 9,
|
|
50
50
|
parent_id: 0,
|
|
51
|
-
name: '
|
|
52
|
-
slug: '
|
|
51
|
+
name: getText('pisell-tabbar-all'),
|
|
52
|
+
slug: 'all',
|
|
53
53
|
icon: ''
|
|
54
54
|
},
|
|
55
55
|
search: {
|
|
56
|
-
id: -1,
|
|
56
|
+
id: '-1',
|
|
57
57
|
shop_id: 9,
|
|
58
58
|
parent_id: 0,
|
|
59
59
|
name: 'Search',
|
|
@@ -63,7 +63,7 @@ export var DEFAULT_ITEMS = {
|
|
|
63
63
|
customClick: true
|
|
64
64
|
},
|
|
65
65
|
expand: {
|
|
66
|
-
id: -2,
|
|
66
|
+
id: '-2',
|
|
67
67
|
shop_id: 9,
|
|
68
68
|
parent_id: 0,
|
|
69
69
|
key: 'expand',
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
* @module PisellTabbar
|
|
4
4
|
*/
|
|
5
5
|
import PisellTabbar from './PisellTabbar';
|
|
6
|
+
import PisellTabbarTemplate1 from './template/Template1';
|
|
6
7
|
export type { PisellTabbarProps, TabbarDataSource, LevelType } from './types';
|
|
8
|
+
export { PisellTabbarTemplate1 };
|
|
7
9
|
export default PisellTabbar;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PisellTabbarProps } from '../../types';
|
|
3
|
+
import '../../PisellTabbar.less';
|
|
4
|
+
/**
|
|
5
|
+
* PisellTabbar - 多层级 Tabbar 组件
|
|
6
|
+
*
|
|
7
|
+
* 支持最多 3 层级的 Tab 导航,每层级可独立展开/收起
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <PisellTabbar
|
|
13
|
+
* dataSource={categoryData}
|
|
14
|
+
* value={[1, 10, 100]}
|
|
15
|
+
* onChange={(value) => console.log('当前选中:', value)}
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const PisellTabbar: React.FC<PisellTabbarProps>;
|
|
20
|
+
export default PisellTabbar;
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import SuperTabs from "../../../PisellSuperTabs";
|
|
11
|
+
import PisellCards from "../../../PisellCards";
|
|
12
|
+
import Iconfont from "../../../iconfont";
|
|
13
|
+
import { useActiveKey, useExpand } from "../../hooks";
|
|
14
|
+
import { addDataSourceItemsByKey, getDefaultActiveKey } from "./utils";
|
|
15
|
+
import { DEFAULT_LEVEL_CONFIG, LEVEL_ADD_ITEMS, getExpandConfig } from "./constants";
|
|
16
|
+
import mock from "../../mock";
|
|
17
|
+
import "../../PisellTabbar.less";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* PisellTabbar - 多层级 Tabbar 组件
|
|
21
|
+
*
|
|
22
|
+
* 支持最多 3 层级的 Tab 导航,每层级可独立展开/收起
|
|
23
|
+
*
|
|
24
|
+
* @component
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <PisellTabbar
|
|
28
|
+
* dataSource={categoryData}
|
|
29
|
+
* value={[1, 10, 100]}
|
|
30
|
+
* onChange={(value) => console.log('当前选中:', value)}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
var PisellTabbar = function PisellTabbar(props) {
|
|
35
|
+
var _props$dataSource = props.dataSource,
|
|
36
|
+
dataSource = _props$dataSource === void 0 ? props !== null && props !== void 0 && props.__designMode ? mock : mock : _props$dataSource,
|
|
37
|
+
value = props.value,
|
|
38
|
+
onChange = props.onChange,
|
|
39
|
+
className = props.className,
|
|
40
|
+
style = props.style,
|
|
41
|
+
customLevelConfig = props.levelConfig,
|
|
42
|
+
customExpandConfig = props.expandConfig,
|
|
43
|
+
_props$maxLevel = props.maxLevel,
|
|
44
|
+
maxLevel = _props$maxLevel === void 0 ? 3 : _props$maxLevel;
|
|
45
|
+
|
|
46
|
+
// 激活的 key 管理
|
|
47
|
+
var _useActiveKey = useActiveKey({
|
|
48
|
+
initialActiveKey: value || getDefaultActiveKey(dataSource, 'id'),
|
|
49
|
+
onChange: onChange
|
|
50
|
+
}),
|
|
51
|
+
setActiveKey = _useActiveKey.setActiveKey,
|
|
52
|
+
getActiveKey = _useActiveKey.getActiveKey,
|
|
53
|
+
_setActiveKey = _useActiveKey._setActiveKey,
|
|
54
|
+
activeKey = _useActiveKey.activeKey;
|
|
55
|
+
console.log('getActiveKey', activeKey);
|
|
56
|
+
|
|
57
|
+
// 展开状态管理
|
|
58
|
+
var _useExpand = useExpand(),
|
|
59
|
+
expand = _useExpand.expand,
|
|
60
|
+
toggleExpand = _useExpand.toggleExpand,
|
|
61
|
+
getExpand = _useExpand.getExpand;
|
|
62
|
+
|
|
63
|
+
// 展开配置
|
|
64
|
+
var expandConfig = customExpandConfig || getExpandConfig();
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 同步外部 value 到内部状态
|
|
68
|
+
*/
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
if (value) {
|
|
71
|
+
_setActiveKey(value);
|
|
72
|
+
}
|
|
73
|
+
}, [JSON.stringify(value)]);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 获取层级配置
|
|
77
|
+
*/
|
|
78
|
+
var getLevelConfig = useCallback(function (level) {
|
|
79
|
+
return _objectSpread(_objectSpread({}, DEFAULT_LEVEL_CONFIG[level]), customLevelConfig === null || customLevelConfig === void 0 ? void 0 : customLevelConfig[level]);
|
|
80
|
+
}, [customLevelConfig]);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 处理一级 Tab 切换
|
|
84
|
+
*/
|
|
85
|
+
var handleLevel1Change = useCallback(function (key, item) {
|
|
86
|
+
var _item$children;
|
|
87
|
+
setActiveKey(0, key, item !== null && item !== void 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length ? 0 : undefined);
|
|
88
|
+
}, [setActiveKey, activeKey]);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 处理二级 Tab 切换
|
|
92
|
+
*/
|
|
93
|
+
var handleLevel2Change = useCallback(function (key, item) {
|
|
94
|
+
var _item$children2;
|
|
95
|
+
setActiveKey(1, key, item !== null && item !== void 0 && (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length ? 0 : undefined);
|
|
96
|
+
}, [setActiveKey, activeKey]);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 处理三级 Tab 切换
|
|
100
|
+
*/
|
|
101
|
+
var handleLevel3Change = useCallback(function (key) {
|
|
102
|
+
setActiveKey(2, key);
|
|
103
|
+
}, [setActiveKey, activeKey]);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 渲染 level2/level3 自定义点击卡片(展开按钮)
|
|
107
|
+
*/
|
|
108
|
+
var renderExpandCard = useCallback(function (cardProps, level, isExpanded) {
|
|
109
|
+
var _cardProps$active;
|
|
110
|
+
var config = expandConfig[isExpanded ? 'active' : 'inactive'];
|
|
111
|
+
var levelCfg = getLevelConfig(level);
|
|
112
|
+
return /*#__PURE__*/React.createElement(PisellCards.TextCard, _extends({}, cardProps, {
|
|
113
|
+
text: config.text,
|
|
114
|
+
variant: "outlined",
|
|
115
|
+
widthMode: "auto",
|
|
116
|
+
prefixIcon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
117
|
+
type: config.icon,
|
|
118
|
+
style: {
|
|
119
|
+
color: '#000',
|
|
120
|
+
fontSize: 20
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
textConfig: {
|
|
124
|
+
textAlign: 'center',
|
|
125
|
+
color: '#000000',
|
|
126
|
+
flex: 'none'
|
|
127
|
+
},
|
|
128
|
+
style: {
|
|
129
|
+
borderRadius: '20px',
|
|
130
|
+
background: '#ffffff',
|
|
131
|
+
display: 'flex',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
height: levelCfg.cardHeight,
|
|
135
|
+
minWidth: 100
|
|
136
|
+
},
|
|
137
|
+
width: 'auto',
|
|
138
|
+
active: _objectSpread(_objectSpread({}, cardProps.active), {}, {
|
|
139
|
+
style: _objectSpread(_objectSpread({}, (_cardProps$active = cardProps.active) === null || _cardProps$active === void 0 ? void 0 : _cardProps$active.style), {}, {
|
|
140
|
+
color: '#ffffff',
|
|
141
|
+
background: '#7f56d9'
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
}, [expandConfig, activeKey, getLevelConfig]);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 渲染 level2/level3 普通卡片
|
|
149
|
+
*/
|
|
150
|
+
var renderNormalCard = useCallback(function (cardProps, level) {
|
|
151
|
+
var _cardProps$active2;
|
|
152
|
+
var itemData = cardProps.dataSource;
|
|
153
|
+
var levelCfg = getLevelConfig(level);
|
|
154
|
+
return /*#__PURE__*/React.createElement(PisellCards.TextCard, _extends({}, cardProps, {
|
|
155
|
+
text: itemData.name,
|
|
156
|
+
variant: "outlined",
|
|
157
|
+
widthMode: "auto",
|
|
158
|
+
textConfig: {
|
|
159
|
+
textAlign: 'center',
|
|
160
|
+
color: '#000',
|
|
161
|
+
maxLines: 2,
|
|
162
|
+
ellipsis: true
|
|
163
|
+
},
|
|
164
|
+
style: {
|
|
165
|
+
height: levelCfg.cardHeight,
|
|
166
|
+
borderRadius: '20px',
|
|
167
|
+
background: '#ffffff',
|
|
168
|
+
minWidth: 100
|
|
169
|
+
},
|
|
170
|
+
width: 'auto',
|
|
171
|
+
active: _objectSpread(_objectSpread({}, cardProps.active), {}, {
|
|
172
|
+
style: _objectSpread(_objectSpread({}, (_cardProps$active2 = cardProps.active) === null || _cardProps$active2 === void 0 ? void 0 : _cardProps$active2.style), {}, {
|
|
173
|
+
color: '#fff',
|
|
174
|
+
background: '#7f56d9'
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
}));
|
|
178
|
+
}, [getLevelConfig]);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 一级 Tabbar 数据源
|
|
182
|
+
*/
|
|
183
|
+
var level1DataSource = useMemo(function () {
|
|
184
|
+
return addDataSourceItemsByKey(dataSource, LEVEL_ADD_ITEMS.level1);
|
|
185
|
+
}, [dataSource]);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 渲染一级 Tab Item
|
|
189
|
+
*/
|
|
190
|
+
var renderLevel1Item = useCallback(function (itemProps) {
|
|
191
|
+
var itemData = itemProps.dataSource;
|
|
192
|
+
var level1Config = getLevelConfig('level1');
|
|
193
|
+
var isExpanded = getExpand('level1');
|
|
194
|
+
|
|
195
|
+
// 处理展开按钮
|
|
196
|
+
if (itemData !== null && itemData !== void 0 && itemData.customClick) {
|
|
197
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
198
|
+
card: function card(cardProps) {
|
|
199
|
+
return renderExpandCard(cardProps, 'level1', isExpanded);
|
|
200
|
+
},
|
|
201
|
+
onClick: function onClick() {
|
|
202
|
+
return toggleExpand('level1');
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 普通项
|
|
208
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
209
|
+
card: function card(cardProps) {
|
|
210
|
+
return renderNormalCard(cardProps, 'level1');
|
|
211
|
+
},
|
|
212
|
+
panel: function panel(panelProps) {
|
|
213
|
+
var _panelProps$dataSourc;
|
|
214
|
+
if (panelProps !== null && panelProps !== void 0 && (_panelProps$dataSourc = panelProps.dataSource) !== null && _panelProps$dataSourc !== void 0 && (_panelProps$dataSourc = _panelProps$dataSourc.children) !== null && _panelProps$dataSourc !== void 0 && _panelProps$dataSourc.length && maxLevel >= 2) {
|
|
215
|
+
return renderLevel2Panel(panelProps);
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
},
|
|
219
|
+
panelContainer: function panelContainer() {
|
|
220
|
+
return document.querySelector('.pisell-super-tabs-slot-bottom-sku-list-tabbar');
|
|
221
|
+
}
|
|
222
|
+
}));
|
|
223
|
+
}, [getLevelConfig, getExpand, toggleExpand, maxLevel, activeKey]);
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 渲染二级 Tabbar 面板
|
|
227
|
+
*/
|
|
228
|
+
var renderLevel2Panel = useCallback(function (panelProps) {
|
|
229
|
+
if (maxLevel < 2) return null;
|
|
230
|
+
var _dataSource = panelProps.dataSource.children || [];
|
|
231
|
+
if (_dataSource.length) {
|
|
232
|
+
_dataSource = addDataSourceItemsByKey(_dataSource, LEVEL_ADD_ITEMS.level2);
|
|
233
|
+
}
|
|
234
|
+
var level2Config = getLevelConfig('level2');
|
|
235
|
+
var isExpanded2 = getExpand('level2');
|
|
236
|
+
var skuId = "sku-list-tabbar-".concat(panelProps.dataSource.id);
|
|
237
|
+
return /*#__PURE__*/React.createElement(SuperTabs, {
|
|
238
|
+
id: skuId,
|
|
239
|
+
tabItemStyle: {},
|
|
240
|
+
dataSource: _dataSource,
|
|
241
|
+
value: String(getActiveKey(1)),
|
|
242
|
+
onChange: handleLevel2Change,
|
|
243
|
+
rowKey: "id",
|
|
244
|
+
style: {
|
|
245
|
+
flex: 1,
|
|
246
|
+
background: level2Config.superTabsBg
|
|
247
|
+
},
|
|
248
|
+
gridProps: {
|
|
249
|
+
direction: 'horizontal',
|
|
250
|
+
gap: 4,
|
|
251
|
+
wrap: isExpanded2 ? 'wrap' : 'nowrap',
|
|
252
|
+
startSlot: /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
style: {
|
|
254
|
+
paddingLeft: level2Config.paddingLeft
|
|
255
|
+
}
|
|
256
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
257
|
+
type: "pisell2-trend-down-01",
|
|
258
|
+
style: {
|
|
259
|
+
color: '#fff',
|
|
260
|
+
fontSize: 24,
|
|
261
|
+
marginRight: 8
|
|
262
|
+
}
|
|
263
|
+
}))
|
|
264
|
+
},
|
|
265
|
+
scrollViewProps: {
|
|
266
|
+
style: {
|
|
267
|
+
padding: '4px 8px'
|
|
268
|
+
},
|
|
269
|
+
overflow: !isExpanded2 ? 'x' : 'hidden',
|
|
270
|
+
scrollbarStyle: 'none',
|
|
271
|
+
scrollActionsConfig: {
|
|
272
|
+
type: 'lrArrows',
|
|
273
|
+
show: true
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
renderItem: function renderItem(itemProps) {
|
|
277
|
+
var itemData = itemProps.dataSource;
|
|
278
|
+
|
|
279
|
+
// 处理展开按钮
|
|
280
|
+
if (itemData !== null && itemData !== void 0 && itemData.customClick) {
|
|
281
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
282
|
+
card: function card(cardProps) {
|
|
283
|
+
return renderExpandCard(cardProps, 'level2', isExpanded2);
|
|
284
|
+
},
|
|
285
|
+
onClick: function onClick() {
|
|
286
|
+
return toggleExpand('level2');
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 普通项
|
|
292
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
293
|
+
card: function card(cardProps) {
|
|
294
|
+
return renderNormalCard(cardProps, 'level2');
|
|
295
|
+
},
|
|
296
|
+
panel: function panel(panelProps2) {
|
|
297
|
+
var _panelProps2$dataSour;
|
|
298
|
+
if (panelProps2 !== null && panelProps2 !== void 0 && (_panelProps2$dataSour = panelProps2.dataSource) !== null && _panelProps2$dataSour !== void 0 && (_panelProps2$dataSour = _panelProps2$dataSour.children) !== null && _panelProps2$dataSour !== void 0 && _panelProps2$dataSour.length && maxLevel >= 3) {
|
|
299
|
+
return renderLevel3Panel(panelProps2);
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
},
|
|
303
|
+
panelContainer: function panelContainer() {
|
|
304
|
+
return document.querySelector(".pisell-super-tabs-slot-bottom-".concat(skuId));
|
|
305
|
+
}
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}, [maxLevel, activeKey, getActiveKey, handleLevel2Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard]);
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 渲染三级 Tabbar 面板
|
|
313
|
+
*/
|
|
314
|
+
var renderLevel3Panel = useCallback(function (panelProps2) {
|
|
315
|
+
if (maxLevel < 3) return null;
|
|
316
|
+
var _dataSource2 = panelProps2.dataSource.children || [];
|
|
317
|
+
if (_dataSource2.length) {
|
|
318
|
+
_dataSource2 = addDataSourceItemsByKey(_dataSource2, LEVEL_ADD_ITEMS.level3);
|
|
319
|
+
}
|
|
320
|
+
var level3Config = getLevelConfig('level3');
|
|
321
|
+
var isExpanded3 = getExpand('level3');
|
|
322
|
+
var skuId = "sku-list-tabbar-".concat(panelProps2.dataSource.id);
|
|
323
|
+
return /*#__PURE__*/React.createElement(SuperTabs, {
|
|
324
|
+
id: skuId,
|
|
325
|
+
tabItemStyle: {},
|
|
326
|
+
dataSource: _dataSource2,
|
|
327
|
+
value: String(getActiveKey(2)),
|
|
328
|
+
onChange: handleLevel3Change,
|
|
329
|
+
rowKey: "id",
|
|
330
|
+
style: {
|
|
331
|
+
flex: 1,
|
|
332
|
+
background: level3Config.superTabsBg
|
|
333
|
+
},
|
|
334
|
+
gridProps: {
|
|
335
|
+
direction: 'horizontal',
|
|
336
|
+
gap: 4,
|
|
337
|
+
wrap: isExpanded3 ? 'wrap' : 'nowrap',
|
|
338
|
+
startSlot: /*#__PURE__*/React.createElement("div", {
|
|
339
|
+
style: {
|
|
340
|
+
paddingLeft: level3Config.paddingLeft
|
|
341
|
+
}
|
|
342
|
+
}, /*#__PURE__*/React.createElement(Iconfont, {
|
|
343
|
+
type: "pisell2-trend-down-01",
|
|
344
|
+
style: {
|
|
345
|
+
color: '#fff',
|
|
346
|
+
fontSize: 24,
|
|
347
|
+
marginRight: 8
|
|
348
|
+
}
|
|
349
|
+
}))
|
|
350
|
+
},
|
|
351
|
+
scrollViewProps: {
|
|
352
|
+
style: {
|
|
353
|
+
padding: '4px 8px'
|
|
354
|
+
},
|
|
355
|
+
overflow: !isExpanded3 ? 'x' : 'hidden',
|
|
356
|
+
scrollbarStyle: 'none',
|
|
357
|
+
scrollActionsConfig: {
|
|
358
|
+
type: 'lrArrows',
|
|
359
|
+
show: true
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
renderItem: function renderItem(itemProps) {
|
|
363
|
+
var itemData = itemProps.dataSource;
|
|
364
|
+
|
|
365
|
+
// 处理展开按钮
|
|
366
|
+
if (itemData !== null && itemData !== void 0 && itemData.customClick) {
|
|
367
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
368
|
+
card: function card(cardProps) {
|
|
369
|
+
return renderExpandCard(cardProps, 'level3', isExpanded3);
|
|
370
|
+
},
|
|
371
|
+
onClick: function onClick() {
|
|
372
|
+
return toggleExpand('level3');
|
|
373
|
+
}
|
|
374
|
+
}));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// 普通项
|
|
378
|
+
return /*#__PURE__*/React.createElement(PisellCards.MultilevelCard, _extends({}, itemProps, {
|
|
379
|
+
card: function card(cardProps) {
|
|
380
|
+
return renderNormalCard(cardProps, 'level3');
|
|
381
|
+
}
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}, [maxLevel, activeKey, getActiveKey, handleLevel3Change, getExpand, toggleExpand, getLevelConfig, renderExpandCard, renderNormalCard]);
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 渲染一级 Tabbar
|
|
389
|
+
*/
|
|
390
|
+
var level1Config = getLevelConfig('level1');
|
|
391
|
+
var isExpanded1 = getExpand('level1');
|
|
392
|
+
return dataSource.length ? /*#__PURE__*/React.createElement("div", {
|
|
393
|
+
className: classNames('pisell-tabbar', className),
|
|
394
|
+
style: style
|
|
395
|
+
}, /*#__PURE__*/React.createElement(SuperTabs, {
|
|
396
|
+
id: "sku-list-tabbar",
|
|
397
|
+
tabItemStyle: {},
|
|
398
|
+
dataSource: level1DataSource,
|
|
399
|
+
value: String(getActiveKey(0)),
|
|
400
|
+
onChange: handleLevel1Change,
|
|
401
|
+
rowKey: "id",
|
|
402
|
+
style: {
|
|
403
|
+
flex: 1,
|
|
404
|
+
background: level1Config.superTabsBg
|
|
405
|
+
},
|
|
406
|
+
gridProps: {
|
|
407
|
+
direction: 'horizontal',
|
|
408
|
+
gap: 4,
|
|
409
|
+
wrap: isExpanded1 ? 'wrap' : 'nowrap'
|
|
410
|
+
},
|
|
411
|
+
scrollViewProps: {
|
|
412
|
+
style: {
|
|
413
|
+
padding: '4px 8px'
|
|
414
|
+
},
|
|
415
|
+
overflow: !isExpanded1 ? 'x' : 'hidden',
|
|
416
|
+
scrollbarStyle: 'none',
|
|
417
|
+
scrollActionsConfig: {
|
|
418
|
+
type: 'lrArrows',
|
|
419
|
+
show: true
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
renderItem: renderLevel1Item
|
|
423
|
+
})) : null;
|
|
424
|
+
};
|
|
425
|
+
PisellTabbar.displayName = 'PisellTabbar';
|
|
426
|
+
export default PisellTabbar;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TabbarLevelConfig, LevelType } from '../../types';
|
|
2
|
+
export { getExpandConfig, DEFAULT_ITEMS } from '../../constants';
|
|
3
|
+
/**
|
|
4
|
+
* 默认层级配置
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_LEVEL_CONFIG: Record<LevelType, TabbarLevelConfig>;
|
|
7
|
+
/**
|
|
8
|
+
* 获取层级对应的添加项配置
|
|
9
|
+
*/
|
|
10
|
+
export declare const LEVEL_ADD_ITEMS: Record<LevelType, ('all' | 'search' | 'expand')[]>;
|