jianghu-ui 1.0.1

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 (112) hide show
  1. package/README.md +376 -0
  2. package/dist/jianghu-ui.css +2318 -0
  3. package/dist/jianghu-ui.js +2 -0
  4. package/dist/jianghu-ui.js.LICENSE.txt +1 -0
  5. package/package.json +56 -0
  6. package/src/Design.stories.mdx +195 -0
  7. package/src/Introduction.stories.mdx +148 -0
  8. package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
  9. package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
  10. package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
  11. package/src/components/JhCard/JhCard.md +246 -0
  12. package/src/components/JhCard/JhCard.stories.js +688 -0
  13. package/src/components/JhCard/JhCard.vue +604 -0
  14. package/src/components/JhCheckCard/JhCheckCard.md +245 -0
  15. package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
  16. package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
  17. package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
  18. package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
  19. package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
  20. package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
  21. package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
  22. package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
  23. package/src/components/JhDescriptions/JhDescriptions.md +724 -0
  24. package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
  25. package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
  26. package/src/components/JhDraggable/JhDraggable.md +66 -0
  27. package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
  28. package/src/components/JhDraggable/JhDraggable.vue +254 -0
  29. package/src/components/JhDrawer/JhDrawer.md +68 -0
  30. package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
  31. package/src/components/JhDrawer/JhDrawer.vue +281 -0
  32. package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
  33. package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
  34. package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
  35. package/src/components/JhEditableTable/JhEditableTable.md +507 -0
  36. package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
  37. package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
  38. package/src/components/JhFileInput/JhFileInput.md +56 -0
  39. package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
  40. package/src/components/JhFileInput/JhFileInput.vue +253 -0
  41. package/src/components/JhForm/JhForm.md +676 -0
  42. package/src/components/JhForm/JhForm.stories.js +1375 -0
  43. package/src/components/JhForm/JhForm.vue +657 -0
  44. package/src/components/JhFormField/JhFormField.stories.js +217 -0
  45. package/src/components/JhFormField/JhFormField.vue +439 -0
  46. package/src/components/JhFormFields/JhFormFields.md +647 -0
  47. package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
  48. package/src/components/JhFormFields/JhFormFields.vue +998 -0
  49. package/src/components/JhFormList/JhFormList.md +303 -0
  50. package/src/components/JhFormList/JhFormList.stories.js +661 -0
  51. package/src/components/JhFormList/JhFormList.vue +1127 -0
  52. package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
  53. package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
  54. package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
  55. package/src/components/JhLayout/JhLayout.md +580 -0
  56. package/src/components/JhLayout/JhLayout.stories.js +414 -0
  57. package/src/components/JhLayout/JhLayout.vue +387 -0
  58. package/src/components/JhList/JhList.md +441 -0
  59. package/src/components/JhList/JhList.stories.js +524 -0
  60. package/src/components/JhList/JhList.vue +571 -0
  61. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
  62. package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
  63. package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
  64. package/src/components/JhMask/JhMask.md +62 -0
  65. package/src/components/JhMask/JhMask.stories.js +270 -0
  66. package/src/components/JhMask/JhMask.vue +123 -0
  67. package/src/components/JhMenu/JhMenu.md +85 -0
  68. package/src/components/JhMenu/JhMenu.stories.js +384 -0
  69. package/src/components/JhMenu/JhMenu.vue +545 -0
  70. package/src/components/JhModal/JhModal.md +68 -0
  71. package/src/components/JhModal/JhModal.stories.js +562 -0
  72. package/src/components/JhModal/JhModal.vue +235 -0
  73. package/src/components/JhModalForm/JhModalForm.md +69 -0
  74. package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
  75. package/src/components/JhModalForm/JhModalForm.vue +298 -0
  76. package/src/components/JhPageContainer/JhPageContainer.md +409 -0
  77. package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
  78. package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
  79. package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
  80. package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
  81. package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
  82. package/src/components/JhScene/JhScene.md +64 -0
  83. package/src/components/JhScene/JhScene.stories.js +317 -0
  84. package/src/components/JhScene/JhScene.vue +376 -0
  85. package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
  86. package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
  87. package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
  88. package/src/components/JhStepsForm/JhStepsForm.md +666 -0
  89. package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
  90. package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
  91. package/src/components/JhTable/JhTable.md +730 -0
  92. package/src/components/JhTable/JhTable.stories.js +1444 -0
  93. package/src/components/JhTable/JhTable.vue +2298 -0
  94. package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
  95. package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
  96. package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
  97. package/src/components/JhToast/JhToast.md +67 -0
  98. package/src/components/JhToast/JhToast.stories.js +386 -0
  99. package/src/components/JhToast/JhToast.vue +239 -0
  100. package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
  101. package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
  102. package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
  103. package/src/components/JhWaterMark/JhWaterMark.md +190 -0
  104. package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
  105. package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
  106. package/src/components/README.md +52 -0
  107. package/src/index.js +135 -0
  108. package/src/style/globalCSSJHV4.css +348 -0
  109. package/src/style/globalCSSVuetifyV4.css +637 -0
  110. package/src/style/storybook.css +4 -0
  111. package/src/tailwind.css +3 -0
  112. package/src/utils/vuetify.js +31 -0
