hy-dispatch-ui-v3 0.2.36 → 0.2.37

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.
@@ -0,0 +1,316 @@
1
+ import { defineComponent, ref, computed, watch, resolveComponent, openBlock, createElementBlock, createBlock, unref, withCtx, createVNode, normalizeClass, createTextVNode, toDisplayString, createElementVNode, Fragment, renderList, createCommentVNode, normalizeStyle } from 'vue';
2
+ import { ElPopover, ElIcon } from 'element-plus';
3
+ import { Warning } from '@element-plus/icons-vue';
4
+ import { useLocale } from '../../hooks/useLocale.mjs';
5
+ import { HyTooltip } from '../hyTooltip/index.mjs';
6
+ import { HyButton } from '../hyButton/index.mjs';
7
+ import { HyIcon } from '../hyIcon/index.mjs';
8
+ import { isPermission, isBoolean } from '../../utils/is.mjs';
9
+
10
+ import "./style/tableActionButton.scss";
11
+
12
+ const __default__ = defineComponent({
13
+ name: "HyTableActionButton"
14
+ });
15
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
16
+ props: {
17
+ type: {
18
+ type: String,
19
+ default: "default"
20
+ // default 默认 primary 亮色 success 添加 danger 删除
21
+ },
22
+ size: {
23
+ type: String,
24
+ default: () => {
25
+ return "small";
26
+ }
27
+ },
28
+ disabled: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ // 默认按钮样式
33
+ svgName: {
34
+ type: String,
35
+ default: () => {
36
+ return "addV2";
37
+ }
38
+ },
39
+ // 默认按钮文案
40
+ label: {
41
+ type: String,
42
+ default: () => {
43
+ return "\u6DFB\u52A0";
44
+ }
45
+ },
46
+ // 类型
47
+ buttonClass: {
48
+ type: String,
49
+ default: () => {
50
+ return "button_addTo";
51
+ }
52
+ },
53
+ // 操作数据
54
+ operateList: {
55
+ type: Array,
56
+ default: () => {
57
+ return [];
58
+ }
59
+ }
60
+ },
61
+ emits: ["change"],
62
+ setup(__props, { expose: __expose, emit: __emit }) {
63
+ const props = __props;
64
+ const emits = __emit;
65
+ const { t } = useLocale();
66
+ const visible = ref(false);
67
+ const dataList = ref([]);
68
+ const selectedData = ref(null);
69
+ const buttonTxt = computed(() => {
70
+ if (selectedData.value) {
71
+ const label = selectedData.value.label || "";
72
+ const labelList = label.split(" ");
73
+ return label.replace(`${labelList[0]} `, labelList[0]);
74
+ }
75
+ return props.label;
76
+ });
77
+ function buttonChange(item) {
78
+ emits("change", item.value);
79
+ }
80
+ function getDataList(dataList2 = []) {
81
+ const arr = [];
82
+ dataList2.forEach((item) => {
83
+ const children = item.children || [];
84
+ let list = [];
85
+ children.forEach((operate) => {
86
+ if (operateShowHandler(operate)) {
87
+ list.push(operate);
88
+ }
89
+ });
90
+ if (list.length) {
91
+ arr.push({
92
+ ...item,
93
+ children: list
94
+ });
95
+ }
96
+ });
97
+ return arr;
98
+ }
99
+ function setSelectedData() {
100
+ dataList.value = getDataList(props.operateList);
101
+ const length = dataList.value.length;
102
+ if (length === 1) {
103
+ const item = dataList.value[0];
104
+ if (item.children && item.children.length === 1) {
105
+ selectedData.value = item.children[0];
106
+ return;
107
+ }
108
+ }
109
+ selectedData.value = null;
110
+ }
111
+ function operateShowHandler(operate) {
112
+ if (operate.permission && !isPermission(operate.permission)) {
113
+ return false;
114
+ }
115
+ const show = unref(operate.show);
116
+ if (isBoolean(show)) return show;
117
+ return true;
118
+ }
119
+ watch(() => props.operateList, setSelectedData, { deep: true, immediate: true });
120
+ __expose({});
121
+ return (_ctx, _cache) => {
122
+ const _component_ArrowDown = resolveComponent("ArrowDown");
123
+ return dataList.value.length ? (openBlock(), createElementBlock("div", {
124
+ key: 0,
125
+ class: "hy-action-button"
126
+ }, [
127
+ selectedData.value ? (openBlock(), createBlock(unref(HyTooltip), {
128
+ key: 0,
129
+ "open-delay": 500,
130
+ disabled: !selectedData.value.altText,
131
+ content: selectedData.value.altText,
132
+ "is-always": true,
133
+ placement: "bottom"
134
+ }, {
135
+ default: withCtx(() => [
136
+ createVNode(unref(HyButton), {
137
+ type: __props.type,
138
+ size: __props.size,
139
+ disabled: __props.disabled,
140
+ class: normalizeClass(selectedData.value.buttonClass || __props.buttonClass),
141
+ svgName: selectedData.value.svgName || __props.svgName,
142
+ onClick: ($event) => buttonChange(selectedData.value)
143
+ }, {
144
+ default: withCtx(() => [
145
+ createTextVNode(
146
+ toDisplayString(buttonTxt.value),
147
+ 1
148
+ /* TEXT */
149
+ )
150
+ ]),
151
+ _: 1
152
+ /* STABLE */
153
+ }, 8, ["type", "size", "disabled", "class", "svgName", "onClick"])
154
+ ]),
155
+ _: 1
156
+ /* STABLE */
157
+ }, 8, ["disabled", "content"])) : (openBlock(), createBlock(unref(ElPopover), {
158
+ key: 1,
159
+ visible: visible.value,
160
+ "onUpdate:visible": ($event) => visible.value = $event,
161
+ placement: "bottom",
162
+ "open-delay": 200,
163
+ disabled: __props.disabled,
164
+ trigger: "click"
165
+ }, {
166
+ reference: withCtx(() => [
167
+ createVNode(unref(HyButton), {
168
+ type: __props.type,
169
+ size: __props.size,
170
+ disabled: __props.disabled,
171
+ class: normalizeClass(__props.buttonClass),
172
+ onClick: ($event) => buttonChange(selectedData.value)
173
+ }, {
174
+ content: withCtx(() => [
175
+ createElementVNode("div", { class: "h-full flex items-center justify-center pl-[14px]" }, [
176
+ createVNode(unref(HyIcon), { "svg-name": __props.svgName }, null, 8, ["svg-name"]),
177
+ createElementVNode(
178
+ "span",
179
+ { class: "ml-[6px]" },
180
+ toDisplayString(__props.label),
181
+ 1
182
+ /* TEXT */
183
+ ),
184
+ createElementVNode(
185
+ "div",
186
+ {
187
+ class: normalizeClass(["w-[1px] h-full ml-[7px]", {
188
+ "bg-auxiliary": __props.type === "default",
189
+ "bg-success": __props.type === "success",
190
+ "bg-theme": __props.type === "primary",
191
+ "bg-danger-2": __props.type === "danger"
192
+ }])
193
+ },
194
+ null,
195
+ 2
196
+ /* CLASS */
197
+ ),
198
+ createElementVNode("div", { class: "w-[30px] h-full flex items-center justify-center" }, [
199
+ createVNode(unref(ElIcon), {
200
+ color: "rgb(var(--hy-main))",
201
+ style: normalizeStyle([{ "transition": "0.3s all linear" }, {
202
+ transform: visible.value ? "rotateX(180deg)" : "rotateX(0deg)"
203
+ }])
204
+ }, {
205
+ default: withCtx(() => [
206
+ createVNode(_component_ArrowDown)
207
+ ]),
208
+ _: 1
209
+ /* STABLE */
210
+ }, 8, ["style"])
211
+ ])
212
+ ])
213
+ ]),
214
+ _: 1
215
+ /* STABLE */
216
+ }, 8, ["type", "size", "disabled", "class", "onClick"])
217
+ ]),
218
+ default: withCtx(() => [
219
+ createElementVNode("ul", { class: "max-h-[500px] overflow-x-auto box-border" }, [
220
+ (openBlock(true), createElementBlock(
221
+ Fragment,
222
+ null,
223
+ renderList(dataList.value, (item, index) => {
224
+ return openBlock(), createElementBlock(
225
+ "li",
226
+ {
227
+ key: index,
228
+ class: normalizeClass([{
229
+ "border-b border-border": index !== dataList.value.length - 1
230
+ }, "box-border text-xs text-auxiliary"])
231
+ },
232
+ [
233
+ item.title ? (openBlock(), createElementBlock(
234
+ "div",
235
+ {
236
+ key: 0,
237
+ class: "box-border pt-2 px-2 over_one_line mb-1"
238
+ },
239
+ toDisplayString(item.title),
240
+ 1
241
+ /* TEXT */
242
+ )) : createCommentVNode("v-if", true),
243
+ createElementVNode("ul", { class: "text-sm text-main" }, [
244
+ (openBlock(true), createElementBlock(
245
+ Fragment,
246
+ null,
247
+ renderList(item.children, (row) => {
248
+ return openBlock(), createElementBlock("li", {
249
+ key: row.value,
250
+ class: "h-[32px] flex items-center justify-between px-2 box-border clickBox hover:text-theme hover:bg-backgroundv3",
251
+ onClick: ($event) => buttonChange(row)
252
+ }, [
253
+ createVNode(unref(HyTooltip), {
254
+ "open-delay": 500,
255
+ content: row.label,
256
+ "is-always": true,
257
+ placement: "bottom"
258
+ }, {
259
+ default: withCtx(() => [
260
+ createElementVNode(
261
+ "div",
262
+ {
263
+ class: normalizeClass([row.textClass, "max-w-[200px] over_one_line"])
264
+ },
265
+ toDisplayString(row.label),
266
+ 3
267
+ /* TEXT, CLASS */
268
+ )
269
+ ]),
270
+ _: 2
271
+ /* DYNAMIC */
272
+ }, 1032, ["content"]),
273
+ row.altText ? (openBlock(), createBlock(unref(HyTooltip), {
274
+ key: 0,
275
+ "open-delay": 500,
276
+ content: row.altText,
277
+ "is-always": true,
278
+ placement: "top"
279
+ }, {
280
+ default: withCtx(() => [
281
+ createVNode(unref(ElIcon), { class: "flex-shrink-0 ml-2 text-auxiliary" }, {
282
+ default: withCtx(() => [
283
+ createVNode(unref(Warning))
284
+ ]),
285
+ _: 1
286
+ /* STABLE */
287
+ })
288
+ ]),
289
+ _: 1
290
+ /* STABLE */
291
+ }, 8, ["content"])) : createCommentVNode("v-if", true)
292
+ ], 8, ["onClick"]);
293
+ }),
294
+ 128
295
+ /* KEYED_FRAGMENT */
296
+ ))
297
+ ])
298
+ ],
299
+ 2
300
+ /* CLASS */
301
+ );
302
+ }),
303
+ 128
304
+ /* KEYED_FRAGMENT */
305
+ ))
306
+ ])
307
+ ]),
308
+ _: 1
309
+ /* STABLE */
310
+ }, 8, ["visible", "onUpdate:visible", "disabled"]))
311
+ ])) : createCommentVNode("v-if", true);
312
+ };
313
+ }
314
+ });
315
+
316
+ export { _sfc_main as default };
@@ -21,6 +21,7 @@ export { HyAudioPlayer } from './hyAudioPlayer/index.mjs';
21
21
  export { ElInput, HyInput } from './hyInput/index.mjs';
