@sheinx/base 3.6.0-beta.18 → 3.6.0-beta.19
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/cjs/checkbox/checkbox.type.d.ts +4 -0
- package/cjs/checkbox/checkbox.type.d.ts.map +1 -1
- package/cjs/checkbox/simple-checkbox.d.ts.map +1 -1
- package/cjs/checkbox/simple-checkbox.js +2 -1
- package/cjs/empty/empty.d.ts.map +1 -1
- package/cjs/empty/empty.js +1 -0
- package/cjs/icons/config.d.ts +2 -0
- package/cjs/icons/config.d.ts.map +1 -1
- package/cjs/icons/config.js +3 -1
- package/cjs/icons/icons.d.ts +1 -0
- package/cjs/icons/icons.d.ts.map +1 -1
- package/cjs/icons/icons.js +4 -0
- package/cjs/table/table.d.ts.map +1 -1
- package/cjs/table/table.js +26 -12
- package/cjs/table/table.type.d.ts +15 -0
- package/cjs/table/table.type.d.ts.map +1 -1
- package/cjs/table/tbody-empty.d.ts +7 -0
- package/cjs/table/tbody-empty.d.ts.map +1 -0
- package/cjs/table/tbody-empty.js +23 -0
- package/cjs/table/thead-filter.d.ts +12 -0
- package/cjs/table/thead-filter.d.ts.map +1 -0
- package/cjs/table/thead-filter.js +267 -0
- package/cjs/table/thead.d.ts.map +1 -1
- package/cjs/table/thead.js +35 -5
- package/cjs/table/thead.type.d.ts +2 -2
- package/cjs/table/thead.type.d.ts.map +1 -1
- package/cjs/tree/tree-checkbox.d.ts +1 -2
- package/cjs/tree/tree-checkbox.d.ts.map +1 -1
- package/cjs/tree/tree-checkbox.js +3 -16
- package/cjs/tree/tree-checkbox.type.d.ts +3 -4
- package/cjs/tree/tree-checkbox.type.d.ts.map +1 -1
- package/cjs/tree/tree-content.d.ts.map +1 -1
- package/cjs/tree/tree-content.js +47 -23
- package/cjs/tree/tree-content.type.d.ts +6 -4
- package/cjs/tree/tree-content.type.d.ts.map +1 -1
- package/cjs/tree/tree-list.d.ts.map +1 -1
- package/cjs/tree/tree-list.js +4 -2
- package/cjs/tree/tree-list.type.d.ts +2 -2
- package/cjs/tree/tree-list.type.d.ts.map +1 -1
- package/cjs/tree/tree-node.d.ts.map +1 -1
- package/cjs/tree/tree-node.js +1 -0
- package/cjs/tree/tree-node.type.d.ts +3 -3
- package/cjs/tree/tree-node.type.d.ts.map +1 -1
- package/cjs/tree/tree-root.d.ts.map +1 -1
- package/cjs/tree/tree-root.js +12 -1
- package/cjs/tree/tree-root.type.d.ts +2 -2
- package/cjs/tree/tree-root.type.d.ts.map +1 -1
- package/cjs/tree/tree-simple-node.d.ts.map +1 -1
- package/cjs/tree/tree-simple-node.js +7 -3
- package/cjs/tree/tree-virtual-node.d.ts.map +1 -1
- package/cjs/tree/tree-virtual-node.js +7 -4
- package/cjs/tree/tree.d.ts.map +1 -1
- package/cjs/tree/tree.js +6 -3
- package/cjs/tree/tree.type.d.ts +12 -0
- package/cjs/tree/tree.type.d.ts.map +1 -1
- package/cjs/tree-select/tree-select.d.ts.map +1 -1
- package/cjs/tree-select/tree-select.js +2 -1
- package/cjs/tree-select/tree-select.type.d.ts +2 -2
- package/cjs/tree-select/tree-select.type.d.ts.map +1 -1
- package/esm/checkbox/checkbox.type.d.ts +4 -0
- package/esm/checkbox/checkbox.type.d.ts.map +1 -1
- package/esm/checkbox/simple-checkbox.d.ts.map +1 -1
- package/esm/checkbox/simple-checkbox.js +2 -1
- package/esm/empty/empty.d.ts.map +1 -1
- package/esm/empty/empty.js +1 -0
- package/esm/icons/config.d.ts +2 -0
- package/esm/icons/config.d.ts.map +1 -1
- package/esm/icons/config.js +3 -1
- package/esm/icons/icons.d.ts +1 -0
- package/esm/icons/icons.d.ts.map +1 -1
- package/esm/icons/icons.js +4 -0
- package/esm/table/table.d.ts.map +1 -1
- package/esm/table/table.js +27 -13
- package/esm/table/table.type.d.ts +15 -0
- package/esm/table/table.type.d.ts.map +1 -1
- package/esm/table/tbody-empty.d.ts +7 -0
- package/esm/table/tbody-empty.d.ts.map +1 -0
- package/esm/table/tbody-empty.js +16 -0
- package/esm/table/thead-filter.d.ts +12 -0
- package/esm/table/thead-filter.d.ts.map +1 -0
- package/esm/table/thead-filter.js +259 -0
- package/esm/table/thead.d.ts.map +1 -1
- package/esm/table/thead.js +35 -5
- package/esm/table/thead.type.d.ts +2 -2
- package/esm/table/thead.type.d.ts.map +1 -1
- package/esm/tree/tree-checkbox.d.ts +1 -2
- package/esm/tree/tree-checkbox.d.ts.map +1 -1
- package/esm/tree/tree-checkbox.js +3 -16
- package/esm/tree/tree-checkbox.type.d.ts +3 -4
- package/esm/tree/tree-checkbox.type.d.ts.map +1 -1
- package/esm/tree/tree-content.d.ts.map +1 -1
- package/esm/tree/tree-content.js +47 -23
- package/esm/tree/tree-content.type.d.ts +6 -4
- package/esm/tree/tree-content.type.d.ts.map +1 -1
- package/esm/tree/tree-list.d.ts.map +1 -1
- package/esm/tree/tree-list.js +4 -2
- package/esm/tree/tree-list.type.d.ts +2 -2
- package/esm/tree/tree-list.type.d.ts.map +1 -1
- package/esm/tree/tree-node.d.ts.map +1 -1
- package/esm/tree/tree-node.js +1 -0
- package/esm/tree/tree-node.type.d.ts +3 -3
- package/esm/tree/tree-node.type.d.ts.map +1 -1
- package/esm/tree/tree-root.d.ts.map +1 -1
- package/esm/tree/tree-root.js +12 -1
- package/esm/tree/tree-root.type.d.ts +2 -2
- package/esm/tree/tree-root.type.d.ts.map +1 -1
- package/esm/tree/tree-simple-node.d.ts.map +1 -1
- package/esm/tree/tree-simple-node.js +7 -3
- package/esm/tree/tree-virtual-node.d.ts.map +1 -1
- package/esm/tree/tree-virtual-node.js +6 -3
- package/esm/tree/tree.d.ts.map +1 -1
- package/esm/tree/tree.js +6 -3
- package/esm/tree/tree.type.d.ts +12 -0
- package/esm/tree/tree.type.d.ts.map +1 -1
- package/esm/tree-select/tree-select.d.ts.map +1 -1
- package/esm/tree-select/tree-select.js +2 -1
- package/esm/tree-select/tree-select.type.d.ts +2 -2
- package/esm/tree-select/tree-select.type.d.ts.map +1 -1
- package/package.json +2 -2
- package/cjs/tree/tree-virtual-content.d.ts +0 -5
- package/cjs/tree/tree-virtual-content.d.ts.map +0 -1
- package/cjs/tree/tree-virtual-content.js +0 -202
- package/esm/tree/tree-virtual-content.d.ts +0 -5
- package/esm/tree/tree-virtual-content.d.ts.map +0 -1
- package/esm/tree/tree-virtual-content.js +0 -196
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
var _hooks = require("@sheinx/hooks");
|
|
10
|
-
var _treeCheckbox = _interopRequireDefault(require("./tree-checkbox"));
|
|
11
|
-
var _treeContext = require("./tree-context");
|
|
12
|
-
var _icons = _interopRequireDefault(require("../icons"));
|
|
13
|
-
var _spin = _interopRequireDefault(require("../spin"));
|
|
14
|
-
var _config = require("../config");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
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); }
|
|
18
|
-
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; }
|
|
19
|
-
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; }
|
|
20
|
-
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; }
|
|
21
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
|
-
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); }
|
|
23
|
-
var NodeVirtualContent = function NodeVirtualContent(props) {
|
|
24
|
-
var jssStyle = props.jssStyle,
|
|
25
|
-
id = props.id,
|
|
26
|
-
level = props.level,
|
|
27
|
-
active = props.active,
|
|
28
|
-
data = props.data,
|
|
29
|
-
line = props.line,
|
|
30
|
-
iconClass = props.iconClass,
|
|
31
|
-
contentClassProp = props.contentClass,
|
|
32
|
-
expandIcons = props.expandIcons,
|
|
33
|
-
renderItem = props.renderItem,
|
|
34
|
-
expanded = props.expanded,
|
|
35
|
-
fetching = props.fetching,
|
|
36
|
-
inlineNode = props.inlineNode,
|
|
37
|
-
childrenKey = props.childrenKey,
|
|
38
|
-
parentClickExpand = props.parentClickExpand,
|
|
39
|
-
doubleClickExpand = props.doubleClickExpand,
|
|
40
|
-
bindContent = props.bindContent,
|
|
41
|
-
highlight = props.highlight,
|
|
42
|
-
setFetching = props.setFetching,
|
|
43
|
-
loader = props.loader,
|
|
44
|
-
onChange = props.onChange,
|
|
45
|
-
onToggle = props.onToggle,
|
|
46
|
-
onNodeClick = props.onNodeClick;
|
|
47
|
-
var forceUpdate = (0, _hooks.useRender)();
|
|
48
|
-
var _useTreeContext = (0, _treeContext.useTreeContext)(),
|
|
49
|
-
isDisabled = _useTreeContext.isDisabled,
|
|
50
|
-
bindUpdate = _useTreeContext.bindUpdate;
|
|
51
|
-
var clickLock = (0, _react.useRef)(false);
|
|
52
|
-
var config = (0, _config.useConfig)();
|
|
53
|
-
var disabled = isDisabled(id);
|
|
54
|
-
bindUpdate(id, forceUpdate);
|
|
55
|
-
var contentStyle = (jssStyle === null || jssStyle === void 0 ? void 0 : jssStyle.tree()) || {};
|
|
56
|
-
var rootClass = (0, _classnames.default)(contentStyle.contentWrapper, _defineProperty(_defineProperty(_defineProperty({}, contentStyle.childnode, data[childrenKey] && data[childrenKey].length > 0), contentStyle.inlineContent, inlineNode), contentStyle.contentDisabled, disabled));
|
|
57
|
-
var contentClass = (0, _classnames.default)(contentStyle.content, _hooks.util.isString(contentClassProp) && contentClassProp, _hooks.util.isFunc(contentClassProp) && contentClassProp(data));
|
|
58
|
-
// const textClass = classNames(contentStyle.text, disabled ? contentStyle.textDisabled : '');
|
|
59
|
-
var textClass = (0, _classnames.default)(contentStyle.text);
|
|
60
|
-
var hasExpandIcons = expandIcons !== undefined;
|
|
61
|
-
var children = data[childrenKey];
|
|
62
|
-
var hasChildren = children && children.length > 0;
|
|
63
|
-
var contentDataProps = function contentDataProps() {
|
|
64
|
-
var dataProps = {};
|
|
65
|
-
if (highlight) {
|
|
66
|
-
dataProps['data-active'] = active;
|
|
67
|
-
}
|
|
68
|
-
// if (disabled) {
|
|
69
|
-
// dataProps['data-disabled'] = disabled;
|
|
70
|
-
// }
|
|
71
|
-
return dataProps;
|
|
72
|
-
};
|
|
73
|
-
var handleIndicatorClick = function handleIndicatorClick() {
|
|
74
|
-
onToggle === null || onToggle === void 0 || onToggle(id);
|
|
75
|
-
if (data[childrenKey] !== undefined) return;
|
|
76
|
-
if (loader) {
|
|
77
|
-
setFetching(true);
|
|
78
|
-
var result = loader(id, data);
|
|
79
|
-
if (_hooks.util.isPromise(result)) {
|
|
80
|
-
result.then(function () {
|
|
81
|
-
setFetching(false);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var handleNodeClick = function handleNodeClick() {
|
|
87
|
-
if (parentClickExpand && hasChildren) {
|
|
88
|
-
if (clickLock.current) {
|
|
89
|
-
clickLock.current = false;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
handleIndicatorClick();
|
|
93
|
-
} else {
|
|
94
|
-
onNodeClick(data, id);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var handleClick = function handleClick() {
|
|
98
|
-
clickLock.current = true;
|
|
99
|
-
};
|
|
100
|
-
var handleNodeExpand = function handleNodeExpand() {
|
|
101
|
-
if (!doubleClickExpand) return;
|
|
102
|
-
if (hasChildren) handleIndicatorClick();
|
|
103
|
-
};
|
|
104
|
-
var renderLoading = function renderLoading() {
|
|
105
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
106
|
-
style: {
|
|
107
|
-
left: (level - 1) * 24
|
|
108
|
-
},
|
|
109
|
-
className: contentStyle.iconWrapper,
|
|
110
|
-
"data-expanded": expanded,
|
|
111
|
-
"data-icon": hasExpandIcons,
|
|
112
|
-
dir: config.direction,
|
|
113
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_spin.default, {
|
|
114
|
-
size: 12,
|
|
115
|
-
jssStyle: jssStyle,
|
|
116
|
-
ignoreConfig: true,
|
|
117
|
-
name: "ring"
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
var renderIndicator = function renderIndicator() {
|
|
122
|
-
var children = data[childrenKey];
|
|
123
|
-
var icon = expandIcons ? expandIcons[expanded ? 1 : 0] : expanded ? _icons.default.tree.LineExpand : _icons.default.tree.LineCollapse;
|
|
124
|
-
var indicator;
|
|
125
|
-
if (line) {
|
|
126
|
-
indicator = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
127
|
-
className: contentStyle.iconWrapper,
|
|
128
|
-
"data-expanded": expanded,
|
|
129
|
-
"data-icon": hasExpandIcons,
|
|
130
|
-
dir: config.direction,
|
|
131
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
132
|
-
className: (0, _classnames.default)(contentStyle.icon, iconClass),
|
|
133
|
-
onClick: handleIndicatorClick,
|
|
134
|
-
dir: config.direction,
|
|
135
|
-
children: _hooks.util.isFunc(icon) ? icon(data) : icon
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
indicator = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
140
|
-
style: {
|
|
141
|
-
left: (level - 1) * 24
|
|
142
|
-
},
|
|
143
|
-
className: contentStyle.iconWrapper,
|
|
144
|
-
"data-expanded": expanded,
|
|
145
|
-
"data-icon": hasExpandIcons,
|
|
146
|
-
dir: config.direction,
|
|
147
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
148
|
-
className: (0, _classnames.default)(contentStyle.icon, iconClass),
|
|
149
|
-
onClick: handleIndicatorClick,
|
|
150
|
-
dir: config.direction,
|
|
151
|
-
children: _hooks.util.isFunc(icon) ? icon(data) : hasExpandIcons ? icon : _icons.default.tree.Expand
|
|
152
|
-
})
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (children && children.length > 0) return indicator;
|
|
156
|
-
if (Array.isArray(children) || children === null) return null;
|
|
157
|
-
if (fetching && !children) return renderLoading();
|
|
158
|
-
if (loader && children === undefined) return indicator;
|
|
159
|
-
return null;
|
|
160
|
-
};
|
|
161
|
-
var renderCheckbox = function renderCheckbox() {
|
|
162
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_treeCheckbox.default, {
|
|
163
|
-
jssStyle: jssStyle,
|
|
164
|
-
id: id,
|
|
165
|
-
disabled: disabled,
|
|
166
|
-
className: contentStyle.checkbox,
|
|
167
|
-
onChange: onChange,
|
|
168
|
-
onClick: handleClick
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
var renderNode = function renderNode() {
|
|
172
|
-
var render = _hooks.util.isFunc(renderItem) ? renderItem : function (item) {
|
|
173
|
-
return item[renderItem];
|
|
174
|
-
};
|
|
175
|
-
return render(data, expanded, active, id);
|
|
176
|
-
};
|
|
177
|
-
var contentEvent = {
|
|
178
|
-
onClick: inlineNode ? undefined : handleNodeClick
|
|
179
|
-
};
|
|
180
|
-
var textEvent = {
|
|
181
|
-
onClick: inlineNode ? handleNodeClick : undefined
|
|
182
|
-
};
|
|
183
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
184
|
-
className: rootClass,
|
|
185
|
-
dir: config.direction,
|
|
186
|
-
children: [renderIndicator(), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread(_objectSpread({
|
|
187
|
-
dir: config.direction,
|
|
188
|
-
"data-expanded": expanded,
|
|
189
|
-
ref: bindContent,
|
|
190
|
-
className: contentClass
|
|
191
|
-
}, contentDataProps()), contentEvent), {}, {
|
|
192
|
-
children: [onChange && renderCheckbox(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
|
|
193
|
-
dir: config.direction,
|
|
194
|
-
className: textClass,
|
|
195
|
-
onDoubleClick: handleNodeExpand
|
|
196
|
-
}, textEvent), {}, {
|
|
197
|
-
children: renderNode()
|
|
198
|
-
}))]
|
|
199
|
-
}))]
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
var _default = exports.default = NodeVirtualContent;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { KeygenResult } from '@sheinx/hooks';
|
|
2
|
-
import { TreeVirtualContextProps } from './tree-content.type';
|
|
3
|
-
declare const NodeVirtualContent: <DataItem, Value extends KeygenResult[]>(props: TreeVirtualContextProps<DataItem, Value>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export default NodeVirtualContent;
|
|
5
|
-
//# sourceMappingURL=tree-virtual-content.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tree-virtual-content.d.ts","sourceRoot":"","sources":["tree-virtual-content.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAmB,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAO9D,QAAA,MAAM,kBAAkB,sIA6NvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,196 +0,0 @@
|
|
|
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 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; }
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
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); }
|
|
7
|
-
import { useRef } from 'react';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import { util, useRender } from '@sheinx/hooks';
|
|
10
|
-
import Checkbox from "./tree-checkbox";
|
|
11
|
-
import { useTreeContext } from "./tree-context";
|
|
12
|
-
import Icons from "../icons";
|
|
13
|
-
import Spin from "../spin";
|
|
14
|
-
import { useConfig } from "../config";
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
var NodeVirtualContent = function NodeVirtualContent(props) {
|
|
18
|
-
var jssStyle = props.jssStyle,
|
|
19
|
-
id = props.id,
|
|
20
|
-
level = props.level,
|
|
21
|
-
active = props.active,
|
|
22
|
-
data = props.data,
|
|
23
|
-
line = props.line,
|
|
24
|
-
iconClass = props.iconClass,
|
|
25
|
-
contentClassProp = props.contentClass,
|
|
26
|
-
expandIcons = props.expandIcons,
|
|
27
|
-
renderItem = props.renderItem,
|
|
28
|
-
expanded = props.expanded,
|
|
29
|
-
fetching = props.fetching,
|
|
30
|
-
inlineNode = props.inlineNode,
|
|
31
|
-
childrenKey = props.childrenKey,
|
|
32
|
-
parentClickExpand = props.parentClickExpand,
|
|
33
|
-
doubleClickExpand = props.doubleClickExpand,
|
|
34
|
-
bindContent = props.bindContent,
|
|
35
|
-
highlight = props.highlight,
|
|
36
|
-
setFetching = props.setFetching,
|
|
37
|
-
loader = props.loader,
|
|
38
|
-
onChange = props.onChange,
|
|
39
|
-
onToggle = props.onToggle,
|
|
40
|
-
onNodeClick = props.onNodeClick;
|
|
41
|
-
var forceUpdate = useRender();
|
|
42
|
-
var _useTreeContext = useTreeContext(),
|
|
43
|
-
isDisabled = _useTreeContext.isDisabled,
|
|
44
|
-
bindUpdate = _useTreeContext.bindUpdate;
|
|
45
|
-
var clickLock = useRef(false);
|
|
46
|
-
var config = useConfig();
|
|
47
|
-
var disabled = isDisabled(id);
|
|
48
|
-
bindUpdate(id, forceUpdate);
|
|
49
|
-
var contentStyle = (jssStyle === null || jssStyle === void 0 ? void 0 : jssStyle.tree()) || {};
|
|
50
|
-
var rootClass = classNames(contentStyle.contentWrapper, _defineProperty(_defineProperty(_defineProperty({}, contentStyle.childnode, data[childrenKey] && data[childrenKey].length > 0), contentStyle.inlineContent, inlineNode), contentStyle.contentDisabled, disabled));
|
|
51
|
-
var contentClass = classNames(contentStyle.content, util.isString(contentClassProp) && contentClassProp, util.isFunc(contentClassProp) && contentClassProp(data));
|
|
52
|
-
// const textClass = classNames(contentStyle.text, disabled ? contentStyle.textDisabled : '');
|
|
53
|
-
var textClass = classNames(contentStyle.text);
|
|
54
|
-
var hasExpandIcons = expandIcons !== undefined;
|
|
55
|
-
var children = data[childrenKey];
|
|
56
|
-
var hasChildren = children && children.length > 0;
|
|
57
|
-
var contentDataProps = function contentDataProps() {
|
|
58
|
-
var dataProps = {};
|
|
59
|
-
if (highlight) {
|
|
60
|
-
dataProps['data-active'] = active;
|
|
61
|
-
}
|
|
62
|
-
// if (disabled) {
|
|
63
|
-
// dataProps['data-disabled'] = disabled;
|
|
64
|
-
// }
|
|
65
|
-
return dataProps;
|
|
66
|
-
};
|
|
67
|
-
var handleIndicatorClick = function handleIndicatorClick() {
|
|
68
|
-
onToggle === null || onToggle === void 0 || onToggle(id);
|
|
69
|
-
if (data[childrenKey] !== undefined) return;
|
|
70
|
-
if (loader) {
|
|
71
|
-
setFetching(true);
|
|
72
|
-
var result = loader(id, data);
|
|
73
|
-
if (util.isPromise(result)) {
|
|
74
|
-
result.then(function () {
|
|
75
|
-
setFetching(false);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var handleNodeClick = function handleNodeClick() {
|
|
81
|
-
if (parentClickExpand && hasChildren) {
|
|
82
|
-
if (clickLock.current) {
|
|
83
|
-
clickLock.current = false;
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
handleIndicatorClick();
|
|
87
|
-
} else {
|
|
88
|
-
onNodeClick(data, id);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
var handleClick = function handleClick() {
|
|
92
|
-
clickLock.current = true;
|
|
93
|
-
};
|
|
94
|
-
var handleNodeExpand = function handleNodeExpand() {
|
|
95
|
-
if (!doubleClickExpand) return;
|
|
96
|
-
if (hasChildren) handleIndicatorClick();
|
|
97
|
-
};
|
|
98
|
-
var renderLoading = function renderLoading() {
|
|
99
|
-
return /*#__PURE__*/_jsx("span", {
|
|
100
|
-
style: {
|
|
101
|
-
left: (level - 1) * 24
|
|
102
|
-
},
|
|
103
|
-
className: contentStyle.iconWrapper,
|
|
104
|
-
"data-expanded": expanded,
|
|
105
|
-
"data-icon": hasExpandIcons,
|
|
106
|
-
dir: config.direction,
|
|
107
|
-
children: /*#__PURE__*/_jsx(Spin, {
|
|
108
|
-
size: 12,
|
|
109
|
-
jssStyle: jssStyle,
|
|
110
|
-
ignoreConfig: true,
|
|
111
|
-
name: "ring"
|
|
112
|
-
})
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
var renderIndicator = function renderIndicator() {
|
|
116
|
-
var children = data[childrenKey];
|
|
117
|
-
var icon = expandIcons ? expandIcons[expanded ? 1 : 0] : expanded ? Icons.tree.LineExpand : Icons.tree.LineCollapse;
|
|
118
|
-
var indicator;
|
|
119
|
-
if (line) {
|
|
120
|
-
indicator = /*#__PURE__*/_jsx("span", {
|
|
121
|
-
className: contentStyle.iconWrapper,
|
|
122
|
-
"data-expanded": expanded,
|
|
123
|
-
"data-icon": hasExpandIcons,
|
|
124
|
-
dir: config.direction,
|
|
125
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
126
|
-
className: classNames(contentStyle.icon, iconClass),
|
|
127
|
-
onClick: handleIndicatorClick,
|
|
128
|
-
dir: config.direction,
|
|
129
|
-
children: util.isFunc(icon) ? icon(data) : icon
|
|
130
|
-
})
|
|
131
|
-
});
|
|
132
|
-
} else {
|
|
133
|
-
indicator = /*#__PURE__*/_jsx("span", {
|
|
134
|
-
style: {
|
|
135
|
-
left: (level - 1) * 24
|
|
136
|
-
},
|
|
137
|
-
className: contentStyle.iconWrapper,
|
|
138
|
-
"data-expanded": expanded,
|
|
139
|
-
"data-icon": hasExpandIcons,
|
|
140
|
-
dir: config.direction,
|
|
141
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
142
|
-
className: classNames(contentStyle.icon, iconClass),
|
|
143
|
-
onClick: handleIndicatorClick,
|
|
144
|
-
dir: config.direction,
|
|
145
|
-
children: util.isFunc(icon) ? icon(data) : hasExpandIcons ? icon : Icons.tree.Expand
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
if (children && children.length > 0) return indicator;
|
|
150
|
-
if (Array.isArray(children) || children === null) return null;
|
|
151
|
-
if (fetching && !children) return renderLoading();
|
|
152
|
-
if (loader && children === undefined) return indicator;
|
|
153
|
-
return null;
|
|
154
|
-
};
|
|
155
|
-
var renderCheckbox = function renderCheckbox() {
|
|
156
|
-
return /*#__PURE__*/_jsx(Checkbox, {
|
|
157
|
-
jssStyle: jssStyle,
|
|
158
|
-
id: id,
|
|
159
|
-
disabled: disabled,
|
|
160
|
-
className: contentStyle.checkbox,
|
|
161
|
-
onChange: onChange,
|
|
162
|
-
onClick: handleClick
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var renderNode = function renderNode() {
|
|
166
|
-
var render = util.isFunc(renderItem) ? renderItem : function (item) {
|
|
167
|
-
return item[renderItem];
|
|
168
|
-
};
|
|
169
|
-
return render(data, expanded, active, id);
|
|
170
|
-
};
|
|
171
|
-
var contentEvent = {
|
|
172
|
-
onClick: inlineNode ? undefined : handleNodeClick
|
|
173
|
-
};
|
|
174
|
-
var textEvent = {
|
|
175
|
-
onClick: inlineNode ? handleNodeClick : undefined
|
|
176
|
-
};
|
|
177
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
178
|
-
className: rootClass,
|
|
179
|
-
dir: config.direction,
|
|
180
|
-
children: [renderIndicator(), /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread(_objectSpread({
|
|
181
|
-
dir: config.direction,
|
|
182
|
-
"data-expanded": expanded,
|
|
183
|
-
ref: bindContent,
|
|
184
|
-
className: contentClass
|
|
185
|
-
}, contentDataProps()), contentEvent), {}, {
|
|
186
|
-
children: [onChange && renderCheckbox(), /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
|
|
187
|
-
dir: config.direction,
|
|
188
|
-
className: textClass,
|
|
189
|
-
onDoubleClick: handleNodeExpand
|
|
190
|
-
}, textEvent), {}, {
|
|
191
|
-
children: renderNode()
|
|
192
|
-
}))]
|
|
193
|
-
}))]
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
export default NodeVirtualContent;
|