@pareto-engineering/design-system 4.0.0-alpha.79 → 4.0.0-alpha.82
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/cjs/a/Label/styles.scss +1 -1
- package/dist/cjs/a/People/styles.scss +1 -1
- package/dist/cjs/a/Tooltip/Tooltip.js +21 -5
- package/dist/cjs/a/Tooltip/styles.scss +44 -39
- package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
- package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
- package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +1 -1
- package/dist/cjs/f/fields/TextInput/TextInput.js +1 -2
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +1 -2
- package/dist/cjs/g/DragAndDrop/DragAndDrop.js +99 -0
- package/dist/cjs/g/DragAndDrop/common/DraggableItem/DraggableItem.js +80 -0
- package/dist/cjs/g/DragAndDrop/common/DraggableItem/index.js +13 -0
- package/dist/cjs/g/DragAndDrop/common/DraggableItem/styles.scss +12 -0
- package/dist/cjs/g/DragAndDrop/common/index.js +12 -0
- package/dist/cjs/g/{ExpandableLexicalPreview/common/ExpandButton → DragAndDrop}/index.js +3 -3
- package/dist/cjs/g/DragAndDrop/styles.scss +6 -0
- package/dist/cjs/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +44 -17
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +79 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +13 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/dist/cjs/g/ExpandableLexicalPreview/common/index.js +3 -3
- package/dist/cjs/g/index.js +8 -1
- package/dist/es/a/Label/styles.scss +1 -1
- package/dist/es/a/People/styles.scss +1 -1
- package/dist/es/a/Tooltip/Tooltip.js +21 -5
- package/dist/es/a/Tooltip/styles.scss +44 -39
- package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
- package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
- package/dist/es/f/fields/SelectInput/common/Single/Single.js +1 -1
- package/dist/es/f/fields/TextInput/TextInput.js +1 -2
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +1 -2
- package/dist/es/g/DragAndDrop/DragAndDrop.js +90 -0
- package/dist/es/g/DragAndDrop/common/DraggableItem/DraggableItem.js +72 -0
- package/dist/es/g/DragAndDrop/common/DraggableItem/index.js +2 -0
- package/dist/es/g/DragAndDrop/common/DraggableItem/styles.scss +12 -0
- package/dist/es/g/DragAndDrop/common/index.js +1 -0
- package/dist/es/g/DragAndDrop/index.js +2 -0
- package/dist/es/g/DragAndDrop/styles.scss +6 -0
- package/dist/es/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +45 -18
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +70 -0
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
- package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/dist/es/g/ExpandableLexicalPreview/common/index.js +1 -1
- package/dist/es/g/index.js +2 -1
- package/package.json +4 -4
- package/src/stories/a/Tooltip.stories.jsx +7 -12
- package/src/stories/g/DragAndDrop.stories.jsx +114 -0
- package/src/stories/g/ExpandableLexicalPreview.stories.jsx +12 -5
- package/src/ui/a/Label/styles.scss +1 -1
- package/src/ui/a/People/styles.scss +1 -1
- package/src/ui/a/Tooltip/Tooltip.jsx +27 -4
- package/src/ui/a/Tooltip/styles.scss +44 -39
- package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +8 -3
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +0 -14
- package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +16 -14
- package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +9 -7
- package/src/ui/f/fields/TextInput/TextInput.jsx +9 -8
- package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +9 -9
- package/src/ui/g/DragAndDrop/DragAndDrop.jsx +121 -0
- package/src/ui/g/DragAndDrop/common/DraggableItem/DraggableItem.jsx +98 -0
- package/src/ui/g/DragAndDrop/common/DraggableItem/index.js +2 -0
- package/src/ui/g/DragAndDrop/common/DraggableItem/styles.scss +12 -0
- package/src/ui/g/DragAndDrop/common/index.js +1 -0
- package/src/ui/g/DragAndDrop/index.js +2 -0
- package/src/ui/g/DragAndDrop/styles.scss +6 -0
- package/src/ui/g/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +61 -25
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.jsx +80 -0
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
- package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
- package/src/ui/g/ExpandableLexicalPreview/common/index.js +1 -1
- package/src/ui/g/index.js +1 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +753 -49
- package/dist/cjs/g/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -111
- package/dist/es/g/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -99
- package/dist/es/g/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
- package/src/ui/g/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +0 -119
- package/src/ui/g/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactDom = require("react-dom");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
11
|
+
var _a = require("../../../../a");
|
|
12
|
+
require("./styles.scss");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
15
|
+
|
|
16
|
+
// Local Definitions
|
|
17
|
+
|
|
18
|
+
const baseClassName = _exports.default.base;
|
|
19
|
+
const copyStyles = (sourceDocument, targetDocument) => {
|
|
20
|
+
Array.from(sourceDocument.querySelectorAll('link[rel="stylesheet"], style')).forEach(link => {
|
|
21
|
+
targetDocument.head.appendChild(link.cloneNode(true));
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* This is the component description.
|
|
26
|
+
*/
|
|
27
|
+
const NewWindowPortal = _ref => {
|
|
28
|
+
let {
|
|
29
|
+
children,
|
|
30
|
+
pageTitle,
|
|
31
|
+
onBlock,
|
|
32
|
+
onOpen
|
|
33
|
+
} = _ref;
|
|
34
|
+
const [newWindow, setNewWindow] = (0, _react.useState)(null);
|
|
35
|
+
const container = (0, _react.useMemo)(() => document.createElement('div'), []);
|
|
36
|
+
const {
|
|
37
|
+
userTheme = 'light'
|
|
38
|
+
} = (0, _a.useTheme)();
|
|
39
|
+
(0, _react.useEffect)(() => {
|
|
40
|
+
if (!container) return;
|
|
41
|
+
container.classList.add(baseClassName, 'new-window-portal', `ui-${userTheme}`);
|
|
42
|
+
const newExternalWindow = window.open('', pageTitle, 'width="100%",height="100%"');
|
|
43
|
+
if (newExternalWindow) {
|
|
44
|
+
newExternalWindow.document.title = pageTitle;
|
|
45
|
+
newExternalWindow.document.body.appendChild(container);
|
|
46
|
+
setNewWindow(newExternalWindow);
|
|
47
|
+
onOpen();
|
|
48
|
+
} else {
|
|
49
|
+
console.warn('A new window / tab could not be opened. Check your settings and/or extensions, maybe it was blocked.');
|
|
50
|
+
onBlock();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line consistent-return
|
|
54
|
+
return () => {
|
|
55
|
+
container.classList.remove(...container.classList);
|
|
56
|
+
newExternalWindow?.close();
|
|
57
|
+
};
|
|
58
|
+
}, [container, pageTitle, userTheme]);
|
|
59
|
+
(0, _react.useEffect)(() => {
|
|
60
|
+
if (newWindow) {
|
|
61
|
+
copyStyles(document, newWindow.document);
|
|
62
|
+
}
|
|
63
|
+
}, [newWindow]);
|
|
64
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(children, container);
|
|
65
|
+
};
|
|
66
|
+
NewWindowPortal.propTypes = {
|
|
67
|
+
/**
|
|
68
|
+
* The children JSX
|
|
69
|
+
*/
|
|
70
|
+
children: _propTypes.default.node,
|
|
71
|
+
/**
|
|
72
|
+
* The new window page title
|
|
73
|
+
*/
|
|
74
|
+
pageTitle: _propTypes.default.string.isRequired
|
|
75
|
+
};
|
|
76
|
+
NewWindowPortal.defaultProps = {
|
|
77
|
+
// someProp:false
|
|
78
|
+
};
|
|
79
|
+
var _default = exports.default = NewWindowPortal;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NewWindowPortal", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _NewWindowPortal.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _NewWindowPortal = _interopRequireDefault(require("./NewWindowPortal"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "NewWindowPortal", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _NewWindowPortal.NewWindowPortal;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _NewWindowPortal = require("./NewWindowPortal");
|
package/dist/cjs/g/index.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "DragAndDrop", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _DragAndDrop.DragAndDrop;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "ExpandableLexicalPreview", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
9
15
|
return _ExpandableLexicalPreview.ExpandableLexicalPreview;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
12
|
-
var _ExpandableLexicalPreview = require("./ExpandableLexicalPreview");
|
|
18
|
+
var _ExpandableLexicalPreview = require("./ExpandableLexicalPreview");
|
|
19
|
+
var _DragAndDrop = require("./DragAndDrop");
|
|
@@ -20,9 +20,9 @@ $default-font-size: calc(1em * var(--s-1));
|
|
|
20
20
|
color: var(--on-x, var(--on-#{$default-color}));
|
|
21
21
|
display: inline-flex;
|
|
22
22
|
font-size: $default-font-size;
|
|
23
|
+
gap: calc(var(--gap) / 2);
|
|
23
24
|
padding: $default-padding;
|
|
24
25
|
white-space: nowrap;
|
|
25
|
-
|
|
26
26
|
&.#{bem.$modifier-compact} {
|
|
27
27
|
padding: $compact-padding;
|
|
28
28
|
}
|
|
@@ -11,7 +11,7 @@ $default-padding:var(--u);
|
|
|
11
11
|
$default-horizontal-margin: .5em;
|
|
12
12
|
|
|
13
13
|
$default-grid-gap: 1em;
|
|
14
|
-
$default-margin:
|
|
14
|
+
$default-margin: 1em;
|
|
15
15
|
$default-image-margin: var(--default-image-margin, #{$default-margin});
|
|
16
16
|
$default-color: var(--default-color, var(--paragraph));
|
|
17
17
|
|
|
@@ -18,14 +18,22 @@ const Tooltip = ({
|
|
|
18
18
|
style,
|
|
19
19
|
position,
|
|
20
20
|
color,
|
|
21
|
+
description,
|
|
22
|
+
content,
|
|
21
23
|
children
|
|
22
24
|
// ...otherProps
|
|
23
25
|
}) => /*#__PURE__*/React.createElement("div", {
|
|
24
26
|
id: id,
|
|
25
|
-
className: [baseClassName, componentClassName, userClassName,
|
|
26
|
-
style: style
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
className: [baseClassName, componentClassName, userClassName, `x-${color}`].filter(e => e).join(' '),
|
|
28
|
+
style: style
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: "tooltip-trigger-wrapper",
|
|
31
|
+
"aria-describedby": description
|
|
32
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: `tooltip-content ${position}`,
|
|
34
|
+
role: "tooltip",
|
|
35
|
+
id: description
|
|
36
|
+
}, content));
|
|
29
37
|
Tooltip.propTypes = {
|
|
30
38
|
/**
|
|
31
39
|
* The HTML id for this element
|
|
@@ -40,9 +48,17 @@ Tooltip.propTypes = {
|
|
|
40
48
|
*/
|
|
41
49
|
style: PropTypes.objectOf(PropTypes.string),
|
|
42
50
|
/**
|
|
43
|
-
* The children JSX
|
|
51
|
+
* The children JSX where the tooltip will be applied
|
|
44
52
|
*/
|
|
45
53
|
children: PropTypes.node.isRequired,
|
|
54
|
+
/**
|
|
55
|
+
* The content JSX that renders the tooltip content
|
|
56
|
+
*/
|
|
57
|
+
content: PropTypes.node.isRequired,
|
|
58
|
+
/**
|
|
59
|
+
* The text description to identify the element that describes the tooltip
|
|
60
|
+
*/
|
|
61
|
+
description: PropTypes.string.isRequired,
|
|
46
62
|
/**
|
|
47
63
|
* The position of the tooltip with respect to the trigger element
|
|
48
64
|
*/
|
|
@@ -7,50 +7,55 @@ $default-inline-padding: var(--theme-default-padding);
|
|
|
7
7
|
$default-width: var(--tooltip-width, 20rem);
|
|
8
8
|
|
|
9
9
|
.#{bem.$base}.tooltip {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
display: inline-block;
|
|
11
|
+
position: relative;
|
|
12
|
+
|
|
13
|
+
> .tooltip-content {
|
|
14
|
+
background: var(--x);
|
|
15
|
+
border: var(--theme-default-border-style) var(--ui-lines);
|
|
16
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
17
|
+
opacity: 0;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
padding: $default-block-padding $default-inline-padding;
|
|
20
|
+
position: absolute;
|
|
21
|
+
transform: translateX(var(--horizontal, 0)) translateY(var(--vertical, 0));
|
|
22
|
+
transition: opacity .2s ease, transform .2s ease;
|
|
23
|
+
visibility: hidden;
|
|
24
|
+
width: $default-width;
|
|
25
|
+
z-index: 10;
|
|
26
|
+
|
|
27
|
+
&.top {
|
|
28
|
+
--horizontal: -50%;
|
|
29
|
+
bottom: calc(100% + $default-block-padding);
|
|
30
|
+
left: 50%;
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
&.right {
|
|
34
|
+
--vertical: 50%;
|
|
35
|
+
bottom: 50%;
|
|
36
|
+
left: calc(100% + $default-inline-padding);
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
&.bottom {
|
|
40
|
+
--horizontal: -50%;
|
|
41
|
+
left: 50%;
|
|
42
|
+
top: calc(100% + $default-block-padding);
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
&.left {
|
|
46
|
+
--vertical: 50%;
|
|
47
|
+
bottom: 50%;
|
|
48
|
+
right: calc(100% + $default-inline-padding);
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
> .tooltip-trigger-wrapper {
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
|
|
55
|
+
&:is(:hover, :focus-visible, :active) + .tooltip-content {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
transition-delay: 200ms;
|
|
58
|
+
visibility: visible;
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -20,11 +20,11 @@ const ColorPicker = ({
|
|
|
20
20
|
className: userClassName,
|
|
21
21
|
style,
|
|
22
22
|
icon,
|
|
23
|
-
|
|
23
|
+
defaultColorHex,
|
|
24
24
|
onChange
|
|
25
25
|
// ...otherProps
|
|
26
26
|
}) => {
|
|
27
|
-
const [colorValue, setColor] = useColor(
|
|
27
|
+
const [colorValue, setColor] = useColor(defaultColorHex);
|
|
28
28
|
const parentRef = useRef(null);
|
|
29
29
|
const [isOpen, setIsOpen] = useState(false);
|
|
30
30
|
useOutsideClick(parentRef, () => setIsOpen(false));
|
|
@@ -75,9 +75,13 @@ ColorPicker.propTypes = {
|
|
|
75
75
|
/**
|
|
76
76
|
* The React-written, css properties for this element.
|
|
77
77
|
*/
|
|
78
|
-
style: PropTypes.objectOf(PropTypes.string)
|
|
78
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
79
|
+
/**
|
|
80
|
+
* The required default hex value for the color picker
|
|
81
|
+
*/
|
|
82
|
+
defaultColorHex: PropTypes.string
|
|
79
83
|
};
|
|
80
84
|
ColorPicker.defaultProps = {
|
|
81
|
-
|
|
85
|
+
defaultColorHex: '#ffffff'
|
|
82
86
|
};
|
|
83
87
|
export default ColorPicker;
|
|
@@ -61,8 +61,6 @@ const ToolbarPlugin = ({
|
|
|
61
61
|
const [activeEditor, setActiveEditor] = useState(editor);
|
|
62
62
|
const [blockType, setBlockType] = useState('paragraph');
|
|
63
63
|
const [rootType, setRootType] = useState('root');
|
|
64
|
-
const [fontColor, setFontColor] = useState('#000000');
|
|
65
|
-
const [bgColor, setBgColor] = useState('#ffffff');
|
|
66
64
|
const [fontSize, setFontSize] = useState('15px');
|
|
67
65
|
const [isEditable, setIsEditable] = useState(() => editor.isEditable());
|
|
68
66
|
const [isBold, setIsBold] = useState(false);
|
|
@@ -128,8 +126,6 @@ const ToolbarPlugin = ({
|
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
setFontSize($getSelectionStyleValueForProperty(selection, 'font-size', '15px'));
|
|
131
|
-
setFontColor($getSelectionStyleValueForProperty(selection, 'color', '#000'));
|
|
132
|
-
setBgColor($getSelectionStyleValueForProperty(selection, 'background-color', '#fff'));
|
|
133
129
|
}
|
|
134
130
|
}, [activeEditor]);
|
|
135
131
|
useEffect(() => editor.registerCommand(SELECTION_CHANGE_COMMAND, (_payload, newEditor) => {
|
|
@@ -229,11 +225,9 @@ const ToolbarPlugin = ({
|
|
|
229
225
|
className: "group"
|
|
230
226
|
}, /*#__PURE__*/React.createElement(ColorPicker, {
|
|
231
227
|
icon: "'",
|
|
232
|
-
color: fontColor,
|
|
233
228
|
onChange: onFontColorSelect
|
|
234
229
|
}), /*#__PURE__*/React.createElement(ColorPicker, {
|
|
235
230
|
icon: "#",
|
|
236
|
-
color: bgColor,
|
|
237
231
|
onChange: onBgColorSelect
|
|
238
232
|
})), /*#__PURE__*/React.createElement("div", {
|
|
239
233
|
className: "group"
|
|
@@ -151,7 +151,7 @@ const Multiple = ({
|
|
|
151
151
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
152
152
|
style: style,
|
|
153
153
|
ref: parentRef
|
|
154
|
-
}, getComboboxProps()), /*#__PURE__*/React.createElement(FormLabel, _extends({
|
|
154
|
+
}, getComboboxProps()), label && /*#__PURE__*/React.createElement(FormLabel, _extends({
|
|
155
155
|
className: [baseClassName, componentClassName].filter(e => e).join(' ')
|
|
156
156
|
}, getLabelProps(), {
|
|
157
157
|
name: name,
|
|
@@ -51,7 +51,7 @@ const Single = ({
|
|
|
51
51
|
id: id,
|
|
52
52
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
53
53
|
style: style
|
|
54
|
-
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
54
|
+
}, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
55
55
|
name: name,
|
|
56
56
|
color: labelColor,
|
|
57
57
|
optional: optional
|
|
@@ -52,11 +52,10 @@ const TextInput = ({
|
|
|
52
52
|
...symbolStyle,
|
|
53
53
|
...style
|
|
54
54
|
}
|
|
55
|
-
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
55
|
+
}, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
56
56
|
name: name,
|
|
57
57
|
color: labelColor,
|
|
58
58
|
optional: optional
|
|
59
|
-
// {...otherProps}
|
|
60
59
|
}, label), /*#__PURE__*/React.createElement(InputWrapper, inputWrapperProps, /*#__PURE__*/React.createElement("input", _extends({
|
|
61
60
|
id: name,
|
|
62
61
|
className: "input",
|
|
@@ -42,11 +42,10 @@ const TextareaInput = ({
|
|
|
42
42
|
id: id,
|
|
43
43
|
className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
|
|
44
44
|
style: style
|
|
45
|
-
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
45
|
+
}, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
46
46
|
name: name,
|
|
47
47
|
color: labelColor,
|
|
48
48
|
optional: optional
|
|
49
|
-
// {...otherProps}
|
|
50
49
|
}, label), /*#__PURE__*/React.createElement("textarea", _extends({
|
|
51
50
|
id: name,
|
|
52
51
|
className: "textarea"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
+
import { DraggableItem } from "./common";
|
|
8
|
+
|
|
9
|
+
// Local Definitions
|
|
10
|
+
|
|
11
|
+
import "./styles.scss";
|
|
12
|
+
const baseClassName = styleNames.base;
|
|
13
|
+
const componentClassName = 'drag-and-drop';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is the component description.
|
|
17
|
+
*/
|
|
18
|
+
const DragAndDrop = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
as: Wrapper,
|
|
23
|
+
onOrderChange,
|
|
24
|
+
items
|
|
25
|
+
// ...otherProps
|
|
26
|
+
}) => {
|
|
27
|
+
const [draggableItems, setDraggableItems] = useState(items);
|
|
28
|
+
const handleDrop = (e, dragOverItemIndex) => {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
const dragItemIndex = e.dataTransfer.getData('text');
|
|
31
|
+
const orderedItems = [...draggableItems];
|
|
32
|
+
const [reorderedItem] = orderedItems.splice(dragItemIndex, 1);
|
|
33
|
+
orderedItems.splice(dragOverItemIndex, 0, reorderedItem);
|
|
34
|
+
setDraggableItems(orderedItems);
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
onOrderChange?.(draggableItems);
|
|
38
|
+
}, [draggableItems, onOrderChange]);
|
|
39
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
40
|
+
id: id,
|
|
41
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
42
|
+
style: style
|
|
43
|
+
// {...otherProps}
|
|
44
|
+
}, draggableItems.map(({
|
|
45
|
+
identifier,
|
|
46
|
+
disabled,
|
|
47
|
+
Content,
|
|
48
|
+
...rest
|
|
49
|
+
}, index) => /*#__PURE__*/React.createElement(DraggableItem, _extends({
|
|
50
|
+
draggable: true,
|
|
51
|
+
onDrop: e => handleDrop(e, index),
|
|
52
|
+
index: index,
|
|
53
|
+
key: identifier
|
|
54
|
+
}, rest), Content)));
|
|
55
|
+
};
|
|
56
|
+
DragAndDrop.propTypes = {
|
|
57
|
+
/**
|
|
58
|
+
* The HTML id for this element
|
|
59
|
+
*/
|
|
60
|
+
id: PropTypes.string,
|
|
61
|
+
/**
|
|
62
|
+
* The HTML class names for this element
|
|
63
|
+
*/
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
/**
|
|
66
|
+
* The React-written, css properties for this element.
|
|
67
|
+
*/
|
|
68
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
69
|
+
/**
|
|
70
|
+
* The html element to use to display this component.
|
|
71
|
+
*/
|
|
72
|
+
as: PropTypes.string,
|
|
73
|
+
/**
|
|
74
|
+
* The node list of items to be dragged around
|
|
75
|
+
*/
|
|
76
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
|
77
|
+
Content: PropTypes.node.isRequired,
|
|
78
|
+
identifier: PropTypes.string.isRequired,
|
|
79
|
+
as: PropTypes.string
|
|
80
|
+
})).isRequired,
|
|
81
|
+
/*
|
|
82
|
+
* A function to be called when the draggable items are re-ordered
|
|
83
|
+
*/
|
|
84
|
+
onOrderChange: PropTypes.func
|
|
85
|
+
};
|
|
86
|
+
DragAndDrop.defaultProps = {
|
|
87
|
+
as: 'ul'
|
|
88
|
+
};
|
|
89
|
+
DragAndDrop.DraggableItem = DraggableItem;
|
|
90
|
+
export default DragAndDrop;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
+
import "./styles.scss";
|
|
8
|
+
|
|
9
|
+
// Local Definitions
|
|
10
|
+
|
|
11
|
+
const baseClassName = styleNames.base;
|
|
12
|
+
const componentClassName = 'draggable-item';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This is the component description.
|
|
16
|
+
*/
|
|
17
|
+
const DraggableItem = ({
|
|
18
|
+
id,
|
|
19
|
+
className: userClassName,
|
|
20
|
+
style,
|
|
21
|
+
as: Wrapper,
|
|
22
|
+
children,
|
|
23
|
+
index,
|
|
24
|
+
...otherProps
|
|
25
|
+
}) => {
|
|
26
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
27
|
+
const handleDragStart = e => {
|
|
28
|
+
setIsDragging(true);
|
|
29
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
30
|
+
e.dataTransfer.setData('text/plain', index);
|
|
31
|
+
};
|
|
32
|
+
const handleDragEnd = () => {
|
|
33
|
+
setIsDragging(false);
|
|
34
|
+
};
|
|
35
|
+
const handleDragOver = e => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/React.createElement(Wrapper, _extends({
|
|
39
|
+
id: id,
|
|
40
|
+
className: [baseClassName, componentClassName, userClassName, isDragging && 'dragging'].filter(e => e).join(' '),
|
|
41
|
+
style: style,
|
|
42
|
+
onDragStart: e => handleDragStart(e),
|
|
43
|
+
onDragOver: e => handleDragOver(e),
|
|
44
|
+
onDragEnd: e => handleDragEnd(e)
|
|
45
|
+
}, otherProps), children);
|
|
46
|
+
};
|
|
47
|
+
DraggableItem.propTypes = {
|
|
48
|
+
/**
|
|
49
|
+
* The HTML id for this element
|
|
50
|
+
*/
|
|
51
|
+
id: PropTypes.string,
|
|
52
|
+
/**
|
|
53
|
+
* The HTML class names for this element
|
|
54
|
+
*/
|
|
55
|
+
className: PropTypes.string,
|
|
56
|
+
/**
|
|
57
|
+
* The React-written, css properties for this element.
|
|
58
|
+
*/
|
|
59
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
60
|
+
/**
|
|
61
|
+
* The children JSX
|
|
62
|
+
*/
|
|
63
|
+
children: PropTypes.node,
|
|
64
|
+
/**
|
|
65
|
+
* The html element to use to display this component.
|
|
66
|
+
*/
|
|
67
|
+
as: PropTypes.string
|
|
68
|
+
};
|
|
69
|
+
DraggableItem.defaultProps = {
|
|
70
|
+
as: 'li'
|
|
71
|
+
};
|
|
72
|
+
export default DraggableItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DraggableItem } from "./DraggableItem";
|