@arc-fusion/pb-editor-wrapper
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,101 +0,62 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}) | ||
exports.default = void 0 | ||
}); | ||
exports.default = void 0; | ||
var _react = require('@emotion/react') | ||
var _react = require("@emotion/react"); | ||
var _propTypes = _interopRequireDefault(require('prop-types')) | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react2 = require('react') | ||
var _react2 = require("react"); | ||
var _pencil = _interopRequireDefault(require('./img/svg/pencil.svg')) | ||
var _pencil = _interopRequireDefault(require("./img/svg/pencil.svg")); | ||
var _trash = _interopRequireDefault(require('./img/svg/trash.svg')) | ||
var _trash = _interopRequireDefault(require("./img/svg/trash.svg")); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj } | ||
} | ||
var _locator = _interopRequireDefault(require("./img/svg/locator.svg")); | ||
function _slicedToArray(arr, i) { | ||
return ( | ||
_arrayWithHoles(arr) || | ||
_iterableToArrayLimit(arr, i) || | ||
_unsupportedIterableToArray(arr, i) || | ||
_nonIterableRest() | ||
) | ||
} | ||
var _plugin = _interopRequireDefault(require("./img/svg/plugin.svg")); | ||
function _nonIterableRest() { | ||
throw new TypeError( | ||
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' | ||
) | ||
} | ||
var _plus = _interopRequireDefault(require("./img/svg/plus.svg")); | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return | ||
if (typeof o === 'string') return _arrayLikeToArray(o, minLen) | ||
var n = Object.prototype.toString.call(o).slice(8, -1) | ||
if (n === 'Object' && o.constructor) n = o.constructor.name | ||
if (n === 'Map' || n === 'Set') return Array.from(o) | ||
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) | ||
return _arrayLikeToArray(o, minLen) | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) { | ||
arr2[i] = arr[i] | ||
} | ||
return arr2 | ||
} | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === 'undefined' || !(Symbol.iterator in Object(arr))) return | ||
var _arr = [] | ||
var _n = true | ||
var _d = false | ||
var _e = undefined | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value) | ||
if (i && _arr.length === i) break | ||
} | ||
} catch (err) { | ||
_d = true | ||
_e = err | ||
} finally { | ||
try { | ||
if (!_n && _i['return'] != null) _i['return']() | ||
} finally { | ||
if (_d) throw _e | ||
} | ||
} | ||
return _arr | ||
} | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var FeatureWrapper = function FeatureWrapper(_ref) { | ||
var fingerprint = _ref.fingerprint, | ||
onHover = _ref.onHover, | ||
onClick = _ref.onClick, | ||
onEdit = _ref.onEdit, | ||
onDelete = _ref.onDelete, | ||
children = _ref.children | ||
plugins = _ref.plugins, | ||
isChain = _ref.isChain, | ||
onHover = _ref.onHover, | ||
onHoverEnd = _ref.onHoverEnd, | ||
onAdd = _ref.onAdd, | ||
onEdit = _ref.onEdit, | ||
onDelete = _ref.onDelete, | ||
onLocate = _ref.onLocate, | ||
onPluginLoad = _ref.onPluginLoad, | ||
children = _ref.children; | ||
var _useState = (0, _react2.useState)(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isHovered = _useState2[0], | ||
setHover = _useState2[1] | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isHovered = _useState2[0], | ||
setHover = _useState2[1]; | ||
var styles = { | ||
wrapper: { | ||
margin: '2px', | ||
position: 'relative', | ||
highlighted: { | ||
zIndex: 99999, | ||
boxShadow: '0 0 0 2px #3760ff', | ||
boxShadow: '2px -2px 0px #3760ff, -2px -2px 0px #3760ff, -2px 2px 0px #3760ff, 2px 2px 0px #3760ff', | ||
transition: 'all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1)' | ||
@@ -113,4 +74,4 @@ }, | ||
right: '5px', | ||
width: '75px', | ||
padding: '5px 0', | ||
padding: '5px', | ||
width: 'initial', | ||
borderRadius: '5px', | ||
@@ -123,63 +84,129 @@ '& i': { | ||
} | ||
}, | ||
button: { | ||
fontFamily: 'OutputSans', | ||
fontSize: '13px', | ||
zIndex: 2147483646, | ||
textAlign: 'center', | ||
backgroundColor: '#3760FF', | ||
color: '#FFFFFF', | ||
cursor: 'pointer', | ||
boxShadow: 'none', | ||
border: 'none', | ||
':hover': { | ||
backgroundColor: '#5272f3' | ||
} | ||
}, | ||
buttonTop: { | ||
position: 'absolute', | ||
top: '-20px', | ||
borderTopLeftRadius: '5px', | ||
borderTopRightRadius: '5px', | ||
width: '65px', | ||
height: '20px', | ||
right: 0, | ||
left: 0, | ||
marginLeft: 'auto', | ||
marginRight: 'auto' | ||
}, | ||
buttonBottom: { | ||
position: 'absolute', | ||
bottom: '-20px', | ||
borderBottomLeftRadius: '5px', | ||
borderBottomRightRadius: '5px', | ||
width: '65px', | ||
height: '20px', | ||
right: 0, | ||
left: 0, | ||
marginLeft: 'auto', | ||
marginRight: 'auto' | ||
}, | ||
buttonIcon: { | ||
width: '10px', | ||
display: 'inline', | ||
margin: 0, | ||
padding: 0 | ||
} | ||
} | ||
} | ||
}; | ||
var onFeatureHover = function onFeatureHover() { | ||
setHover(true) | ||
onHover && onHover(fingerprint) | ||
} | ||
setHover(true); | ||
onHover && onHover(fingerprint); | ||
}; | ||
return (0, _react.jsx)( | ||
'div', | ||
{ | ||
css: [styles.wrapper, isHovered && styles.wrapper.highlighted], | ||
onMouseEnter: onFeatureHover, | ||
onMouseLeave: function onMouseLeave() { | ||
return setHover(false) | ||
} | ||
}, | ||
isHovered && | ||
(0, _react.jsx)( | ||
'div', | ||
{ | ||
css: styles.wrapper.actions | ||
}, | ||
(0, _react.jsx)( | ||
'i', | ||
{ | ||
onClick: function onClick() { | ||
return onEdit(fingerprint) | ||
} | ||
}, | ||
(0, _react.jsx)('img', { | ||
src: _pencil.default, | ||
alt: 'edit' | ||
}) | ||
), | ||
(0, _react.jsx)( | ||
'i', | ||
{ | ||
onClick: function onClick() { | ||
return onDelete(fingerprint) | ||
} | ||
}, | ||
(0, _react.jsx)('img', { | ||
src: _trash.default, | ||
alt: 'remove' | ||
}) | ||
) | ||
), | ||
children | ||
) | ||
} | ||
var onFeatureHoverEnd = function onFeatureHoverEnd() { | ||
setHover(false); | ||
onHoverEnd && onHoverEnd(fingerprint); | ||
}; | ||
return isChain ? (0, _react.jsx)("div", { | ||
"data-fusion-component": fingerprint, | ||
"data-fusion-plugins": plugins | ||
}, children) : (0, _react.jsx)("div", { | ||
css: [styles.wrapper, isHovered && styles.wrapper.highlighted], | ||
onMouseEnter: onFeatureHover, | ||
onMouseLeave: onFeatureHoverEnd, | ||
"data-fusion-component": fingerprint | ||
}, isHovered && (0, _react.jsx)(React.Fragment, null, (0, _react.jsx)("button", { | ||
css: styles.wrapper.buttonTop, | ||
onClick: function onClick() { | ||
return onAdd(fingerprint, 'top'); | ||
} | ||
}, (0, _react.jsx)("i", null, (0, _react.jsx)("img", { | ||
css: styles.wrapper.buttonIcon, | ||
src: _plus.default | ||
}))), (0, _react.jsx)("button", { | ||
css: styles.wrapper.buttonBottom, | ||
onClick: function onClick() { | ||
return onAdd(fingerprint, 'bottom'); | ||
} | ||
}, (0, _react.jsx)("i", null, (0, _react.jsx)("img", { | ||
css: styles.wrapper.buttonIcon, | ||
src: _plus.default | ||
}))), (0, _react.jsx)("div", { | ||
css: styles.wrapper.actions | ||
}, plugins && (0, _react.jsx)("i", { | ||
onClick: function onClick() { | ||
return onPluginLoad(fingerprint, plugins); | ||
} | ||
}, (0, _react.jsx)("img", { | ||
src: _plugin.default, | ||
alt: "plugin" | ||
})), (0, _react.jsx)("i", { | ||
onClick: function onClick() { | ||
return onEdit(fingerprint); | ||
} | ||
}, (0, _react.jsx)("img", { | ||
src: _pencil.default, | ||
alt: "edit" | ||
})), (0, _react.jsx)("i", { | ||
onClick: function onClick() { | ||
return onLocate(fingerprint); | ||
} | ||
}, (0, _react.jsx)("img", { | ||
src: _locator.default, | ||
alt: "locate" | ||
})), (0, _react.jsx)("i", { | ||
onClick: function onClick() { | ||
return onDelete(fingerprint); | ||
} | ||
}, (0, _react.jsx)("img", { | ||
src: _trash.default, | ||
alt: "remove" | ||
})))), children); | ||
}; | ||
FeatureWrapper.propTypes = { | ||
fingerprint: _propTypes.default.string.isRequired, | ||
isChain: _propTypes.default.bool, | ||
onHover: _propTypes.default.func, | ||
onHoverEnd: _propTypes.default.func, | ||
onClick: _propTypes.default.func, | ||
onEdit: _propTypes.default.func, | ||
onDelete: _propTypes.default.func | ||
} | ||
var _default = FeatureWrapper | ||
exports.default = _default | ||
onDelete: _propTypes.default.func, | ||
onLocate: _propTypes.default.func, | ||
onPluginLoad: _propTypes.default.func | ||
}; | ||
var _default = FeatureWrapper; | ||
exports.default = _default; |
@@ -1,15 +0,15 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}) | ||
Object.defineProperty(exports, 'FeatureWrapper', { | ||
}); | ||
Object.defineProperty(exports, "FeatureWrapper", { | ||
enumerable: true, | ||
get: function get() { | ||
return _FeatureWrapper.default | ||
return _FeatureWrapper.default; | ||
} | ||
}) | ||
}); | ||
var _FeatureWrapper = _interopRequireDefault(require('./FeatureWrapper')) | ||
var _FeatureWrapper = _interopRequireDefault(require("./FeatureWrapper")); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj } | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
{ | ||
"name": "@arc-fusion/pb-editor-wrapper", | ||
"description": "PageBuilder Preview Wrapper", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"module": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "files": [ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12123
10
199