22
22
  export { ElTimePicker, HyTimePicker } from './hyTimePicker/index.mjs';
23
23
  export { HyBatchTableForm, HyTableForm } from './hyTableForm/index.mjs';
24
+ export { HyTableActionButton } from './hyTableActionButton/index.mjs';
24
25
  export { resetAppFormValue, useAppForm } from './hyForm/js/useAppForm.mjs';
25
26
  export { resetAppSearchValue, useAppSearch } from './hySearch/js/useAppSearch.mjs';
26
27
  export { useAppTable } from './hyTable/js/useAppTable.mjs';
package/es/index.mjs CHANGED
@@ -19,6 +19,7 @@ export { HyNoPermissionsMap } from './components/hyNoPermissionsMap/index.mjs';
19
19
  export { HyOrgCascader } from './components/hyOrgCascader/index.mjs';
20
20
  export { HySearch } from './components/hySearch/index.mjs';
21
21
  export { HyTable } from './components/hyTable/index.mjs';
22
+ export { HyTableActionButton } from './components/hyTableActionButton/index.mjs';
22
23
  export { HyTree } from './components/hyTree/index.mjs';
23
24
  export { HyUserAvatar } from './components/hyUserAvatar/index.mjs';
24
25
  export { HyVideoPlayer } from './components/hyVideoPlayer/index.mjs';
