@donglegeyu/company-ui 2.1.0 → 2.2.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.
@@ -7,29 +7,42 @@ export interface DrawerDetailTab {
7
7
  label: ReactNode;
8
8
  content: ReactNode;
9
9
  }
10
+ /** 顶部核心区的关键字段行(label + value 纯文字行,对齐设计稿) */
11
+ export interface DrawerDetailField {
12
+ label: ReactNode;
13
+ value: ReactNode;
14
+ }
10
15
  export interface DrawerDetailTemplateProps extends Omit<DrawerProps, "onClose" | "footer" | "destroyOnClose" | "maskClosable"> {
11
- /** 抽屉是否打开 */
16
+ /** 抽屉标题(Head 行 16px/600,含关闭图标) */
17
+ title?: ReactNode;
18
+ /** 是否打开 */
12
19
  open: boolean;
13
20
  /** 关闭回调 */
14
21
  onClose: () => void;
15
- /** 抽屉标题(顶部核心区标题) */
16
- title?: ReactNode;
17
- /** 抽屉宽度(业务约定详情抽屉默认 640;表单抽屉 DrawerFormTemplate 为 440) */
22
+ /** 24px 大标题(Head 下方内容区首行,与 tags/actions 同行) */
23
+ name?: ReactNode;
24
+ /** 大标题右侧的状态标签(CompanyTag 数组或自定义 ReactNode) */
25
+ tags?: ReactNode;
26
+ /** 大标题行最右侧的操作区(如「编辑」主按钮),与标题解耦 */
27
+ titleActions?: ReactNode;
28
+ /** 大标题下方的关键字段行(label 45% 灰 + value 88% 黑,行距 4px) */
29
+ fields?: DrawerDetailField[];
30
+ /** 抽屉宽度(业务约定详情抽屉默认 440,对齐设计稿;表单抽屉同为 440) */
18
31
  width?: number | string;
19
32
  /**
20
33
  * 点击遮罩是否关闭;详情为只读、无填写内容会丢失,业务约定默认 true。
21
34
  * 与 DrawerFormTemplate 的默认 false 相反(表单有未保存数据,误触会丢失)。
22
35
  */
23
36
  maskClosable?: boolean;
24
- /** 顶部核心区内容(状态标签、关键字段等),固定在抽屉顶部、不随内容滚动 */
37
+ /** 自定义顶部核心区内容(传入后替代内置 name/tags/titleActions/fields 结构) */
25
38
  headerContent?: ReactNode;
26
- /** 顶部核心区副标题/说明文字 */
39
+ /** 顶部核心区副标题/说明文字(内置结构时渲染在 fields 下方、分割线上方) */
27
40
  description?: ReactNode;
28
41
  /** 内容区分 Tab 配置;不传则直接渲染 children */
29
42
  tabs?: DrawerDetailTab[];
30
43
  /** 受控当前 Tab */
31
44
  activeTabKey?: string;
32
- /** 非受控默认 Tab */
45
+ /** 非受控 defaultActiveKey */
33
46
  defaultActiveTabKey?: string;
34
47
  /** Tab 切换回调 */
35
48
  onTabChange?: (key: string) => void;
@@ -33,7 +33,11 @@ var DrawerDetailTemplateInner = ({
33
33
  open,
34
34
  onClose,
35
35
  title,
36
- width = 640,
36
+ name,
37
+ tags,
38
+ titleActions,
39
+ fields,
40
+ width = 440,
37
41
  maskClosable = true,
38
42
  headerContent,
39
43
  description,
@@ -49,7 +53,8 @@ var DrawerDetailTemplateInner = ({
49
53
  }, ref) => {
50
54
  const { token } = import_antd.theme.useToken();
51
55
  const isPresent = (value) => value !== void 0 && value !== null;
52
- const hasHeader = isPresent(headerContent) || isPresent(description);
56
+ const hasStructuredHeader = isPresent(name) || isPresent(tags) || isPresent(titleActions) || fields && fields.length > 0;
57
+ const hasHeader = hasStructuredHeader || isPresent(headerContent) || isPresent(description);
53
58
  const mergedClassNames = (info) => {
54
59
  const base = typeof classNames === "function" ? classNames(info) : classNames;
55
60
  return {
@@ -58,26 +63,29 @@ var DrawerDetailTemplateInner = ({
58
63
  };
59
64
  };
60
65
  const bodyNode = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "drawer-detail-template", ref, children: [
61
- hasHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
66
+ hasHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drawer-detail-template__header", children: headerContent ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
62
67
  "div",
63
68
  {
64
- className: "drawer-detail-template__header",
65
- style: {
66
- padding: `${token.paddingMD}px ${token.paddingLG}px`
67
- },
69
+ className: "drawer-detail-template__header-inner",
70
+ style: { padding: `${token.paddingMD}px ${token.paddingLG}px` },
68
71
  children: [
69
- headerContent,
70
- isPresent(description) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
- "div",
72
- {
73
- className: "drawer-detail-template__description",
74
- style: { marginTop: token.marginXS },
75
- children: description
76
- }
77
- ) : null
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "drawer-detail-template__name-row", children: [
73
+ isPresent(name) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "drawer-detail-template__name", children: name }) : null,
74
+ tags,
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "drawer-detail-template__name-spacer" }),
76
+ isPresent(titleActions) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drawer-detail-template__title-actions", children: titleActions }) : null
77
+ ] }),
78
+ fields && fields.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drawer-detail-template__fields", children: fields.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "drawer-detail-template__field", children: [
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "drawer-detail-template__field-label", children: [
80
+ field.label,
81
+ ":"
82
+ ] }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "drawer-detail-template__field-value", children: field.value ?? "--" })
84
+ ] }, index)) }) : null,
85
+ isPresent(description) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drawer-detail-template__description", children: description }) : null
78
86
  ]
