rj-grid 0.2.5 → 0.2.7

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.
package/dist/rj-grid.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { reactive, ref, watch, computed, defineComponent, h, inject, openBlock, createElementBlock, normalizeStyle, Fragment, renderList, normalizeClass, createElementVNode, withModifiers, createTextVNode, toDisplayString, unref, createCommentVNode, createBlock, onMounted, nextTick, resolveDynamicComponent, withDirectives, withKeys, vModelText, vShow, mergeProps, toHandlers, render, vModelCheckbox, vModelSelect, vModelDynamic, resolveComponent, createVNode, onBeforeUnmount, useSlots, renderSlot, provide, isRef, createSlots, withCtx } from "vue";
7
+ import { reactive, ref, watch, computed, defineComponent, h, inject, openBlock, createElementBlock, normalizeStyle, Fragment, renderList, normalizeClass, createElementVNode, withModifiers, createTextVNode, toDisplayString, unref, createCommentVNode, createBlock, onMounted, nextTick, resolveDynamicComponent, withDirectives, withKeys, vModelText, vShow, mergeProps, toHandlers, vModelCheckbox, vModelSelect, vModelDynamic, resolveComponent, createVNode, onBeforeUnmount, useSlots, renderSlot, provide, isRef, createSlots, withCtx } from "vue";
8
8
  function getValueByPath(obj, path) {
9
9
  if (!path)
10
10
  return void 0;
@@ -6109,14 +6109,16 @@ const RjSlotRender = defineComponent({
6109
6109
  };
6110
6110
  }
6111
6111
  });