package/es/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
- const version = "0.2.35";
1
+ const version = "0.2.36";
2
2
 
3
3
  export { version };
@@ -40,11 +40,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
40
40
  svgName: {
41
41
  type: String
42
42
  },
43
- expand: {
44
- // 展开,仅普通按钮支持
45
- type: Boolean,
46
- default: false
47
- },
48
43
  link: {
49
44
  // 链接按钮
50
45
  type: Boolean,
@@ -128,60 +123,31 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
128
123
  }, {
129
124
  default: vue.withCtx(() => [
130
125
  vue.renderSlot(_ctx.$slots, "content", {}, () => [
131
- vue.createElementVNode(
132
- "div",
133
- {
134
- class: vue.normalizeClass(["flex items-center text-main", {
135
- "px-3": !__props.expand,
136
- "pl-3 pr-1.5": __props.expand
137
- }])
138
- },
139
- [
140
- !__props.loading ? vue.renderSlot(_ctx.$slots, "svg", {}, () => [
141
- __props.svgName ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.HyIcon), {
142
- key: 0,
143
- "svg-name": __props.svgName,
144
- "class-name": "!w-3 !h-3 text-main mr-2"
145
- }, null, 8, ["svg-name"])) : vue.createCommentVNode("v-if", true)
146
- ], void 0, 0) : (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElIcon), {
147
- key: 1,
148
- color: "rgb(var(--hy-main))",
149
- class: "is-loading mr-2"
150
- }, {
151
- default: vue.withCtx(() => [
152
- vue.createVNode(vue.unref(iconsVue.Loading))
153
- ]),
154
- _: 1
155
- /* STABLE */
156
- })),
157
- vue.renderSlot(_ctx.$slots, "default")
158
- ],
159
- 2
160
- /* CLASS */
161
- )
126
+ vue.createElementVNode("div", { class: "flex items-center text-main px-3" }, [
127
+ !__props.loading ? vue.renderSlot(_ctx.$slots, "svg", {}, () => [
128
+ __props.svgName ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.HyIcon), {
129
+ key: 0,
130
+ "svg-name": __props.svgName,
131
+ "class-name": "!w-3 !h-3 text-main mr-2"
132
+ }, null, 8, ["svg-name"])) : vue.createCommentVNode("v-if", true)
133
+ ], void 0, 0) : (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElIcon), {
134
+ key: 1,
135
+ color: "rgb(var(--hy-main))",
136
+ class: "is-loading mr-2"
137
+ }, {
138
+ default: vue.withCtx(() => [
139
+ vue.createVNode(vue.unref(iconsVue.Loading))
140
+ ]),
141
+ _: 1
142
+ /* STABLE */
143
+ })),
144
+ vue.renderSlot(_ctx.$slots, "default")
145
+ ])
162
146
  ])
