@meethive/components 0.0.13 → 0.0.15

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 (57) hide show
  1. package/es/EditTable/Body.js +108 -24
  2. package/es/EditTable/EditTable.js +111 -35
  3. package/es/EditTable/FormItem.js +46 -18
  4. package/es/EditTable/Group.js +167 -53
  5. package/es/EditTable/Header.js +79 -21
  6. package/es/EditTable/components/ContextMenu/Menu.js +79 -29
  7. package/es/EditTable/components/Search/Search.js +132 -33
  8. package/es/EditTable/components/Search/Sort.js +91 -32
  9. package/es/FullPage/FullPage.js +23 -9
  10. package/es/Icon/Icon.js +43 -23
  11. package/es/Markdown/Markdown.js +9 -4
  12. package/es/RadioButton/RadioButton.js +31 -12
  13. package/es/Skeleton/Skeleton.js +33 -9
  14. package/es/Skeleton/components/DashBoardCard.js +40 -9
  15. package/es/Skeleton/components/DashBoardChart.js +67 -9
  16. package/es/Skeleton/components/Detail.js +75 -9
  17. package/es/Skeleton/components/Drawer.js +59 -9
  18. package/es/Skeleton/components/Item.js +17 -7
  19. package/es/Skeleton/components/List.js +27 -11
  20. package/es/Skeleton/components/ListCard.js +36 -10
  21. package/es/Skeleton/components/ListCardItem.js +71 -8
  22. package/es/Skeleton/components/ListTable.js +53 -9
  23. package/es/Skeleton/components/Page.js +40 -10
  24. package/es/Skeleton/components/Search.js +39 -8
  25. package/es/Skeleton/components/Tree.js +46 -9
  26. package/es/TimeFormat/TimeFormat.js +18 -9
  27. package/es/Title/Title.js +22 -10
  28. package/es/ValueItem/ValueItem.js +171 -43
  29. package/lib/EditTable/Body.js +108 -24
  30. package/lib/EditTable/EditTable.js +111 -35
  31. package/lib/EditTable/FormItem.js +46 -18
  32. package/lib/EditTable/Group.js +167 -53
  33. package/lib/EditTable/Header.js +79 -21
  34. package/lib/EditTable/components/ContextMenu/Menu.js +79 -29
  35. package/lib/EditTable/components/Search/Search.js +132 -33
  36. package/lib/EditTable/components/Search/Sort.js +91 -32
  37. package/lib/FullPage/FullPage.js +23 -9
  38. package/lib/Icon/Icon.js +43 -23
  39. package/lib/Markdown/Markdown.js +9 -4
  40. package/lib/RadioButton/RadioButton.js +31 -12
  41. package/lib/Skeleton/Skeleton.js +33 -9
  42. package/lib/Skeleton/components/DashBoardCard.js +40 -9
  43. package/lib/Skeleton/components/DashBoardChart.js +67 -9
  44. package/lib/Skeleton/components/Detail.js +75 -9
  45. package/lib/Skeleton/components/Drawer.js +59 -9
  46. package/lib/Skeleton/components/Item.js +17 -7
  47. package/lib/Skeleton/components/List.js +27 -11
  48. package/lib/Skeleton/components/ListCard.js +36 -10
  49. package/lib/Skeleton/components/ListCardItem.js +71 -8
  50. package/lib/Skeleton/components/ListTable.js +53 -9
  51. package/lib/Skeleton/components/Page.js +40 -10
  52. package/lib/Skeleton/components/Search.js +39 -8
  53. package/lib/Skeleton/components/Tree.js +46 -9
  54. package/lib/TimeFormat/TimeFormat.js +18 -9
  55. package/lib/Title/Title.js +22 -10
  56. package/lib/ValueItem/ValueItem.js +171 -43
  57. package/package.json +9 -9
