@donglegeyu/company-ui 2.6.0 → 2.7.0

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.
@@ -44,6 +44,10 @@ export interface TreeTableTemplateProps<T = Record<string, unknown>> extends Omi
44
44
  onNodeEdit?: (key: string) => void;
45
45
  /** 树节点 hover 操作:删除按钮回调 */
46
46
  onNodeDelete?: (key: string) => void;
47
+ /** 左树底部「新增」按钮回调(不传则不显示按钮) */
48
+ onTreeAdd?: () => void;
49
+ /** 左树底部新增按钮文案 */
50
+ treeAddText?: string;
47
51
  /** 左树面板初始宽度(支持拖拽调节) */
48
52
  treeWidth?: number;
49
53
  /** 左树面板最小宽度(拖拽下限) */
@@ -55,6 +55,8 @@ var TreeTableTemplate = (props) => {
55
55
  onNodeAdd,
56
56
  onNodeEdit,
57
57
  onNodeDelete,
58
+ onTreeAdd,
59
+ treeAddText = "新增部门",
58
60
  treeWidth = 232,
59
61
  minTreeWidth = 200,
60
62
  maxTreeWidth = 480,
@@ -207,40 +209,49 @@ var TreeTableTemplate = (props) => {
207
209
  children: typeof node.title === "function" ? node.title(node) : node.title
208
210
  }
209
211
  ),
210
- hasNodeActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ttt-tree-node-actions", onClick: (e) => e.stopPropagation(), children: [
211
- onNodeAdd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "新增", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
- import_basic_components.CompanyButton,
213
- {
214
- type: "text",
215
- size: "small",
216
- className: "ttt-tree-action-btn",
217
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.PlusOutlined, {}),
218
- onClick: () => onNodeAdd(String(node.key))
219
- }
220
- ) }),
221
- onNodeEdit && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "编辑", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
- import_basic_components.CompanyButton,
223
- {
224
- type: "text",
225
- size: "small",
226
- className: "ttt-tree-action-btn",
227
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EditOutlined, {}),
228
- onClick: () => onNodeEdit(String(node.key))
229
- }
230
- ) }),
231
- onNodeDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "删除", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
232
- import_basic_components.CompanyButton,
233
- {
234
- type: "text",
235
- size: "small",
236
- className: "ttt-tree-action-btn",
237
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DeleteOutlined, {}),
238
- onClick: () => onNodeDelete(String(node.key))
239
- }
240
- ) })
241
- ] })
212
+ hasNodeActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ttt-tree-node-actions", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
+ import_basic_components.CompanyDropdown,
214
+ {
215
+ trigger: ["click"],
216
+ menu: {
217
+ items: [
218
+ ...onNodeAdd ? [{ key: "add", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.PlusOutlined, {}), label: "新增" }] : [],
219
+ ...onNodeEdit ? [{ key: "edit", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EditOutlined, {}), label: "编辑" }] : [],
220
+ ...onNodeDelete ? [{ key: "delete", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DeleteOutlined, {}), label: "删除" }] : []
221
+ ],
222
+ onClick: ({ key }) => {
223
+ if (key === "add")
224
+ onNodeAdd == null ? void 0 : onNodeAdd(String(node.key));
225
+ else if (key === "edit")
226
+ onNodeEdit == null ? void 0 : onNodeEdit(String(node.key));
227
+ else if (key === "delete")
228
+ onNodeDelete == null ? void 0 : onNodeDelete(String(node.key));
229
+ }
230
+ },
231
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
232
+ import_basic_components.CompanyButton,
233
+ {
234
+ type: "text",
235
+ size: "small",
236
+ className: "ttt-tree-action-btn",
237
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.MoreOutlined, {}),
238
+ onClick: (e) => e.stopPropagation()
239
+ }
240
+ )
241
+ }
242
+ ) })
242
243
  ] })
243
244
  }
245
+ ),
246
+ onTreeAdd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
247
+ import_basic_components.CompanyButton,
248
+ {
249
+ block: true,
250
+ className: "ttt-tree-add-btn",
251
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.PlusOutlined, {}),
252
+ onClick: onTreeAdd,
253
+ children: treeAddText
254
+ }
244
255
  )