79
87
  }
80
- ) : null,
88
+ ) }) : null,
81
89
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "drawer-detail-template__content", children: tabs && tabs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
90
  import_basic_components.CompanyTabs,
83
91
  {
@@ -88,17 +96,17 @@ var DrawerDetailTemplateInner = ({
88
96
  items: tabs.map((tab) => ({
89
97
  key: tab.key,
90
98
  label: tab.label,
91
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { padding: token.paddingLG }, children: tab.content })
99
+ children: tab.content
92
100
  }))
93
101
  }
94
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { padding: token.paddingLG }, children }) })
102
+ ) : children })
95
103
  ] });
96
104
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
105
  import_basic_components.CompanyDrawer,
98
106
  {
99
107
  open,
100
108
  title,
101
- width,
109
+ size: width,
102
110
  onClose,
103
111
  maskClosable,
104
112
  footer: footer ?? null,
@@ -19,7 +19,57 @@
19
19
  background: var(--color-bg-container);
20
20
  }
21
21
 
22
+ // 大标题行:24px/600 大标题 + 状态 Tag + 弹性占位 + 操作按钮
23
+ &__name-row {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 8px;
27
+ margin-bottom: 12px;
28
+ }
29
+
30
+ &__name {
31
+ font-size: 24px;
32
+ font-weight: 600;
33
+ line-height: 32px;
34
+ color: rgba(0, 0, 0, 0.88);
35
+ }
36
+
37
+ &__name-spacer {
38
+ flex: 1;
39
+ }
40
+
41
+ &__title-actions {
42
+ display: flex;
43
+ align-items: center;
44
+ gap: 8px;
45
+ }
46
+
47
+ // 关键字段行:label 45% 灰 + value 88% 黑,行间 gap 4px(对齐设计稿)
48
+ &__fields {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 4px;
52
+ }
53
+
54
+ &__field {
55
+ display: flex;
56
+ align-items: baseline;
57
+ line-height: 22px;
58
+ font-size: 14px;
59
+ }
60
+
61
+ &__field-label {
62
+ color: rgba(0, 0, 0, 0.45);
63
+ white-space: nowrap;
64
+ }
65
+
66
+ &__field-value {
67
+ color: rgba(0, 0, 0, 0.88);
68
+ word-break: break-all;
69
+ }
70
+
22
71
  &__description {
72
+ margin-top: 12px;
23
73
  color: var(--color-text-tertiary);
24
74
  }
25
75
 
@@ -7,7 +7,7 @@ export { default as FormPageTemplate } from "./FormPageTemplate";
7
7
  export { default as DrawerFormTemplate } from "./DrawerFormTemplate";
8
8
  export type { DrawerFormTemplateProps } from "./DrawerFormTemplate";