@@ -1,43 +1,54 @@
1
- import { defineComponent, ref, reactive, computed, watch, onMounted } from 'vue';
2
- import { Tabs as ATabs, TabPane as ATabPane, Dropdown as ADropdown, Menu as AMenu, MenuItem as AMenuItem, Tooltip as ATooltip, Modal as AModal, Form as AForm, FormItem as AFormItem, Input as AInput, Button as AButton, Modal } from 'ant-design-vue';
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, createElementVNode as _createElementVNode, createBlock as _createBlock, createCommentVNode as _createCommentVNode, vShow as _vShow, withDirectives as _withDirectives, normalizeClass as _normalizeClass } from "vue";
3
+ const _hoisted_1 = {
4
+ class: "jetlinks-table-group-error-warp"
5
+ };
6
+ const _hoisted_2 = {
7
+ style: {
8
+ "color": "#1d2129"
9
+ }
10
+ };
11
+ const _hoisted_3 = {
12
+ key: 1,
13
+ class: "jetlinks-table-group-error-warp"
14
+ };
15
+ const _hoisted_4 = {
16
+ style: {
17
+ "color": "#1d2129"
18
+ }
19
+ };
20
+ import { ref, reactive, computed, watch, onMounted } from 'vue';
21
+ import { Modal } from 'ant-design-vue';
3
22
  import { randomNumber } from '@meethive/utils';
4
23
  import { isFullScreen } from './utils';
5
24
  import { useTableGroupError, useTableWrapper } from './context';
6
25
  import { useLocaleReceiver } from '../LocaleReciver';
7
26
  import genEditTableStyle from './style';
