@entryscape/rdforms 10.16.0 → 10.17.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.
@@ -5,19 +5,8 @@
5
5
  * @license MIT
6
6
  */
7
7
 
8
- /*!
9
- * The buffer module from node.js, for the browser.
10
- *
11
- * @author Feross Aboukhadijeh <https://feross.org>
12
- * @license MIT
13
- */
14
-
15
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
16
-
17
8
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
18
9
 
19
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
20
-
21
10
  /**
22
11
  * @license React
23
12
  * react-dom.production.min.js
@@ -68,30 +57,6 @@
68
57
  * LICENSE file in the root directory of this source tree.
69
58
  */
70
59
 
71
- /**
72
- * Character class utilities for XML NS 1.0 edition 3.
73
- *
74
- * @author Louis-Dominique Dubeau
75
- * @license MIT
76
- * @copyright Louis-Dominique Dubeau
77
- */
78
-
79
- /**
80
- * Character classes and associated utilities for the 2nd edition of XML 1.1.
81
- *
82
- * @author Louis-Dominique Dubeau
83
- * @license MIT
84
- * @copyright Louis-Dominique Dubeau
85
- */
86
-
87
- /**
88
- * Character classes and associated utilities for the 5th edition of XML 1.0.
89
- *
90
- * @author Louis-Dominique Dubeau
91
- * @license MIT
92
- * @copyright Louis-Dominique Dubeau
93
- */
94
-
95
60
  /** @license React v16.13.1
96
61
  * react-is.production.min.js
97
62
  *
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "application profile",
9
9
  "linked data"
10
10
  ],
11
- "version": "10.16.0",
11
+ "version": "10.17.0",
12
12
  "main": "dist/rdforms.node.js",
13
13
  "browser": "dist/rdforms.react.js",
14
14
  "module": "main.js",
@@ -23,20 +23,20 @@
23
23
  "@emotion/styled": "^11.14.1",
24
24
  "@entryscape/rdfjson": "2.7.7",
25
25
  "@fortawesome/fontawesome-free": "^5.15.4",
26
- "@mui/icons-material": "^7.3.4",
27
- "@mui/material": "^7.3.4",
26
+ "@mui/icons-material": "^7.3.11",
27
+ "@mui/material": "^7.3.11",
28
28
  "@mui/x-date-pickers": "^5.0.20",
29
- "arrive": "^2.5.2",
29
+ "arrive": "^2.5.3",
30
30
  "bootstrap": "^4.6.2",
31
31
  "bootstrap-datepicker": "^1.10.1",
32
32
  "bootstrap-material-datetimepicker": "bitbucket:metasolutions/bootstrap-material-datetimepicker#webpack",
33
33
  "bootstrap-material-design": "^4.1.3",
34
34
  "circular-dependency-plugin": "^5.2.2",
35
- "core-js": "^3.46.0",
35
+ "core-js": "^3.49.0",
36
36
  "ifdef-loader": "^2.3.2",
37
37
  "jquery": "^3.7.1",
38
38
  "jquery-mousewheel": "^3.2.2",
39
- "lodash-es": "^4.17.21",
39
+ "lodash-es": "^4.18.1",
40
40
  "moment": "^2.30.1",
41
41
  "nls-loader": "bitbucket:metasolutions/nls-loader#master",
42
42
  "node-fetch": "^2.7.0",
@@ -47,19 +47,19 @@
47
47
  "regenerator-runtime": "^0.13.11",
48
48
  "select2": "4.0.8",
49
49
  "sizzle": "^2.3.10",
50
- "terser-webpack-plugin": "^5.3.14",
50
+ "terser-webpack-plugin": "^5.6.0",
51
51
  "whatwg-fetch": "^3.6.20"
52
52
  },
53
53
  "devDependencies": {
54
- "@babel/cli": "^7.28.3",
55
- "@babel/core": "^7.28.4",
54
+ "@babel/cli": "^7.28.6",
55
+ "@babel/core": "^7.29.0",
56
56
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
57
57
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
58
- "@babel/plugin-transform-class-properties": "^7.27.1",
59
- "@babel/plugin-transform-modules-commonjs": "^7.27.1",
60
- "@babel/plugin-transform-react-jsx": "^7.27.1",
61
- "@babel/preset-env": "^7.28.3",
62
- "@babel/preset-react": "^7.27.1",
58
+ "@babel/plugin-transform-class-properties": "^7.28.6",
59
+ "@babel/plugin-transform-modules-commonjs": "^7.28.6",
60
+ "@babel/plugin-transform-react-jsx": "^7.28.6",
61
+ "@babel/preset-env": "^7.29.5",
62
+ "@babel/preset-react": "^7.28.5",
63
63
  "babel-loader": "^8.4.1",
64
64
  "babel-plugin-transform-react-jsx": "^6.24.1",
65
65
  "copy-webpack-plugin": "^9.1.0",
@@ -69,7 +69,7 @@
69
69
  "eslint-plugin-import": "^2.32.0",
70
70
  "eslint-plugin-requirejs": "^3.2.0",
71
71
  "html-loader": "^3.1.2",
72
- "html-webpack-plugin": "^5.6.4",
72
+ "html-webpack-plugin": "^5.6.7",
73
73
  "html-webpack-tags-plugin": "^3.0.2",
74
74
  "imports-loader": "^0.8.0",
75
75
  "mini-css-extract-plugin": "^0.4.5",
@@ -79,9 +79,9 @@
79
79
  "style-loader": "^3.3.4",
80
80
  "svg-inline-loader": "^0.8.2",
81
81
  "ttf-loader": "^1.0.2",
82
- "webpack": "^5.102.1",
82
+ "webpack": "^5.107.1",
83
83
  "webpack-cli": "^5.1.4",
84
- "webpack-dev-server": "^5.2.2",
84
+ "webpack-dev-server": "^5.2.4",
85
85
  "webpack-merge": "^5.10.0",
86
86
  "webpack-node-externals": "^3.0.0"
87
87
  },
@@ -24,6 +24,8 @@ export default class Item {
24
24
  this._styles = [
25
25
  'heading',
26
26
  'invisible',
27
+ 'invisibleInPresent',
28
+ 'invisibleInEdit',
27
29
  'invisibleGroup',
28
30
  'stars',
29
31
  'commentOn',
@@ -7,7 +7,7 @@ import { bindingReport } from '../model/validate';
7
7
  const showNow = (editor, item, bindings, includeLevel) => {
8
8
  // Invisible should be created as components and hidden using display: none
9
9
  // Otherwise certain extentions such as autoUUID does not work.
10
- /* if (item.hasStyle('invisible')) {
10
+ /* if (item.hasStyle('invisible') || item.hasStyle('invisibleInEdit')) {
11
11
  return false;
12
12
  } */
