@shopgate/pwa-ui-shared 7.25.0-beta.2 → 7.26.0-beta.1

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.
@@ -4,5 +4,5 @@ import React from'react';import PropTypes from'prop-types';import compose from'l
4
4
  */var CLOSE_DELAY=250;/**
5
5
  * The Context Menu Item component.
6
6
  * @param {Object} props The component props.
7
- * @returns {JSX}
8
- */var Item=function Item(_ref){var children=_ref.children,closeMenu=_ref.closeMenu,onClick=_ref.onClick,disabled=_ref.disabled,autoClose=_ref.autoClose,className=_ref.className;var handleClick=compose(onClick,autoClose?function(){return setTimeout(closeMenu,CLOSE_DELAY);}:noop);return React.createElement(Glow,{disabled:disabled},React.createElement("div",{className:classNames(getItemClass(disabled),className),onClick:disabled?noop:handleClick,"aria-hidden":true,"data-test-id":"contextMenuButton"},children));};Item.defaultProps={autoClose:true,children:null,className:'',closeMenu:function closeMenu(){},onClick:function onClick(){},disabled:false};export default Item;
7
+ * @returns {JSX.Element}
8
+ */var Item=function Item(_ref){var children=_ref.children,closeMenu=_ref.closeMenu,onClick=_ref.onClick,disabled=_ref.disabled,autoClose=_ref.autoClose,className=_ref.className;var handleClick=compose(onClick,autoClose?function(){return setTimeout(closeMenu,CLOSE_DELAY);}:noop);return React.createElement(Glow,{disabled:disabled},React.createElement("button",{className:classNames(getItemClass(disabled),className),onClick:disabled?noop:handleClick,"data-test-id":"contextMenuButton",type:"button",disabled:disabled},children));};Item.defaultProps={autoClose:true,children:null,className:'',closeMenu:function closeMenu(){},onClick:function onClick(){},disabled:false};export default Item;
@@ -1,4 +1,4 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component,Children}from'react';import PropTypes from'prop-types';import{ConnectedReactPortal}from'@shopgate/engage/components';import classNames from'classnames';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import MoreVertIcon from"../icons/MoreVertIcon";import Position from"./components/Position";import Item from"./components/Item";import styles from"./style";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component,Children}from'react';import PropTypes from'prop-types';import{ConnectedReactPortal}from'@shopgate/engage/components';import classNames from'classnames';import Backdrop from'@shopgate/pwa-common/components/Backdrop';import{FocusTrap}from'focus-trap-react';import MoreVertIcon from"../icons/MoreVertIcon";import Position from"./components/Position";import Item from"./components/Item";import styles from"./style";/**
2
2
  * The ContextMenu component.
3
3
  */var ContextMenu=/*#__PURE__*/function(_Component){/**
4
4
  * The Constructor.
@@ -6,10 +6,15 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
6
6
  */function ContextMenu(props){var _this2;_classCallCheck(this,ContextMenu);_this2=_callSuper(this,ContextMenu,[props]);/**
7
7
  * Handles any menu toggling interactions.
8
8
  * @param {Object} [e] Event
9
- */_defineProperty(_this2,"handleMenuToggle",function(e){if(e){e.preventDefault();e.stopPropagation();}if(_this2.elementRef){_this2.setState(function(_ref){var active=_ref.active;var state={active:!active};if(_this2.props.onStateChange){_this2.props.onStateChange(state);}return state;});}});_this2.elementRef=null;_this2.state={active:props.isOpened};return _this2;}/** @inheritDoc */_inherits(ContextMenu,_Component);return _createClass(ContextMenu,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(_ref2){var isOpened=_ref2.isOpened;if(typeof isOpened==='boolean'&&this.state.active!==isOpened){this.setState({active:isOpened});}}/**
9
+ */_defineProperty(_this2,"handleMenuToggle",function(e){if(e){e.preventDefault();e.stopPropagation();}if(_this2.elementRef){_this2.setState(function(_ref){var active=_ref.active;var newState={active:!active};if(_this2.props.onStateChange){_this2.props.onStateChange(newState);}return newState;});}});_this2.elementRef=null;_this2.menuRef=null;_this2.state={active:props.isOpened};return _this2;}/** @inheritDoc */_inherits(ContextMenu,_Component);return _createClass(ContextMenu,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(_ref2){var isOpened=_ref2.isOpened;if(typeof isOpened==='boolean'&&this.state.active!==isOpened){this.setState({active:isOpened});}}/**
10
+ * update the focus of the context menu popup
11
+ * @param {Object} prevProps previous props
12
+ * @param {Object} prevState previous state
13
+ */},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){// Check if active changed from false to true
14
+ if(!prevState.active&&this.state.active&&this.menuRef){this.menuRef.focus();}}/**
10
15
  * Gets the offset of the DOM element.
11
16
  * @returns {Object}
12
17
  */},{key:"offset",get:function get(){if(this.elementRef){return this.elementRef.getBoundingClientRect();}return{top:0,left:0};}},{key:"render",value:/**
13
18
  * Renders the component.
14
- * @returns {JSX}
15
- */function render(){var _this3=this;var _this$props=this.props,children=_this$props.children,classes=_this$props.classes,disabled=_this$props.disabled,showToggle=_this$props.showToggle,scroll=_this$props.scroll;var active=this.state.active;var useScroll=typeof scroll==='boolean'&&!!scroll;return React.createElement("div",{"data-test-id":"contextMenu",ref:function ref(_ref3){_this3.elementRef=_ref3;},className:classNames(styles.container,classes.container,'ui-shared__context-menu'),"aria-hidden":true},showToggle&&React.createElement("button",{className:classNames(styles.button,classes.button,_defineProperty({},styles.disabled,disabled)),onClick:this.handleMenuToggle,disabled:disabled,type:"button","aria-hidden":true},React.createElement(MoreVertIcon,null)),React.createElement(ConnectedReactPortal,{isOpened:active},React.createElement("div",{className:styles.overlay},React.createElement(Backdrop,{isVisible:true,level:0,opacity:0,onClick:this.handleMenuToggle}),React.createElement(Position,{offset:this.offset},React.createElement("div",{className:classNames(styles.menu,_defineProperty({},styles.scrollable,useScroll))},Children.map(children,function(child){if(!child){return null;}return React.cloneElement(child,{closeMenu:_this3.handleMenuToggle});}))))));}}]);}(Component);_defineProperty(ContextMenu,"Item",Item);_defineProperty(ContextMenu,"defaultProps",{children:null,classes:{container:'',button:''},disabled:false,showToggle:true,isOpened:null,onStateChange:null,scroll:null});export default ContextMenu;
19
+ * @returns {JSX.Element}
20
+ */function render(){var _this3=this;var _this$props=this.props,children=_this$props.children,classes=_this$props.classes,disabled=_this$props.disabled,showToggle=_this$props.showToggle,scroll=_this$props.scroll;var active=this.state.active;var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var useScroll=typeof scroll==='boolean'&&!!scroll;return React.createElement("div",{"data-test-id":"contextMenu",ref:function ref(_ref3){_this3.elementRef=_ref3;},className:classNames(styles.container,classes.container,'ui-shared__context-menu')},showToggle&&React.createElement("button",{className:classNames(styles.button,classes.button,_defineProperty({},styles.disabled,disabled)),onClick:this.handleMenuToggle,disabled:disabled,type:"button","aria-label":__('navigation.open_menu'),"aria-haspopup":"true","aria-expanded":active,"aria-controls":"contextMenuDialog"},React.createElement(MoreVertIcon,{"aria-hidden":true})),React.createElement(ConnectedReactPortal,{isOpened:active},React.createElement(FocusTrap,{active:active},React.createElement("div",{className:styles.overlay},React.createElement(Backdrop,{isVisible:true,level:0,opacity:0,onClick:this.handleMenuToggle}),React.createElement(Position,{offset:this.offset},React.createElement("div",{className:classNames(styles.menu,_defineProperty({},styles.scrollable,useScroll)),ref:function ref(node){_this3.menuRef=node;},tabIndex:"-1","aria-modal":"true",role:"dialog"},Children.map(children,function(child){if(!child){return null;}return React.cloneElement(child,{closeMenu:_this3.handleMenuToggle});}),React.createElement("button",{onClick:this.handleMenuToggle,className:"sr-only","aria-label":__('common.close'),type:"button"},__('common.close'))))))));}}]);}(Component);_defineProperty(ContextMenu,"Item",Item);_defineProperty(ContextMenu,"defaultProps",{children:null,classes:{container:'',button:''},disabled:false,showToggle:true,isOpened:null,onStateChange:null,scroll:null});_defineProperty(ContextMenu,"contextTypes",{i18n:PropTypes.func});export default ContextMenu;
@@ -2,5 +2,5 @@ import React from'react';import PropTypes from'prop-types';import BasicDialog fr
2
2
  * Renders a simple dialog with a title and html content as a message.