9
9
  export { default as DrawerDetailTemplate } from "./DrawerDetailTemplate";
10
- export type { DrawerDetailTemplateProps, DrawerDetailTab } from "./DrawerDetailTemplate";
10
+ export type { DrawerDetailTemplateProps, DrawerDetailTab, DrawerDetailField, } from "./DrawerDetailTemplate";
11
11
  export { default as DetailPageTemplate } from "./DetailPageTemplate";
12
12
  export type { DetailFieldItem, DetailTagItem, DetailTabItem } from "./DetailPageTemplate";
13
13
  export { default as IconSelect } from "./IconSelect";
@@ -7,29 +7,42 @@ export interface DrawerDetailTab {
7
7
  label: ReactNode;
8
8
  content: ReactNode;
9
9
  }
10
+ /** 顶部核心区的关键字段行(label + value 纯文字行,对齐设计稿) */
11
+ export interface DrawerDetailField {
12
+ label: ReactNode;
13
+ value: ReactNode;
14
+ }
10
15
  export interface DrawerDetailTemplateProps extends Omit<DrawerProps, "onClose" | "footer" | "destroyOnClose" | "maskClosable"> {
11
- /** 抽屉是否打开 */
16
+ /** 抽屉标题(Head 行 16px/600,含关闭图标) */
17
+ title?: ReactNode;
18
+ /** 是否打开 */
12
19
  open: boolean;
13
20
  /** 关闭回调 */
14
21
  onClose: () => void;
15
- /** 抽屉标题(顶部核心区标题) */
16
- title?: ReactNode;
17
- /** 抽屉宽度(业务约定详情抽屉默认 640;表单抽屉 DrawerFormTemplate 为 440) */
22
+ /** 24px 大标题(Head 下方内容区首行,与 tags/actions 同行) */
23
+ name?: ReactNode;
24
+ /** 大标题右侧的状态标签(CompanyTag 数组或自定义 ReactNode) */
25
+ tags?: ReactNode;
26
+ /** 大标题行最右侧的操作区(如「编辑」主按钮),与标题解耦 */
27
+ titleActions?: ReactNode;
28
+ /** 大标题下方的关键字段行(label 45% 灰 + value 88% 黑,行距 4px) */
29
+ fields?: DrawerDetailField[];
30
+ /** 抽屉宽度(业务约定详情抽屉默认 440,对齐设计稿;表单抽屉同为 440) */
18
31
  width?: number | string;
19
32
  /**
20
33
  * 点击遮罩是否关闭;详情为只读、无填写内容会丢失,业务约定默认 true。
21
34
  * 与 DrawerFormTemplate 的默认 false 相反(表单有未保存数据,误触会丢失)。
22
35
  */
23
36
  maskClosable?: boolean;
24
- /** 顶部核心区内容(状态标签、关键字段等),固定在抽屉顶部、不随内容滚动 */
37
+ /** 自定义顶部核心区内容(传入后替代内置 name/tags/titleActions/fields 结构) */
25
38
  headerContent?: ReactNode;
26
- /** 顶部核心区副标题/说明文字 */
39
+ /** 顶部核心区副标题/说明文字(内置结构时渲染在 fields 下方、分割线上方) */
27
40
  description?: ReactNode;
28
41
  /** 内容区分 Tab 配置;不传则直接渲染 children */
29
42
  tabs?: DrawerDetailTab[];
30
43
  /** 受控当前 Tab */
31
44
  activeTabKey?: string;
32
- /** 非受控默认 Tab */
45
+ /** 非受控 defaultActiveKey */
33
46
  defaultActiveTabKey?: string;
34
47
  /** Tab 切换回调 */
35
48
  onTabChange?: (key: string) => void;
@@ -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 = ["open", "onClose", "title", "width", "maskClosable", "headerContent", "description", "tabs", "activeTabKey", "defaultActiveTabKey", "onTabChange", "children", "footer", "classNames", "styles"];
2
+ var _excluded = ["open", "onClose", "title", "name", "tags", "titleActions", "fields", "width", "maskClosable", "headerContent", "description", "tabs", "activeTabKey", "defaultActiveTabKey", "onTabChange", "children", "footer", "classNames", "styles"];
3
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
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
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; }
@@ -14,14 +14,20 @@ import { companyTheme } from "../../theme";
14
14
  import "./index.scss";
