@hbdlzy/ui-core 0.1.7 → 0.1.8

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.
Files changed (67) hide show
  1. package/README.md +30 -2
  2. package/components.manifest.json +15 -1
  3. package/dist/index.cjs +5 -5
  4. package/dist/index.d.ts +50 -13
  5. package/dist/index.js +229 -17
  6. package/dist/ripple/index.cjs +42 -0
  7. package/dist/ripple/index.d.ts +8 -1
  8. package/dist/ripple/index.js +171 -0
  9. package/dist/style.css +1 -1
  10. package/package.json +17 -2
  11. package/src/components/BaseCard/BaseCard.types.d.ts +36 -0
  12. package/src/components/BaseCard/BaseCard.vue.d.ts +122 -0
  13. package/src/components/BaseCard/README.md +33 -0
  14. package/src/components/BaseCard/index.d.ts +3 -0
  15. package/src/components/BaseEChart/BaseEChart.types.d.ts +26 -0
  16. package/src/components/BaseEChart/BaseEChart.vue.d.ts +66 -0
  17. package/src/components/BaseEChart/README.md +33 -0
  18. package/src/components/BaseEChart/index.d.ts +3 -0
  19. package/src/components/BaseExportButton/BaseExportButton.types.d.ts +21 -0
  20. package/src/components/BaseExportButton/BaseExportButton.utils.d.ts +4 -0
  21. package/src/components/BaseExportButton/BaseExportButton.vue.d.ts +128 -0
  22. package/src/components/BaseExportButton/README.md +34 -0
  23. package/src/components/BaseExportButton/index.d.ts +5 -0
  24. package/src/components/BaseTable/BaseTable.types.d.ts +178 -0
  25. package/src/components/BaseTable/BaseTable.vue +16 -13
  26. package/src/components/BaseTable/BaseTable.vue.d.ts +157 -0
  27. package/src/components/BaseTable/README.md +45 -0
  28. package/src/components/BaseTable/index.d.ts +3 -0
  29. package/src/components/OutlinedCascader/OutlinedCascader.types.d.ts +28 -0
  30. package/src/components/OutlinedCascader/OutlinedCascader.vue.d.ts +94 -0
  31. package/src/components/OutlinedCascader/README.md +34 -0
  32. package/src/components/OutlinedCascader/index.d.ts +3 -0
  33. package/src/components/OutlinedDatePicker/OutlinedDatePicker.types.d.ts +30 -0
  34. package/src/components/OutlinedDatePicker/OutlinedDatePicker.vue.d.ts +97 -0
  35. package/src/components/OutlinedDatePicker/README.md +34 -0
  36. package/src/components/OutlinedDatePicker/index.d.ts +3 -0
  37. package/src/components/OutlinedDateTimePicker/OutlinedDateTimePicker.types.d.ts +29 -0
  38. package/src/components/OutlinedDateTimePicker/OutlinedDateTimePicker.vue.d.ts +106 -0
  39. package/src/components/OutlinedDateTimePicker/README.md +33 -0
  40. package/src/components/OutlinedDateTimePicker/index.d.ts +3 -0
  41. package/src/components/OutlinedInput/OutlinedInput.types.d.ts +32 -0
  42. package/src/components/OutlinedInput/OutlinedInput.vue.d.ts +106 -0
  43. package/src/components/OutlinedInput/README.md +34 -0
  44. package/src/components/OutlinedInput/index.d.ts +3 -0
  45. package/src/components/OutlinedSelect/OutlinedSelect.types.d.ts +41 -0
  46. package/src/components/OutlinedSelect/OutlinedSelect.vue.d.ts +125 -0
  47. package/src/components/OutlinedSelect/README.md +34 -0
  48. package/src/components/OutlinedSelect/index.d.ts +3 -0
  49. package/src/components/OutlinedTimePicker/OutlinedTimePicker.types.d.ts +31 -0
  50. package/src/components/OutlinedTimePicker/OutlinedTimePicker.vue.d.ts +103 -0
  51. package/src/components/OutlinedTimePicker/README.md +33 -0
  52. package/src/components/OutlinedTimePicker/index.d.ts +3 -0
  53. package/src/components/OutlinedTreeSelect/OutlinedTreeSelect.types.d.ts +49 -0
  54. package/src/components/OutlinedTreeSelect/OutlinedTreeSelect.vue.d.ts +146 -0
  55. package/src/components/OutlinedTreeSelect/README.md +34 -0
  56. package/src/components/OutlinedTreeSelect/index.d.ts +3 -0
  57. package/src/components/SvgIcon/README.md +33 -0
  58. package/src/components/SvgIcon/SvgIcon.types.d.ts +6 -0
  59. package/src/components/SvgIcon/SvgIcon.vue.d.ts +32 -0
  60. package/src/components/SvgIcon/index.d.ts +3 -0
  61. package/src/echarts/index.d.ts +9 -0
  62. package/src/excel/exportExcel.d.ts +18 -0
  63. package/src/index.d.ts +30 -0
  64. package/src/index.ts +78 -13
  65. package/src/ripple/README.md +160 -0
  66. package/src/ripple/index.d.ts +9 -0
  67. package/src/ripple/index.ts +15 -1