3
3
  * This is the default dialog if no type has been specified.
4
4
  * @param {Object} props The component properties.
5
- * @returns {JSX} The rendered component.
5
+ * @returns {JSX.Element} The rendered component.
6
6
  */var HtmlContentDialog=function HtmlContentDialog(_ref){var actions=_ref.actions,message=_ref.message,title=_ref.title;return React.createElement(BasicDialog,{title:title,actions:actions},React.createElement("div",{dangerouslySetInnerHTML:{__html:message}}));};HtmlContentDialog.defaultProps={title:BasicDialog.defaultProps.title};export default HtmlContentDialog;
@@ -1,7 +1,7 @@
1
- import React from'react';import PropTypes from'prop-types';import I18n from'@shopgate/pwa-common/components/I18n';import styles from"./style";/**
1
+ import React from'react';import PropTypes from'prop-types';import{I18n}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import styles from"./style";/**
2
2
  * The discount badge component.
3
3
  * @param {Object} props The component props
4
4
  * @param {string} [props.className] Additional CSS style definitions
5
5
  * @param {string} props.text The text contents of the component.
6
- * @returns {JSX}
7
- */var DiscountBadge=function DiscountBadge(_ref){var text=_ref.text,className=_ref.className,display=_ref.display,discount=_ref.discount;return React.createElement("div",{"data-test-id":text,className:"ui-shared__discount-badge"},React.createElement(I18n.Text,{className:"".concat(styles[display]," ").concat(className),string:text,params:[discount]}));};DiscountBadge.defaultProps={className:'',discount:null,display:'small'};export default DiscountBadge;
6
+ * @returns {JSX.Element}
7
+ */var DiscountBadge=function DiscountBadge(_ref){var text=_ref.text,className=_ref.className,display=_ref.display,discount=_ref.discount;return React.createElement("div",{"data-test-id":text,className:"ui-shared__discount-badge","aria-label":"".concat(i18n.text('cart.discount'),": ").concat(text)},React.createElement(I18n.Text,{className:"".concat(styles[display]," ").concat(className),string:text,params:[discount],"aria-hidden":true}));};DiscountBadge.defaultProps={className:'',discount:null,display:'small'};export default DiscountBadge;
@@ -1,6 +1,6 @@
1
- import _camelCase from"lodash/camelCase";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||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);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';import CheckedIcon from'@shopgate/pwa-ui-shared/icons/RadioCheckedIcon';import UncheckedIcon from'@shopgate/pwa-ui-shared/icons/RadioUncheckedIcon';import I18n from'@shopgate/pwa-common/components/I18n';import style from"./style";/**
1
+ import _camelCase from"lodash/camelCase";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||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);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';import CheckedIcon from'@shopgate/pwa-ui-shared/icons/RadioCheckedIcon';import UncheckedIcon from'@shopgate/pwa-ui-shared/icons/RadioUncheckedIcon';import{I18n}from'@shopgate/engage/components';import style from"./style";/**
2
2
  * RadioItem component.
