@entryscape/rdforms 10.12.3 → 10.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rdforms.bmd.js +2 -2
- package/dist/rdforms.bootstrap.js +10 -10
- package/dist/rdforms.jquery.js +2 -2
- package/dist/rdforms.node.js +1 -1
- package/dist/rdforms.react.js +3 -3
- package/package.json +3 -3
- package/src/view/View.js +1 -0
- package/src/view/bootstrap/labels.js +7 -2
- package/src/view/jquery/labels.js +1 -1
- package/src/view/react/labels.js +74 -28
- package/src/view/renderingContext.js +2 -0
- package/src/view/resources/rdforms.css +9 -0
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"application profile",
|
|
9
9
|
"linked data"
|
|
10
10
|
],
|
|
11
|
-
"version": "10.
|
|
11
|
+
"version": "10.13.0",
|
|
12
12
|
"main": "dist/rdforms.node.js",
|
|
13
13
|
"browser": "dist/rdforms.react.js",
|
|
14
14
|
"module": "main.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"license": "LGPL-3.0-only",
|
|
17
17
|
"homepage": "https://rdforms.org",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@entryscape/rdfjson": "2.7.
|
|
19
|
+
"@entryscape/rdfjson": "2.7.7"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@entryscape/rdfjson": "2.7.
|
|
22
|
+
"@entryscape/rdfjson": "2.7.7",
|
|
23
23
|
"@emotion/react": "^11.4.1",
|
|
24
24
|
"@emotion/styled": "^11.3.0",
|
|
25
25
|
"@fortawesome/fontawesome-free": "^5.8.1",
|
package/src/view/View.js
CHANGED
|
@@ -23,6 +23,7 @@ export default class View {
|
|
|
23
23
|
this.topLevel = params.topLevel !== false;
|
|
24
24
|
this.compact = params.compact !== false;
|
|
25
25
|
this.showDescription = params.showDescription === true;
|
|
26
|
+
this.popupOnLabel = params.popupOnLabel !== false;
|
|
26
27
|
this.styleCls = params.styleCls || '';
|
|
27
28
|
this.truncateLimit = params.truncateLimit !== undefined ? params.truncateLimit : 10;
|
|
28
29
|
this.truncate = params.truncate !== undefined ? params.truncate : false;
|
|
@@ -67,7 +67,7 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
|
67
67
|
let desc = utils.getLocalizedValue(descMap, context.view.getLocale()).value
|
|
68
68
|
|
|
69
69
|
if (!compactField && desc) {
|
|
70
|
-
jquery('<div class="rdformsDescription"
|
|
70
|
+
jquery('<div class="rdformsDescription">').text(desc).appendTo(rowNode);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
renderingContext.attachItemInfo(item, $label[0], context);
|
|
@@ -76,6 +76,11 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
renderingContext.attachItemInfo = function (item, aroundNode, context) {
|
|
79
|
+
if (context.view.popupOnLabel === false) {
|
|
80
|
+
renderingContext.domClassToggle(aroundNode, 'rdformsNoPopup', true);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
renderingContext.domSetAttr(aroundNode, 'role', 'button');
|
|
79
84
|
if (item == null || (item.getProperty() == null && item.getDescriptionMap() == null
|
|
80
85
|
&& item.getEditDescriptionMap() == null)) {
|
|
81
86
|
jquery(aroundNode).addClass('noPointer');
|
|
@@ -102,7 +107,7 @@ renderingContext.attachItemInfo = function (item, aroundNode, context) {
|
|
|
102
107
|
}
|
|
103
108
|
const popoverOptions = {
|
|
104
109
|
html: true,
|
|
105
|
-
container: renderingContext.getPopoverContainer(),
|
|
110
|
+
container: aroundNode, // renderingContext.getPopoverContainer(),
|
|
106
111
|
placement: 'auto',
|
|
107
112
|
trigger: 'focus',
|
|
108
113
|
title: label,
|
|
@@ -36,7 +36,7 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context, labelR
|
|
|
36
36
|
const desc = utils.getLocalizedValue(item.getDescriptionMap(), context.view.getLocale()).value
|
|
37
37
|
|
|
38
38
|
if (!compactField && desc) {
|
|
39
|
-
jquery('<div class="rdformsDescription"
|
|
39
|
+
jquery('<div class="rdformsDescription">').text(desc).appendTo(rowNode);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
package/src/view/react/labels.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { Fragment, useState, useEffect, forwardRef } from 'react';
|
|
3
3
|
import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import ClickAwayListener from '@mui/
|
|
5
|
+
import { ClickAwayListener } from '@mui/base/ClickAwayListener';
|
|
6
6
|
import renderingContext from '../renderingContext';
|
|
7
7
|
import utils from '../../utils';
|
|
8
8
|
import { Editor } from './Wrappers';
|
|
@@ -26,6 +26,39 @@ const StyledTooltip = styled(
|
|
|
26
26
|
},
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
|
+
const ItemTooltipTitle = ({description, propinfo, setOpen, tooltipId}) => {
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
console.log("Inited useEffect");
|
|
32
|
+
const focusListener = (event) => {
|
|
33
|
+
console.log("Focuslistener called");
|
|
34
|
+
let el = event.target;
|
|
35
|
+
let external = true;
|
|
36
|
+
while (el) {
|
|
37
|
+
if (el.id === tooltipId) {
|
|
38
|
+
external = false;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
el = el.parentElement;
|
|
42
|
+
}
|
|
43
|
+
if (external) {
|
|
44
|
+
setOpen(false);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
window.addEventListener('focusin', focusListener);
|
|
48
|
+
return () => {
|
|
49
|
+
console.log("Focuslistener removed");
|
|
50
|
+
window.removeEventListener('focusin', focusListener);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
return (<>
|
|
55
|
+
<p className="rdformsLinebreaks rdformsDescription">
|
|
56
|
+
{description}
|
|
57
|
+
</p>
|
|
58
|
+
{propinfo}
|
|
59
|
+
</>);
|
|
60
|
+
};
|
|
61
|
+
|
|
29
62
|
const ItemTooltip = (props) => {
|
|
30
63
|
const [open, setOpen] = useState(false);
|
|
31
64
|
const handleTooltipClose = () => {
|
|
@@ -42,28 +75,31 @@ const ItemTooltip = (props) => {
|
|
|
42
75
|
const descriptionMap = props.context.view instanceof Editor ?
|
|
43
76
|
props.item.getEditDescriptionMap() || props.item.getDescriptionMap() : props.item.getDescriptionMap()
|
|
44
77
|
|| (property ? '' : props.context.view.messages.info_missing || '');
|
|
45
|
-
const description = utils.getLocalizedValue(descriptionMap, props.context.view.getLocale()).value
|
|
78
|
+
const description = utils.getLocalizedValue(descriptionMap, props.context.view.getLocale()).value;
|
|
79
|
+
const tooltipId = `tt_${props.binding.getHash()}`;
|
|
46
80
|
|
|
47
81
|
return (
|
|
48
82
|
<ClickAwayListener onClickAway={handleTooltipClose}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
<div id={tooltipId}>
|
|
84
|
+
<StyledTooltip
|
|
85
|
+
title={<ItemTooltipTitle description={description} propinfo={propinfo} setOpen={setOpen} tooltipId={tooltipId}></ItemTooltipTitle>}
|
|
86
|
+
placement="bottom-start"
|
|
87
|
+
disableHoverListener
|
|
88
|
+
disableTouchListener
|
|
89
|
+
disableFocusListener
|
|
90
|
+
onFocus={handleTooltipOpen}
|
|
91
|
+
onOpen={handleTooltipOpen}
|
|
92
|
+
onClose={handleTooltipClose}
|
|
93
|
+
open={open}
|
|
94
|
+
slotProps={{
|
|
95
|
+
popper: {
|
|
96
|
+
disablePortal: true
|
|
97
|
+
},
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<span onClick={handleTooltipOpen}>{props.children}</span>
|
|
101
|
+
</StyledTooltip>
|
|
102
|
+
</div>
|
|
67
103
|
</ClickAwayListener>
|
|
68
104
|
);
|
|
69
105
|
};
|
|
@@ -92,16 +128,22 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context) => {
|
|
|
92
128
|
item.getDescriptionMap();
|
|
93
129
|
const desc = utils.getLocalizedValue(descMap, context.view.getLocale()).value;
|
|
94
130
|
if (!compactField && desc) {
|
|
95
|
-
description = <div className="rdformsDescription"
|
|
131
|
+
description = <div className="rdformsDescription">{desc}</div>;
|
|
96
132
|
}
|
|
97
133
|
}
|
|
98
134
|
|
|
99
135
|
const labelId = binding ? context.view.createLabelIndex(binding) : undefined;
|
|
136
|
+
const rdformsLabel = context.view.popupOnLabel ? 'rdformsLabel' : 'rdformsLabel rdformsNoPopup';
|
|
137
|
+
const role = context.view.popupOnLabel ? 'button' : null;
|
|
100
138
|
label = item.hasStyle('heading') ?
|
|
101
|
-
<h2 tabIndex="0" id={labelId} className="rdformsLabelRow"><span className=
|
|
102
|
-
<span tabIndex="0" id={labelId} className="rdformsLabelRow"><span className=
|
|
103
|
-
|
|
104
|
-
|
|
139
|
+
<h2 tabIndex="0" id={labelId} className="rdformsLabelRow"><span className={rdformsLabel} role={role}>{label}</span></h2> :
|
|
140
|
+
<span tabIndex="0" id={labelId} className="rdformsLabelRow"><span className={rdformsLabel} role={role}>{label}</span></span>;
|
|
141
|
+
if (context.view.popupOnLabel) {
|
|
142
|
+
rowNode.appendChild(<Fragment key={`${binding ? binding.getHash() : item._internalId}_label` }><ItemTooltip
|
|
143
|
+
context={context} item={item} binding={binding}>{label}</ItemTooltip>{description}</Fragment>);
|
|
144
|
+
} else {
|
|
145
|
+
rowNode.appendChild(<Fragment key={`${binding ? binding.getHash() : item._internalId}_label` }>{label}{description}</Fragment>);
|
|
146
|
+
}
|
|
105
147
|
};
|
|
106
148
|
|
|
107
149
|
renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
@@ -115,9 +157,13 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
|
|
|
115
157
|
} else {
|
|
116
158
|
label = '';
|
|
117
159
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
label = <
|
|
160
|
+
const rdformsLabel = context.view.popupOnLabel ? 'rdformsLabel' : 'rdformsLabel rdformsNoPopup';
|
|
161
|
+
const role = context.view.popupOnLabel ? 'button' : null;
|
|
162
|
+
label = item.hasStyle('heading') ? <h2 tabIndex="0" className={rdformsLabel} role={role}>{label}</h2> :
|
|
163
|
+
<span tabIndex="0" className={rdformsLabel} role={role}>{label}</span>;
|
|
164
|
+
if (context.view.popupOnLabel) {
|
|
165
|
+
label = <ItemTooltip item={item} context={context} binding={binding}>{label}</ItemTooltip>;
|
|
166
|
+
}
|
|
121
167
|
|
|
122
168
|
const card = item.getCardinality();
|
|
123
169
|
const b = context.view.messages;
|
|
@@ -336,6 +336,7 @@ const groupPresenter = (fieldDiv, binding, context) => {
|
|
|
336
336
|
showDescription: context.view.showDescription,
|
|
337
337
|
defaultLanguage: context.view.defaultLanguage,
|
|
338
338
|
filterTranslations: context.view.filterTranslations,
|
|
339
|
+
popupOnLabel: context.view.popupOnLabel,
|
|
339
340
|
truncate: context.view.truncate,
|
|
340
341
|
truncateLimit: context.view.truncateLimit,
|
|
341
342
|
includeLevel: context.view.includeLevel, // Copied from groupEditor, was this.includeLevel but that 'this' does not make sense here
|
|
@@ -354,6 +355,7 @@ const groupEditor = (fieldDiv, binding, context) => {
|
|
|
354
355
|
binding,
|
|
355
356
|
topLevel: false,
|
|
356
357
|
compact: context.view.compact,
|
|
358
|
+
popupOnLabel: context.view.popupOnLabel,
|
|
357
359
|
showDescription: context.view.showDescription,
|
|
358
360
|
truncate: context.view.truncate,
|
|
359
361
|
truncateLimit: context.view.truncateLimit,
|
|
@@ -204,6 +204,15 @@ a.rdformsUrl:hover {
|
|
|
204
204
|
cursor: pointer;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
.rdformsLabel.rdformsNoPopup:hover {
|
|
208
|
+
text-decoration: initial;
|
|
209
|
+
cursor: initial;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.rdformsLabel .popover:hover {
|
|
213
|
+
cursor: initial;
|
|
214
|
+
}
|
|
215
|
+
|
|
207
216
|
.rdformsLabel.noPointer:hover {
|
|
208
217
|
text-decoration: none;
|
|
209
218
|
cursor: default;
|