@@ -0,0 +1,281 @@
1
+ <template>
2
+ <v-navigation-drawer
3
+ v-model="isShownInternal"
4
+ :permanent="isShownInternal"
5
+ fixed
6
+ temporary
7
+ :right="position === 'right'"
8
+ :left="position === 'left'"
9
+ :bottom="isBottomPosition"
10
+ :width="drawerWidth"
11
+ :height="drawerHeight"
12
+ v-bind="mergedDrawerProps"
13
+ v-on="drawerListeners"
14
+ :class="drawerClasses"
15
+ :style="drawerStyles"
16
+ >
17
+ <!-- 抽屉标题 -->
18
+ <v-row v-if="title" class="jh-drawer-header px-4 bg-white sticky top-0 z-10" no-gutters align="center">
19
+ <span class="text-h7 font-weight-bold py-4">{{ title }}</span>
20
+ <v-spacer></v-spacer>
21
+
22
+ <!-- 操作按钮组 -->
23
+ <div class="jh-drawer-action-btn-group">
24
+ <!-- 自定义操作按钮插槽 -->
25
+ <slot name="actions">
26
+ <!-- 默认按钮组 -->
27
+ <v-btn
28
+ v-if="showCancelButton"
29
+ class="elevation-0 grey lighten-4"
30
+ @click="handleCancel"
31
+ small
32
+ >
33
+ {{ cancelText }}
34
+ </v-btn>
35
+
36
+ <v-btn
37
+ v-if="showConfirmButton"
38
+ color="success"
39
+ class="ml-2"
40
+ small
41
+ @click="handleConfirm"
42
+ >
43
+ {{ confirmText }}
44
+ </v-btn>
45
+ </slot>
46
+ </div>
47
+ </v-row>
48
+
49
+ <v-divider class="jh-divider"></v-divider>
50
+
51
+ <!-- 抽屉内容 -->
52
+ <div class="pa-4">
53
+ <!-- 完全自定义内容插槽 -->
54
+ <slot></slot>
55
+ </div>
56
+
57
+ <!-- 抽屉关闭按钮 -->
58
+ <v-btn
59
+ v-if="shouldRenderCloseButton"
60
+ elevation="0"
61
+ color="success"
62
+ fab
63
+ absolute
64
+ top
65
+ left
66
+ small
67
+ tile
68
+ class="drawer-close-float-btn"
69
+ @click="handleCancel"
70
+ >
71
+ <v-icon>mdi-close</v-icon>
72
+ </v-btn>
73
+ </v-navigation-drawer>
74
+ </template>
75
+
76
+ <script>
77
+ export default {
78
+ name: 'JhDrawer',
79
+ inheritAttrs: false,
80
+
81
+ props: {
82
+ // 抽屉显示状态
83
+ value: {
84
+ type: Boolean,
85
+ default: false
86
+ },
87
+
88
+ // 抽屉标题
89
+ title: {
90
+ type: String,
91
+ default: ''
92
+ },
93
+
94
+ // 抽屉位置
95
+ position: {
96
+ type: String,
97
+ default: 'right',
98
+ validator: (v) => ['left', 'right', 'bottom'].includes(v)
99
+ },
100
+
101
+ // 抽屉宽度
102
+ width: {
103
+ type: [String, Number],
104
+ default: '90%'
105
+ },
106
+
107
+ // 底部抽屉高度
108
+ height: {
109
+ type: [String, Number],
110
+ default: '60vh'
111
+ },
112
+
113
+ // 按钮配置
114
+ showConfirmButton: {
115
+ type: Boolean,
116
+ default: true
117
+ },
118
+ showCancelButton: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+ showCloseButton: {
123
+ type: Boolean,
124
+ default: true
125
+ },
126
+ confirmText: {
127
+ type: String,
128
+ default: '确认'
129
+ },
130
+ cancelText: {
131
+ type: String,
132
+ default: '取消'
133
+ },
134
+ },
135
+
136
+ data() {
137
+ return {
138
+ isShownInternal: this.value,
139
+ };
140
+ },
141
+ computed: {
142
+ isBottomPosition() {
143
+ return this.position === 'bottom';
144
+ },
145
+ drawerWidth() {
146
+ return this.isBottomPosition ? '100%' : this.width;
147
+ },
148
+ drawerHeight() {
149
+ return this.isBottomPosition ? this.height : undefined;
150
+ },
151
+ shouldRenderCloseButton() {
152
+ return this.showCloseButton && !this.isBottomPosition;
153
+ },
154
+ drawerClasses() {
155
+ return [
156
+ 'elevation-24',
157
+ { 'jh-drawer-bottom': this.isBottomPosition },
158
+ this.$attrs.class
159
+ ];
160
+ },
161
+ drawerStyles() {
162
+ const attrsStyle = this.$attrs ? this.$attrs.style : null;
163
+ if (!this.isBottomPosition) {
164
+ return attrsStyle || null;
165
+ }
166
+ const baseStyle = {
167
+ borderTopLeftRadius: '16px',
168
+ borderTopRightRadius: '16px',
169
+ top: 'auto',
170
+ bottom: '0',
171
+ left: '0',
172
+ right: '0'
173
+ };
174
+ return attrsStyle ? [baseStyle, attrsStyle] : baseStyle;
175
+ },
176
+ // 合并透传属性,只排除组件内部明确处理的属性
177
+ mergedDrawerProps() {
178
+ // 只排除组件内部明确处理的属性,其他所有属性都透传给 v-navigation-drawer
179
+ const excludedAttrs = [
180
+ 'class', 'style',
181
+ // 这些属性在组件内部有特殊处理
182
+ 'value', 'modelValue', 'permanent', 'fixed', 'temporary', 'right', 'left', 'bottom', 'width', 'height',
183
+ // JhDrawer 特有的 props(不在 v-navigation-drawer 中)
184
+ 'title', 'position', 'showConfirmButton', 'showCancelButton', 'showCloseButton',
185
+ 'confirmText', 'cancelText'
186
+ ];
187
+
188
+ const { class: cls, style, ...rest } = this.$attrs || {};
189
+ const filteredAttrs = {};
190
+
191
+ Object.keys(rest).forEach(key => {
192
+ const keyKebab = key.replace(/([A-Z])/g, '-$1').toLowerCase();
193
+ // 只排除明确处理的属性,其他都透传
194
+ if (!excludedAttrs.includes(key) && !excludedAttrs.includes(keyKebab)) {
195
+ filteredAttrs[key] = rest[key];
196
+ }
197
+ });
198
+
199
+ return filteredAttrs;
200
+ },
201
+ // 透传所有事件,只排除组件内部明确处理的事件
202
+ drawerListeners() {
203
+ // 只排除组件内部明确处理的事件,其他所有事件都透传给 v-navigation-drawer
204
+ const excludedEvents = [
205
+ // JhDrawer 特有的事件(不在 v-navigation-drawer 中)
206
+ 'open', 'close', 'confirm', 'cancel'
207
+ ];
208
+
209
+ const listeners = { ...this.$listeners || {} };
210
+ const filteredListeners = {};
211
+
212
+ Object.keys(listeners).forEach(key => {
213
+ // 只排除明确处理的事件,其他都透传
214
+ if (!excludedEvents.includes(key)) {
215
+ filteredListeners[key] = listeners[key];
216
+ }
217
+ });
218
+
219
+ return filteredListeners;
220
+ }
221
+ },
222
+
223
+ watch: {
224
+ value(val) {
225
+ this.isShownInternal = val;
226
+ if (val) {
227
+ this.$emit('open');
228
+ }
229
+ },
230
+ isShownInternal(val) {
231
+ if (!val) {
232
+ this.$emit('input', false);
233
+ this.$emit('close');
234
+ }
235
+ }
236
+ },
237
+
238
+ methods: {
239
+ // 处理取消
240
+ handleCancel() {
241
+ this.$emit('cancel');
242
+ this.isShownInternal = false;
243
+ },
244
+
245
+ // 处理确认
246
+ handleConfirm() {
247
+ this.$emit('confirm');
248
+ },
249
+
250
+ // 打开抽屉
251
+ open() {
252
+ this.isShownInternal = true;
253
+ },
254
+
255
+ // 关闭抽屉
256
+ close() {
257
+ this.isShownInternal = false;
258
+ }
259
+ }
260
+ };
261
+ </script>
262
+
263
+ <style scoped>
264
+ .jh-drawer-header {
265
+ border-bottom: 1px solid #e0e0e0;
266
+ }
267
+
268
+ .jh-drawer-action-btn-group {
269
+ display: flex;
270
+ align-items: center;
271
+ }
272
+
273
+ .jh-drawer-bottom {
274
+ border-top-left-radius: 16px;
275
+ border-top-right-radius: 16px;
276
+ }
277
+
278
+ .drawer-close-float-btn {
279
+ z-index: 1000;
280
+ }
281
+ </style>
@@ -0,0 +1,69 @@
1
+ # JhDrawerForm - 抽屉表单组件
2
+
3
+ JhDrawerForm 结合 JhForm 与抽屉交互,提供一站式的复杂表单容器,适用于创建、编辑、批量配置等场景。
4
+
5
+ ## 功能特性
6
+
7
+ - 🧱 **抽屉展示**:继承 JhDrawer 交互,支持左右滑出、头部按钮、浮动关闭
8
+ - 🧩 **JSON 配置渲染**:内置 JhForm,可通过字段配置快速生成表单
9
+ - 🔁 **自动重置**:抽屉打开时自动重置表单与校验状态
10
+ - 🧯 **表单方法透出**:提供 `getFormData`、`validate` 等方法,方便父组件调用
11
+ - 🎛️ **插槽灵活**:支持 `field-xxx` 自定义字段、`actions` 重写按钮区
12
+
13
+ ## 基础用法
14
+
15
+ ```vue
16
+ <template>
17
+ <jh-drawer-form
18
+ v-model="drawerVisible"
19
+ title="编辑商品"
20
+ :fields="formFields"
21
+ :initial-data="formData"
22
+ @confirm="submit"
23
+ />
24
+ </template>
25
+ ```
26
+
27
+ ## API
28
+
29
+ ### Props
30
+
31
+ | 参数 | 说明 | 类型 | 默认值 |
32
+ | --- | --- | --- | --- |
33
+ | value | v-model,抽屉显隐 | boolean | false |
34
+ | title | 抽屉标题 | string | `表单` |
35
+ | position | 抽屉位置 `left/right` | string | `right` |
36
+ | width | 抽屉宽度 | string | `90%` |
37
+ | showConfirmButton | 是否显示确认按钮 | boolean | true |
38
+ | confirmText | 确认按钮文本 | string | `确认` |
39
+ | cancelText | 取消按钮文本 | string | `取消` |
40
+ | formRef | 内部 JhForm 的 ref 名称 | string | `drawerForm` |
41
+ | validateBeforeConfirm | 点击确认时是否先校验 | boolean | true |
42
+ | fields | JhForm 字段配置数组 | Array | [] |
43
+ | initialData | 初始表单数据 | Object | `{}` |
44
+ | rowClass | 自定义行 class | string | `mt-0` |
45
+ | validationRules | 通用验证规则 | Object | 预置常用规则 |
46
+
47
+ ### Events
48
+
49
+ | 事件名 | 说明 | 回调参数 |
50
+ | --- | --- | --- |
51
+ | input | `v-model` 更新事件 | (visible: boolean) |
52
+ | close | 抽屉关闭时触发 | - |
53
+ | confirm | 校验通过后触发 | (formData: object) |
54
+ | cancel | 点击取消/浮动按钮时触发 | - |
55
+ | field-change | JhForm 字段变化时触发 | ({ key, value, formData }) |
56
+
57
+ ### Slots
58
+
59
+ | 名称 | 说明 |
60
+ | --- | --- |
61
+ | default | 覆盖整个内容区域,自行渲染 |
62
+ | actions | 自定义头部按钮区 |
63
+ | field-`key` | 针对某个字段自定义渲染,`key` 为字段 `key` 值 |
64
+
65
+ ## 常用技巧
66
+
67
+ - 通过 `this.$refs.drawerForm.getFormData()` 可在外层随时读取当前表单
68
+ - 如果需要在关闭后保留数据,可在外部监听 `close` 再决定是否重置
69
+ - 表单字段中可结合 `type: 'slot'` 与 `field-xxx` 插槽编写自定义组件