3
- */var RadioItem=/*#__PURE__*/function(_PureComponent){function RadioItem(){_classCallCheck(this,RadioItem);return _callSuper(this,RadioItem,arguments);}_inherits(RadioItem,_PureComponent);return _createClass(RadioItem,[{key:"render",value:function render(){var _this$props=this.props,ItemLabel=_this$props.label,name=_this$props.name,onChange=_this$props.onChange,checked=_this$props.checked,className=_this$props.className,attributes=_this$props.attributes;var _ref=attributes||{},disabled=_ref.disabled;return React.createElement("label",{className:classNames(style.container,className,_defineProperty({},style.disabled,!!disabled),_camelCase(name),'radioItem'),htmlFor:this.key},checked&&React.createElement(CheckedIcon,{className:classNames(style.active,style.icon,'checkedIcon')}),!checked&&React.createElement(UncheckedIcon,{className:classNames(style.icon,'uncheckedIcon')}),React.createElement("input",_extends({className:classNames(style.input,'input'),checked:checked,type:"radio",name:name,onChange:onChange},attributes)),React.createElement(I18n.Text,{className:classNames(style.label,'label'),string:ItemLabel}));}}]);}(PureComponent);_defineProperty(RadioItem,"defaultProps",{attributes:null,checked:false,className:'',onChange:function onChange(){}/**
3
+ */var RadioItem=/*#__PURE__*/function(_PureComponent){function RadioItem(){_classCallCheck(this,RadioItem);return _callSuper(this,RadioItem,arguments);}_inherits(RadioItem,_PureComponent);return _createClass(RadioItem,[{key:"render",value:function render(){var _this$props=this.props,ItemLabel=_this$props.label,name=_this$props.name,onChange=_this$props.onChange,checked=_this$props.checked,className=_this$props.className,attributes=_this$props.attributes;var _ref=attributes||{},disabled=_ref.disabled;return React.createElement("label",{className:classNames(style.container,className,_defineProperty({},style.disabled,!!disabled),_camelCase(name),'radioItem'),htmlFor:name},checked&&React.createElement(CheckedIcon,{className:classNames(style.active,style.icon,'checkedIcon')}),!checked&&React.createElement(UncheckedIcon,{className:classNames(style.icon,'uncheckedIcon')}),React.createElement("input",_extends({className:classNames('sr-only','input'),checked:checked,id:name,type:"radio",name:name,onChange:onChange,"aria-labelledby":"".concat(name,"-label")},attributes)),React.createElement("span",{"aria-hidden":true,id:"".concat(name,"-label"),className:classNames(style.label,'label')},React.createElement(I18n.Text,{string:ItemLabel})));}}]);}(PureComponent);_defineProperty(RadioItem,"defaultProps",{attributes:null,checked:false,className:'',onChange:function onChange(){}/**
4
4
  * Renders the component.
5
- * @returns {JSX}
5
+ * @returns {JSX.Element}
6
6
  */});export default RadioItem;
@@ -1,2 +1,2 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var input=css({display:'none'}).toString();var container=css({display:'flex',marginLeft:-1// Removes margin of svg.
2
- }).toString();var icon=css({width:24,height:24,flexShrink:0}).toString();var disabled=css({opacity:0.25,pointerEvents:'none'}).toString();var label=css({flex:1,fontSize:'1rem',lineHeight:1.5,marginLeft:themeConfig.variables.gap.small,marginBottom:themeConfig.variables.gap.small}).toString();var active=css({color:"var(--color-primary, ".concat(themeConfig.colors.primary,")")}).toString();export default{input:input,icon:icon,disabled:disabled,container:container,label:label,active:active};
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var container=css({display:'flex',marginLeft:-1// Removes margin of svg.
2
+ }).toString();var icon=css({width:24,height:24,flexShrink:0}).toString();var disabled=css({opacity:0.25,pointerEvents:'none'}).toString();var label=css({flex:1,fontSize:'1rem',lineHeight:1.5,marginLeft:themeConfig.variables.gap.small,marginBottom:themeConfig.variables.gap.small}).toString();var active=css({color:"var(--color-primary, ".concat(themeConfig.colors.primary,")")}).toString();export default{icon:icon,disabled:disabled,container:container,label:label,active:active};
@@ -1,5 +1,5 @@
1
1
  import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import I18n from'@shopgate/pwa-common/components/I18n';import styles from"./style";/**
2
2
  * Error message component.
3
3
  * @param {Object} props The component props.
4
- * @returns {JSX}
5
- */var ErrorText=function ErrorText(_ref){var className=_ref.className,errorText=_ref.errorText,translate=_ref.translate;return React.createElement("div",{className:classNames(className,styles,'errorText')},translate&&React.createElement(I18n.Text,{string:errorText}),!translate&&errorText);};ErrorText.defaultProps={className:null,errorText:null,translate:true};export default ErrorText;
4
+ * @returns {JSX.Element}
5
+ */var ErrorText=function ErrorText(_ref){var className=_ref.className,errorText=_ref.errorText,translate=_ref.translate;return React.createElement("div",{className:classNames(className,styles,'errorText'),role:"alert","aria-live":"assertive","aria-atomic":"true"},translate&&React.createElement(I18n.Text,{string:errorText}),!translate&&errorText);};ErrorText.defaultProps={className:null,errorText:null,translate:true};export default ErrorText;
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import classNames fro
2
2
  * The NoResults component.
3
3
  * @param {Object} props The component props.
4
4
  * @returns {JSX}
5
- */var NoResults=function NoResults(props){return React.createElement("div",{className:classNames(styles.wrapper,props.className,' ui-shared__no-results'),"data-test-id":"noResults"},React.createElement("div",{className:styles.icon},React.createElement(Icon,null)),React.createElement("div",{className:styles.headline},React.createElement(I18n.Text,{string:props.headlineText,params:props})),React.createElement("div",{className:styles.text},React.createElement(I18n.Text,{string:props.bodyText,params:props})));};NoResults.defaultProps={className:null};export default NoResults;
5
+ */var NoResults=function NoResults(props){return React.createElement("div",{className:classNames(styles.wrapper,props.className,' ui-shared__no-results'),"data-test-id":"noResults"},React.createElement("div",{className:styles.icon},React.createElement(Icon,null)),React.createElement("div",{className:styles.headline,role:"alert","aria-atomic":"true"},React.createElement(I18n.Text,{string:props.headlineText,params:props})),React.createElement("div",{className:styles.text,role:"alert","aria-atomic":"true"},React.createElement(I18n.Text,{string:props.bodyText,params:props})));};NoResults.defaultProps={className:null};export default NoResults;
package/Price/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import I18n from'@shopgate/pwa-common/components/I18n';import showTaxDisclaimer from'@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import styles from"./style";/**
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import{I18n}from'@shopgate/engage/components';import showTaxDisclaimer from'@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import styles from"./style";/**
2
2
  * The Price component
3
3
  * @param {Object} props The component props
4
4
  * @param {string} [props.className] CSS classes
@@ -7,11 +7,11 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
7
7
  * @param {number} props.unitPriceMin The minimum price of possible child products
8
8
  * @param {boolean} props.discounted Tells if the pice is discounted
9
9
  * @param {Object} context The component context.
10
- * @return {JSX}
10
+ * @return {JSX.Element}
11
11
  */var Price=function Price(props,context){// Added with PWA 6 - CCP-2372
12
12
  var _useWidgetSettings=useWidgetSettings('@shopgate/engage/components/TaxDisclaimer'),show=_useWidgetSettings.show,hint=_useWidgetSettings.hint;// use widget setting if set to true/false, otherwise use market logic
13
- var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;var containerClasses=classNames(styles.container,props.className,_defineProperty({},styles.discounted,props.discounted),'price',props.discounted?'ui-shared__price-discounted':'ui-shared__price');var _context$i18n=context.i18n(),__=_context$i18n.__,_p=_context$i18n._p;var ariaPrice;if(props.unitPriceMin){ariaPrice=__('price.from',{price:_p(props.unitPriceMin,props.currency,props.fractions)});}else{ariaPrice=_p(props.unitPrice,props.currency,props.fractions);}ariaPrice=ariaPrice.replace('-',"\u2212");/* eslint-disable jsx-a11y/aria-role */ /**
13
+ var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;var containerClasses=classNames(styles.container,props.className,_defineProperty({},styles.discounted,props.discounted),'price',props.discounted?'ui-shared__price-discounted':'ui-shared__price');var _context$i18n=context.i18n(),__=_context$i18n.__,_p=_context$i18n._p;var ariaPrice;if(props.unitPriceMin){ariaPrice=__('price.from',{price:_p(props.unitPriceMin,props.currency,props.fractions)});}else{ariaPrice=_p(props.unitPrice,props.currency,props.fractions);}ariaPrice=ariaPrice.replace('-',"\u2212");/**
14
14
  * A unitPriceMin > 0 means, that the product has child products with different prices.
15
15
  * The unitPriceMin contains the lowest of these prices and will be
16
16
  * displayed with a 'From' prefix.
17
- */return React.createElement("div",{className:containerClasses,"data-test-id":"minPrice: ".concat(props.unitPriceMin," price: ").concat(props.unitPrice," currency: ").concat(props.currency)},React.createElement("span",{role:"text","aria-label":__('price.label',{price:ariaPrice})},props.unitPriceMin?React.createElement(I18n.Text,{string:"price.from"},React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,forKey:"price",price:props.unitPriceMin})):React.createElement(React.Fragment,null,props.allowFree&&props.unitPrice===0?React.createElement(I18n.Text,{string:"price.free"}):React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,price:props.unitPrice}))),props.taxDisclaimer&&showDisclaimer?React.createElement("div",{role:"text",className:styles.disclaimer,"aria-label":__('product.tax_disclaimer')},hint||'*'):null);/* eslint-enable jsx-a11y/aria-role */};Price.defaultProps={className:'',unitPriceMin:0,discounted:false,fractions:true,taxDisclaimer:false,allowFree:false};Price.contextTypes={i18n:PropTypes.func};export default Price;
17
+ */return React.createElement("div",{className:containerClasses,"data-test-id":"minPrice: ".concat(props.unitPriceMin," price: ").concat(props.unitPrice," currency: ").concat(props.currency)},React.createElement("span",{"aria-label":__('price.label',{price:ariaPrice})},props.unitPriceMin?React.createElement(I18n.Text,{"aria-hidden":true,string:"price.from"},React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,forKey:"price",price:props.unitPriceMin})):React.createElement(React.Fragment,null,props.allowFree&&props.unitPrice===0?React.createElement(I18n.Text,{string:"price.free"}):React.createElement(I18n.Price,{currency:props.currency,fractions:props.fractions,price:props.unitPrice}))),props.taxDisclaimer&&showDisclaimer?React.createElement("div",{className:styles.disclaimer},React.createElement("span",null,hint||'*'),React.createElement("span",{className:styles.hidden,"aria-label":__('product.tax_disclaimer_aria')},__('product.tax_disclaimer_aria'))):null);};Price.defaultProps={className:'',unitPriceMin:0,discounted:false,fractions:true,taxDisclaimer:false,allowFree:false};Price.contextTypes={i18n:PropTypes.func};export default Price;
package/Price/style.js CHANGED
@@ -1 +1 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var container=css({display:'flex',position:'relative',whiteSpace:'nowrap'}).toString();var disclaimer=css({color:'initial',fontSize:14,position:'absolute',right:-10,top:0}).toString();var discounted=css({color:"var(--color-primary, ".concat(themeConfig.colors.primary,")")}).toString();export default{container:container,disclaimer:disclaimer,discounted:discounted};
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var container=css({display:'flex',position:'relative',whiteSpace:'nowrap'}).toString();var disclaimer=css({color:'initial',fontSize:14,position:'absolute',right:-10,top:0}).toString();var discounted=css({color:"var(--color-primary, ".concat(themeConfig.colors.primary,")")}).toString();var hidden=css({position:'absolute',width:'1px',height:'1px',padding:0,margin:'-1px',overflow:'hidden',border:0}).toString();export default{container:container,disclaimer:disclaimer,discounted:discounted,hidden:hidden};
@@ -19,13 +19,11 @@ return Math.round(90-Math.atan(width/height)*(180/Math.PI));};/**
19
19
  */function PriceStriked(props){var _this2;_classCallCheck(this,PriceStriked);_this2=_callSuper(this,PriceStriked,[props]);/**
20
20
  * Sets the calculated angle for the DOM element
21
21
  * and returns true if succeeded.
22
- * @param {Object} element The target element.
23
22
  * @returns {boolean}
24
23
  */_defineProperty(_this2,"setAngle",function(){if(_this2.element){_this2.angle=calcAngle(_this2.element);return true;}return false;});_this2.angle=null;_this2.element=null;return _this2;}/**
25
24
  * Updates the component one more time with the calculated angle
26
25
  * based on the DOM element.
27
26
  */_inherits(PriceStriked,_Component);return _createClass(PriceStriked,[{key:"componentDidMount",value:function componentDidMount(){if(this.setAngle()){this.forceUpdate();}}},{key:"render",value:/**
28
27
  * Renders the component.
29
- * @returns {JSX}
30
- */function render(){var _this3=this;var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__,_p=_this$context$i18n._p;var angleStyle=this.angle?styles.getAngleStyle(this.angle):'';return React.createElement("div",{// eslint-disable-next-line jsx-a11y/aria-role
31
- role:"text",className:"".concat(styles.basic," ").concat(this.props.className," ").concat(angleStyle," price-striked ui-shared__price-striked")},React.createElement("span",{ref:function ref(_ref){_this3.element=_ref;},"data-test-id":"strikedPrice: ".concat(this.props.value),"aria-label":__('price.label_old_price',{price:_p(this.props.value,this.props.currency,true)})},React.createElement(I18n.Price,{price:this.props.value,currency:this.props.currency})));}}]);}(Component);_defineProperty(PriceStriked,"defaultProps",{className:''});_defineProperty(PriceStriked,"contextTypes",{i18n:PropTypes.func});export default PriceStriked;
28
+ * @returns {JSX.Element}
29
+ */function render(){var _this3=this;var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__,_p=_this$context$i18n._p;var angleStyle=this.angle?styles.getAngleStyle(this.angle):'';return React.createElement(React.Fragment,null,React.createElement("div",{className:"".concat(styles.basic," ").concat(this.props.className," ").concat(angleStyle," price-striked ui-shared__price-striked")},React.createElement("span",{"aria-hidden":true,ref:function ref(_ref){_this3.element=_ref;},"data-test-id":"strikedPrice: ".concat(this.props.value)},React.createElement(I18n.Price,{price:this.props.value,currency:this.props.currency}))),React.createElement("span",{className:"sr-only"},__('price.label_old_price',{price:_p(this.props.value,this.props.currency,true)})));}}]);}(Component);_defineProperty(PriceStriked,"defaultProps",{className:''});_defineProperty(PriceStriked,"contextTypes",{i18n:PropTypes.func});export default PriceStriked;
@@ -1,5 +1,5 @@
1
1
  import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var basic=css({whiteSpace:'nowrap','& span':{position:'relative',':before':{// The strike-through effect is achieved by using the :before pseudo-class.
2
- borderColor:'currentColor',content:'""',position:'absolute',left:0,right:0,top:'50%'}},color:themeColors.shade3}).toString();/**
2
+ borderColor:'currentColor',content:'""',position:'absolute',left:0,right:0,top:'50%'}},color:themeColors.shade11}).toString();/**
3
3
  * Returns a class for the rotated strike-through line.
4
4
  * @param {number} angle The calculated angle for the strike-through line.
5
5
  * @returns {string} Classname
@@ -1,4 +1,4 @@
1
- import React from'react';import PropTypes from'prop-types';import ToggleIcon from'@shopgate/pwa-ui-shared/ToggleIcon';import FlashEnabledIcon from'@shopgate/pwa-ui-shared/icons/FlashEnabledIcon';import FlashDisabledIcon from'@shopgate/pwa-ui-shared/icons/FlashDisabledIcon';import{SCANNER_FLASH}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import styles from"./style";/**
1
+ import React from'react';import PropTypes from'prop-types';import ToggleIcon from'@shopgate/pwa-ui-shared/ToggleIcon';import FlashEnabledIcon from'@shopgate/pwa-ui-shared/icons/FlashEnabledIcon';import FlashDisabledIcon from'@shopgate/pwa-ui-shared/icons/FlashDisabledIcon';import{SCANNER_FLASH}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';import{SurroundPortals}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import styles from"./style";/**
2
2
  * The FlashlightButton component.
3
- * @returns {JSX}
4
- */var FlashlightButton=function FlashlightButton(_ref){var flashlightState=_ref.flashlightState,onToggle=_ref.onToggle;return React.createElement(SurroundPortals,{portalName:SCANNER_FLASH},React.createElement("button",{className:styles.button,onClick:onToggle,role:"link",type:"button"},React.createElement(ToggleIcon,{on:flashlightState,onIcon:React.createElement(FlashEnabledIcon,{className:styles.icon}),offIcon:React.createElement(FlashDisabledIcon,{className:styles.icon})})));};export default FlashlightButton;
3
+ * @returns {JSX.Element}
4
+ */var FlashlightButton=function FlashlightButton(_ref){var flashlightState=_ref.flashlightState,onToggle=_ref.onToggle;return React.createElement(SurroundPortals,{portalName:SCANNER_FLASH},React.createElement("button",{className:styles.button,onClick:onToggle,role:"link",type:"button","aria-label":i18n.text(flashlightState?'scanner.flashlight.switchOff':'scanner.flashlight.switchOn')},React.createElement(ToggleIcon,{on:flashlightState,onIcon:React.createElement(FlashEnabledIcon,{className:styles.icon}),offIcon:React.createElement(FlashDisabledIcon,{className:styles.icon})})),React.createElement("div",{className:"sr-only",role:"status","aria-live":"polite"},i18n.text(flashlightState?'scanner.flashlight.on':'scanner.flashlight.off')));};export default FlashlightButton;
@@ -1,4 +1,4 @@
1
- import React from'react';import I18n from'@shopgate/pwa-common/components/I18n';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{SCANNER_INSTRUCTIONS}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';/**
2
- * The FlashlightButton component.
3
- * @returns {JSX}
1
+ import React from'react';import{I18n,SurroundPortals}from'@shopgate/engage/components';import{SCANNER_INSTRUCTIONS}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';/**
2
+ * The Scanner Instructions component.
3
+ * @returns {JSX.Element}
4
4
  */var ScannerInstructions=function ScannerInstructions(){return React.createElement(SurroundPortals,{portalName:SCANNER_INSTRUCTIONS},React.createElement(I18n.Text,{string:"scanner.instructions"}));};export default ScannerInstructions;