package/src/index.ts CHANGED
@@ -1,7 +1,71 @@
1
+ import type { App, Component, Plugin } from 'vue'
1
2
  import { installRipple } from './ripple'
3
+ import BaseCard from './components/BaseCard'
4
+ import BaseTable from './components/BaseTable'
5
+ import BaseEChart from './components/BaseEChart'
6
+ import BaseExportButton from './components/BaseExportButton'
7
+ import SvgIcon from './components/SvgIcon'
8
+ import OutlinedInput from './components/OutlinedInput'
9
+ import OutlinedSelect from './components/OutlinedSelect'
10
+ import OutlinedDatePicker from './components/OutlinedDatePicker'
11
+ import OutlinedDateTimePicker from './components/OutlinedDateTimePicker'
12
+ import OutlinedTimePicker from './components/OutlinedTimePicker'
13
+ import OutlinedCascader from './components/OutlinedCascader'
14
+ import OutlinedTreeSelect from './components/OutlinedTreeSelect'
2
15
 
3
16
  installRipple()
4
17
 
18
+ const componentEntries: Array<[string, Component]> = [
19
+ ['BaseCard', BaseCard],
20
+ ['BaseTable', BaseTable],
21
+ ['BaseEChart', BaseEChart],
22
+ ['BaseExportButton', BaseExportButton],
23
+ ['SvgIcon', SvgIcon],
24
+ ['OutlinedInput', OutlinedInput],
25
+ ['OutlinedSelect', OutlinedSelect],
26
+ ['OutlinedDatePicker', OutlinedDatePicker],
27
+ ['OutlinedDateTimePicker', OutlinedDateTimePicker],
28
+ ['OutlinedTimePicker', OutlinedTimePicker],
29
+ ['OutlinedCascader', OutlinedCascader],
30
+ ['OutlinedTreeSelect', OutlinedTreeSelect]
31
+ ]
32
+
33
+ export const uiCoreComponents = componentEntries.map(([name, component]) => ({
34
+ name,
35
+ component
36
+ }))
37
+
38
+ export function installUiCore(app: App) {
39
+ componentEntries.forEach(([name, component]) => {
40
+ app.component(name, component)
41
+ })
42
+
43
+ installRipple(app)
44
+ }
45
+
46
+ export const HbdlUICore: Plugin = {
47
+ install: installUiCore
48
+ }
49
+
50
+ export default HbdlUICore
51
+
52
+ declare module 'vue' {
53
+ export interface GlobalComponents {
54
+ BaseCard: typeof BaseCard
55
+ BaseTable: typeof BaseTable
56
+ BaseEChart: typeof BaseEChart
57
+ BaseExportButton: typeof BaseExportButton
58
+ SvgIcon: typeof SvgIcon
59
+ OutlinedInput: typeof OutlinedInput
60
+ OutlinedSelect: typeof OutlinedSelect
61
+ OutlinedDatePicker: typeof OutlinedDatePicker
62
+ OutlinedDateTimePicker: typeof OutlinedDateTimePicker
63
+ OutlinedTimePicker: typeof OutlinedTimePicker
64
+ OutlinedCascader: typeof OutlinedCascader
65
+ OutlinedTreeSelect: typeof OutlinedTreeSelect
66
+ }
67
+ }
68
+
5
69
  export { echarts } from './echarts'
