@easy-editor/materials-dashboard-button 0.0.2
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/.vite/plugins/vite-plugin-external-deps.ts +224 -0
- package/.vite/plugins/vite-plugin-material-dev.ts +218 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +9 -0
- package/dist/component.esm.js +97 -0
- package/dist/component.esm.js.map +1 -0
- package/dist/component.js +106 -0
- package/dist/component.js.map +1 -0
- package/dist/component.min.js +2 -0
- package/dist/component.min.js.map +1 -0
- package/dist/index.cjs +394 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +391 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +399 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/meta.esm.js +298 -0
- package/dist/meta.esm.js.map +1 -0
- package/dist/meta.js +309 -0
- package/dist/meta.js.map +1 -0
- package/dist/meta.min.js +2 -0
- package/dist/meta.min.js.map +1 -0
- package/dist/src/component.d.ts +26 -0
- package/dist/src/configure.d.ts +7 -0
- package/dist/src/constants.d.ts +16 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/meta.d.ts +7 -0
- package/dist/src/snippets.d.ts +7 -0
- package/package.json +64 -0
- package/rollup.config.js +222 -0
- package/src/component.module.css +119 -0
- package/src/component.tsx +80 -0
- package/src/configure.ts +258 -0
- package/src/constants.ts +18 -0
- package/src/index.tsx +7 -0
- package/src/meta.ts +28 -0
- package/src/snippets.ts +49 -0
- package/src/type.d.ts +8 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +7 -0
- package/vite.config.ts +54 -0
package/dist/meta.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EasyEditorMaterialsButtonMeta={})}(this,function(e){"use strict";const t="EasyEditorMaterialsButton";const a={componentName:t,title:"按钮",group:"interaction",devMode:"proCode",npm:{package:"@easy-editor/materials-dashboard-button",version:"0.0.1",globalName:t,componentName:t},snippets:[{title:"主要按钮",screenshot:"",schema:{componentName:t,props:{text:"主要按钮",variant:"primary",size:"medium"},$dashboard:{rect:{width:120,height:40}}}},{title:"发光按钮",screenshot:"",schema:{componentName:t,props:{text:"发光按钮",variant:"outline",size:"large",glowEnable:!0},$dashboard:{rect:{width:140,height:48}}}}],configure:{props:[{type:"group",title:"属性",setter:"TabSetter",items:[{type:"group",key:"config",title:"配置",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"id",title:"ID",setter:"NodeIdSetter",extraProps:{label:!1}},{name:"title",title:"标题",setter:"StringSetter",extraProps:{getValue:e=>e.getExtraPropValue("title"),setValue(e,t){e.setExtraPropValue("title",t)}}},{type:"group",title:"基础属性",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"rect",title:"位置尺寸",setter:"RectSetter",extraProps:{getValue:e=>e.getExtraPropValue("$dashboard.rect"),setValue(e,t){e.setExtraPropValue("$dashboard.rect",t)}}}]},{type:"group",title:"内容",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"text",title:"按钮文本",setter:"StringSetter",extraProps:{defaultValue:"按钮"}}]},{type:"group",title:"样式",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"variant",title:"变体",setter:{componentName:"SelectSetter",props:{options:[{label:"主要",value:"primary"},{label:"次要",value:"secondary"},{label:"轮廓",value:"outline"},{label:"幽灵",value:"ghost"},{label:"危险",value:"danger"}]}},extraProps:{defaultValue:"primary"}},{name:"size",title:"尺寸",setter:{componentName:"SelectSetter",props:{options:[{label:"小",value:"small"},{label:"中",value:"medium"},{label:"大",value:"large"}]}},extraProps:{defaultValue:"medium"}},{name:"glowEnable",title:"发光效果",setter:"SwitchSetter",extraProps:{defaultValue:!1}}]},{type:"group",title:"链接",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"href",title:"链接地址",setter:"StringSetter"},{name:"target",title:"打开方式",setter:{componentName:"SelectSetter",props:{options:[{label:"新窗口",value:"_blank"},{label:"当前窗口",value:"_self"}]}},extraProps:{defaultValue:"_blank"}}]},{type:"group",title:"行为",setter:{componentName:"CollapseSetter",props:{icon:!1}},items:[{name:"disabled",title:"禁用",setter:"SwitchSetter",extraProps:{defaultValue:!1}},{name:"loading",title:"加载中",setter:"SwitchSetter",extraProps:{defaultValue:!1}},{name:"loadingText",title:"加载文本",setter:"StringSetter",extraProps:{defaultValue:"加载中..."}}]}]},{type:"group",key:"data",title:"数据",items:[{name:"dataBinding",title:"数据绑定",setter:"DataBindingSetter"}]},{type:"group",key:"advanced",title:"高级",items:[{name:"condition",title:"显隐控制",setter:"SwitchSetter",extraProps:{defaultValue:!0,supportVariable:!0}}]}]}],component:{},supports:{},advanced:{}}};e.default=a,e.meta=a,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=meta.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.min.js","sources":["../../../../shared/src/index.ts","../src/constants.ts","../src/meta.ts","../src/snippets.ts","../src/configure.ts"],"sourcesContent":["/**\n * Shared types, components and utilities for EasyEditor materials\n * @package @easy-editor/materials-shared\n */\n\n// 物料分组常量\nexport const MaterialGroup = {\n /** 内置 */\n INNER: 'inner',\n /** 基础 */\n BASIC: 'basic',\n /** 图表 */\n CHART: 'chart',\n /** 数据展示 */\n DISPLAY: 'display',\n /** 媒体 */\n MEDIA: 'media',\n /** 交互 */\n INTERACTION: 'interaction',\n /** 地图 */\n MAP: 'map',\n} as const\n\nexport type MaterialGroup = (typeof MaterialGroup)[keyof typeof MaterialGroup]\n\n// 工具函数\nexport { cn } from './lib/utils'\n\nexport * from './types'\n","/**\n * 物料常量配置\n * 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值\n */\n\n/**\n * UMD 全局变量基础名称\n * 用于构建:\n * - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsButtonMeta)\n * - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsButtonComponent)\n * - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsButton)\n */\nexport const COMPONENT_NAME = 'EasyEditorMaterialsButton'\n\n/**\n * 包名\n */\nexport const PACKAGE_NAME = '@easy-editor/materials-dashboard-button'\n","/**\n * Button Meta\n * 按钮组件元数据\n */\n\nimport type { ComponentMetadata } from '@easy-editor/core'\nimport { MaterialGroup } from '@easy-editor/materials-shared'\nimport { COMPONENT_NAME, PACKAGE_NAME } from './constants'\nimport configure from './configure'\nimport snippets from './snippets'\nimport pkg from '../package.json'\n\nexport const meta: ComponentMetadata = {\n componentName: COMPONENT_NAME,\n title: '按钮',\n group: MaterialGroup.INTERACTION,\n devMode: 'proCode',\n npm: {\n package: PACKAGE_NAME,\n version: pkg.version,\n globalName: COMPONENT_NAME,\n componentName: COMPONENT_NAME,\n },\n snippets,\n configure,\n}\n\nexport default meta\n","/**\n * Button Snippets\n * 按钮组件代码片段\n */\n\nimport type { Snippet } from '@easy-editor/core'\nimport { COMPONENT_NAME } from './constants'\n\nexport const snippets: Snippet[] = [\n {\n title: '主要按钮',\n screenshot: '',\n schema: {\n componentName: COMPONENT_NAME,\n props: {\n text: '主要按钮',\n variant: 'primary',\n size: 'medium',\n },\n $dashboard: {\n rect: {\n width: 120,\n height: 40,\n },\n },\n },\n },\n {\n title: '发光按钮',\n screenshot: '',\n schema: {\n componentName: COMPONENT_NAME,\n props: {\n text: '发光按钮',\n variant: 'outline',\n size: 'large',\n glowEnable: true,\n },\n $dashboard: {\n rect: {\n width: 140,\n height: 48,\n },\n },\n },\n },\n]\n\nexport default snippets\n","/**\n * Button Configure\n * 按钮组件配置\n */\n\nimport type { Configure } from '@easy-editor/core'\n\nexport const configure: Configure = {\n props: [\n {\n type: 'group',\n title: '属性',\n setter: 'TabSetter',\n items: [\n {\n type: 'group',\n key: 'config',\n title: '配置',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n // 基础配置\n {\n name: 'id',\n title: 'ID',\n setter: 'NodeIdSetter',\n extraProps: {\n // @ts-expect-error label is not a valid extra prop\n label: false,\n },\n },\n {\n name: 'title',\n title: '标题',\n setter: 'StringSetter',\n extraProps: {\n getValue(target) {\n return target.getExtraPropValue('title')\n },\n setValue(target, value) {\n target.setExtraPropValue('title', value)\n },\n },\n },\n {\n type: 'group',\n title: '基础属性',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n {\n name: 'rect',\n title: '位置尺寸',\n setter: 'RectSetter',\n extraProps: {\n getValue(target) {\n return target.getExtraPropValue('$dashboard.rect')\n },\n setValue(target, value) {\n target.setExtraPropValue('$dashboard.rect', value)\n },\n },\n },\n ],\n },\n // 组件配置\n {\n type: 'group',\n title: '内容',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n {\n name: 'text',\n title: '按钮文本',\n setter: 'StringSetter',\n extraProps: {\n defaultValue: '按钮',\n },\n },\n ],\n },\n {\n type: 'group',\n title: '样式',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n {\n name: 'variant',\n title: '变体',\n setter: {\n componentName: 'SelectSetter',\n props: {\n options: [\n { label: '主要', value: 'primary' },\n { label: '次要', value: 'secondary' },\n { label: '轮廓', value: 'outline' },\n { label: '幽灵', value: 'ghost' },\n { label: '危险', value: 'danger' },\n ],\n },\n },\n extraProps: {\n defaultValue: 'primary',\n },\n },\n {\n name: 'size',\n title: '尺寸',\n setter: {\n componentName: 'SelectSetter',\n props: {\n options: [\n { label: '小', value: 'small' },\n { label: '中', value: 'medium' },\n { label: '大', value: 'large' },\n ],\n },\n },\n extraProps: {\n defaultValue: 'medium',\n },\n },\n {\n name: 'glowEnable',\n title: '发光效果',\n setter: 'SwitchSetter',\n extraProps: {\n defaultValue: false,\n },\n },\n ],\n },\n {\n type: 'group',\n title: '链接',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n {\n name: 'href',\n title: '链接地址',\n setter: 'StringSetter',\n },\n {\n name: 'target',\n title: '打开方式',\n setter: {\n componentName: 'SelectSetter',\n props: {\n options: [\n { label: '新窗口', value: '_blank' },\n { label: '当前窗口', value: '_self' },\n ],\n },\n },\n extraProps: {\n defaultValue: '_blank',\n },\n },\n ],\n },\n {\n type: 'group',\n title: '行为',\n setter: {\n componentName: 'CollapseSetter',\n props: {\n icon: false,\n },\n },\n items: [\n {\n name: 'disabled',\n title: '禁用',\n setter: 'SwitchSetter',\n extraProps: {\n defaultValue: false,\n },\n },\n {\n name: 'loading',\n title: '加载中',\n setter: 'SwitchSetter',\n extraProps: {\n defaultValue: false,\n },\n },\n {\n name: 'loadingText',\n title: '加载文本',\n setter: 'StringSetter',\n extraProps: {\n defaultValue: '加载中...',\n },\n },\n ],\n },\n ],\n },\n {\n type: 'group',\n key: 'data',\n title: '数据',\n items: [\n {\n name: 'dataBinding',\n title: '数据绑定',\n setter: 'DataBindingSetter',\n },\n ],\n },\n {\n type: 'group',\n key: 'advanced',\n title: '高级',\n items: [\n {\n name: 'condition',\n title: '显隐控制',\n setter: 'SwitchSetter',\n extraProps: {\n defaultValue: true,\n supportVariable: true,\n },\n },\n ],\n },\n ],\n },\n ],\n component: {},\n supports: {},\n advanced: {},\n}\n\nexport default configure\n"],"names":["COMPONENT_NAME","meta","componentName","title","group","devMode","npm","package","version","globalName","snippets","screenshot","schema","props","text","variant","size","$dashboard","rect","width","height","glowEnable","configure","type","setter","items","key","icon","name","extraProps","label","getValue","target","getExtraPropValue","setValue","value","setExtraPropValue","defaultValue","options","supportVariable","component","supports","advanced"],"mappings":"oQAMO,MCMMA,EAAiB,4BCAvB,MAAMC,EAA0B,CACrCC,cAAeF,EACfG,MAAO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AAY,CACVQ,cAAc,IAGlB,CACET,KAAM,cACNzB,MAAO,OACPqB,OAAQ,eACRK,WAAY,CACVQ,aAAc,eAO1B,CACEd,KAAM,QACNG,IAAK,OACLvB,MAAO,KACPsB,MAAO,CACL,CACEG,KAAM,cACNzB,MAAO,OACPqB,OAAQ,uBAId,CACED,KAAM,QACNG,IAAK,WACLvB,MAAO,KACPsB,MAAO,CACL,CACEG,KAAM,YACNzB,MAAO,OACPqB,OAAQ,eACRK,WAAY,CACVQ,cAAc,EACdE,iBAAiB,SAQ/BC,UAAW,CAAA,EACXC,SAAU,CAAA,EACVC,SAAU,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button Component
|
|
3
|
+
* 按钮组件
|
|
4
|
+
*/
|
|
5
|
+
import type { CSSProperties, Ref, MouseEvent } from 'react';
|
|
6
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
|
|
7
|
+
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
8
|
+
export interface ButtonProps {
|
|
9
|
+
ref?: Ref<HTMLButtonElement>;
|
|
10
|
+
/** 按钮文本 */
|
|
11
|
+
text?: string;
|
|
12
|
+
/** 按钮变体 */
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
/** 按钮尺寸 */
|
|
15
|
+
size?: ButtonSize;
|
|
16
|
+
/** 是否禁用 */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** 是否显示发光效果 */
|
|
19
|
+
glowEnable?: boolean;
|
|
20
|
+
/** 点击事件 */
|
|
21
|
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
22
|
+
/** 外部样式 */
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
26
|
+
export default Button;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 物料常量配置
|
|
3
|
+
* 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* UMD 全局变量基础名称
|
|
7
|
+
* 用于构建:
|
|
8
|
+
* - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsButtonMeta)
|
|
9
|
+
* - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsButtonComponent)
|
|
10
|
+
* - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsButton)
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMPONENT_NAME = "EasyEditorMaterialsButton";
|
|
13
|
+
/**
|
|
14
|
+
* 包名
|
|
15
|
+
*/
|
|
16
|
+
export declare const PACKAGE_NAME = "@easy-editor/materials-dashboard-button";
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easy-editor/materials-dashboard-button",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Button component for EasyEditor dashboard",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"jsdelivr": "dist/index.min.js",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/Easy-Editor/EasyMaterials",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "JinSo <kimjinso@qq.com>",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"@easy-editor",
|
|
25
|
+
"easyeditor",
|
|
26
|
+
"low-code",
|
|
27
|
+
"dashboard",
|
|
28
|
+
"button",
|
|
29
|
+
"component",
|
|
30
|
+
"react"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/Easy-Editor/EasyMaterials",
|
|
35
|
+
"directory": "packages/dashboard/interaction/button"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/Easy-Editor/EasyMaterials/issues"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@easy-editor/core": "*",
|
|
42
|
+
"react": "^18 || ^19",
|
|
43
|
+
"react-dom": "^18 || ^19",
|
|
44
|
+
"@types/react": "^18 || ^19",
|
|
45
|
+
"@types/react-dom": "^18 || ^19"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@easy-editor/materials-shared": "0.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"dev": "vite",
|
|
52
|
+
"format": "biome format --write .",
|
|
53
|
+
"lint": "biome check .",
|
|
54
|
+
"build": "npm-run-all -nl build:*",
|
|
55
|
+
"build:clean": "rimraf dist/",
|
|
56
|
+
"build:js": "rollup -c",
|
|
57
|
+
"build:types": "pnpm types",
|
|
58
|
+
"types": "npm-run-all -nl types:*",
|
|
59
|
+
"types:src": "tsc --project tsconfig.build.json",
|
|
60
|
+
"test-types": "tsc --project tsconfig.test.json"
|
|
61
|
+
},
|
|
62
|
+
"module": "dist/index.esm.js",
|
|
63
|
+
"unpkg": "dist/index.min.js"
|
|
64
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import babel from '@rollup/plugin-babel'
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
3
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
4
|
+
import json from '@rollup/plugin-json'
|
|
5
|
+
import { terser } from 'rollup-plugin-terser'
|
|
6
|
+
import cleanup from 'rollup-plugin-cleanup'
|
|
7
|
+
import postcss from 'rollup-plugin-postcss'
|
|
8
|
+
import pkg from './package.json' with { type: 'json' }
|
|
9
|
+
|
|
10
|
+
const GLOBAL_NAME = 'EasyEditorMaterialsButton'
|
|
11
|
+
|
|
12
|
+
// 外部依赖(不打包进组件)
|
|
13
|
+
const external = ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core']
|
|
14
|
+
|
|
15
|
+
const globals = {
|
|
16
|
+
react: 'React',
|
|
17
|
+
'react-dom': 'ReactDOM',
|
|
18
|
+
'react/jsx-runtime': 'jsxRuntime',
|
|
19
|
+
'@easy-editor/core': 'EasyEditorCore',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const plugins = [
|
|
23
|
+
nodeResolve({
|
|
24
|
+
extensions: ['.js', '.ts', '.jsx', '.tsx'],
|
|
25
|
+
}),
|
|
26
|
+
commonjs(),
|
|
27
|
+
json(),
|
|
28
|
+
postcss({
|
|
29
|
+
modules: {
|
|
30
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
|
31
|
+
},
|
|
32
|
+
autoModules: true,
|
|
33
|
+
minimize: true,
|
|
34
|
+
inject: true,
|
|
35
|
+
}),
|
|
36
|
+
babel({
|
|
37
|
+
extensions: ['.js', '.ts', '.jsx', '.tsx'],
|
|
38
|
+
exclude: 'node_modules/**',
|
|
39
|
+
babelrc: false,
|
|
40
|
+
babelHelpers: 'bundled',
|
|
41
|
+
presets: [
|
|
42
|
+
['@babel/preset-react', { runtime: 'automatic' }],
|
|
43
|
+
[
|
|
44
|
+
'@babel/preset-typescript',
|
|
45
|
+
{
|
|
46
|
+
allowDeclareFields: true,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
51
|
+
cleanup({
|
|
52
|
+
comments: ['some', /PURE/],
|
|
53
|
+
extensions: ['.js', '.ts'],
|
|
54
|
+
}),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
export default [
|
|
58
|
+
/* ---------------------------------- 元数据构建 --------------------------------- */
|
|
59
|
+
// 元数据 ESM 构建(用于动态 import)
|
|
60
|
+
{
|
|
61
|
+
input: 'src/meta.ts',
|
|
62
|
+
output: [
|
|
63
|
+
{
|
|
64
|
+
file: 'dist/meta.esm.js',
|
|
65
|
+
format: 'esm',
|
|
66
|
+
sourcemap: true,
|
|
67
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (meta, esm) */`,
|
|
68
|
+
exports: 'named',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
plugins,
|
|
72
|
+
external,
|
|
73
|
+
},
|
|
74
|
+
// 元数据 UMD 构建(备用方案)
|
|
75
|
+
{
|
|
76
|
+
input: 'src/meta.ts',
|
|
77
|
+
output: [
|
|
78
|
+
{
|
|
79
|
+
file: 'dist/meta.js',
|
|
80
|
+
format: 'umd',
|
|
81
|
+
name: `${GLOBAL_NAME}Meta`,
|
|
82
|
+
globals,
|
|
83
|
+
sourcemap: true,
|
|
84
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (meta) */`,
|
|
85
|
+
exports: 'named',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
plugins,
|
|
89
|
+
external,
|
|
90
|
+
},
|
|
91
|
+
// 元数据压缩版本(UMD,备用方案)
|
|
92
|
+
{
|
|
93
|
+
input: 'src/meta.ts',
|
|
94
|
+
output: [
|
|
95
|
+
{
|
|
96
|
+
file: 'dist/meta.min.js',
|
|
97
|
+
format: 'umd',
|
|
98
|
+
name: `${GLOBAL_NAME}Meta`,
|
|
99
|
+
globals,
|
|
100
|
+
sourcemap: true,
|
|
101
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (meta, minified) */`,
|
|
102
|
+
exports: 'named',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
plugins: [...plugins, terser()],
|
|
106
|
+
external,
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/* ---------------------------------- 组件构建 ---------------------------------- */
|
|
110
|
+
// 组件 ESM 构建(用于动态 import)
|
|
111
|
+
{
|
|
112
|
+
input: 'src/component.tsx',
|
|
113
|
+
output: [
|
|
114
|
+
{
|
|
115
|
+
file: 'dist/component.esm.js',
|
|
116
|
+
format: 'esm',
|
|
117
|
+
sourcemap: true,
|
|
118
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (component, esm) */`,
|
|
119
|
+
exports: 'named',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
plugins,
|
|
123
|
+
external,
|
|
124
|
+
},
|
|
125
|
+
// 组件 UMD 构建(备用方案)
|
|
126
|
+
{
|
|
127
|
+
input: 'src/component.tsx',
|
|
128
|
+
output: [
|
|
129
|
+
{
|
|
130
|
+
file: 'dist/component.js',
|
|
131
|
+
format: 'umd',
|
|
132
|
+
name: `${GLOBAL_NAME}Component`,
|
|
133
|
+
globals,
|
|
134
|
+
sourcemap: true,
|
|
135
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (component) */`,
|
|
136
|
+
exports: 'named',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
plugins,
|
|
140
|
+
external,
|
|
141
|
+
},
|
|
142
|
+
// 组件压缩版本(UMD,备用方案)
|
|
143
|
+
{
|
|
144
|
+
input: 'src/component.tsx',
|
|
145
|
+
output: [
|
|
146
|
+
{
|
|
147
|
+
file: 'dist/component.min.js',
|
|
148
|
+
format: 'umd',
|
|
149
|
+
name: `${GLOBAL_NAME}Component`,
|
|
150
|
+
globals,
|
|
151
|
+
sourcemap: true,
|
|
152
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (component, minified) */`,
|
|
153
|
+
exports: 'named',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
plugins: [...plugins, terser()],
|
|
157
|
+
external,
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/* ---------------------------------- 完整构建 ---------------------------------- */
|
|
161
|
+
// UMD 构建(用于 CDN 和浏览器)
|
|
162
|
+
{
|
|
163
|
+
input: 'src/index.tsx',
|
|
164
|
+
output: [
|
|
165
|
+
{
|
|
166
|
+
file: 'dist/index.js',
|
|
167
|
+
format: 'umd',
|
|
168
|
+
name: GLOBAL_NAME,
|
|
169
|
+
globals,
|
|
170
|
+
sourcemap: true,
|
|
171
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} */`,
|
|
172
|
+
exports: 'named',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
plugins,
|
|
176
|
+
external,
|
|
177
|
+
},
|
|
178
|
+
// ESM 构建(用于现代打包工具)
|
|
179
|
+
{
|
|
180
|
+
input: 'src/index.tsx',
|
|
181
|
+
output: [
|
|
182
|
+
{
|
|
183
|
+
file: 'dist/index.esm.js',
|
|
184
|
+
format: 'esm',
|
|
185
|
+
sourcemap: true,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
plugins,
|
|
189
|
+
external,
|
|
190
|
+
},
|
|
191
|
+
// CJS 构建(用于 Node.js)
|
|
192
|
+
{
|
|
193
|
+
input: 'src/index.tsx',
|
|
194
|
+
output: [
|
|
195
|
+
{
|
|
196
|
+
file: 'dist/index.cjs',
|
|
197
|
+
format: 'cjs',
|
|
198
|
+
sourcemap: true,
|
|
199
|
+
exports: 'named',
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
plugins,
|
|
203
|
+
external,
|
|
204
|
+
},
|
|
205
|
+
// 压缩版本(用于生产环境)
|
|
206
|
+
{
|
|
207
|
+
input: 'src/index.tsx',
|
|
208
|
+
output: [
|
|
209
|
+
{
|
|
210
|
+
file: 'dist/index.min.js',
|
|
211
|
+
format: 'umd',
|
|
212
|
+
name: GLOBAL_NAME,
|
|
213
|
+
globals,
|
|
214
|
+
sourcemap: true,
|
|
215
|
+
banner: `/* @easy-editor/materials-dashboard-button v${pkg.version} (minified) */`,
|
|
216
|
+
exports: 'named',
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
plugins: [...plugins, terser()],
|
|
220
|
+
external,
|
|
221
|
+
},
|
|
222
|
+
]
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button Component Styles
|
|
3
|
+
* 按钮组件样式
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.button {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
gap: 8px;
|
|
11
|
+
border: none;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
transition: all 0.2s ease;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
user-select: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button:disabled {
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* 尺寸 */
|
|
27
|
+
.sizeSmall {
|
|
28
|
+
padding: 0 12px;
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sizeMedium {
|
|
34
|
+
padding: 0 16px;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
border-radius: 6px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sizeLarge {
|
|
40
|
+
padding: 0 24px;
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* 变体 */
|
|
46
|
+
.variantPrimary {
|
|
47
|
+
background: linear-gradient(135deg, #00d4ff, #0099cc);
|
|
48
|
+
color: #fff;
|
|
49
|
+
box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.variantPrimary:hover:not(:disabled) {
|
|
53
|
+
transform: translateY(-1px);
|
|
54
|
+
box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.variantPrimary:active:not(:disabled) {
|
|
58
|
+
transform: translateY(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.variantSecondary {
|
|
62
|
+
background: rgba(255, 255, 255, 0.1);
|
|
63
|
+
color: #fff;
|
|
64
|
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.variantSecondary:hover:not(:disabled) {
|
|
68
|
+
background: rgba(255, 255, 255, 0.15);
|
|
69
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.variantOutline {
|
|
73
|
+
background: transparent;
|
|
74
|
+
color: #00d4ff;
|
|
75
|
+
border: 1px solid #00d4ff;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.variantOutline:hover:not(:disabled) {
|
|
79
|
+
background: rgba(0, 212, 255, 0.1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.variantGhost {
|
|
83
|
+
background: transparent;
|
|
84
|
+
color: #fff;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.variantGhost:hover:not(:disabled) {
|
|
88
|
+
background: rgba(255, 255, 255, 0.1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.variantDanger {
|
|
92
|
+
background: linear-gradient(135deg, #ff4d4f, #cc3333);
|
|
93
|
+
color: #fff;
|
|
94
|
+
box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.variantDanger:hover:not(:disabled) {
|
|
98
|
+
transform: translateY(-1px);
|
|
99
|
+
box-shadow: 0 4px 12px rgba(255, 77, 79, 0.4);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* 发光效果 */
|
|
103
|
+
.glow {
|
|
104
|
+
animation: buttonGlow 2s ease-in-out infinite;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@keyframes buttonGlow {
|
|
108
|
+
0%,
|
|
109
|
+
100% {
|
|
110
|
+
box-shadow:
|
|
111
|
+
0 0 5px currentColor,
|
|
112
|
+
0 0 10px currentColor;
|
|
113
|
+
}
|
|
114
|
+
50% {
|
|
115
|
+
box-shadow:
|
|
116
|
+
0 0 10px currentColor,
|
|
117
|
+
0 0 20px currentColor;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button Component
|
|
3
|
+
* 按钮组件
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CSSProperties, Ref, MouseEvent } from 'react'
|
|
7
|
+
import { cn } from '@easy-editor/materials-shared'
|
|
8
|
+
import styles from './component.module.css'
|
|
9
|
+
|
|
10
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'
|
|
11
|
+
export type ButtonSize = 'small' | 'medium' | 'large'
|
|
12
|
+
|
|
13
|
+
export interface ButtonProps {
|
|
14
|
+
ref?: Ref<HTMLButtonElement>
|
|
15
|
+
/** 按钮文本 */
|
|
16
|
+
text?: string
|
|
17
|
+
/** 按钮变体 */
|
|
18
|
+
variant?: ButtonVariant
|
|
19
|
+
/** 按钮尺寸 */
|
|
20
|
+
size?: ButtonSize
|
|
21
|
+
/** 是否禁用 */
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
/** 是否显示发光效果 */
|
|
24
|
+
glowEnable?: boolean
|
|
25
|
+
/** 点击事件 */
|
|
26
|
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void
|
|
27
|
+
/** 外部样式 */
|
|
28
|
+
style?: CSSProperties
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getSizeClass = (size: ButtonSize): string => {
|
|
32
|
+
switch (size) {
|
|
33
|
+
case 'small':
|
|
34
|
+
return styles.sizeSmall
|
|
35
|
+
case 'medium':
|
|
36
|
+
return styles.sizeMedium
|
|
37
|
+
case 'large':
|
|
38
|
+
return styles.sizeLarge
|
|
39
|
+
default:
|
|
40
|
+
return styles.sizeMedium
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const getVariantClass = (variant: ButtonVariant): string => {
|
|
45
|
+
switch (variant) {
|
|
46
|
+
case 'primary':
|
|
47
|
+
return styles.variantPrimary
|
|
48
|
+
case 'secondary':
|
|
49
|
+
return styles.variantSecondary
|
|
50
|
+
case 'outline':
|
|
51
|
+
return styles.variantOutline
|
|
52
|
+
case 'ghost':
|
|
53
|
+
return styles.variantGhost
|
|
54
|
+
case 'danger':
|
|
55
|
+
return styles.variantDanger
|
|
56
|
+
default:
|
|
57
|
+
return styles.variantPrimary
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
62
|
+
ref,
|
|
63
|
+
text = '按钮',
|
|
64
|
+
variant = 'primary',
|
|
65
|
+
size = 'medium',
|
|
66
|
+
disabled = false,
|
|
67
|
+
glowEnable = false,
|
|
68
|
+
onClick,
|
|
69
|
+
style: externalStyle,
|
|
70
|
+
}) => {
|
|
71
|
+
const buttonClass = cn(styles.button, getSizeClass(size), getVariantClass(variant), glowEnable && styles.glow)
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<button className={buttonClass} disabled={disabled} onClick={onClick} ref={ref} style={externalStyle} type='button'>
|
|
75
|
+
{text ? <span>{text}</span> : null}
|
|
76
|
+
</button>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default Button
|