@talend/react-forms
Version:
React forms library based on json schema form.
41 lines • 1.34 kB
JavaScript
import PropTypes from 'prop-types';
import theme from './TextModeArrayTemplate.module.scss';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function renderListItem(val, index, renderItem) {
const valueIsObject = typeof val === 'object';
const classNames = valueIsObject ? theme.block : undefined;
return /*#__PURE__*/_jsx("li", {
className: classNames,
children: valueIsObject ? renderItem(index) : val
}, index);
}
export default function TextModeArrayTemplate(props) {
const {
id,
renderItem,
schema,
value
} = props;
return /*#__PURE__*/_jsxs("div", {
className: theme['tf-array-text-mode'],
children: [/*#__PURE__*/_jsx("dt", {
className: "tf-title-text-mode",
id: id,
children: schema.title
}), /*#__PURE__*/_jsx("dd", {
children: /*#__PURE__*/_jsx("ol", {
"aria-labelledby": id,
children: value.map((val, index) => renderListItem(val, index, renderItem))
})
})]
});
}
if (process.env.NODE_ENV !== 'production') {
TextModeArrayTemplate.propTypes = {
id: PropTypes.string,
renderItem: PropTypes.func,
schema: PropTypes.object.isRequired,
value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.object, PropTypes.string])).isRequired
};
}
//# sourceMappingURL=TextModeArrayTemplate.component.js.map