15
15
 
16
16
  /** 详情抽屉内容区的 Tab 项 */
17
+
18
+ /** 顶部核心区的关键字段行(label + value 纯文字行,对齐设计稿) */
17
19
  import { jsx as _jsx } from "react/jsx-runtime";
18
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
21
  var DrawerDetailTemplateInner = function DrawerDetailTemplateInner(_ref, ref) {
20
22
  var open = _ref.open,
21
23
  onClose = _ref.onClose,
22
24
  title = _ref.title,
25
+ name = _ref.name,
26
+ tags = _ref.tags,
27
+ titleActions = _ref.titleActions,
28
+ fields = _ref.fields,
23
29
  _ref$width = _ref.width,
24
- width = _ref$width === void 0 ? 640 : _ref$width,
30
+ width = _ref$width === void 0 ? 440 : _ref$width,
25
31
  _ref$maskClosable = _ref.maskClosable,
26
32
  maskClosable = _ref$maskClosable === void 0 ? true : _ref$maskClosable,
27
33
  headerContent = _ref.headerContent,
@@ -40,7 +46,8 @@ var DrawerDetailTemplateInner = function DrawerDetailTemplateInner(_ref, ref) {
40
46
  var isPresent = function isPresent(value) {
41
47
  return value !== undefined && value !== null;
42
48
  };
43
- var hasHeader = isPresent(headerContent) || isPresent(description);
49
+ var hasStructuredHeader = isPresent(name) || isPresent(tags) || isPresent(titleActions) || fields && fields.length > 0;
50
+ var hasHeader = hasStructuredHeader || isPresent(headerContent) || isPresent(description);
44
51
 
45
52
  // classNames 支持对象/函数两种形式:统一走函数形式,确保 body 固定类不被覆盖
46
53
  var mergedClassNames = function mergedClassNames(info) {
@@ -52,18 +59,44 @@ var DrawerDetailTemplateInner = function DrawerDetailTemplateInner(_ref, ref) {
52
59
  var bodyNode = /*#__PURE__*/_jsxs("div", {
53
60
  className: "drawer-detail-template",
54
61
  ref: ref,
55
- children: [hasHeader ? /*#__PURE__*/_jsxs("div", {
62
+ children: [hasHeader ? /*#__PURE__*/_jsx("div", {
56
63
  className: "drawer-detail-template__header",
57
- style: {
58
- padding: "".concat(token.paddingMD, "px ").concat(token.paddingLG, "px")
59
- },
60
- children: [headerContent, isPresent(description) ? /*#__PURE__*/_jsx("div", {
61
- className: "drawer-detail-template__description",
64
+ children: headerContent !== null && headerContent !== void 0 ? headerContent : /*#__PURE__*/_jsxs("div", {
65
+ className: "drawer-detail-template__header-inner",
62
66
  style: {
63
- marginTop: token.marginXS
67
+ padding: "".concat(token.paddingMD, "px ").concat(token.paddingLG, "px")
64
68
  },
65
- children: description
66
- }) : null]
69
+ children: [/*#__PURE__*/_jsxs("div", {
70
+ className: "drawer-detail-template__name-row",
71
+ children: [isPresent(name) ? /*#__PURE__*/_jsx("span", {
72
+ className: "drawer-detail-template__name",
73
+ children: name
74
+ }) : null, tags, /*#__PURE__*/_jsx("span", {
75
+ className: "drawer-detail-template__name-spacer"
76
+ }), isPresent(titleActions) ? /*#__PURE__*/_jsx("div", {
77
+ className: "drawer-detail-template__title-actions",
78
+ children: titleActions
79
+ }) : null]
80
+ }), fields && fields.length > 0 ? /*#__PURE__*/_jsx("div", {
81
+ className: "drawer-detail-template__fields",
82
+ children: fields.map(function (field, index) {
83
+ var _field$value;
84
+ return /*#__PURE__*/_jsxs("div", {
85
+ className: "drawer-detail-template__field",
86
+ children: [/*#__PURE__*/_jsxs("span", {
87
+ className: "drawer-detail-template__field-label",
88
+ children: [field.label, "\uFF1A"]
89
+ }), /*#__PURE__*/_jsx("span", {
90
+ className: "drawer-detail-template__field-value",
91
+ children: (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : "--"
92
+ })]
93
+ }, index);
94
+ })
95
+ }) : null, isPresent(description) ? /*#__PURE__*/_jsx("div", {
96
+ className: "drawer-detail-template__description",
97
+ children: description
98
+ }) : null]
99
+ })
67
100
  }) : null, /*#__PURE__*/_jsx("div", {
68
101
  className: "drawer-detail-template__content",
69
102
  children: tabs && tabs.length > 0 ? /*#__PURE__*/_jsx(CompanyTabs, {
@@ -75,20 +108,10 @@ var DrawerDetailTemplateInner = function DrawerDetailTemplateInner(_ref, ref) {
75
108
  return {
76
109
  key: tab.key,
77
110
  label: tab.label,
78
- children: /*#__PURE__*/_jsx("div", {
79
- style: {
80
- padding: token.paddingLG
81
- },
82
- children: tab.content
83
- })
111
+ children: tab.content
84
112
  };
85
113
  })
86
- }) : /*#__PURE__*/_jsx("div", {
87
- style: {
88
- padding: token.paddingLG
89
- },
90
- children: children
91
- })
114
+ }) : children
92
115
  })]
93
116
  });
94
117
  return /*#__PURE__*/_jsx(ConfigProvider, {
@@ -96,7 +119,7 @@ var DrawerDetailTemplateInner = function DrawerDetailTemplateInner(_ref, ref) {
96
119
  children: /*#__PURE__*/_jsx(CompanyDrawer, _objectSpread(_objectSpread({
97
120
  open: open,
98
121
  title: title,
99
- width: width,
122
+ size: width,
100
123
  onClose: onClose,
101
124
  maskClosable: maskClosable,
102
125
  footer: footer !== null && footer !== void 0 ? footer : null,
@@ -19,7 +19,57 @@
19
19
  background: var(--color-bg-container);
20
20
  }
21
21
 
22
+ // 大标题行:24px/600 大标题 + 状态 Tag + 弹性占位 + 操作按钮
23
+ &__name-row {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 8px;
27
+ margin-bottom: 12px;
28
+ }
29
+
30
+ &__name {
31
+ font-size: 24px;
32
+ font-weight: 600;
33
+ line-height: 32px;
34
+ color: rgba(0, 0, 0, 0.88);
35
+ }
36
+
37
+ &__name-spacer {
38
+ flex: 1;
39
+ }
40
+
41
+ &__title-actions {
42
+ display: flex;
43
+ align-items: center;
44
+ gap: 8px;
45
+ }
46
+
47
+ // 关键字段行:label 45% 灰 + value 88% 黑,行间 gap 4px(对齐设计稿)
48
+ &__fields {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 4px;
52
+ }
53
+
54
+ &__field {
55
+ display: flex;
56
+ align-items: baseline;
57
+ line-height: 22px;
58
+ font-size: 14px;
59
+ }
60
+
61
+ &__field-label {
62
+ color: rgba(0, 0, 0, 0.45);
63
+ white-space: nowrap;
64
+ }
65
+
66
+ &__field-value {
67
+ color: rgba(0, 0, 0, 0.88);
68
+ word-break: break-all;
69
+ }
70
+
22
71
  &__description {
72
+ margin-top: 12px;
23
73
  color: var(--color-text-tertiary);
24
74
  }
25
75
 
@@ -7,7 +7,7 @@ export { default as FormPageTemplate } from "./FormPageTemplate";
7
7
  export { default as DrawerFormTemplate } from "./DrawerFormTemplate";
8
8
  export type { DrawerFormTemplateProps } from "./DrawerFormTemplate";
9
9
  export { default as DrawerDetailTemplate } from "./DrawerDetailTemplate";
10
- export type { DrawerDetailTemplateProps, DrawerDetailTab } from "./DrawerDetailTemplate";
10
+ export type { DrawerDetailTemplateProps, DrawerDetailTab, DrawerDetailField, } from "./DrawerDetailTemplate";
11
11
  export { default as DetailPageTemplate } from "./DetailPageTemplate";
12
12
  export type { DetailFieldItem, DetailTagItem, DetailTabItem } from "./DetailPageTemplate";
13
13
  export { default as IconSelect } from "./IconSelect";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donglegeyu/company-ui",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",