245
256
  ] }),
246
257
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -90,8 +90,9 @@
90
90
  overflow: hidden;
91
91
  text-overflow: ellipsis;
92
92
  white-space: nowrap;
93
- margin-left: 13px;
94
- padding: 0 8px;
93
+ margin-left: 9px;
94
+ padding-left: 4px;
95
+ padding-right: 0;
95
96
  line-height: 28px;
96
97
  border-radius: 6px;
97
98
  transition: all var(--motion-duration-fast, 0.2s)
@@ -107,7 +108,7 @@
107
108
  }
108
109
  }
109
110
 
110
- // 树节点:hover 时在右侧显示操作按钮(新增 / 编辑 / 删除)
111
+ // 树节点:hover 时在右侧显示「更多」操作按钮(点击弹出新增 / 编辑 / 删除下拉菜单)
111
112
  .ttt-tree-node {
112
113
  display: flex;
113
114
  align-items: center;
@@ -126,19 +127,38 @@
126
127
  display: none;
127
128
  align-items: center;
128
129
  flex-shrink: 0;
129
- margin-right: 4px;
130
+ margin-right: 0;
130
131
 
131
132
  .ttt-tree-action-btn {
132
- // 压缩按钮内边距,避免三个按钮挤占过宽
133
+ // 压缩按钮内边距,避免挤占节点标题空间
133
134
  padding-inline: 2px;
134
135
  }
135
136
  }
136
137
  }
137
138
 
139
+ // 树节点内容容器:左内边距 8px → 4px(收紧文字与箭头间距),右内边距归零(选中背景/内容区贴齐右侧)
140
+ .ttt-tree-panel .ant-tree-node-content-wrapper {
141
+ padding-inline: 4px 0;
142
+ }
143
+
144
+ // 树展开/收起箭头(open/close/noop 状态统一):去掉 antd 默认 6px 右外边距,箭头与节点内容贴紧
145
+ .ttt-tree-panel .ant-tree-switcher {
146
+ margin-inline-end: 0;
147
+ }
148
+
138
149
  .ttt-tree-panel .ant-tree-node-content-wrapper:hover .ttt-tree-node-actions {
139
150
  display: inline-flex;
140
151
  }
141
152
 
153
+ // 左树底部「新增」按钮:树内容不超一屏时跟随内容,超一屏时吸底(sticky 原生行为,无需 JS 判断)
154
+ .ttt-tree-add-btn {
155
+ position: sticky;
156
+ bottom: 0;
157
+ z-index: 1;
158
+ margin-top: calc(var(--spacing-xs, 8) * 1px);
159
+ background: var(--color-bg-container);
160
+ }
161
+
142
162
  // 右侧列表:复用 StatisticsListPage,隐藏其内置标题栏(页面标题由模板统一渲染)
143
163
  .ttt-body > .statistics-list-page {
144
164
  flex: 1;
@@ -44,6 +44,10 @@ export interface TreeTableTemplateProps<T = Record<string, unknown>> extends Omi
44
44
  onNodeEdit?: (key: string) => void;
45
45
  /** 树节点 hover 操作:删除按钮回调 */
46
46
  onNodeDelete?: (key: string) => void;
47
+ /** 左树底部「新增」按钮回调(不传则不显示按钮) */
48
+ onTreeAdd?: () => void;
49
+ /** 左树底部新增按钮文案 */
50
+ treeAddText?: string;
47
51
  /** 左树面板初始宽度(支持拖拽调节) */
48
52
  treeWidth?: number;
49
53
  /** 左树面板最小宽度(拖拽下限) */
@@ -1,5 +1,5 @@
1
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
- var _excluded = ["title", "titleExtra", "titleActions", "viewEndpoint", "treeData", "rootNode", "treeSearchPlaceholder", "defaultSelectedKey", "onTreeSelect", "onNodeAdd", "onNodeEdit", "onNodeDelete", "treeWidth", "minTreeWidth", "maxTreeWidth", "className", "style"];
2
+ var _excluded = ["title", "titleExtra", "titleActions", "viewEndpoint", "treeData", "rootNode", "treeSearchPlaceholder", "defaultSelectedKey", "onTreeSelect", "onNodeAdd", "onNodeEdit", "onNodeDelete", "onTreeAdd", "treeAddText", "treeWidth", "minTreeWidth", "maxTreeWidth", "className", "style"];
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
5
  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; } }
