ng-layout-form
Version:
layout form
78 lines (76 loc) • 2.76 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/grid/gridView.tsx
var gridView_exports = {};
__export(gridView_exports, {
GridView: () => GridView
});
module.exports = __toCommonJS(gridView_exports);
var import_ng_lib_tsx = require("ng-lib-tsx");
var import_react = require("react");
var import_util = require("../util/util");
function GridViewComp({ outRef, ...props }) {
const { formConf, columns, showRowNumber, dataSource, defaultValue, ...others } = props;
(0, import_ng_lib_tsx.useExtendRef)(outRef, () => ({
getConfig() {
if (!formConf.error) {
return formConf;
} else {
return { children: columns };
}
}
}));
const memoProps = (0, import_react.useMemo)(() => {
let indexCol = showRowNumber;
let cols = (Array.isArray(formConf) ? formConf : (formConf == null ? void 0 : formConf.children) || []).filter((item) => {
isNaN(item.width) && delete item.width;
const render = (0, import_util.parseFunction)(item["render"]);
render && (item["render"] = render);
if (item.xtype !== "rownumberer") {
return item;
} else {
indexCol = {
title: item.label
};
item.width && (indexCol["with"] = item.width);
return false;
}
});
if (columns) {
cols = import_ng_lib_tsx.NG.isFunction(columns) ? columns(cols) : [...columns, ...cols];
}
return { indexCol, cols };
}, [formConf, showRowNumber, columns]);
const NGGrid = (0, import_ng_lib_tsx.getRegisterComponent)("NGGrid");
return /* @__PURE__ */ React.createElement(
NGGrid,
{
...others,
ref: outRef,
columns: memoProps.cols,
dataSource: dataSource || defaultValue,
showRowNumber: memoProps.indexCol
}
);
}
var GridView = (0, import_ng_lib_tsx.compHoc)((0, import_util.LayConfWrap)(GridViewComp));
(0, import_ng_lib_tsx.registerComponent)({ GridView });
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
GridView
});