ng-layout-form
Version:
layout form
54 lines (52 loc) • 2.26 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/form/viewItem.tsx
var viewItem_exports = {};
__export(viewItem_exports, {
default: () => viewItem_default
});
module.exports = __toCommonJS(viewItem_exports);
var import_util = require("../util/util");
var TextItem = (0, import_util.getComp)({ xtype: "NGText" }).instance;
function viewItem_default(props) {
var _a;
const { "data-item": item, ...others } = props;
const { src, value } = props;
let val = value;
let Comp = TextItem;
if (src && item.xtype === "NGImage" || item.xtype === "NGButton") {
Comp = (0, import_util.getComp)(item).instance;
} else if (item.xtype === "NGRangePicker") {
val = Array.isArray(value) ? value.join("-") : value;
} else if (Array.isArray(item.data || item.options)) {
const dataList = item.data || item.options;
if (Array.isArray(value)) {
const sets = new Set(value);
val = (item.data || item.options).filter((item2) => sets.has(item2.value)).map((item2) => item2.label).join(",");
} else {
val = (_a = dataList.find((item2) => item2.value === value)) == null ? void 0 : _a.label;
}
} else if (Array.isArray(value)) {
val = value.map((item2) => item2 == null ? void 0 : item2.label).join(",");
} else {
val = (val == null ? void 0 : val.label) || (val == null ? void 0 : val.toString());
}
return /* @__PURE__ */ React.createElement(Comp, { ...others, value: val });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});