13
13
  if (item.hasStyle('presenterOnly')) {
@@ -6,7 +6,8 @@ import View from './View';
6
6
  const showNow = (editor, item, bindings) => {
7
7
  if (bindings.length === 0 ||
8
8
  // item.hasStyle('deprecated') ||
9
- item.hasStyle('invisible')) {
9
+ item.hasStyle('invisible') ||
10
+ item.hasStyle('invisibleInPresent')) {
10
11
  return false;
11
12
  }
12
13
  const prop = item.getProperty();
@@ -25,7 +25,7 @@ export default class ValidationPresenter extends Presenter {
25
25
  }
26
26
 
27
27
  showNow(item, bindings) {
28
- if (item.hasStyle('invisible')) {
28
+ if (item.hasStyle('invisible') || item.hasStyle('invisibleInPresent')) {
29
29
  return false;
30
30
  }
31
31
  if (bindings.length > 0) {
package/src/view/View.js CHANGED
@@ -330,7 +330,10 @@ export default class View {
330
330
 
331
331
  this._binding2node[binding.getHash()] = fieldDiv;
332
332
  this.addComponent(fieldDiv, binding);
333
- if (item.hasStyle('invisible')) {
333
+ const isEditor = this._subEditors !== undefined;
334
+ if (item.hasStyle('invisible') ||
335
+ (item.hasStyle('invisibleInEdit') && isEditor)
336
+ ) {
334
337
  renderingContext.domClassToggle(newRow || lastRow, 'rdformsInvisible', true);
335
338
  }
336
339
  return newRow || lastRow;
@@ -116,4 +116,10 @@ renderingContext.attachItemInfo = function (item, aroundNode, context) {
116
116
  }</div>${propinfo}`,
117
117
  };
118
118
  jquery(aroundNode).popover(popoverOptions).attr('data-toggle', 'popover');
119
+ jquery(aroundNode).on('keydown', (e) => {
120
+ if (e.key === 'Escape' && aroundNode.getAttribute('aria-describedby')) {
121
+ jquery(aroundNode).popover('hide');
122
+ e.stopPropagation();
123
+ }
124
+ });
119
125
  };
@@ -1,8 +1,10 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import React, { Fragment, useState, useEffect, forwardRef } from 'react';
3
3
  import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
4
- import { styled } from '@mui/material/styles';
5
4
  import ClickAwayListener from '@mui/material/ClickAwayListener';
5
+ import IconButton from '@mui/material/IconButton';
6
+ import { styled } from '@mui/material/styles';
7
+ import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
6
8
  import renderingContext from '../renderingContext';
7
9
  import utils from '../../utils';
8
10
  import { Editor } from './Wrappers';
@@ -26,77 +28,67 @@ const StyledTooltip = styled(
26
28
  },
27
29
  }));
28
30
 
29
- const ItemTooltipTitle = ({description, propinfo, setOpen, tooltipId}) => {
30
- useEffect(() => {
31
- const focusListener = (event) => {
32
- let el = event.target;
33
- let external = true;
34
- while (el) {
35
- if (el.id === tooltipId) {
36
- external = false;
37
- break;
38
- }
39
- el = el.parentElement;
40
- }
41
- if (external) {
42
- setOpen(false);
43
- }
44
- };
45
- window.addEventListener('focusin', focusListener);
46
- return () => {
47
- window.removeEventListener('focusin', focusListener);
48
- };
49
- }, []);
50
-
51
- return (<>
52
- <p className="rdformsLinebreaks rdformsDescription">
53
- {description}
54
- </p>
55
- {propinfo}
56
- </>);
31
+ const getDescription = (item, view) => {
32
+ const descMap = view instanceof Editor
33
+ ? item.getEditDescriptionMap() || item.getDescriptionMap()
34
+ : item.getDescriptionMap();
35
+ return utils.getLocalizedValue(descMap, view.getLocale()).value;
57
36
  };
58
37
 
59
- const ItemTooltip = (props) => {
60
- const [open, setOpen] = useState(false);
61
- const handleTooltipClose = () => {
62
- setOpen(false);
63
- };
64
- const handleTooltipOpen = () => {
65
- setOpen(true);
38
+ const DescriptionIcon = ({ item, context }) => {
39
+ const { view } = context;
40
+ const description = getDescription(item, view);
41
+ const [pinned, setPinned] = useState(false);
42
+ const [hovered, setHovered] = useState(false);
43
+
44
+ const property = item.getProperty();
45
+ const fallbackDescription = !description && !property
46
+ ? view.messages.info_missing || ''
47
+ : '';
48
+ const shownDescription = description || fallbackDescription;
49
+ if (!shownDescription && !property) return null;
50
+
51
+ const propinfo = property
52
+ ? <div className="rdformsProperty"><a target="_blank" href={property}>{property}</a></div>
53
+ : null;
54
+
55
+ const tooltipContent = (
56
+ <>
57
+ {shownDescription ? <p className="rdformsLinebreaks rdformsDescription">{shownDescription}</p> : null}
58
+ {propinfo}
59
+ </>
60
+ );
61
+
62
+
63
+ const handleClick = () => setPinned(!pinned);
64
+ const handleKeyDown = (e) => {
65
+ if (e.key !== 'Escape' || !pinned) return;
66
+ setPinned(false);
67
+ e.stopPropagation();
66
68
  };
67
- let propinfo = '';
68
- const property = props.item.getProperty();
69
- if (property) {
70
- propinfo = <div className="rdformsProperty"><a target="_blank" href={property}>{property}</a></div>;
71
- }
72
- const descriptionMap = props.context.view instanceof Editor ?
73
- props.item.getEditDescriptionMap() || props.item.getDescriptionMap() : props.item.getDescriptionMap()
74
- || (property ? '' : props.context.view.messages.info_missing || '');
75
- const description = utils.getLocalizedValue(descriptionMap, props.context.view.getLocale()).value;
76
- const tooltipId = `tt_${props.binding ? props.binding.getHash() : props.item.getHash()}`;
77
69
 
78
70
  return (
79
- <ClickAwayListener onClickAway={handleTooltipClose}>
80
- <div id={tooltipId}>
71
+ <ClickAwayListener onClickAway={() => setPinned(false)}>
72
+ <span>
81
73
  <StyledTooltip
82
- title={<ItemTooltipTitle description={description} propinfo={propinfo} setOpen={setOpen} tooltipId={tooltipId}></ItemTooltipTitle>}
83
- placement="bottom-start"
84
- disableHoverListener
85
- disableTouchListener
86
- disableFocusListener
87
- onFocus={handleTooltipOpen}
88
- onOpen={handleTooltipOpen}
89
- onClose={handleTooltipClose}
90
- open={open}
91
- slotProps={{
92
- popper: {
93
- disablePortal: true
94
- },
95
- }}
74
+ title={tooltipContent}
75
+ placement="top-start"
76
+ open={pinned || hovered}
77
+ onOpen={() => setHovered(true)}
78
+ onClose={() => setHovered(false)}
96
79
  >
97
- <span onClick={handleTooltipOpen}>{props.children}</span>
80
+ <IconButton
81
+ className="rdformsDescriptionIcon"
82
+ size="small"
83
+ aria-label={view.messages.info_description}
84
+ onClick={handleClick}
85
+ onKeyDown={handleKeyDown}
86
+ sx={{ marginLeft: '0px !important' }}
87
+ >
88
+ <HelpOutlineIcon fontSize="inherit" />
89
+ </IconButton>
98
90
  </StyledTooltip>
99
- </div>
91
+ </span>
100
92
  </ClickAwayListener>
101
93
  );
102
94
  };
@@ -130,18 +122,12 @@ renderingContext.renderPresenterLabel = (rowNode, binding, item, context) => {
130
122
  }
131
123
 
132
124
  const labelId = binding ? context.view.createLabelIndex(binding) : undefined;
133
- const rdformsLabel = context.view.popupOnLabel ? 'rdformsLabel' : 'rdformsLabel rdformsNoPopup';
134
- const role = context.view.popupOnLabel ? 'button' : null;
135
125
  const HeadingElement = `h${context.view.headingLevel}`;
126
+ const descriptionIcon = context.view.popupOnLabel ? <DescriptionIcon item={item} context={context} /> : null;
136
127
  label = item.hasStyle('heading') ?
137
- <HeadingElement tabIndex="0" id={labelId} className="rdformsLabelRow"><span className={rdformsLabel} role={role}>{label}</span></HeadingElement> :
138
- <span tabIndex="0" id={labelId} className="rdformsLabelRow"><span className={rdformsLabel} role={role}>{label}</span></span>;
139
- if (context.view.popupOnLabel) {
140
- rowNode.appendChild(<Fragment key={`${binding ? binding.getHash() : item.getHash()}_label` }><ItemTooltip
141
- context={context} item={item} binding={binding}>{label}</ItemTooltip>{description}</Fragment>);
142
- } else {
143
- rowNode.appendChild(<Fragment key={`${binding ? binding.getHash() : item.getHash()}_label` }>{label}{description}</Fragment>);
144
- }
128
+ <HeadingElement tabIndex="0" id={labelId} className="rdformsLabelRow"><span className="rdformsLabel">{label}</span>{descriptionIcon}</HeadingElement> :
129
+ <span tabIndex="0" id={labelId} className="rdformsLabelRow"><span className="rdformsLabel">{label}</span>{descriptionIcon}</span>;
130
+ rowNode.appendChild(<Fragment key={`${binding ? binding.getHash() : item.getHash()}_label` }>{label}{description}</Fragment>);
145
131
  };
146
132
 
147
133
  renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
@@ -155,14 +141,9 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
155
141
  } else {
156
142
  label = '';
157
143
  }
158
- const rdformsLabel = context.view.popupOnLabel ? 'rdformsLabel' : 'rdformsLabel rdformsNoPopup';
159
- const role = context.view.popupOnLabel ? 'button' : null;
160
144
  const HeadingElement = `h${context.view.headingLevel}`;
161
- label = item.hasStyle('heading') ? <HeadingElement tabIndex="0" className={rdformsLabel} role={role}>{label}</HeadingElement> :
162
- <span tabIndex="0" className={rdformsLabel} role={role}>{label}</span>;
163
- if (context.view.popupOnLabel) {
164
- label = <ItemTooltip item={item} context={context} binding={binding}>{label}</ItemTooltip>;
165
- }
145
+ label = item.hasStyle('heading') ? <HeadingElement tabIndex="0" className="rdformsLabel">{label}</HeadingElement> :
146
+ <span tabIndex="0" className="rdformsLabel">{label}</span>;
166
147
 
167
148
  const card = item.getCardinality();
168
149
  const b = context.view.messages;
@@ -207,8 +188,9 @@ renderingContext.renderEditorLabel = (rowNode, binding, item, context) => {
207
188
  }
208
189
 
209
190
  const labelId = context.view.createLabelIndex(binding);
191
+ const descriptionIcon = context.view.popupOnLabel ? <DescriptionIcon item={item} context={context} /> : null;
210
192
  rowNode.appendChild(<Fragment key={`${binding.getHash()}_label`}><div id={labelId} className="rdformsLabelRow">{
211
- label}{mark}{Button && <Button></Button>}</div>{description}</Fragment>);
193
+ label}{mark}{descriptionIcon}{Button && <Button></Button>}</div>{description}</Fragment>);
212
194
  }
213
195
  };
214
196
 
@@ -14,6 +14,16 @@
14
14
  display: flex;
15
15
  }
16
16
 
17
+ .rdformsLabel:hover {
18
+ text-decoration: none;
19
+ cursor: default;
20
+ }
21
+
22
+ .rdformsDescriptionIcon {
23
+ color: grey !important;
24
+ font-size: 16px !important;
25
+ }
26
+
17
27
  .rdformsLabelRow .MuiButtonBase-root {
18
28
  margin-top: -4px;
19
29
  margin-left: 7px;
@@ -244,4 +254,4 @@ div.MuiTooltip-tooltip {
244
254
 
245
255
  .rdformsPresenter .rdformsInline {
246
256
  padding-left: 0em;
247
- }
257
+ }
@@ -74,7 +74,6 @@
74
74
  display: none;
75
75
  }
76
76
 
77
-
78
77
  /* === End colors === */
79
78
 
80
79
  .rdformsInvisible {
@@ -793,4 +792,4 @@ a.rdformsUrl:hover {
793
792
 
794
793
  .rdformsPresenter .rdformsInline {
795
794
  padding-left: 1em;
796
- }
795
+ }