@@ -18,8 +18,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
18
18
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
19
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
20
20
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
21
- import { PlusOutlined, EditOutlined, DeleteOutlined } from "@ant-design/icons";
22
- import { CompanyButton, CompanyInput, CompanyTooltip, CompanyTree } from "../../basic-components";
21
+ import { MoreOutlined, PlusOutlined, EditOutlined, DeleteOutlined } from "@ant-design/icons";
22
+ import { CompanyButton, CompanyDropdown, CompanyInput, CompanyTree } from "../../basic-components";
23
23
  import { PageTitle, SvgIcon } from "../../shared-components";
24
24
  import { StatisticsListPage } from "../StatisticsListPage";
25
25
  import { useCompanyToken } from "../../theme/useCompanyToken";
@@ -77,6 +77,9 @@ export var TreeTableTemplate = function TreeTableTemplate(props) {
77
77
  onNodeAdd = props.onNodeAdd,
78
78
  onNodeEdit = props.onNodeEdit,
79
79
  onNodeDelete = props.onNodeDelete,
80
+ onTreeAdd = props.onTreeAdd,
81
+ _props$treeAddText = props.treeAddText,
82
+ treeAddText = _props$treeAddText === void 0 ? "新增部门" : _props$treeAddText,
80
83
  _props$treeWidth = props.treeWidth,
81
84
  treeWidth = _props$treeWidth === void 0 ? 232 : _props$treeWidth,
82
85
  _props$minTreeWidth = props.minTreeWidth,
@@ -260,48 +263,51 @@ export var TreeTableTemplate = function TreeTableTemplate(props) {
260
263
  className: "ttt-tree-node-label",
261
264
  title: typeof node.title === "string" ? node.title : undefined,
262
265
  children: typeof node.title === "function" ? node.title(node) : node.title
263
- }), hasNodeActions && /*#__PURE__*/_jsxs("span", {
266
+ }), hasNodeActions && /*#__PURE__*/_jsx("span", {
264
267
  className: "ttt-tree-node-actions",
265
268
  onClick: function onClick(e) {
266
269
  return e.stopPropagation();
267
270
  },
268
- children: [onNodeAdd && /*#__PURE__*/_jsx(CompanyTooltip, {
269
- title: "\u65B0\u589E",
270
- children: /*#__PURE__*/_jsx(CompanyButton, {
271
- type: "text",
272
- size: "small",
273
- className: "ttt-tree-action-btn",
274
- icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
275
- onClick: function onClick() {
276
- return onNodeAdd(String(node.key));
271
+ children: /*#__PURE__*/_jsx(CompanyDropdown, {
272
+ trigger: ["click"],
273
+ menu: {
274
+ items: [].concat(_toConsumableArray(onNodeAdd ? [{
275
+ key: "add",
276
+ icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
277
+ label: "新增"
278
+ }] : []), _toConsumableArray(onNodeEdit ? [{
279
+ key: "edit",
280
+ icon: /*#__PURE__*/_jsx(EditOutlined, {}),
281
+ label: "编辑"
282
+ }] : []), _toConsumableArray(onNodeDelete ? [{
283
+ key: "delete",
284
+ icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
285
+ label: "删除"
286
+ }] : [])),
287
+ onClick: function onClick(_ref) {
288
+ var key = _ref.key;
289
+ if (key === "add") onNodeAdd === null || onNodeAdd === void 0 || onNodeAdd(String(node.key));else if (key === "edit") onNodeEdit === null || onNodeEdit === void 0 || onNodeEdit(String(node.key));else if (key === "delete") onNodeDelete === null || onNodeDelete === void 0 || onNodeDelete(String(node.key));
277
290
  }
278
- })
279
- }), onNodeEdit && /*#__PURE__*/_jsx(CompanyTooltip, {
280
- title: "\u7F16\u8F91",
281
- children: /*#__PURE__*/_jsx(CompanyButton, {
282
- type: "text",
283
- size: "small",
284
- className: "ttt-tree-action-btn",
285
- icon: /*#__PURE__*/_jsx(EditOutlined, {}),
286
- onClick: function onClick() {
287
- return onNodeEdit(String(node.key));
288
- }
289
- })
290
- }), onNodeDelete && /*#__PURE__*/_jsx(CompanyTooltip, {
291
- title: "\u5220\u9664",
291
+ },
292
292
  children: /*#__PURE__*/_jsx(CompanyButton, {
293
293
  type: "text",
294
294
  size: "small",
295
295
  className: "ttt-tree-action-btn",
296
- icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
297
- onClick: function onClick() {
298
- return onNodeDelete(String(node.key));
296
+ icon: /*#__PURE__*/_jsx(MoreOutlined, {}),
297
+ onClick: function onClick(e) {
298
+ return e.stopPropagation();
299
299
  }
300
300
  })
301
- })]
301
+ })
302
302
  })]
303
303
  });
