-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.x' into 3.x
- Loading branch information
Showing
19 changed files
with
272 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Browsers that we support | ||
last 2 versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
packages/neos-ui-guest-frame/src/InlineUI/InlineValidationErrors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, {PureComponent, Fragment} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {connect} from 'react-redux'; | ||
import {$transform} from 'plow-js'; | ||
import {selectors} from '@neos-project/neos-ui-redux-store'; | ||
import {neos} from '@neos-project/neos-ui-decorators'; | ||
import {Tooltip} from '@neos-project/react-ui-components'; | ||
import throttle from 'lodash.throttle'; | ||
import style from './style.css'; | ||
|
||
import {findAllOccurrencesOfNodePropertyInGuestFrame, getAbsolutePositionOfElementInGuestFrame, getGuestFrameWindow, getGuestFrameBody} from '@neos-project/neos-ui-guest-frame/src/dom'; | ||
|
||
@neos(globalRegistry => ({ | ||
nodeTypesRegistry: globalRegistry.get('@neos-project/neos-ui-contentrepository') | ||
})) | ||
@connect($transform({ | ||
inlineValidationErrors: selectors.CR.Nodes.inlineValidationErrorsSelector | ||
})) | ||
export default class InlineValidationTooltips extends PureComponent { | ||
static propTypes = { | ||
inlineValidationErrors: PropTypes.object | ||
}; | ||
|
||
iframeWindow = getGuestFrameWindow(); | ||
|
||
tooltipRefs = new WeakMap(); | ||
|
||
invalidInlinePropertiesDomNodes = []; | ||
|
||
updateTooltipsPosition = () => { | ||
this.invalidInlinePropertiesDomNodes.forEach(domNode => { | ||
const position = getAbsolutePositionOfElementInGuestFrame(domNode); | ||
const tooltipNode = this.tooltipRefs.get(domNode) && this.tooltipRefs.get(domNode).current; | ||
if (tooltipNode && tooltipNode.children.length === 2) { | ||
const [border, tooltip] = tooltipNode.children; | ||
|
||
border.style.top = position.top + 'px'; | ||
border.style.left = position.left + 'px'; | ||
border.style.width = position.width + 'px'; | ||
border.style.height = position.height + 'px'; | ||
|
||
tooltip.style.top = position.top + position.height + 'px'; | ||
tooltip.style.left = position.left + 'px'; | ||
} | ||
}); | ||
} | ||
|
||
updateTooltipsPositionDebounced = throttle(this.updateTooltipsPosition, 5); | ||
|
||
mutationObserver = new MutationObserver(this.updateTooltipsPositionDebounced); | ||
|
||
componentDidMount() { | ||
this.iframeWindow.addEventListener('resize', this.updateTooltipsPositionDebounced); | ||
|
||
this.mutationObserver.observe(getGuestFrameBody(), { | ||
childList: true, | ||
subtree: true, | ||
attributes: true, | ||
characterData: true | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.iframeWindow.removeEventListener('resize', this.updateTooltipsPositionDebounced); | ||
this.mutationObserver.disconnect(); | ||
} | ||
|
||
render() { | ||
const {inlineValidationErrors} = this.props; | ||
|
||
return <Fragment>{Object.keys(inlineValidationErrors).map(contextAndPropertyName => { | ||
const validationErrorsForProperty = inlineValidationErrors[contextAndPropertyName]; | ||
const [contextPath, propertyName] = contextAndPropertyName.split(' '); | ||
const domNodes = findAllOccurrencesOfNodePropertyInGuestFrame(contextPath, propertyName); | ||
return domNodes.map((domNode, index) => { | ||
this.invalidInlinePropertiesDomNodes.push(domNode); | ||
const position = getAbsolutePositionOfElementInGuestFrame(domNode); | ||
const ref = React.createRef(); | ||
this.tooltipRefs.set(domNode, ref); | ||
return <div key={index} ref={ref}> | ||
<div className={style.border} style={{ | ||
top: position.top, | ||
left: position.left, | ||
width: position.width, | ||
height: position.height | ||
}}/> | ||
<div className={style.tooltip} style={{ | ||
top: position.top + position.height, | ||
left: position.left | ||
}}> | ||
<Tooltip renderInline asError><ul>{validationErrorsForProperty.map((error, index) => <li key={index}>{error}</li>)}</ul></Tooltip> | ||
</div> | ||
</div>; | ||
}); | ||
})}</Fragment>; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/neos-ui-guest-frame/src/InlineUI/InlineValidationErrors/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.border { | ||
border: 2px solid var(--colors-Error); | ||
position: absolute; | ||
pointer-events: none; | ||
} | ||
|
||
.tooltip { | ||
position: absolute; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.