8
- export default defineComponent({
9
- name: 'JEditTableGroup',
10
- components: {
11
- ATabs,
12
- ATabPane,
13
- ADropdown,
14
- AMenu,
15
- AMenuItem,
16
- ATooltip,
17
- AModal,
18
- AForm,
19
- AFormItem,
20
- AInput,
21
- AButton
27
+ const __sfc_main__ = _defineComponent({
28
+ ...{
29
+ name: 'JEditTableGroup'
22
30
  },
31
+ __name: 'Group',
23
32
  props: {
24
33
  options: {
25
34
  type: Array,
26
- default: () => []
35
+ required: false
27
36
  },
28
37
  activeKey: {
29
38
  type: String,
30
- default: undefined
39
+ required: false
31
40
  },
32
41
  readonly: {
33
42
  type: Boolean,
34
- default: false
43
+ required: false
35
44
  }
36
45
  },
37
46
  emits: ['delete', 'edit', 'add', 'change', 'update:activeKey'],
38
- setup(props, {
39
- emit
47
+ setup(__props, {
48
+ emit: __emit
40
49
  }) {
50
+ const props = __props;
51
+ const emit = __emit;
41
52
  const [contextLocale] = useLocaleReceiver('EditTable');
42
53
  const myActiveKey = ref(props.activeKey);
43
54
  const visible = ref(false);
@@ -54,7 +65,7 @@ export default defineComponent({
54
65
  const onAdd = (targetKey, action) => {
55
66
  if (action === 'add') {
56
67
  type.value = 'add';
57
- const groupName = props.options.filter(item => item.label.includes(contextLocale.value.Group.one));
68
+ const groupName = (props.options || []).filter(item => item.label.includes(contextLocale.value.Group.one));
58
69
  let index = addIndex.value + 1;
59
70
  let findStatus = false;
60
71
  while (!findStatus) {
@@ -103,7 +114,7 @@ export default defineComponent({
103
114
  }
104
115
  };
105
116
  const change = () => {
106
- const item = props.options.find(item => item.value === myActiveKey.value);
117
+ const item = (props.options || []).find(item => item.value === myActiveKey.value);
107
118
  emit('change', myActiveKey.value, item.label);
108
119
  emit('update:activeKey', myActiveKey.value);
109
120
  };
@@ -115,17 +126,17 @@ export default defineComponent({
115
126
  Modal.confirm({
116
127
  title: contextLocale.value.Group.deleteMessage,
117
128
  onOk: () => {
118
- const index = props.options.findIndex(item => item.value === record.value);
129
+ const index = (props.options || []).findIndex(item => item.value === record.value);
119
130
  let label = '';
120
- if (index !== 0 && index === props.options.length - 1) {
121
- myActiveKey.value = props.options[index - 1].value;
122
- label = props.options[index - 1].label;
123
- } else if (index === 0 && props.options.length === 1) {
124
- myActiveKey.value = props.options[0].value;
125
- label = props.options[0].label;
131
+ if (index !== 0 && index === (props.options || []).length - 1) {
132
+ myActiveKey.value = (props.options || [])[index - 1].value;
133
+ label = (props.options || [])[index - 1].label;
134
+ } else if (index === 0 && (props.options || []).length === 1) {
135
+ myActiveKey.value = (props.options || [])[0].value;
136
+ label = (props.options || [])[0].label;
126
137
  } else {
127
- myActiveKey.value = props.options[index + 1].value;
128
- label = props.options[index + 1].label;
138
+ myActiveKey.value = (props.options || [])[index + 1].value;
139
+ label = (props.options || [])[index + 1].label;
129
140
  }
130
141
  emit('delete', record.value, index);
131
142
  emit('change', myActiveKey.value, label);
@@ -134,38 +145,141 @@ export default defineComponent({
134
145
  }
135
146
  };
136
147
  const popContainer = e => {
137
- return tableWrapperRef.value || e;
148
+ return tableWrapperRef?.value || e;
138
149
  };
139
150
  const modalContainer = () => {
140
151
  if (isFullScreen()) {
141
- return tableWrapperRef.value || document.body;
152
+ return tableWrapperRef?.value || document.body;
142
153
  }
143
154
  return document.body;
144
155
  };
145
156
  onMounted(() => {
146
- myActiveKey.value = props.options[0]?.value;
147
- emit('change', myActiveKey.value, props.options[0]?.label);
157
+ myActiveKey.value = props.options?.[0]?.value;
158
+ emit('change', myActiveKey.value, props.options?.[0]?.label);
148
159
  emit('update:activeKey', myActiveKey.value);
149
160
  });
150
161
  watch(() => props.activeKey, val => {
151
162
  myActiveKey.value = val;
152
163
  });
153
- return {
154
- hashId,
155
- contextLocale,
156
- myActiveKey,
157
- visible,
158
- errorMap,
159
- tableWrapperRef,
160
- formRef,
161
- formData,
162
- onAdd,
163
- onCancel,
164
- onOk,
165
- change,
166
- menuClick,
167
- popContainer,
168
- modalContainer
164
+ return (_ctx, _cache) => {
165
+ const _component_a_menu_item = _resolveComponent("a-menu-item");
166
+ const _component_a_menu = _resolveComponent("a-menu");
167
+ const _component_a_tooltip = _resolveComponent("a-tooltip");
168
+ const _component_a_dropdown = _resolveComponent("a-dropdown");
169
+ const _component_a_tab_pane = _resolveComponent("a-tab-pane");
170
+ const _component_a_tabs = _resolveComponent("a-tabs");
171
+ const _component_a_input = _resolveComponent("a-input");
172
+ const _component_a_form_item = _resolveComponent("a-form-item");
173
+ const _component_a_button = _resolveComponent("a-button");
174
+ const _component_a_form = _resolveComponent("a-form");
175
+ const _component_a_modal = _resolveComponent("a-modal");
176
+ return _openBlock(), _createElementBlock("div", {
177
+ class: _normalizeClass(['jetlinks-table-group-warp', _unref(hashId)])
178
+ }, [_createVNode(_component_a_tabs, {
179
+ "active-key": myActiveKey.value,
180
+ "onUpdate:activeKey": _cache[0] || (_cache[0] = $event => myActiveKey.value = $event),
181
+ type: "editable-card",
182
+ "hide-add": __props.readonly,
183
+ onEdit: onAdd,
184
+ onChange: change
185
+ }, {
186
+ default: _withCtx(() => [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(__props.options, item => {
187
+ return _openBlock(), _createBlock(_component_a_tab_pane, {
188
+ key: item.value,
189
+ closable: false
190
+ }, {
191
+ tab: _withCtx(() => [myActiveKey.value === item.value ? (_openBlock(), _createBlock(_component_a_dropdown, {
192
+ key: 0,
193
+ trigger: ['click'],
194
+ "get-popup-container": node => _unref(tableWrapperRef) || node,
195
+ disabled: __props.readonly
196
+ }, {
197
+ overlay: _withCtx(() => [_createVNode(_component_a_menu, {
198
+ onClick: e => menuClick(e, item)
199
+ }, {
200
+ default: _withCtx(() => [_createVNode(_component_a_menu_item, {
201
+ key: "edit"
202
+ }, {
203
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(_unref(contextLocale).Group.edit), 1 /* TEXT */)]),
204
+ _: 1 /* STABLE */
205
+ }), _createVNode(_component_a_menu_item, {
206
+ key: "delete"
207
+ }, {
208
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(_unref(contextLocale).Group.delete), 1 /* TEXT */)]),
209
+ _: 1 /* STABLE */
210
+ })]),
211
+ _: 1 /* STABLE */
212
+ }, 8 /* PROPS */, ["onClick"])]),
213
+ default: _withCtx(() => [_createElementVNode("div", _hoisted_1, [_createTextVNode(_toDisplayString(item.label) + " (" + _toDisplayString(item.effective) + ") ", 1 /* TEXT */), _unref(errorMap)[item.value] ? (_openBlock(), _createBlock(_component_a_tooltip, {
214
+ key: 0,
215
+ color: "#ffffff",
216
+ "arrow-point-at-center": "",
217
+ "get-popup-container": popContainer
218
+ }, {
219
+ title: _withCtx(() => [_createElementVNode("span", _hoisted_2, _toDisplayString(_unref(contextLocale).Group.validate), 1 /* TEXT */)]),
220
+ default: _withCtx(() => [_cache[2] || (_cache[2] = _createElementVNode("div", {
221
+ class: "jetlinks-table-group-error-target"
222
+ }, null, -1 /* CACHED */))]),
223
+ _: 1 /* STABLE */
224
+ })) : _createCommentVNode("v-if", true)])]),
225
+ _: 2 /* DYNAMIC */
226
+ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["get-popup-container", "disabled"])) : (_openBlock(), _createElementBlock("div", _hoisted_3, [_createTextVNode(_toDisplayString(item.label) + " (" + _toDisplayString(item.effective) + ") ", 1 /* TEXT */), _unref(errorMap)[item.value] ? (_openBlock(), _createBlock(_component_a_tooltip, {
227
+ key: 0,
228
+ color: "#ffffff",
229
+ "arrow-point-at-center": "",
230
+ "get-container": popContainer
231
+ }, {
232
+ title: _withCtx(() => [_createElementVNode("span", _hoisted_4, _toDisplayString(_unref(contextLocale).Group.validate), 1 /* TEXT */)]),
233
+ default: _withCtx(() => [_cache[3] || (_cache[3] = _createElementVNode("div", {
234
+ class: "jetlinks-table-group-error-target"
235
+ }, null, -1 /* CACHED */))]),
236
+ _: 1 /* STABLE */
237
+ })) : _createCommentVNode("v-if", true)]))]),
238
+ _: 2 /* DYNAMIC */
239
+ }, 1024 /* DYNAMIC_SLOTS */);
240
+ }), 128 /* KEYED_FRAGMENT */))]),
241
+ _: 1 /* STABLE */
242
+ }, 8 /* PROPS */, ["active-key", "hide-add"]), _createVNode(_component_a_modal, {
243
+ open: visible.value,
244
+ title: _unref(contextLocale).Group.editGroup,
245
+ "mask-closable": false,
246
+ "get-container": modalContainer,
247
+ onCancel: onCancel,
248
+ onOk: onOk
249
+ }, {
250
+ default: _withCtx(() => [_createVNode(_component_a_form, {
251
+ ref_key: "formRef",
252
+ ref: formRef,
253
+ model: formData,
254
+ onFinish: onOk
255
+ }, {
256
+ default: _withCtx(() => [_createVNode(_component_a_form_item, {
257
+ name: "label",
258
+ rules: [{
259
+ required: true,
260
+ message: _unref(contextLocale).Group.placeholder
261
+ }, {
262
+ max: 16,
263
+ message: _unref(contextLocale).Group.max
264
+ }]
265
+ }, {
266
+ default: _withCtx(() => [_createVNode(_component_a_input, {
267
+ value: formData.label,
268
+ "onUpdate:value": _cache[1] || (_cache[1] = $event => formData.label = $event),
269
+ placeholder: _unref(contextLocale).Group.placeholder
270
+ }, null, 8 /* PROPS */, ["value", "placeholder"])]),
271
+ _: 1 /* STABLE */
272
+ }, 8 /* PROPS */, ["rules"]), _withDirectives(_createVNode(_component_a_form_item, null, {
273
+ default: _withCtx(() => [_createVNode(_component_a_button, {
274
+ "html-type": "submit"
275
+ })]),
276
+ _: 1 /* STABLE */
277
+ }, 512 /* NEED_PATCH */), [[_vShow, false]])]),
278
+ _: 1 /* STABLE */
279
+ }, 8 /* PROPS */, ["model"])]),
280
+ _: 1 /* STABLE */
281
+ }, 8 /* PROPS */, ["open", "title"])], 2 /* CLASS */);
169
282
  };
170
283
  }
171
- });
284
+ });
285
+ export default __sfc_main__;
@@ -1,36 +1,53 @@
1
- import { defineComponent, reactive, computed } from 'vue';
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, mergeProps as _mergeProps, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle } from "vue";
3
+ const _hoisted_1 = ["id"];
4
+ const _hoisted_2 = {
5
+ class: "table-header-cell-title"
6
+ };
7
+ const _hoisted_3 = {
8
+ class: "cell-title-box"
9
+ };
10
+ const _hoisted_4 = {
11
+ key: 1
12
+ };
13
+ const _hoisted_5 = {
14
+ key: 0,
15
+ class: "header-cell-required"
16
+ };
17
+ const _hoisted_6 = {
18
+ key: 0,
19
+ class: "table-header-cell-trigger"
20
+ };
21
+ import { reactive, computed } from 'vue';
2
22
  import { SearchModal, Sort } from './components/Search';
3
23
  import { useHScroll, useTableTool } from './hooks';
4
24
  import HeaderItemRender from './HeaderRender.js';
5
25
  import useEditTableStyle from './style';
6
- import AIcon from '../Icon';
7
- export default defineComponent({
8
- name: 'JEditTableHeader',
9
- components: {
10
- SearchModal,
11
- Sort,
12
- HeaderItemRender,
13
- AIcon
26
+ const __sfc_main__ = _defineComponent({
27
+ ...{
28
+ name: 'JEditTableHeader'
14
29
  },
30
+ __name: 'Header',
15
31
  props: {
16
32
  columns: {
17
33
  type: Array,
18
- default: () => []
34
+ required: false
19
35
  },
20
36
  searchColumns: {
21
37
  type: Array,
22
- default: undefined
38
+ required: false
23
39
  },
24
40
  serial: {
25
41
  type: Boolean,
26
- default: false
42
+ required: false
27
43
  },
28
44
  style: {
29
45
  type: Object,
30
- default: undefined
46
+ required: false
31
47
  }
32
48
  },
33
- setup(props) {
49
+ setup(__props) {
50
+ const props = __props;
34
51
  const prefixCls = computed(() => 'jetlinks-edit-table');
35
52
  const [wrapSSR, hashId] = useEditTableStyle(prefixCls);
36
53
  const tableTool = useTableTool();
@@ -46,12 +63,53 @@ export default defineComponent({
46
63
  const sortClick = () => {
47
64
  searchData.visible = false;
48
65
  };
49
- return {
50
- hashId,
51
- tableTool,
52
- searchData,
53
- showFilter,
54
- sortClick
66
+ return (_ctx, _cache) => {
67
+ const _component_AIcon = _resolveComponent("AIcon");
68
+ return _openBlock(), _createElementBlock("div", {
69
+ class: _normalizeClass(['jetlinks-edit-table-header-container', _unref(hashId)]),
70
+ style: _normalizeStyle(__props.style)
71
+ }, [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(__props.columns, (item, index) => {
72
+ return _openBlock(), _createElementBlock("div", {
73
+ key: item.dataIndex,
74
+ class: "jetlinks-edit-table-header-cell",
75
+ id: item.dataIndex,
76
+ style: _normalizeStyle({
77
+ width: `${item.width}px`,
78
+ left: `${item.left || 200 * index}px`
79
+ })
80
+ }, [_createElementVNode("div", {
81
+ class: _normalizeClass({
82
+ 'jetlinks-edit-table-header-cell-box': true,
83
+ 'header-cell-box-tool': !!(item.sort || item.filter)
84
+ })
85
+ }, [_createElementVNode("div", _hoisted_2, [_createElementVNode("div", _hoisted_3, [item.render ? (_openBlock(), _createBlock(HeaderItemRender, {
86
+ key: 0,
87
+ "render-fn": item.render,
88
+ value: item.title
89
+ }, null, 8 /* PROPS */, ["render-fn", "value"])) : (_openBlock(), _createElementBlock("span", _hoisted_4, _toDisplayString(item.title), 1 /* TEXT */))]), item.form?.required ? (_openBlock(), _createElementBlock("span", _hoisted_5, "*")) : _createCommentVNode("v-if", true)]), !!(item.sort || item.filter) ? (_openBlock(), _createElementBlock("div", _hoisted_6, [item.filter ? (_openBlock(), _createBlock(_component_AIcon, {
90
+ key: 0,
91
+ type: "SearchOutlined",
92
+ style: {
93
+ "color": "rgba(0, 0, 0, 0.25)"
94
+ },
95
+ onClick: () => showFilter(item.filter.key || item.dataIndex)
96
+ }, null, 8 /* PROPS */, ["onClick"])) : _createCommentVNode("v-if", true), item.sort ? (_openBlock(), _createBlock(_unref(Sort), _mergeProps({
97
+ key: 1,
98
+ ref_for: true
99
+ }, item.sort, {
100
+ key: item.dataIndex,
101
+ active: _unref(tableTool).sortData.dataIndex === item.dataIndex,
102
+ "selected-row-keys": _unref(tableTool).sortData.dataIndex === item.dataIndex ? _unref(tableTool).sortData.orderKeys : [],
103
+ "data-index": item.dataIndex,
104
+ onClick: sortClick
105
+ }), null, 16 /* FULL_PROPS */, ["active", "selected-row-keys", "data-index"])) : _createCommentVNode("v-if", true)])) : _createCommentVNode("v-if", true)], 2 /* CLASS */)], 12 /* STYLE, PROPS */, _hoisted_1);
106
+ }), 128 /* KEYED_FRAGMENT */)), searchData.visible ? (_openBlock(), _createBlock(_unref(SearchModal), {
107
+ key: 0,
108
+ "search-key": searchData.key,
109
+ columns: __props.searchColumns,
110
+ onClose: _cache[0] || (_cache[0] = $event => searchData.visible = false)
111
+ }, null, 8 /* PROPS */, ["search-key", "columns"])) : _createCommentVNode("v-if", true)], 6 /* CLASS, STYLE */);
55
112
  };
56
113
  }
57
- });
114
+ });
115
+ export default __sfc_main__;
@@ -1,45 +1,46 @@
1
- import { defineComponent, ref, computed, onMounted, nextTick } from 'vue';
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, createVNode as _createVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withCtx as _withCtx, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
3
+ import { ref, computed, onMounted, nextTick } from 'vue';
2
4
  import { Menu } from 'ant-design-vue';
3
5
  import AIcon from '../../../Icon';
4
6
  import { useLocaleReceiver } from '../../../LocaleReciver';
5
7
  import useEditTableStyle from '../../style';
6
- const MenuItem = Menu.Item;
7
- export default defineComponent({
8
- name: 'JEditTableContextMenu',
9
- components: {
10
- Menu,
11
- MenuItem,
12
- AIcon
8
+ const __sfc_main__ = _defineComponent({
9
+ ...{
10
+ name: 'JEditTableContextMenu'
13
11
  },
12
+ __name: 'Menu',
14
13
  props: {
15
14
  data: {
16
15
  type: Object,
17
- default: () => ({})
16
+ required: false
18
17
  },
19
18
  onClose: {
20
19
  type: Function,
21
- default: () => {}
20
+ required: false
22
21
  },
23
22
  onClick: {
24
23
  type: Function,
25
- default: () => {}
24
+ required: false
26
25
  },
27
26
  onCopy: {
28
27
  type: Function,
29
- default: () => {}
28
+ required: false
30
29
  },
31
30
  paste: {
32
31
  type: Object,
33
- default: () => ({})
32
+ required: false
34
33
  }
35
34
  },
36
- setup(props) {
35
+ setup(__props) {
36
+ const MenuItem = Menu.Item;
37
+ const props = __props;
37
38
  const contextMenu = ref(null);
38
39
  const prefixCls = computed(() => 'jetlinks-edit-table');
39
40
  const [wrapSSR, hashId] = useEditTableStyle(prefixCls);
40
41
  const [contextLocale] = useLocaleReceiver('EditTable');
41
42
  const showDetail = computed(() => {
42
- return !props.data.id;
43
+ return !props.data?.id;
43
44
  });
44
45
  const showPaste = computed(() => {
45
46
  return !props.paste;
@@ -51,28 +52,77 @@ export default defineComponent({
51
52
  key
52
53
  }) => {
53
54
  if (key === 'copy') {
54
- props.onCopy(props.data);
55
+ props.onCopy?.(props.data);
55
56
  }
56
- props.onClick(key);
57
+ props.onClick?.(key);
57
58
  };
58
59
  const close = () => {
59
60
  setTimeout(() => {
60
- props.onClose();
61
+ props.onClose?.();
61
62
  }, 300);
62
63
  };
63
64
  onMounted(async () => {
64
65
  await nextTick();
65
- contextMenu.value.focus();
66
+ contextMenu.value?.focus();
66
67
  });
67
- return {
68
- contextMenu,
69
- hashId,
70
- contextLocale,
71
- showDetail,
72
- showPaste,
73
- showDelete,
74
- clickFunc,
75
- close
68
+ return (_ctx, _cache) => {
69
+ return _openBlock(), _createElementBlock("div", {
70
+ class: _normalizeClass(['jetlinks-edit-table-context-menu', _unref(hashId)]),
71
+ ref_key: "contextMenu",
72
+ ref: contextMenu,
73
+ tabindex: "-1",
74
+ onBlur: close
75
+ }, [_createVNode(_unref(Menu), {
76
+ onClick: clickFunc
77
+ }, {
78
+ default: _withCtx(() => [_createVNode(_unref(MenuItem), {
79
+ key: "add"
80
+ }, {
81
+ icon: _withCtx(() => [_createVNode(_unref(AIcon), {
82
+ type: "PlusSquareOutlined"
83
+ })]),
84
+ default: _withCtx(() => [_createTextVNode(" " + _toDisplayString(_unref(contextLocale).contextMenu.add), 1 /* TEXT */)]),
85
+ _: 1 /* STABLE */
86
+ }), _createVNode(_unref(MenuItem), {
87
+ key: "copy"
88
+ }, {
89
+ icon: _withCtx(() => [_createVNode(_unref(AIcon), {
90
+ type: "icon-copy"
91
+ })]),
92
+ default: _withCtx(() => [_createTextVNode(" " + _toDisplayString(_unref(contextLocale).contextMenu.copy), 1 /* TEXT */)]),
93
+ _: 1 /* STABLE */
94
+ }), _createVNode(_unref(MenuItem), {
95
+ key: "paste",
96
+ disabled: showPaste.value
97
+ }, {
98
+ icon: _withCtx(() => [_createVNode(_unref(AIcon), {
99
+ type: "icon-paste"
100
+ })]),
101
+ default: _withCtx(() => [_createTextVNode(" " + _toDisplayString(_unref(contextLocale).contextMenu.paste), 1 /* TEXT */)]),
102
+ _: 1 /* STABLE */
103
+ }, 8 /* PROPS */, ["disabled"]), _createVNode(_unref(MenuItem), {
104
+ key: "detail",
105
+ disabled: showDetail.value
106
+ }, {
107
+ icon: _withCtx(() => [_createVNode(_unref(AIcon), {
108
+ type: "icon-chakan"
109
+ })]),
110
+ default: _withCtx(() => [_createTextVNode(" " + _toDisplayString(_unref(contextLocale).contextMenu.detail), 1 /* TEXT */)]),
111
+ _: 1 /* STABLE */
112
+ }, 8 /* PROPS */, ["disabled"]), _createVNode(_unref(MenuItem), {
113
+ key: "delete",
114
+ class: "danger",
115
+ disabled: showDelete.value
116
+ }, {
117
+ icon: _withCtx(() => [_createVNode(_unref(AIcon), {
118
+ type: "DeleteOutlined"
119
+ })]),
120
+ default: _withCtx(() => [_createTextVNode(" " + _toDisplayString(_unref(contextLocale).contextMenu.delete), 1 /* TEXT */)]),
121
+ _: 1 /* STABLE */
122
+ }, 8 /* PROPS */, ["disabled"])]),
123
+ _: 1 /* STABLE */
124
+ })], 34 /* CLASS, NEED_HYDRATION */);
76
125
  };
77
126
  }
78
- });
127
+ });
128
+ export default __sfc_main__;