Skip to content

Commit cb50922

Browse files
authored
Merge pull request #186 from opentiny/patch-grid-event
fix: fix grid events dynamic change don not work
2 parents dfa0051 + a722003 commit cb50922

6 files changed

Lines changed: 428 additions & 485 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"@ai-sdk/deepseek@1.0.7": "patches/@ai-sdk__deepseek@1.0.7.patch",
3030
"@ai-sdk/openai-compatible@1.0.7": "patches/@ai-sdk__openai-compatible@1.0.7.patch",
3131
"@opentiny/vue-renderless@3.28.2": "patches/@opentiny__vue-renderless@3.28.2.patch",
32-
"@opentiny/vue-form-item@3.28.0": "patches/@opentiny__vue-form-item@3.28.0.patch"
32+
"@opentiny/vue-form-item@3.28.0": "patches/@opentiny__vue-form-item@3.28.0.patch",
33+
"@opentiny/vue-grid@3.28.0": "patches/@opentiny__vue-grid@3.28.0.patch"
3334
}
3435
},
3536
"keywords": [],

packages/frameworks/vue/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
"@opentiny/tiny-robot": "0.3.3",
7171
"@opentiny/tiny-robot-kit": "0.3.3",
7272
"@opentiny/tiny-robot-svgs": "0.3.3",
73-
"@opentiny/vue": "^3.28.0",
74-
"@opentiny/vue-renderless": "^3.28.2",
75-
"@opentiny/vue-icon": "^3.28.0",
76-
"@opentiny/vue-theme": "^3.28.0",
73+
"@opentiny/vue": "~3.28.0",
74+
"@opentiny/vue-renderless": "~3.28.2",
75+
"@opentiny/vue-icon": "~3.28.0",
76+
"@opentiny/vue-theme": "~3.28.0",
7777
"uuid": "^11.1.0",
7878
"vue": "^3.5.13",
7979
"@opentiny/tiny-engine-builtin-component": "^2.6.0"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/lib/index.js b/lib/index.js
2+
index fc662a8ce85dbd67b4832961431e8082306ca991..680baed0d9d31ff31eb9401519975a9d8cb68dca 100644
3+
--- a/lib/index.js
4+
+++ b/lib/index.js
5+
@@ -5,7 +5,7 @@ import { debounce, PopupManager, PopperJS, extend, browserInfo, isObject, isEmpt
6+
import { iconError, iconSortTriangleDescending, iconSortTriangleAscending, iconSortTriangle, iconUnfilter, iconEdit, iconConmentRefresh, iconMinscreen, iconFullscreen, iconSetting, iconChevronRight, iconChevronDown, iconGridNoData, iconRadio, iconRadioselected, iconSearch, iconCheckedSur, iconCheck, iconHalfselect, iconArrowBottom, IconEllipsis, iconClose, iconYes, iconExpand, iconPutAway, iconEllipsis, iconMarkOn } from '@opentiny/vue-icon';
7+
import { $prefix, hooks, defineComponent, h, $install, isVue2, isVnode, $props, mergeClass, resolveTheme, useInstanceSlots, useRelation, emitter, resolveMode, useBreakpoint, setup as setup$1 } from '@opentiny/vue-common';
8+
import { uniqueId, toNumber as toNumber$1, isBoolean, each, isObject as isObject$1, isFunction, isArray, findIndexOf, get, set, clone, clear, destructuring, mapTree, eachTree, has, isUndefined, isEqual, find as find$1, filterTree, arrayEach, isNumber, findTree as findTree$1, sum, template, assign, objectMap, sortBy, isString, remove, toStringJSON, toArray, arrayIndexOf } from '@opentiny/vue-renderless/grid/static/';
9+
-import { getFuncText, getDomNode, getRowid, getEventTargetNode, isScale, emitEvent, hasChildrenList, getListeners, getOffsetPos, getFilters, getColumnConfig, formatText, getRowkey, getRowUniqueId, setCellValue, getColumnList, repairFixed, rowToVisible, colToVisible, getCell, assemColumn, GlobalEvent, getCellValue, updateCellTitle, isPx, getClass, getRowNodes, getCellNodeIndex } from '@opentiny/vue-renderless/grid/utils';
10+
+import { getFuncText, getDomNode, getRowid, getEventTargetNode, isScale, emitEvent, hasChildrenList, getListeners, resolveTableListeners, getOffsetPos, getFilters, getColumnConfig, formatText, getRowkey, getRowUniqueId, setCellValue, getColumnList, repairFixed, rowToVisible, colToVisible, getCell, assemColumn, GlobalEvent, getCellValue, updateCellTitle, isPx, getClass, getRowNodes, getCellNodeIndex } from '@opentiny/vue-renderless/grid/utils';
11+
import Tooltip$1 from '@opentiny/vue-tooltip';
12+
import { createVNode, mergeProps, isVNode, createTextVNode, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, createCommentVNode, normalizeStyle, Fragment, renderList } from 'vue';
13+
import { toNumber, findTree, find, isEqual as isEqual$1, arrayEach as arrayEach$1 } from '@opentiny/vue-renderless/grid/static';
14+
@@ -11485,6 +11485,7 @@ var Table = defineComponent({
15+
},
16+
render: function render14() {
17+
var _class4;
18+
+ this.tableListeners = resolveTableListeners(this);
19+
var $grid = this.$grid, bodyProps = this.bodyProps, border = this.border, borderSaas = this.borderSaas, borderVertical = this.borderVertical;
20+
var ctxMenuStore = this.ctxMenuStore, dropConfig = this.dropConfig, editConfig = this.editConfig, editRules = this.editRules, filterStore = this.filterStore;
21+
var hasFilter2 = this.hasFilter, hasTip2 = this.hasTip, height2 = this.height, highlightCell = this.highlightCell, highlightHoverColumn = this.highlightHoverColumn, highlightHoverRow = this.highlightHoverRow;
22+
@@ -12058,8 +12059,8 @@ var Grid = defineComponent({
23+
},
24+
render: function render16() {
25+
var _this50 = this;
26+
- var fetchOption = this.fetchOption, listeners = this.listeners, loading = this.loading, optimizOpt2 = this.optimizOpt, editConfigOpt2 = this.editConfigOpt, tooltipOpt2 = this.tooltipOpt, pager = this.pager, pagerConfig = this.pagerConfig, remoteFilter = this.remoteFilter, remoteSort = this.remoteSort, selectToolbar = this.selectToolbar;
27+
- var seqIndex2 = this.seqIndex, $slots = this.slots, tableCustoms2 = this.tableCustoms, tableData = this.tableData, tableListeners = this.tableListeners, tableLoading = this.tableLoading, tableProps2 = this.tableProps, toolbar = this.toolbar, vSize3 = this.vSize, designConfig = this.designConfig, viewType2 = this.viewType;
28+
+ var fetchOption = this.fetchOption, eventsListeners = this.listeners, loading = this.loading, optimizOpt2 = this.optimizOpt, editConfigOpt2 = this.editConfigOpt, tooltipOpt2 = this.tooltipOpt, pager = this.pager, pagerConfig = this.pagerConfig, remoteFilter = this.remoteFilter, remoteSort = this.remoteSort, selectToolbar = this.selectToolbar;
29+
+ var seqIndex2 = this.seqIndex, $slots = this.slots, tableCustoms2 = this.tableCustoms, tableData = this.tableData, tableLoading = this.tableLoading, tableProps2 = this.tableProps, toolbar = this.toolbar, vSize3 = this.vSize, designConfig = this.designConfig, viewType2 = this.viewType;
30+
var columnAnchor = this.columnAnchor, columnAnchorParams = this.columnAnchorParams, fullScreenClass = this.fullScreenClass;
31+
if (designConfig != null && designConfig.icons) {
32+
Object.assign(GlobalConfig$1.icon, designConfig.icons);
33+
@@ -12073,7 +12074,8 @@ var Grid = defineComponent({
34+
if ((designConfig == null ? void 0 : designConfig.stripe) !== void 0 && !props.stripe) {
35+
props.stripe = designConfig == null ? void 0 : designConfig.stripe;
36+
}
37+
- var tableOns = Object.assign(listeners, tableListeners);
38+
+ var currentTableListeners = getListeners(this.$attrs, isVue2 ? this.$listeners : void 0);
39+
+ var tableOns = Object.assign({}, eventsListeners, currentTableListeners);
40+
var rowClassName = this.handleRowClassName, sortChangeEvent2 = this.sortChangeEvent, filterChangeEvent2 = this.filterChangeEvent;
41+
if (fetchOption) {
42+
Object.assign(props, {

patches/@opentiny__vue-renderless@3.28.2.patch

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,64 @@ index 40ba07091a6f1c2364ae724bc8859de7c0ad2b82..1010ef11e243c70715596dfdb6e4519f
197197
onMounted(api2.mounted);
198198
vm.$on("displayed-value-changed", (param) => {
199199
api2.getDisplayedValue(param);
200+
diff --git a/grid/utils/common.js b/grid/utils/common.js
201+
index a557e68633f95db4b162add9e31273ce81743282..012c24e94d49387bfd5b1d0506f5cffb60a21158 100644
202+
--- a/grid/utils/common.js
203+
+++ b/grid/utils/common.js
204+
@@ -2,6 +2,7 @@ import {
205+
__spreadValues
206+
} from "../../chunk-G2ADBYYC.js";
207+
import { isNull, find, isFunction } from "@opentiny/utils";
208+
+import { isVue2 } from "@opentiny/vue-common";
209+
import { get, set } from "../static";
210+
const gridSize = ["medium", "small", "mini"];
211+
const getSize = ({ size, $parent }) => size || ($parent && gridSize.includes($parent.size) ? $parent.size : null);
212+
@@ -116,7 +117,7 @@ const setCellValue = (row, column, value) => {
213+
};
214+
const hasChildrenList = (item) => item && item.children && item.children.length > 0;
215+
const emitEvent = (vm, type, args) => {
216+
- if (vm.tableListeners[type]) {
217+
+ if (resolveTableListeners(vm)[type]) {
218+
const params = [].concat(args);
219+
vm.$emit(type, ...params);
220+
}
221+
@@ -144,16 +145,22 @@ const getListeners = ($attrs, $listeners) => {
222+
const regHyphenate = /\B([A-Z])/g;
223+
const regEventPrefix = /^on[A-Z]/;
224+
const listeners = {};
225+
- if ($listeners) {
226+
- return $listeners;
227+
+ if ($attrs) {
228+
+ Object.keys($attrs).forEach((name) => {
229+
+ const event = $attrs[name];
230+
+ if (regEventPrefix.test(name) && typeof event === "function") {
231+
+ listeners[name.slice(2).replace(regHyphenate, "-$1").toLowerCase()] = event;
232+
+ }
233+
+ });
234+
}
235+
- Object.keys($attrs).forEach((name) => {
236+
- const event = $attrs[name];
237+
- if (regEventPrefix.test(name) && typeof event === "function") {
238+
- listeners[name.slice(2).replace(regHyphenate, "-$1").toLowerCase()] = event;
239+
- }
240+
- });
241+
- return listeners;
242+
+ if (Object.keys(listeners).length) {
243+
+ return listeners;
244+
+ }
245+
+ return $listeners || listeners;
246+
+};
247+
+const resolveTableListeners = (vm) => {
248+
+ const gridListeners = vm.$grid ? getListeners(vm.$grid.$attrs, isVue2 ? vm.$grid.$listeners : undefined) : {};
249+
+ return Object.assign({}, gridListeners, getListeners(vm.$attrs, isVue2 ? vm.$listeners : undefined));
250+
};
251+
function dfsCopy(tree, callback, parent = void 0, isTree = false, childrenKey = "children") {
252+
let copy;
253+
@@ -190,6 +197,7 @@ export {
254+
getFilters,
255+
getFuncText,
256+
getListeners,
257+
+ resolveTableListeners,
258+
getRowUniqueId,
259+
getRowid,
260+
getRowkey,

0 commit comments

Comments
 (0)