6112
- defineComponent({
6112
+ const RjFnRender = defineComponent({
6113
6113
  name: "RjFnRender",
6114
6114
  props: {
6115
- render: { type: Function, required: true },
6115
+ render: { type: Function, default: void 0 },
6116
6116
  params: { type: Object, required: true }
6117
6117
  },
6118
6118
  setup(props) {
6119
6119
  return () => {
6120
+ if (!props.render)
6121
+ return null;
6120
6122
  const out = props.render(props.params);
6121
6123
  if (out == null)
6122
6124
  return null;
@@ -7035,32 +7037,16 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7035
7037
  return typeof t2 === "function" ? t2(cellParams.value) : t2;
7036
7038
  });
7037
7039
  const slotName = computed(() => "cell-" + props.leaf.colId);
7038
- function vnodeToHtml() {
7040
+ const cellSlot = computed(() => {
7039
7041
  var _a;
7040
- const slotFn = (_a = props.gridSlots) == null ? void 0 : _a[slotName.value];
7041
- let vnode = null;
7042
- if (slotFn)
7043
- vnode = slotFn(cellParams.value);
7044
- else if (props.leaf.col.cellRenderer) {
7045
- const out = props.leaf.col.cellRenderer(cellParams.value);
7046
- vnode = typeof out === "string" || typeof out === "number" ? String(out) : out;
7047
- }
7048
- if (vnode == null)
7049
- return null;
7050
- const host = document.createElement("div");
7051
- render(h("div", null, Array.isArray(vnode) ? vnode : [vnode]), host);
7052
- const html = host.innerHTML;
7053
- render(null, host);
7054
- return html;
7055
- }
7042
+ return ((_a = props.gridSlots) == null ? void 0 : _a[slotName.value]) ? slotName.value : "";
7043
+ });
7044
+ const cellRendererFn = computed(() => cellSlot.value ? void 0 : props.leaf.col.cellRenderer);
7056
7045
  function esc(s) {
7057
7046
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
7058
7047
  }
7059
7048
  const richContent = computed(() => {
7060
7049
  var _a;
7061
- const custom = vnodeToHtml();
7062
- if (custom != null)
7063
- return custom;
7064
7050
  const text = props.display ?? "";
7065
7051
  if (text === "")
7066
7052
  return "";
@@ -7085,12 +7071,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7085
7071
  return html;
7086
7072
  });
7087
7073
  const imgUrls = computed(() => {
7088
- var _a;
7089
7074
  const c = props.leaf.col;
7090
7075
  if (c.type !== "image")
7091
7076
  return [];
7092
7077
  const cfg = c.image || {};
7093
- if (((_a = props.gridSlots) == null ? void 0 : _a[slotName.value]) || c.cellRenderer)
7078
+ if (cellSlot.value || c.cellRenderer)
7094
7079
  return [];
7095
7080
  const raw = cfg.src ? cfg.src(cellParams.value) : props.value;
7096
7081
  if (raw == null || raw === "")
@@ -7121,7 +7106,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7121
7106
  emit("img-preview", url);
7122
7107
  }
7123
7108
  return (_ctx, _cache) => {
7124
- var _a, _b, _c;
7109
+ var _a, _b, _c, _d, _e;
7125
7110
  return openBlock(), createElementBlock("div", {
7126
7111
  class: normalizeClass(["rj-cell", cellClass.value]),
7127
7112
  style: normalizeStyle([baseStyle.value, dynStyle.value]),
@@ -7193,18 +7178,46 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7193
7178
  class: "rj-expand-icon",
7194
7179
  onClick: _cache[6] || (_cache[6] = withModifiers(($event) => _ctx.$emit("toggle-detail", _ctx.drow.key), ["stop"]))
7195
7180
  }, toDisplayString(_ctx.detailOpen ? unref(icons).collapse : unref(icons).expand), 1)) : (openBlock(), createElementBlock("span", _hoisted_5$c)),
7196
- imgUrls.value.length ? (openBlock(), createBlock(_sfc_main$g, mergeProps({ key: 3 }, imgBind.value, { onPreview: onImgPreview }), null, 16)) : (openBlock(), createElementBlock("span", {
7181
+ imgUrls.value.length ? (openBlock(), createBlock(_sfc_main$g, mergeProps({ key: 3 }, imgBind.value, { onPreview: onImgPreview }), null, 16)) : cellSlot.value || cellRendererFn.value ? (openBlock(), createElementBlock("span", {
7197
7182
  key: 4,
7183
+ class: normalizeClass(["rj-cell-inner rj-cell-custom", { wrap: _ctx.leaf.col.wrapText }])
7184
+ }, [
7185
+ ((_b = _ctx.gridSlots) == null ? void 0 : _b[cellSlot.value]) ? (openBlock(), createBlock(unref(RjSlotRender), {
7186
+ key: 0,
7187
+ slots: _ctx.gridSlots,
7188
+ name: cellSlot.value,
7189
+ params: cellParams.value
7190
+ }, null, 8, ["slots", "name", "params"])) : (openBlock(), createBlock(unref(RjFnRender), {
7191
+ key: 1,
7192
+ render: cellRendererFn.value,
7193
+ params: cellParams.value
7194
+ }, null, 8, ["render", "params"]))
7195
+ ], 2)) : (openBlock(), createElementBlock("span", {
7196
+ key: 5,
7198
7197
  class: normalizeClass(["rj-cell-inner", { wrap: _ctx.leaf.col.wrapText }]),
7199
7198
  innerHTML: richContent.value
7200
7199
  }, null, 10, _hoisted_6$c))
7201
- ], 64)) : imgUrls.value.length ? (openBlock(), createBlock(_sfc_main$g, mergeProps({ key: 5 }, imgBind.value, { onPreview: onImgPreview }), null, 16)) : sparkData.value ? (openBlock(), createBlock(_sfc_main$f, {
7200
+ ], 64)) : imgUrls.value.length ? (openBlock(), createBlock(_sfc_main$g, mergeProps({ key: 5 }, imgBind.value, { onPreview: onImgPreview }), null, 16)) : cellSlot.value || cellRendererFn.value ? (openBlock(), createElementBlock("span", {
7202
7201
  key: 6,
7202
+ class: normalizeClass(["rj-cell-inner rj-cell-custom", { wrap: _ctx.leaf.col.wrapText }])
7203
+ }, [
7204
+ ((_c = _ctx.gridSlots) == null ? void 0 : _c[cellSlot.value]) ? (openBlock(), createBlock(unref(RjSlotRender), {
7205
+ key: 0,
7206
+ slots: _ctx.gridSlots,
7207
+ name: cellSlot.value,
7208
+ params: cellParams.value
7209
+ }, null, 8, ["slots", "name", "params"])) : (openBlock(), createBlock(unref(RjFnRender), {
7210
+ key: 1,
7211
+ render: cellRendererFn.value,
7212
+ params: cellParams.value
7213
+ }, null, 8, ["render", "params"]))
7214
+ ], 2)) : sparkData.value ? (openBlock(), createBlock(_sfc_main$f, {
7215
+ key: 7,
7203
7216
  data: sparkData.value,
7204
- style: normalizeStyle(((_b = _ctx.leaf.col.sparkline) == null ? void 0 : _b.style) || "bar"),
7205
- color: (_c = _ctx.leaf.col.sparkline) == null ? void 0 : _c.color
7217
+ style: normalizeStyle(((_d = _ctx.leaf.col.sparkline) == null ? void 0 : _d.style) || "bar"),
7218
+ color: (_e = _ctx.leaf.col.sparkline) == null ? void 0 : _e.color
7206
7219
  }, null, 8, ["data", "style", "color"])) : (openBlock(), createElementBlock("span", {
7207
- key: 7,
7220
+ key: 8,
7208
7221
  class: normalizeClass(["rj-cell-inner", { wrap: _ctx.leaf.col.wrapText }]),
7209
7222
  innerHTML: richContent.value
7210
7223
  }, null, 10, _hoisted_7$b))
package/dist/style.css CHANGED
@@ -985,6 +985,9 @@
985
985
  white-space: normal;
986
986
  word-break: break-all;
987
987
  }
988
+ .rj-cell .rj-cell-inner.rj-cell-custom {
989
+ line-height: normal;
990
+ }
988
991
  .rj-cell.is-editing {
989
992
  padding: 0;
990
993
  overflow: visible;
@@ -38,7 +38,7 @@ export default _default;
38
38
  export declare const RjFnRender: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
39
39
  render: {
40
40
  type: PropType<(p: any) => any>;
41
- required: true;
41
+ default: undefined;
42
42
  };
43
43
  params: {
44
44
  type: PropType<any>;
@@ -47,10 +47,12 @@ export declare const RjFnRender: import("vue").DefineComponent<import("vue").Ext
47
47
  }>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
48
48
  render: {
49
49
  type: PropType<(p: any) => any>;
50
- required: true;
50
+ default: undefined;
51
51
  };
52
52
  params: {
53
53
  type: PropType<any>;
54
54
  required: true;
55
55
  };
56
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
56
+ }>> & Readonly<{}>, {
57
+ render: (p: any) => any;
58
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rj-grid",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "零第三方依赖的自研 Vue3 虚拟表格:虚拟滚动 / 冻结列 / 行拖拽 / 分组透视 / 公式 / SSRM / 主题 i18n / 自然语言查询",
5
5
  "type": "module",
6
6
  "license": "MIT",