6
70
  export type {
7
71
  EChartInitOptions,
@@ -11,30 +75,31 @@ export type {
11
75
  EChartResizeOptions,
12
76
  EChartSetOptionOptions
13
77
  } from './echarts'
14
- export { default as BaseCard } from './components/BaseCard'
78
+ export { BaseCard }
15
79
  export * from './components/BaseCard'
16
- export { default as BaseTable } from './components/BaseTable'
80
+ export { BaseTable }
17
81
  export * from './components/BaseTable'
18
- export { default as BaseEChart } from './components/BaseEChart'
82
+ export { BaseEChart }
19
83
  export * from './components/BaseEChart'
20
- export { default as BaseExportButton } from './components/BaseExportButton'
84
+ export { BaseExportButton }
21
85
  export * from './components/BaseExportButton'
22
- export { default as SvgIcon } from './components/SvgIcon'
86
+ export { SvgIcon }
23
87
  export * from './components/SvgIcon'
24
- export { default as OutlinedInput } from './components/OutlinedInput'
88
+ export { OutlinedInput }
25
89
  export * from './components/OutlinedInput'
26
- export { default as OutlinedSelect } from './components/OutlinedSelect'
90
+ export { OutlinedSelect }
27
91
  export * from './components/OutlinedSelect'
28
- export { default as OutlinedDatePicker } from './components/OutlinedDatePicker'
92
+ export { OutlinedDatePicker }
29
93
  export * from './components/OutlinedDatePicker'
30
- export { default as OutlinedDateTimePicker } from './components/OutlinedDateTimePicker'
94
+ export { OutlinedDateTimePicker }
31
95
  export * from './components/OutlinedDateTimePicker'
32
- export { default as OutlinedTimePicker } from './components/OutlinedTimePicker'
96
+ export { OutlinedTimePicker }
33
97
  export * from './components/OutlinedTimePicker'
34
- export { default as OutlinedCascader } from './components/OutlinedCascader'
98
+ export { OutlinedCascader }
35
99
  export * from './components/OutlinedCascader'
36
- export { default as OutlinedTreeSelect } from './components/OutlinedTreeSelect'
100
+ export { OutlinedTreeSelect }
37
101
  export * from './components/OutlinedTreeSelect'
38
102
  export { exportExcel } from './excel/exportExcel'
39
103
  export type { ExcelCellValue, ExcelExportColumn, ExcelExportOptions } from './excel/exportExcel'
40
- export { installRipple, uninstallRipple } from './ripple'
104
+ export { Ripple, installRipple, uninstallRipple } from './ripple'
105
+ export type { RipplePlugin, RippleTeardown } from './ripple'
@@ -0,0 +1,160 @@
1
+ # Ripple
2
+
3
+ `Ripple` 是组件库提供的全局点击涟漪效果,用来统一按钮、类按钮元素和 Element Plus 按钮的点击反馈。
4
+
5
+ ## 解决的问题
6
+
7
+ - 统一项目里按钮的点击反馈,不需要在每个按钮里写动画 DOM
8
+ - 支持原生 `button`、`[role="button"]`、Element Plus `el-button`
9
+ - 支持 `el-radio-button`、`el-checkbox-button` 的按钮态
10
+ - 自动忽略禁用、加载中和显式关闭 ripple 的元素
11
+ - 支持鼠标、触控和键盘 Enter / Space 触发
12
+
13
+ ## 全局启用
14
+
15
+ 推荐在业务项目入口统一导入 `@hbdlzy/ui`,会自动安装 ripple:
16
+
17
+ ```ts
18
+ import { createApp } from 'vue'
19
+ import ElementPlus from 'element-plus'
20
+ import App from './App.vue'
21
+ import '@hbdlzy/ui'
22
+
23
+ createApp(App).use(ElementPlus).mount('#app')
24
+ ```
25
+
26
+ 如果项目只安装 `@hbdlzy/ui-core`,导入 `@hbdlzy/ui-core` 也会自动安装:
27
+
28
+ ```ts
29
+ import '@hbdlzy/ui-core'
30
+ ```
31
+
32
+ 如果只想引入涟漪能力,可以使用细粒度入口:
33
+
34
+ ```ts
35
+ import { Ripple, installRipple, uninstallRipple } from '@hbdlzy/ui/ripple'
36
+ ```
37
+
38
+ 只安装 `@hbdlzy/ui-core` 时,对应入口为:
39
+
40
+ ```ts
41
+ import { Ripple, installRipple, uninstallRipple } from '@hbdlzy/ui-core/ripple'
42
+ ```
43
+
44
+ ## 手动安装
45
+
46
+ 如果希望显式控制安装时机,可以调用 `installRipple`:
47
+
48
+ ```ts
49
+ import { createApp } from 'vue'
50
+ import App from './App.vue'
51
+ import { installRipple } from '@hbdlzy/ui'
52
+
53
+ const app = createApp(App)
54
+ installRipple()
55
+ app.mount('#app')
56
+ ```
57
+
58
+ 也可以按 Vue 插件形式使用:
59
+
60
+ ```ts
61
+ import { createApp } from 'vue'
62
+ import App from './App.vue'
63
+ import { Ripple } from '@hbdlzy/ui/ripple'
64
+
65
+ createApp(App).use(Ripple).mount('#app')
66
+ ```
67
+
68
+ ## 局部关闭
69
+
70
+ 如果某个按钮或某块区域不需要涟漪效果,添加 `data-hbdl-ripple="false"`:
71
+
72
+ ```vue
73
+ <template>
74
+ <el-button data-hbdl-ripple="false">
75
+ 不显示涟漪
76
+ </el-button>
77
+
78
+ <div data-hbdl-ripple="false">
79
+ <el-button>这块区域内也不显示涟漪</el-button>
80
+ </div>
81
+ </template>
82
+ ```
83
+
84
+ ## 自定义颜色
85
+
86
+ 涟漪默认使用当前文本色 `currentColor`,可通过 CSS 变量覆盖:
87
+
88
+ ```vue
89
+ <template>
90
+ <el-button class="danger-ripple">
91
+ 自定义涟漪颜色
92
+ </el-button>
93
+ </template>
94
+
95
+ <style scoped>
96
+ .danger-ripple {
97
+ --hbdl-ripple-color: #f56c6c;
98
+ }
99
+ </style>
100
+ ```
101
+
102
+ ## 手动卸载
103
+
104
+ 极少数微前端或临时挂载场景需要主动卸载时,可以调用:
105
+
106
+ ```ts
107
+ import { uninstallRipple } from '@hbdlzy/ui'
108
+
109
+ uninstallRipple()
110
+ ```
111
+
112
+ `installRipple()` 会返回卸载函数:
113
+
114
+ ```ts
115
+ const teardown = installRipple()
116
+ teardown()
117
+ ```
118
+
119
+ ## AI 使用指引
120
+
121
+ AI 在接入业务项目时,如果项目使用 `@hbdlzy/ui`,应把 ripple 视为已内置的全局交互能力,不要再复制实现点击水波纹指令或按钮动画。
122
+
123
+ 推荐优先从统一入口导入:
124
+
125
+ ```ts
126
+ import '@hbdlzy/ui'
127
+ ```
128
+
129
+ 需要显式控制时再导入:
130
+
131
+ ```ts
132
+ import { Ripple, installRipple, uninstallRipple } from '@hbdlzy/ui'
133
+ ```
134
+
135
+ 或者从细粒度入口导入:
136
+
137
+ ```ts
138
+ import { Ripple, installRipple, uninstallRipple } from '@hbdlzy/ui/ripple'
139
+ ```
140
+
141
+ AI 生成代码时按下面顺序判断:
142
+
143
+ 1. 新项目入口已经导入 `@hbdlzy/ui` 时,不需要额外写任何 ripple 初始化代码
144
+ 2. 只想手动启用时,使用 `installRipple()`
145
+ 3. 想按 Vue 插件语义接入时,使用 `app.use(Ripple)`
146
+ 4. 局部关闭时,给按钮或父级容器添加 `data-hbdl-ripple="false"`
147
+ 5. 自定义颜色时,设置 `--hbdl-ripple-color`
148
+
149
+ AI 不应该做这些事:
150
+
151
+ - 不要在页面里重复写 `v-ripple` 指令
152
+ - 不要为每个按钮手动插入 ripple 动画节点
153
+ - 不要给禁用或加载中的按钮强行添加涟漪
154
+ - 不要把业务按钮封装成新组件只为实现点击反馈
155
+
156
+ 生成代码前建议同时读取:
157
+
158
+ - `packages/ui-core/components.manifest.json`
159
+ - `packages/ui-core/src/ripple/index.ts`
160
+ - 本 README 的 `全局启用 / 局部关闭 / 自定义颜色` 部分
@@ -0,0 +1,9 @@
1
+ import type { App } from 'vue';
2
+ export type RippleTeardown = () => void;
3
+ export interface RipplePlugin {
4
+ install: (app?: App) => RippleTeardown;
5
+ }
6
+ export declare function installRipple(_app?: App): RippleTeardown;
7
+ export declare function uninstallRipple(): void;
8
+ export declare const Ripple: RipplePlugin;
9
+ export default Ripple;
@@ -1,3 +1,5 @@
1
+ import type { App } from 'vue'
2
+
1
3
  const HBDL_RIPPLE_KEY = '__HBDL_UI_RIPPLE__'
2
4
  const RIPPLE_STYLE_ID = 'hbdl-ui-ripple-style'
3
5
  const RIPPLE_HOST_CLASS = 'hbdl-ripple-host'
@@ -74,7 +76,13 @@ type RippleWindow = Window & {
74
76
 
75
77
  const noop = () => undefined
76
78
 
77
- export function installRipple() {
79
+ export type RippleTeardown = () => void
80
+
81
+ export interface RipplePlugin {
82
+ install: (app?: App) => RippleTeardown
83
+ }
84
+
85
+ export function installRipple(_app?: App): RippleTeardown {
78
86
  if (!canUseDOM()) {
79
87
  return noop
80
88
  }
@@ -112,6 +120,12 @@ export function uninstallRipple() {
112
120
  rippleWindow[HBDL_RIPPLE_KEY]?.teardown()
113
121
  }
114
122
 
123
+ export const Ripple: RipplePlugin = {
124
+ install: installRipple
125
+ }
126
+
127
+ export default Ripple
128
+
115
129
  function canUseDOM() {
116
130
  return typeof window !== 'undefined' && typeof document !== 'undefined'
117
131
  }