163
147
  ]),
164
148
  _: 3
165
149
  /* FORWARDED */
166
- }, 8, ["disabled", "content"]),
167
- __props.expand ? (vue.openBlock(), vue.createElementBlock(
168
- vue.Fragment,
169
- { key: 0 },
170
- [
171
- vue.createElementVNode("div", { class: "w-px h-full bg-success/50" }),
172
- vue.createElementVNode("div", { class: "w-[30px] flex items-center justify-center" }, [
173
- vue.createVNode(vue.unref(elementPlus.ElIcon), { color: "rgb(var(--hy-main))" }, {
174
- default: vue.withCtx(() => [
175
- vue.createVNode(vue.unref(iconsVue.ArrowDown))
176
- ]),
177
- _: 1
178
- /* STABLE */
179
- })
180
- ])
181
- ],
182
- 64
183
- /* STABLE_FRAGMENT */
184
- )) : vue.createCommentVNode("v-if", true)
150
+ }, 8, ["disabled", "content"])
185
151
  ]),
186
152
  vue.createCommentVNode(" \u6E10\u53D8\u906E\u7F69 e "),
187
153
  vue.createElementVNode("div", { class: "hy-button__mask w-full h-full absolute blur-[1px]" })
@@ -30,7 +30,7 @@
30
30
  }
