hd-attribute-set 0.0.0-stage → 0.1.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.
- package/README.md +62 -3
- package/dist/components/attribute-set/index.d.ts +7 -0
- package/dist/components/attribute-set/types.d.ts +27 -0
- package/dist/hd-attribute-set.css +1 -0
- package/dist/hd-attribute-set.js +35 -0
- package/dist/hd-attribute-set.umd.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/package.json +69 -6
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# hd-attribute-set
|
|
2
|
+
|
|
3
|
+
基于 **React + TypeScript + antd** 的属性集组件库,使用 Vite 库模式构建,通过 [CNB 云原生构建](https://docs.cnb.cool/) 自动发布到 npm。
|
|
4
|
+
|
|
5
|
+
## 目录结构
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
├── .cnb.yml # CNB 云原生构建流水线配置
|
|
9
|
+
├── index.html # 本地调试入口(playground)
|
|
10
|
+
├── src
|
|
11
|
+
│ ├── index.ts # 组件库入口(构建产物入口)
|
|
12
|
+
│ ├── App.tsx # 调试页面
|
|
13
|
+
│ ├── main.tsx # 调试页面挂载入口
|
|
14
|
+
│ └── components
|
|
15
|
+
│ └── attribute-set # 属性集组件(antd)
|
|
16
|
+
├── vite.config.ts # Vite 配置(lib 模式)
|
|
17
|
+
└── tsconfig.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 本地开发
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
npm run dev # 启动 playground 调试组件
|
|
25
|
+
npm run build # 构建产物到 dist/(ESM + UMD + CSS + 类型声明)
|
|
26
|
+
npm pack --dry-run # 查看将要发布到 npm 的文件清单
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 使用示例
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { AttributeSet } from 'hd-attribute-set';
|
|
33
|
+
import 'hd-attribute-set/dist/hd-attribute-set.css';
|
|
34
|
+
|
|
35
|
+
<AttributeSet
|
|
36
|
+
title="基础属性"
|
|
37
|
+
items={[
|
|
38
|
+
{ key: 'cpu', label: 'CPU', value: '8 核' },
|
|
39
|
+
{ key: 'memory', label: '内存', value: '16 GB' },
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 发布到 npm(云原生构建)
|
|
45
|
+
|
|
46
|
+
1. 在 npmjs.com 生成 Access Token。
|
|
47
|
+
2. 在 CNB 仓库设置中配置环境变量 `NPM_TOKEN`(或放入密钥仓库,并在 `.cnb.yml` 的 `tag_push` 中增加 `imports` 指向密钥仓库)。
|
|
48
|
+
3. push 到 `main` 分支会自动执行安装 + 构建校验;发布正式版时推送 tag:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm version patch # 0.1.0 -> 0.1.1,自动提交 tag
|
|
52
|
+
git push origin main --tags
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
流水线将自动构建并执行 `npm publish`(`prepublishOnly` 也会兜底执行构建)。
|
|
56
|
+
|
|
57
|
+
## 发布前检查清单
|
|
58
|
+
|
|
59
|
+
- [ ] `package.json` 的 `version` 已升版(与 tag 一致)。
|
|
60
|
+
- [ ] `npm run build` 通过,`dist` 含 `hd-attribute-set.js`、`hd-attribute-set.umd.cjs`、`hd-attribute-set.css`、`index.d.ts`。
|
|
61
|
+
- [ ] `npm pack --dry-run` 中仅包含 `dist` 与 `README.md`,无源码泄露。
|
|
62
|
+
- [ ] 使用方已安装 `antd`(peer 依赖,不在包内打包)。
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AttributeItem, AttributeSetProps } from './types';
|
|
2
|
+
export type { AttributeItem, AttributeSetProps };
|
|
3
|
+
/**
|
|
4
|
+
* 属性集组件:以 antd Descriptions 展示一组键值属性
|
|
5
|
+
*/
|
|
6
|
+
export declare function AttributeSet({ items, title, column, bordered, emptyText }: AttributeSetProps): import("react").JSX.Element;
|
|
7
|
+
export default AttributeSet;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** 单个属性项 */
|
|
3
|
+
export interface AttributeItem {
|
|
4
|
+
/** 唯一标识 */
|
|
5
|
+
key: string;
|
|
6
|
+
/** 属性名 */
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
/** 属性值 */
|
|
9
|
+
value?: ReactNode;
|
|
10
|
+
/** 自定义渲染 */
|
|
11
|
+
render?: (value?: ReactNode) => ReactNode;
|
|
12
|
+
/** Descriptions 的栅格跨度 */
|
|
13
|
+
span?: number;
|
|
14
|
+
}
|
|
15
|
+
/** AttributeSet 组件属性 */
|
|
16
|
+
export interface AttributeSetProps {
|
|
17
|
+
/** 属性集标题 */
|
|
18
|
+
title?: ReactNode;
|
|
19
|
+
/** 属性项列表 */
|
|
20
|
+
items: AttributeItem[];
|
|
21
|
+
/** 每行列数,默认 2 */
|
|
22
|
+
column?: number;
|
|
23
|
+
/** 是否显示边框,默认 true */
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
/** 空数据提示文案 */
|
|
26
|
+
emptyText?: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.hd-attribute-set__title{font-size:16px;font-weight:600}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsxs as s, Fragment as i, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Divider as n, Empty as l, Descriptions as h } from "antd";
|
|
3
|
+
function m({ items: a, title: t, column: d = 2, bordered: c = !0, emptyText: p = "暂无属性" }) {
|
|
4
|
+
return !a || a.length === 0 ? /* @__PURE__ */ s("div", { className: "hd-attribute-set", children: [
|
|
5
|
+
t && /* @__PURE__ */ s(i, { children: [
|
|
6
|
+
/* @__PURE__ */ r("div", { className: "hd-attribute-set__title", children: t }),
|
|
7
|
+
/* @__PURE__ */ r(n, { style: { margin: "8px 0 16px" } })
|
|
8
|
+
] }),
|
|
9
|
+
/* @__PURE__ */ r(l, { image: l.PRESENTED_IMAGE_SIMPLE, description: p })
|
|
10
|
+
] }) : /* @__PURE__ */ s("div", { className: "hd-attribute-set", children: [
|
|
11
|
+
t && /* @__PURE__ */ s(i, { children: [
|
|
12
|
+
/* @__PURE__ */ r("div", { className: "hd-attribute-set__title", children: t }),
|
|
13
|
+
/* @__PURE__ */ r(n, { style: { margin: "8px 0 16px" } })
|
|
14
|
+
] }),
|
|
15
|
+
/* @__PURE__ */ r(
|
|
16
|
+
h,
|
|
17
|
+
{
|
|
18
|
+
size: "small",
|
|
19
|
+
column: d,
|
|
20
|
+
bordered: c,
|
|
21
|
+
items: a.map((e) => ({
|
|
22
|
+
key: e.key,
|
|
23
|
+
label: e.label,
|
|
24
|
+
children: e.render ? e.render(e.value) : e.value ?? "-",
|
|
25
|
+
span: e.span
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
const v = "0.1.0";
|
|
32
|
+
export {
|
|
33
|
+
m as AttributeSet,
|
|
34
|
+
v as version
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("antd")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","antd"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.HdAttributeSet={},r.jsxRuntime,r.antd))})(this,function(r,e,s){"use strict";function n({items:d,title:i,column:l=2,bordered:c=!0,emptyText:p="暂无属性"}){return!d||d.length===0?e.jsxs("div",{className:"hd-attribute-set",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hd-attribute-set__title",children:i}),e.jsx(s.Divider,{style:{margin:"8px 0 16px"}})]}),e.jsx(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:p})]}):e.jsxs("div",{className:"hd-attribute-set",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hd-attribute-set__title",children:i}),e.jsx(s.Divider,{style:{margin:"8px 0 16px"}})]}),e.jsx(s.Descriptions,{size:"small",column:l,bordered:c,items:d.map(t=>({key:t.key,label:t.label,children:t.render?t.render(t.value):t.value??"-",span:t.span}))})]})}const a="0.1.0";r.AttributeSet=n,r.version=a,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hd-attribute-set",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "hd-attribute-set",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "属性集组件库,基于 React + antd",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"component",
|
|
8
|
+
"antd",
|
|
9
|
+
"attribute-set"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "szldjd",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://cnb.cool/szldjd/fee/hd-attribute-set"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://cnb.cool/szldjd/fee/hd-attribute-set/-/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://cnb.cool/szldjd/fee/hd-attribute-set",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"**/*.css",
|
|
28
|
+
"**/*.less"
|
|
29
|
+
],
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"main": "dist/hd-attribute-set.umd.cjs",
|
|
35
|
+
"module": "dist/hd-attribute-set.js",
|
|
36
|
+
"types": "dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/hd-attribute-set.js",
|
|
41
|
+
"require": "./dist/hd-attribute-set.umd.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./dist/*": "./dist/*",
|
|
44
|
+
"./dist/hd-attribute-set.css": "./dist/hd-attribute-set.css"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev": "vite",
|
|
48
|
+
"build": "tsc --noEmit && vite build",
|
|
49
|
+
"preview": "vite preview",
|
|
50
|
+
"prepublishOnly": "npm run build"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"antd": ">=5.0.0",
|
|
54
|
+
"react": ">=17.0.0",
|
|
55
|
+
"react-dom": ">=17.0.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^18.3.0",
|
|
59
|
+
"@types/react-dom": "^18.3.0",
|
|
60
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
61
|
+
"antd": "^5.21.0",
|
|
62
|
+
"less": "^4.2.0",
|
|
63
|
+
"react": "^18.3.0",
|
|
64
|
+
"react-dom": "^18.3.0",
|
|
65
|
+
"typescript": "^5.5.0",
|
|
66
|
+
"vite": "^5.4.0",
|
|
67
|
+
"vite-plugin-dts": "^4.2.0"
|
|
68
|
+
}
|
|
69
|
+
}
|