Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderExperimentalMessage(browserName) {
const underConstructionMessage =
"Debugging is experimental and certain features won't work (i.e, seeing variables, attaching breakpoints)"; // eslint-disable-line max-len
return dom.div(
{ className: "under-construction" },
dom.div(
{ className: "under-construction-message" },
dom.p({}, underConstructionMessage),
dom.img({ src: "/pad-assets/under_construction.png" }),
dom.a(
{
className: "github-link",
target: "_blank",
href: docsUrls.github
},
"Help us make it happen"
)
)
);
}
renderAsInline() {
const {iri, href, rel} = this.getData();
return D.a(
{
className: classnames({
'semantic-inline--rdfa-set': rel !== null,
'semantic-inline--rdfa-unset': rel === null,
}),
href: href,
title: 'Ctrl-click to go to page for ' + iri,
onMouseDownCapture: (e: MouseEvent) => {
if (this.isInsidePropertiesButton(e)) {
e.stopPropagation();
}
},
onClickCapture: (e: MouseEvent) => {
if (this.isInsidePropertiesButton(e)) {
e.stopPropagation();
this.showModal();
className: block('default-input').toString(),
type: 'text',
placeholder,
onChange: e => onChange((e.target as HTMLInputElement).value, index),
value,
}),
btn({
className: block('delete-default').toString(),
onClick: () => onDelete(index),
}, D.span({className: 'fa fa-times'}))
),
error ? (
bsrow({className: block('error').toString()}, bscol({md: 12}, error.message))
) : null,
]),
showAddButton ? D.a({onClick: onAdd}, addButtonLabel) : null,
],
});
}
const dataState = this.props.dataState;
this.lastRenderedDataState = this.dataState();
const size = this.props.values.size;
const canEdit = dataState === DataState.Ready || dataState === DataState.Verifying;
const canAddValue = canEdit && size < definition.maxOccurs;
const canRemoveValue = canEdit && size > definition.minOccurs && size > 0;
const fieldLabel = (getPreferredLabel(definition.label) || 'value').toLowerCase();
return D.div(
{className: COMPONENT_NAME},
this.renderChildren(canRemoveValue),
canAddValue ? (
D.a({
className: classnames({
[`${COMPONENT_NAME}__add-value`]: true,
[`${COMPONENT_NAME}__add-value--first`]: size === 0,
[`${COMPONENT_NAME}__add-value--another`]: size > 0,
}),
onClick: this.addNewValue,
}, `+ Add ${fieldLabel}`)
) : null
);
}
const Link = (props) => {
const {url} = Entity.get(props.entityKey).getData();
if (props.blockProps.parentEditor.props.readOnly === true) {
return D.a({
href: url,
target: '_blank',
}, props.children);
} else {
return D.a({
href: url,
title: 'Ctrl-click to go to ' + url,
onClick: (e: MouseEvent) => {
if (e.ctrlKey) {
window.open(url, '_blank');
}
},
}, props.children);
}
};
});
const addLabel = () => {
const label = [...this.state.label];
const validatedLabel = Validation.validateLabel('');
label.push({value: validatedLabel, lang: lang || ''});
this.updateState({label});
};
return D.div({},
row({
label: 'Label*',
expanded: this.state.label.length > 0,
expandOnMount: true,
onExpand: () => addLabel(),
element: [
this.state.label.map((label, index) => this.renderLabel(label, index, langOptions)),
Boolean(lang) ? D.a({onClick: () => addLabel()}, '+ Add label') : null,
],
}),
row({
label: 'Identifier*',
expanded: this.state.id.isJust,
expandOnMount: true,
onExpand: () => this.updateValues({id: empty}, Validation.validateIri),
error: this.state.id.map(v => v.error).getOrElse(undefined),
element: D.div({className: 'input-group'}, [
input({
className: block('iri-input').toString(),
type: 'text',
placeholder: 'Any IRI to be used as unique identifier for the field definition.',
onChange: e => this.updateValues({id: getFormValue(e)}, Validation.validateIri),
value: this.state.id.isJust ? this.state.id.get().value : undefined,
disabled: this.isEditMode(),