31
31
 
32
32
  & + & {
33
- margin-left: 16px;
33
+ margin-left: 12px;
34
34
  }
35
35
 
36
36
  &.hy-button_default {
@@ -252,7 +252,8 @@ const _sfc_main = {
252
252
  "parent-prop": __props.column.field,
253
253
  index: index$1,
254
254
  loading: __props.loading,
255
- readonly: __props.readonly
255
+ readonly: __props.readonly,
256
+ level: 3
256
257
  }, vue.createSlots({
257
258
  _: 2
258
259
  /* DYNAMIC */
@@ -43,6 +43,10 @@ const _sfc_main = {
43
43
  readonly: {
44
44
  type: Boolean,
45
45
  default: false
46
+ },
47
+ level: {
48
+ type: Number,
49
+ default: 2
46
50
  }
47
51
  },
48
52
  setup(__props) {
@@ -142,21 +146,38 @@ const _sfc_main = {
142
146
  ])) : vue.createCommentVNode("v-if", true)
143
147
  ]),
144
148
  vue.createCommentVNode(" \u5185\u5BB9\u4EC5\u67E5\u770B "),
145
- __props.column.readonly || __props.readonly || !__props.column.type && !__props.column.slot ? (vue.openBlock(), vue.createElementBlock("div", {
146
- key: 0,
147
- class: "w-full text-main h-[32px]"
148
- }, [
149
- vue.unref(index.renderText)(props, __props.column) ? (vue.openBlock(), vue.createElementBlock(
150
- "span",
151
- { key: 0 },
152
- vue.toDisplayString(vue.unref(index.renderText)(props, __props.column)),
153
- 1
154
- /* TEXT */
155
- )) : (vue.openBlock(), vue.createElementBlock("span", {
156
- key: 1,
157
- class: "text-auxiliary"
158
- }, "- -"))
159
- ])) : (vue.openBlock(), vue.createElementBlock(
149
+ __props.column.readonly || __props.readonly || !__props.column.type && !__props.column.slot ? (vue.openBlock(), vue.createElementBlock(
150
+ "div",
151
+ {
152
+ key: 0,
153
+ class: vue.normalizeClass(["w-full flex items-center text-main px-2", {
154
+ "min-h-[40px]": _ctx.size === "large",
155
+ "min-h-[32px]": _ctx.size === "default",
156
+ "min-h-[24px]": _ctx.size === "small",
157
+ "bg-background": __props.level === 1,
158
+ "bg-background-2": __props.level === 2,
159
+ "bg-background-3": __props.level === 3,
160
+ "bg-background-4": __props.level === 4
161
+ }])
162
+ },
163
+ [
164
+ vue.unref(index.renderText)(props, __props.column) ? (vue.openBlock(), vue.createElementBlock(
165
+ "span",
166
+ {
167
+ key: 0,
168
+ class: "break-all"
169
+ },
170
+ vue.toDisplayString(vue.unref(index.renderText)(props, __props.column)),
171
+ 1
172
+ /* TEXT */
173
+ )) : (vue.openBlock(), vue.createElementBlock("span", {
174
+ key: 1,
175
+ class: "text-auxiliary"
176
+ }, "- -"))
177
+ ],
178
+ 2
179
+ /* CLASS */
180
+ )) : (vue.openBlock(), vue.createElementBlock(
160
181
  vue.Fragment,
161
182
  { key: 1 },
162
183
  [
@@ -54,7 +54,7 @@ function isDisabled(props, column) {
54
54
  }
55
55
  function renderText(props, column = {}) {
56
56
  const { type, field, customRender } = column;
57
- const { props: fieldNames, options = [] } = column.attrs || {};
57
+ const { props: fieldNames } = column.attrs || {};
58
58
  if (customRender && typeof customRender === "function") {
59
59
  return customRender({
60
60
  column,
@@ -71,7 +71,8 @@ function renderText(props, column = {}) {
71
71
  return [props.model[lon], props.model[lat]].filter(Boolean).join("\uFF0C");
72
72
  }
73
73
  if (/^(select|radio|checkbox)$/.test(type)) {
74
- const target = options.find(
74
+ const optionList = optionsHandler(props, column);
75
+ const target = optionList.find(
75
76
  (item) => item[fieldNames.value] === props.model?.[field]
76
77
  );
77
78
  return target?.[fieldNames.label] || props.model?.[field] || "";
@@ -310,22 +310,29 @@ const _sfc_main = {
310
310
  )) : vue.createCommentVNode("v-if", true)
311
311
  ]),
312
312
  vue.createElementVNode("div", { class: "w-0 flex-1 flex items-center justify-end ml-3" }, [
313
- vue.createVNode(vue.unref(elementPlus.ElIcon), {
314
- class: "mr-1.5",
315
- color: "rgb(var(--hy-auxiliary))"
316
- }, {
317
- default: vue.withCtx(() => [
318
- vue.createVNode(vue.unref(iconsVue.Warning))
319
- ]),
320
- _: 1
321
- /* STABLE */
322
- }),
323
- checkedList.value?.length >= 8 ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.HyTooltip), {
324
- key: 0,
325
- "is-always": false,
326
- content: vue.unref(t)("table.tooManyFieldsWillAffectReadability"),
327
- class: "mr-2 text-auxiliary"
328
- }, null, 8, ["content"])) : vue.createCommentVNode("v-if", true),
313
+ checkedList.value?.length >= 8 ? (vue.openBlock(), vue.createElementBlock(
314
+ vue.Fragment,
315
+ { key: 0 },
316
+ [
317
+ vue.createVNode(vue.unref(elementPlus.ElIcon), {
318
+ class: "mr-1.5",
319
+ color: "rgb(var(--hy-auxiliary))"
320
+ }, {
321
+ default: vue.withCtx(() => [
322
+ vue.createVNode(vue.unref(iconsVue.Warning))
323
+ ]),
324
+ _: 1
325
+ /* STABLE */
326
+ }),
327
+ vue.createVNode(vue.unref(index$1.HyTooltip), {
328
+ "is-always": false,
329
+ content: vue.unref(t)("table.tooManyFieldsWillAffectReadability"),
330
+ class: "mr-2 text-auxiliary"
331
+ }, null, 8, ["content"])
332
+ ],
333
+ 64
334
+ /* STABLE_FRAGMENT */
335
+ )) : vue.createCommentVNode("v-if", true),
329
336
  vue.createVNode(vue.unref(index$2.HyButton), {
330
337
  type: "primary",
331
338
  size: "small",
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tableActionButton = require('./tableActionButton.vue.js');
6
+ var handler = require('../../utils/handler.js');
7
+
8
+ const HyTableActionButton = handler.withInstall(tableActionButton.default);
9
+
10
+ exports.HyTableActionButton = HyTableActionButton;
11
+ exports.default = HyTableActionButton;
@@ -0,0 +1,5 @@
1
+ .hy-action-button + .hy-action-button,
2
+ .hy-action-button + .hy-button,
3
+ .hy-button + .hy-action-button {
4
+ margin-left: 12px;
5
+ }