@@ -1,5 +1,5 @@
1
- import React from'react';import{createPortal}from'react-dom';import PropTypes from'prop-types';import Grid from'@shopgate/pwa-common/components/Grid';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{SCANNER_BAR}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';import FlashlightButton from"./components/FlashlightButton";import ScannerInstructions from"./components/ScannerInstructions";import styles from"./style";/**
1
+ import React from'react';import{createPortal}from'react-dom';import PropTypes from'prop-types';import{Grid}from'@shopgate/engage/components';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{SCANNER_BAR}from'@shopgate/pwa-common-commerce/scanner/constants/Portals';import FlashlightButton from"./components/FlashlightButton";import ScannerInstructions from"./components/ScannerInstructions";import styles from"./style";/**
2
2
  * @param {boolean} flashlightState The on/off state of the flashlight.
3
3
  * @param {Function} onToggleFlashlight The toggle event triggered by the user.
4
- * @returns {JSX}
4
+ * @returns {React.ReactPortal}
5
5
  */var ScannerBar=function ScannerBar(_ref){var flashlightState=_ref.flashlightState,onToggleFlashlight=_ref.onToggleFlashlight;return createPortal(React.createElement(SurroundPortals,{portalName:SCANNER_BAR,portalProps:{flashlightState:flashlightState,onToggleFlashlight:onToggleFlashlight}},React.createElement(Grid,{className:"".concat(styles.container," ui-shared__scanner-bar")},React.createElement(Grid.Item,{className:styles.column},React.createElement(FlashlightButton,{onToggle:onToggleFlashlight,flashlightState:flashlightState})),React.createElement(Grid.Item,{className:styles.column},React.createElement(ScannerInstructions,null)))),document.getElementById('AppFooter'));};export default ScannerBar;