304
304
  }
305
+ }), onTreeAdd && /*#__PURE__*/_jsx(CompanyButton, {
306
+ block: true,
307
+ className: "ttt-tree-add-btn",
308
+ icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
309
+ onClick: onTreeAdd,
310
+ children: treeAddText
305
311
  })]
306
312
  }), /*#__PURE__*/_jsx(StatisticsListPage, _objectSpread(_objectSpread({}, listProps), {}, {
307
313
  viewEndpoint: viewEndpoint,
@@ -90,8 +90,9 @@
90
90
  overflow: hidden;
91
91
  text-overflow: ellipsis;
92
92
  white-space: nowrap;
93
- margin-left: 13px;
94
- padding: 0 8px;
93
+ margin-left: 9px;
94
+ padding-left: 4px;
95
+ padding-right: 0;
95
96
  line-height: 28px;
96
97
  border-radius: 6px;
97
98
  transition: all var(--motion-duration-fast, 0.2s)
@@ -107,7 +108,7 @@
107
108
  }
108
109
  }
109
110
 
110
- // 树节点:hover 时在右侧显示操作按钮(新增 / 编辑 / 删除)
111
+ // 树节点:hover 时在右侧显示「更多」操作按钮(点击弹出新增 / 编辑 / 删除下拉菜单)
111
112
  .ttt-tree-node {
112
113
  display: flex;
113
114
  align-items: center;
@@ -126,19 +127,38 @@
126
127
  display: none;
127
128
  align-items: center;
128
129
  flex-shrink: 0;
129
- margin-right: 4px;
130
+ margin-right: 0;
130
131
 
131
132
  .ttt-tree-action-btn {
132
- // 压缩按钮内边距,避免三个按钮挤占过宽
133
+ // 压缩按钮内边距,避免挤占节点标题空间
133
134
  padding-inline: 2px;
134
135
  }
135
136
  }
136
137
  }
137
138
 
139
+ // 树节点内容容器:左内边距 8px → 4px(收紧文字与箭头间距),右内边距归零(选中背景/内容区贴齐右侧)
140
+ .ttt-tree-panel .ant-tree-node-content-wrapper {
141
+ padding-inline: 4px 0;
142
+ }
143
+
144
+ // 树展开/收起箭头(open/close/noop 状态统一):去掉 antd 默认 6px 右外边距,箭头与节点内容贴紧
145
+ .ttt-tree-panel .ant-tree-switcher {
146
+ margin-inline-end: 0;
147
+ }
148
+
138
149
  .ttt-tree-panel .ant-tree-node-content-wrapper:hover .ttt-tree-node-actions {
139
150
  display: inline-flex;
140
151
  }
141
152
 
153
+ // 左树底部「新增」按钮:树内容不超一屏时跟随内容,超一屏时吸底(sticky 原生行为,无需 JS 判断)
154
+ .ttt-tree-add-btn {
155
+ position: sticky;
156
+ bottom: 0;
157
+ z-index: 1;
158
+ margin-top: calc(var(--spacing-xs, 8) * 1px);
159
+ background: var(--color-bg-container);
160
+ }
161
+
142
162
  // 右侧列表:复用 StatisticsListPage,隐藏其内置标题栏(页面标题由模板统一渲染)
143
163
  .ttt-body > .statistics-list-page {
144
164
  flex: 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donglegeyu/company-ui",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",