@@ -11,7 +11,7 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
11
11
  */var labelFloating=css({transform:'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)'}).toString();/**
12
12
  * The basic styles for the label.
13
13
  * @type {string}
14
- */var label=css(_extends({position:'absolute',left:0,top:24,lineHeight:'19px',pointerEvents:'none',userSelect:'none',color:themeConfig.colors.shade12,transformOrigin:'left top 0px',willChange:'transform, color',transition:"transform ".concat(easing,", color ").concat(easing)},ellipsisLine)).toString();/**
14
+ */var label=css(_extends({position:'absolute',left:0,top:24,lineHeight:'19px',pointerEvents:'none',userSelect:'none',color:themeConfig.colors.shade11,transformOrigin:'left top 0px',willChange:'transform, color',transition:"transform ".concat(easing,", color ").concat(easing)},ellipsisLine)).toString();/**
15
15
  * Gets the style classes for the label.
16
16
  * @param {boolean} focused Whether the input field is focused.
17
17
  * @param {boolean} floating Whether the label is floating.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-shared",
3
- "version": "7.25.0-beta.2",
3
+ "version": "7.26.0-beta.1",
4
4
  "description": "Shopgate's shared UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
- "@shopgate/pwa-ui-ios": "7.25.0-beta.2",
9
- "@shopgate/pwa-ui-material": "7.25.0-beta.2",
8
+ "@shopgate/pwa-ui-ios": "7.26.0-beta.1",
9
+ "@shopgate/pwa-ui-material": "7.26.0-beta.1",
10
10
  "react-day-picker": "^7.4.8"
11
11
  },
12
12
  "devDependencies": {
13
- "@shopgate/pwa-common": "7.25.0-beta.2",
14
- "@shopgate/pwa-common-commerce": "7.25.0-beta.2",
13
+ "@shopgate/pwa-common": "7.26.0-beta.1",
14
+ "@shopgate/pwa-common-commerce": "7.26.0-beta.1",
15
15
  "classnames": "2.5.1",
16
16
  "react": "~16.14.0"
17
17
  },