@shopgate/pwa-ui-material 7.29.9 → 7.30.0-alpha.11

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.
Files changed (48) hide show
  1. package/Accordion/components/AccordionContent/index.js +55 -2
  2. package/Accordion/components/AccordionContent/spec.js +37 -1
  3. package/Accordion/components/AccordionContent/style.js +9 -1
  4. package/Accordion/index.js +100 -2
  5. package/Accordion/spec.js +41 -1
  6. package/Accordion/style.js +47 -1
  7. package/AppBar/components/Below/index.js +26 -2
  8. package/AppBar/components/Center/index.js +26 -2
  9. package/AppBar/components/Field/index.js +48 -3
  10. package/AppBar/components/Field/style.js +14 -1
  11. package/AppBar/components/Icon/index.js +52 -3
  12. package/AppBar/components/Icon/style.js +14 -1
  13. package/AppBar/components/Left/index.js +26 -2
  14. package/AppBar/components/Right/index.js +26 -2
  15. package/AppBar/components/Title/index.js +46 -3
  16. package/AppBar/components/Title/style.js +11 -1
  17. package/AppBar/index.js +91 -3
  18. package/AppBar/style.js +21 -1
  19. package/BaseDialog/components/Buttons/index.js +29 -2
  20. package/BaseDialog/components/Buttons/spec.js +29 -1
  21. package/BaseDialog/components/Content/index.js +23 -2
  22. package/BaseDialog/components/Content/spec.js +18 -1
  23. package/BaseDialog/components/Title/index.js +32 -2
  24. package/BaseDialog/components/Title/spec.js +18 -1
  25. package/BaseDialog/index.js +46 -2
  26. package/BaseDialog/spec.js +44 -1
  27. package/BaseDialog/style.js +64 -1
  28. package/FloatingActionButton/index.js +56 -3
  29. package/FloatingActionButton/style.js +33 -1
  30. package/NavDrawer/components/Divider/index.js +11 -2
  31. package/NavDrawer/components/Divider/spec.js +10 -1
  32. package/NavDrawer/components/Divider/style.js +12 -2
  33. package/NavDrawer/components/Item/index.js +81 -6
  34. package/NavDrawer/components/Item/style.js +49 -1
  35. package/NavDrawer/components/Section/index.js +32 -2
  36. package/NavDrawer/components/Title/index.js +25 -2
  37. package/NavDrawer/components/Title/style.js +8 -1
  38. package/NavDrawer/index.js +145 -10
  39. package/NavDrawer/spec.js +41 -1
  40. package/NavDrawer/style.js +26 -1
  41. package/NavDrawer/transition.js +20 -1
  42. package/SnackBar/index.js +178 -25
  43. package/SnackBar/style.js +64 -2
  44. package/colors.js +4 -1
  45. package/icons/ShareIcon.js +12 -2
  46. package/index.js +5 -1
  47. package/jest.config.js +1 -1
  48. package/package.json +7 -7
@@ -1,5 +1,48 @@
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,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ import React, { PureComponent } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import classNames from 'classnames';
5
+ import styles from "./style";
6
+
7
+ /**
2
8
  * The AppBarTitle component.
3
- */var AppBarTitle=/*#__PURE__*/function(_PureComponent){function AppBarTitle(){_classCallCheck(this,AppBarTitle);return _callSuper(this,AppBarTitle,arguments);}_inherits(AppBarTitle,_PureComponent);return _createClass(AppBarTitle,[{key:"render",value:/**
9
+ */
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ let AppBarTitle = /*#__PURE__*/function (_PureComponent) {
12
+ function AppBarTitle() {
13
+ return _PureComponent.apply(this, arguments) || this;
14
+ }
15
+ _inheritsLoose(AppBarTitle, _PureComponent);
16
+ var _proto = AppBarTitle.prototype;
17
+ /**
4
18
  * @returns {JSX.Element}
5
- */function render(){var _this$props=this.props,onClick=_this$props.onClick,title=_this$props.title;if(!title)return null;return React.createElement("div",{className:classNames(styles,'theme__app-bar__title'),role:"heading","aria-labelledby":"titleLabel","aria-level":"1","data-test-id":"title: ".concat(title),tabIndex:-1},React.createElement("span",{role:"presentation",onClick:onClick,id:"titleLabel",dangerouslySetInnerHTML:{__html:title}}));}}]);}(PureComponent);_defineProperty(AppBarTitle,"defaultProps",{onClick:null});export default AppBarTitle;
19
+ */
20
+ _proto.render = function render() {
21
+ const {
22
+ onClick,
23
+ title
24
+ } = this.props;
25
+ if (!title) return null;
26
+ return /*#__PURE__*/_jsx("div", {
27
+ className: classNames(styles, 'theme__app-bar__title'),
28
+ role: "heading",
29
+ "aria-labelledby": "titleLabel",
30
+ "aria-level": "1",
31
+ "data-test-id": `title: ${title}`,
32
+ tabIndex: -1,
33
+ children: /*#__PURE__*/_jsx("span", {
34
+ role: "presentation",
35
+ onClick: onClick,
36
+ id: "titleLabel",
37
+ dangerouslySetInnerHTML: {
38
+ __html: title
39
+ }
40
+ })
41
+ });
42
+ };
43
+ return AppBarTitle;
44
+ }(PureComponent);
45
+ AppBarTitle.defaultProps = {
46
+ onClick: null
47
+ };
48
+ export default AppBarTitle;
@@ -1 +1,11 @@
1
- import{css}from'glamor';export default css({fontSize:20,fontWeight:500,flexGrow:1,lineHeight:'56px',overflow:'hidden',padding:'0 16px',textOverflow:'ellipsis',whiteSpace:'nowrap'});
1
+ import { css } from 'glamor';
2
+ export default css({
3
+ fontSize: 20,
4
+ fontWeight: 500,
5
+ flexGrow: 1,
6
+ lineHeight: '56px',
7
+ overflow: 'hidden',
8
+ padding: '0 16px',
9
+ textOverflow: 'ellipsis',
10
+ whiteSpace: 'nowrap'
11
+ });
package/AppBar/index.js CHANGED
@@ -1,8 +1,96 @@
1
- import React,{useMemo,useRef,useLayoutEffect}from'react';import PropTypes from'prop-types';import{getAbsoluteHeight}from'@shopgate/pwa-common/helpers/dom';import{themeShadows,themeColors}from'@shopgate/pwa-common/helpers/config';import{setCSSCustomProp}from'@shopgate/engage/styles';import{SurroundPortals}from'@shopgate/engage/components';import{APP_BAR_CONTENT}from'@shopgate/engage/core/constants';import Field from"./components/Field";import Icon from"./components/Icon";import Title from"./components/Title";import Right from"./components/Right";import Center from"./components/Center";import Left from"./components/Left";import Below from"./components/Below";import styles from"./style";/**
1
+ import React, { useMemo, useRef, useLayoutEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { getAbsoluteHeight } from '@shopgate/pwa-common/helpers/dom';
4
+ import { themeShadows, themeColors } from '@shopgate/pwa-common/helpers/config';
5
+ import { setCSSCustomProp } from '@shopgate/engage/styles';
6
+ import { SurroundPortals } from '@shopgate/engage/components';
7
+ import { APP_BAR_CONTENT } from '@shopgate/engage/core/constants';
8
+ import Field from "./components/Field";
9
+ import Icon from "./components/Icon";
10
+ import Title from "./components/Title";
11
+ import Right from "./components/Right";
12
+ import Center from "./components/Center";
13
+ import Left from "./components/Left";
14
+ import Below from "./components/Below";
15
+ import styles from "./style";
16
+
17
+ /**
2
18
  * Updates the --app-bar-height custom property
3
19
  * @param {Object} ref The app bar ref.
4
- */var updateAppBarHeight=function updateAppBarHeight(ref){if(!ref.current){return;}setCSSCustomProp('--app-bar-height',"".concat(getAbsoluteHeight(ref.current),"px"));};/**
20
+ */
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ const updateAppBarHeight = ref => {
23
+ if (!ref.current) {
24
+ return;
25
+ }
26
+ setCSSCustomProp('--app-bar-height', `${getAbsoluteHeight(ref.current)}px`);
27
+ };
28
+
29
+ /**
5
30
  * The AppBar component
6
31
  * @param {Object} props The component props.
7
32
  * @returns {JSX}
8
- */var AppBar=function AppBar(_ref){var below=_ref.below,center=_ref.center,left=_ref.left,right=_ref.right,backgroundColor=_ref.backgroundColor,textColor=_ref.textColor,shadow=_ref.shadow;var contentRef=useRef(null);var style=useMemo(function(){return{background:backgroundColor,color:textColor,boxShadow:!shadow?'none':themeShadows.material};},[backgroundColor,shadow,textColor]);var observer=useMemo(function(){return new MutationObserver(function(){updateAppBarHeight(contentRef);});},[contentRef]);useLayoutEffect(function(){updateAppBarHeight(contentRef);observer.observe(contentRef.current,{childList:true});return function(){observer.disconnect();};},[contentRef,observer]);return React.createElement("header",{ref:contentRef,className:"".concat(styles.outer," ui-material__app-bar"),"data-test-id":"Navigator",role:"banner",style:style},React.createElement(SurroundPortals,{portalName:APP_BAR_CONTENT},React.createElement("div",{className:styles.inner},React.createElement(Left,{elements:left}),React.createElement(Center,{elements:center}),React.createElement(Right,{elements:right}))),React.createElement(Below,{elements:below}));};AppBar.defaultProps={backgroundColor:themeColors.light,below:null,center:null,left:null,right:null,shadow:true,textColor:themeColors.dark};AppBar.Field=Field;AppBar.Icon=Icon;AppBar.Title=Title;export default AppBar;
33
+ */
34
+ const AppBar = ({
35
+ below,
36
+ center,
37
+ left,
38
+ right,
39
+ backgroundColor,
40
+ textColor,
41
+ shadow
42
+ }) => {
43
+ const contentRef = useRef(null);
44
+ const style = useMemo(() => ({
45
+ background: backgroundColor,
46
+ color: textColor,
47
+ boxShadow: !shadow ? 'none' : themeShadows.material
48
+ }), [backgroundColor, shadow, textColor]);
49
+ const observer = useMemo(() => new MutationObserver(() => {
50
+ updateAppBarHeight(contentRef);
51
+ }), [contentRef]);
52
+ useLayoutEffect(() => {
53
+ updateAppBarHeight(contentRef);
54
+ observer.observe(contentRef.current, {
55
+ childList: true
56
+ });
57
+ return () => {
58
+ observer.disconnect();
59
+ };
60
+ }, [contentRef, observer]);
61
+ return /*#__PURE__*/_jsxs("header", {
62
+ ref: contentRef,
63
+ className: `${styles.outer} ui-material__app-bar`,
64
+ "data-test-id": "Navigator",
65
+ role: "banner",
66
+ style: style,
67
+ children: [/*#__PURE__*/_jsx(SurroundPortals, {
68
+ portalName: APP_BAR_CONTENT,
69
+ children: /*#__PURE__*/_jsxs("div", {
70
+ className: styles.inner,
71
+ children: [/*#__PURE__*/_jsx(Left, {
72
+ elements: left
73
+ }), /*#__PURE__*/_jsx(Center, {
74
+ elements: center
75
+ }), /*#__PURE__*/_jsx(Right, {
76
+ elements: right
77
+ })]
78
+ })
79
+ }), /*#__PURE__*/_jsx(Below, {
80
+ elements: below
81
+ })]
82
+ });
83
+ };
84
+ AppBar.defaultProps = {
85
+ backgroundColor: themeColors.light,
86
+ below: null,
87
+ center: null,
88
+ left: null,
89
+ right: null,
90
+ shadow: true,
91
+ textColor: themeColors.dark
92
+ };
93
+ AppBar.Field = Field;
94
+ AppBar.Icon = Icon;
95
+ AppBar.Title = Title;
96
+ export default AppBar;
package/AppBar/style.js CHANGED
@@ -1 +1,21 @@
1
- import{css}from'glamor';var outer=css({boxSizing:'content-box',left:0,paddingTop:'var(--safe-area-inset-top)',position:'sticky',top:0,width:'100%',zIndex:15});var inner=css({background:'inherit',display:'flex',justifyContent:'space-between',position:'relative',zIndex:14});export default{outer:outer,inner:inner};
1
+ import { css } from 'glamor';
2
+ const outer = css({
3
+ boxSizing: 'content-box',
4
+ left: 0,
5
+ paddingTop: 'var(--safe-area-inset-top)',
6
+ position: 'sticky',
7
+ top: 0,
8
+ width: '100%',
9
+ zIndex: 15
10
+ });
11
+ const inner = css({
12
+ background: 'inherit',
13
+ display: 'flex',
14
+ justifyContent: 'space-between',
15
+ position: 'relative',
16
+ zIndex: 14
17
+ });
18
+ export default {
19
+ outer,
20
+ inner
21
+ };
@@ -1,4 +1,31 @@
1
- import React,{memo}from'react';import PropTypes from'prop-types';import I18n from'@shopgate/pwa-common/components/I18n';import Button from'@shopgate/pwa-ui-shared/Button';import styles from"../../style";/**
1
+ import React, { memo } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import I18n from '@shopgate/pwa-common/components/I18n';
4
+ import Button from '@shopgate/pwa-ui-shared/Button';
5
+ import styles from "../../style";
6
+
7
+ /**
2
8
  * @param {Object} props The component props.
3
9
  * @returns {JSX}
4
- */var Buttons=function Buttons(_ref){var actions=_ref.actions;return actions.map(function(_ref2){var label=_ref2.label,action=_ref2.action,_ref2$disabled=_ref2.disabled,disabled=_ref2$disabled===void 0?false:_ref2$disabled;return React.createElement(Button,{key:label,className:styles.button,flat:true,type:"primary",onClick:action,disabled:disabled},React.createElement(I18n.Text,{string:label}));});};Buttons.defaultProps={actions:[]};export default memo(Buttons);
10
+ */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const Buttons = ({
13
+ actions
14
+ }) => actions.map(({
15
+ label,
16
+ action,
17
+ disabled = false
18
+ }) => /*#__PURE__*/_jsx(Button, {
19
+ className: styles.button,
20
+ flat: true,
21
+ type: "primary",
22
+ onClick: action,
23
+ disabled: disabled,
24
+ children: /*#__PURE__*/_jsx(I18n.Text, {
25
+ string: label
26
+ })
27
+ }, label));
28
+ Buttons.defaultProps = {
29
+ actions: []
30
+ };
31
+ export default /*#__PURE__*/memo(Buttons);
@@ -1 +1,29 @@
1
- import React from'react';import{shallow}from'enzyme';import Button from'@shopgate/pwa-ui-shared/Button';import Buttons from"./index";var actions=[{label:'action0',action:jest.fn()},{label:'action1',action:jest.fn()},{label:'action2',action:jest.fn()}];describe('<Buttons />',function(){it('should not render if no actions are passed',function(){var wrapper=shallow(React.createElement(Buttons,null));expect(wrapper).toMatchSnapshot();expect(wrapper.instance()).toEqual(null);});it('should render buttons',function(){var wrapper=shallow(React.createElement(Buttons,{actions:actions}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(Button).length).toBe(actions.length);});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import Button from '@shopgate/pwa-ui-shared/Button';
4
+ import Buttons from "./index";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const actions = [{
7
+ label: 'action0',
8
+ action: jest.fn()
9
+ }, {
10
+ label: 'action1',
11
+ action: jest.fn()
12
+ }, {
13
+ label: 'action2',
14
+ action: jest.fn()
15
+ }];
16
+ describe('<Buttons />', () => {
17
+ it('should not render if no actions are passed', () => {
18
+ const wrapper = shallow(/*#__PURE__*/_jsx(Buttons, {}));
19
+ expect(wrapper).toMatchSnapshot();
20
+ expect(wrapper.instance()).toEqual(null);
21
+ });
22
+ it('should render buttons', () => {
23
+ const wrapper = shallow(/*#__PURE__*/_jsx(Buttons, {
24
+ actions: actions
25
+ }));
26
+ expect(wrapper).toMatchSnapshot();
27
+ expect(wrapper.find(Button).length).toBe(actions.length);
28
+ });
29
+ });
@@ -1,4 +1,25 @@
1
- import React,{memo}from'react';import PropTypes from'prop-types';import styles from"../../style";/**
1
+ import React, { memo } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styles from "../../style";
4
+
5
+ /**
2
6
  * @param {Object} props The component props.
3
7
  * @returns {JSX}
4
- */var Content=function Content(_ref){var content=_ref.content;if(!content){return null;}return React.createElement("div",{className:styles.body,id:"basicDialogDesc"},content);};Content.defaultProps={content:null};export default memo(Content);
8
+ */
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const Content = ({
11
+ content
12
+ }) => {
13
+ if (!content) {
14
+ return null;
15
+ }
16
+ return /*#__PURE__*/_jsx("div", {
17
+ className: styles.body,
18
+ id: "basicDialogDesc",
19
+ children: content
20
+ });
21
+ };
22
+ Content.defaultProps = {
23
+ content: null
24
+ };
25
+ export default /*#__PURE__*/memo(Content);
@@ -1 +1,18 @@
1
- import React from'react';import{shallow}from'enzyme';import Content from"./index";describe('<Content />',function(){it('should not render if no content is passed',function(){var wrapper=shallow(React.createElement(Content,null));expect(wrapper).toMatchSnapshot();expect(wrapper.instance()).toEqual(null);});it('should render content components',function(){var wrapper=shallow(React.createElement(Content,{content:"Hello World"}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('[id="basicDialogDesc"]').length).toBe(1);});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import Content from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ describe('<Content />', () => {
6
+ it('should not render if no content is passed', () => {
7
+ const wrapper = shallow(/*#__PURE__*/_jsx(Content, {}));
8
+ expect(wrapper).toMatchSnapshot();
9
+ expect(wrapper.instance()).toEqual(null);
10
+ });
11
+ it('should render content components', () => {
12
+ const wrapper = shallow(/*#__PURE__*/_jsx(Content, {
13
+ content: "Hello World"
14
+ }));
15
+ expect(wrapper).toMatchSnapshot();
16
+ expect(wrapper.find('[id="basicDialogDesc"]').length).toBe(1);
17
+ });
18
+ });
@@ -1,4 +1,34 @@
1
- import React,{memo}from'react';import PropTypes from'prop-types';import Ellipsis from'@shopgate/pwa-common/components/Ellipsis';import I18n from'@shopgate/pwa-common/components/I18n';import styles from"../../style";/**
1
+ import React, { memo } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Ellipsis from '@shopgate/pwa-common/components/Ellipsis';
4
+ import I18n from '@shopgate/pwa-common/components/I18n';
5
+ import styles from "../../style";
6
+
7
+ /**
2
8
  * @param {Object} props The component props.
3
9
  * @returns {JSX}
4
- */var Title=function Title(_ref){var title=_ref.title;if(!title){return null;}return React.createElement("div",{className:styles.title,id:"basicDialogTitle",role:"heading","aria-level":"2"},React.createElement(Ellipsis,{rows:3},typeof title==='string'?React.createElement(I18n.Text,{string:title}):title));};Title.defaultProps={title:null};export default memo(Title);
10
+ */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const Title = ({
13
+ title
14
+ }) => {
15
+ if (!title) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/_jsx("div", {
19
+ className: styles.title,
20
+ id: "basicDialogTitle",
21
+ role: "heading",
22
+ "aria-level": "2",
23
+ children: /*#__PURE__*/_jsx(Ellipsis, {
24
+ rows: 3,
25
+ children: typeof title === 'string' ? /*#__PURE__*/_jsx(I18n.Text, {
26
+ string: title
27
+ }) : title
28
+ })
29
+ });
30
+ };
31
+ Title.defaultProps = {
32
+ title: null
33
+ };
34
+ export default /*#__PURE__*/memo(Title);
@@ -1 +1,18 @@
1
- import React from'react';import{shallow}from'enzyme';import Title from"./index";describe('<Title />',function(){it('should not render without a title',function(){var wrapper=shallow(React.createElement(Title,null));expect(wrapper).toMatchSnapshot();expect(wrapper.instance()).toEqual(null);});it('should render with a title',function(){var wrapper=shallow(React.createElement(Title,{title:"Some test title"}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('[id="basicDialogTitle"]').length).toBe(1);});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import Title from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ describe('<Title />', () => {
6
+ it('should not render without a title', () => {
7
+ const wrapper = shallow(/*#__PURE__*/_jsx(Title, {}));
8
+ expect(wrapper).toMatchSnapshot();
9
+ expect(wrapper.instance()).toEqual(null);
10
+ });
11
+ it('should render with a title', () => {
12
+ const wrapper = shallow(/*#__PURE__*/_jsx(Title, {
13
+ title: "Some test title"
14
+ }));
15
+ expect(wrapper).toMatchSnapshot();
16
+ expect(wrapper.find('[id="basicDialogTitle"]').length).toBe(1);
17
+ });
18
+ });
@@ -1,4 +1,12 @@
1
- import React from'react';import PropTypes from'prop-types';import{FocusTrap}from'@shopgate/engage/a11y/components';import Title from"./components/Title";import Content from"./components/Content";import Buttons from"./components/Buttons";import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { FocusTrap } from '@shopgate/engage/a11y/components';
4
+ import Title from "./components/Title";
5
+ import Content from "./components/Content";
6
+ import Buttons from "./components/Buttons";
7
+ import styles from "./style";
8
+
9
+ /**
2
10
  * This component renders a basic dialog in Google Material Design.
3
11
  * @param {Object} props The component props.
4
12
  * @param {ReactNode} props.children The component children to render in the dialog.
@@ -6,4 +14,40 @@ import React from'react';import PropTypes from'prop-types';import{FocusTrap}from
6
14
  * the label and the callback to invoke when the action is triggered
7
15
  * @param {string | ReactNode} props.title The title of the dialog.
8
16
  * @return {JSX.Element} The rendered dialog.
9
- */var BasicDialog=function BasicDialog(_ref){var children=_ref.children,actions=_ref.actions,title=_ref.title;return React.createElement(FocusTrap,null,React.createElement("div",{className:"".concat(styles.container," ui-material__base-dialog"),"data-test-id":"basicDialog",role:"alertdialog","aria-modal":true,"aria-labelledby":"basicDialogTitle basicDialogDesc"},React.createElement("div",{className:styles.content},React.createElement(Title,{title:title}),React.createElement(Content,{content:children})),React.createElement("div",{className:styles.actions},React.createElement("div",{className:styles.innerActions},React.createElement(Buttons,{actions:actions})))));};BasicDialog.defaultProps={children:null,actions:[],title:null};export default BasicDialog;
17
+ */
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
+ const BasicDialog = ({
20
+ children,
21
+ actions,
22
+ title
23
+ }) => /*#__PURE__*/_jsx(FocusTrap, {
24
+ children: /*#__PURE__*/_jsxs("div", {
25
+ className: `${styles.container} ui-material__base-dialog`,
26
+ "data-test-id": "basicDialog",
27
+ role: "alertdialog",
28
+ "aria-modal": true,
29
+ "aria-labelledby": "basicDialogTitle basicDialogDesc",
30
+ children: [/*#__PURE__*/_jsxs("div", {
31
+ className: styles.content,
32
+ children: [/*#__PURE__*/_jsx(Title, {
33
+ title: title
34
+ }), /*#__PURE__*/_jsx(Content, {
35
+ content: children
36
+ })]
37
+ }), /*#__PURE__*/_jsx("div", {
38
+ className: styles.actions,
39
+ children: /*#__PURE__*/_jsx("div", {
40
+ className: styles.innerActions,
41
+ children: /*#__PURE__*/_jsx(Buttons, {
42
+ actions: actions
43
+ })
44
+ })
45
+ })]
46
+ })
47
+ });
48
+ BasicDialog.defaultProps = {
49
+ children: null,
50
+ actions: [],
51
+ title: null
52
+ };
53
+ export default BasicDialog;
@@ -1 +1,44 @@
1
- import React from'react';import{shallow}from'enzyme';import Title from"./components/Title";import Content from"./components/Content";import Buttons from"./components/Buttons";import BasicDialog from"./index";var props={title:'Hello World',children:React.createElement("div",null,"Hello World"),actions:[{label:'action0',action:jest.fn()},{label:'action1',action:jest.fn()},{label:'action2',action:jest.fn()}]};jest.mock('@shopgate/engage/a11y/components');describe('<BasicDialog />',function(){it('should render with minimal props',function(){var wrapper=shallow(React.createElement(BasicDialog,{actions:[]}));expect(wrapper).toMatchSnapshot();});it('should render as expected',function(){var wrapper=shallow(React.createElement(BasicDialog,props));expect(wrapper).toMatchSnapshot();expect(wrapper.find(Title).length).toBe(1);expect(wrapper.find(Title).props().title).toEqual(props.title);expect(wrapper.find(Content).length).toBe(1);expect(wrapper.find(Content).props().content).toEqual(props.children);expect(wrapper.find(Buttons).length).toBe(1);expect(wrapper.find(Buttons).props().actions).toEqual(props.actions);});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import Title from "./components/Title";
4
+ import Content from "./components/Content";
5
+ import Buttons from "./components/Buttons";
6
+ import BasicDialog from "./index";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const props = {
9
+ title: 'Hello World',
10
+ children: /*#__PURE__*/_jsx("div", {
11
+ children: "Hello World"
12
+ }),
13
+ actions: [{
14
+ label: 'action0',
15
+ action: jest.fn()
16
+ }, {
17
+ label: 'action1',
18
+ action: jest.fn()
19
+ }, {
20
+ label: 'action2',
21
+ action: jest.fn()
22
+ }]
23
+ };
24
+ jest.mock('@shopgate/engage/a11y/components');
25
+ describe('<BasicDialog />', () => {
26
+ it('should render with minimal props', () => {
27
+ const wrapper = shallow(/*#__PURE__*/_jsx(BasicDialog, {
28
+ actions: []
29
+ }));
30
+ expect(wrapper).toMatchSnapshot();
31
+ });
32
+ it('should render as expected', () => {
33
+ const wrapper = shallow(/*#__PURE__*/_jsx(BasicDialog, {
34
+ ...props
35
+ }));
36
+ expect(wrapper).toMatchSnapshot();
37
+ expect(wrapper.find(Title).length).toBe(1);
38
+ expect(wrapper.find(Title).props().title).toEqual(props.title);
39
+ expect(wrapper.find(Content).length).toBe(1);
40
+ expect(wrapper.find(Content).props().content).toEqual(props.children);
41
+ expect(wrapper.find(Buttons).length).toBe(1);
42
+ expect(wrapper.find(Buttons).props().actions).toEqual(props.actions);
43
+ });
44
+ });
@@ -1 +1,64 @@
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var outerGap=40;var container=css(_defineProperty(_defineProperty({position:'relative',display:'flex',flexDirection:'column',width:"calc(100vw - ".concat(outerGap*2,"px)"),maxHeight:"calc(100vh - ".concat(outerGap*2,"px)"),borderRadius:2,boxShadow:themeConfig.shadows.dialog,background:themeConfig.colors.light},responsiveMediaQuery('>xs',{webOnly:true}),{width:"calc(80vh - ".concat(outerGap*2,"px)"),maxHeight:"calc(80vh - ".concat(outerGap*2,"px)")}),responsiveMediaQuery('>md',{webOnly:true}),{width:"calc(var(--page-content-width) * 0.5 - ".concat(outerGap*2,"px)"),maxHeight:"calc(var(--page-content-width) * 0.5 - ".concat(outerGap*2,"px)")})).toString();var content=css({padding:themeConfig.variables.gap.small*3,overflowY:'auto'}).toString();var title=css({fontSize:'1.25em',lineHeight:themeConfig.typography.lineHeight,fontWeight:500,paddingBottom:themeConfig.variables.gap.small,marginTop:'-.25em'}).toString();var body=css({color:themeConfig.colors.shade6,flexGrow:1,overflow:'auto'}).toString();var actions=css({alignSelf:'flex-end',padding:themeConfig.variables.gap.small}).toString();var innerActions=css({display:'flex',flexWrap:'wrap',justifyContent:'flex-end'}).toString();var button=css({marginRight:"-".concat(themeConfig.variables.gap.small/2,"px"),textAlign:'right'}).toString();export default{container:container,content:content,title:title,body:body,actions:actions,innerActions:innerActions,button:button};
1
+ import { css } from 'glamor';
2
+ import { responsiveMediaQuery } from '@shopgate/engage/styles';
3
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
+ const outerGap = 40;
5
+ const container = css({
6
+ position: 'relative',
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ width: `calc(100vw - ${outerGap * 2}px)`,
10
+ maxHeight: `calc(100vh - ${outerGap * 2}px)`,
11
+ borderRadius: 2,
12
+ boxShadow: themeConfig.shadows.dialog,
13
+ background: themeConfig.colors.light,
14
+ [responsiveMediaQuery('>xs', {
15
+ webOnly: true
16
+ })]: {
17
+ width: `calc(80vh - ${outerGap * 2}px)`,
18
+ maxHeight: `calc(80vh - ${outerGap * 2}px)`
19
+ },
20
+ [responsiveMediaQuery('>md', {
21
+ webOnly: true
22
+ })]: {
23
+ width: `calc(var(--page-content-width) * 0.5 - ${outerGap * 2}px)`,
24
+ maxHeight: `calc(var(--page-content-width) * 0.5 - ${outerGap * 2}px)`
25
+ }
26
+ }).toString();
27
+ const content = css({
28
+ padding: themeConfig.variables.gap.small * 3,
29
+ overflowY: 'auto'
30
+ }).toString();
31
+ const title = css({
32
+ fontSize: '1.25em',
33
+ lineHeight: themeConfig.typography.lineHeight,
34
+ fontWeight: 500,
35
+ paddingBottom: themeConfig.variables.gap.small,
36
+ marginTop: '-.25em'
37
+ }).toString();
38
+ const body = css({
39
+ color: themeConfig.colors.shade6,
40
+ flexGrow: 1,
41
+ overflow: 'auto'
42
+ }).toString();
43
+ const actions = css({
44
+ alignSelf: 'flex-end',
45
+ padding: themeConfig.variables.gap.small
46
+ }).toString();
47
+ const innerActions = css({
48
+ display: 'flex',
49
+ flexWrap: 'wrap',
50
+ justifyContent: 'flex-end'
51
+ }).toString();
52
+ const button = css({
53
+ marginRight: `-${themeConfig.variables.gap.small / 2}px`,
54
+ textAlign: 'right'
55
+ }).toString();
56
+ export default {
57
+ container,
58
+ content,
59
+ title,
60
+ body,
61
+ actions,
62
+ innerActions,
63
+ button
64
+ };
@@ -1,6 +1,59 @@
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 colors from"../colors";import styles from"./style";var SIZE_BIG='big';var SIZE_SMALL='small';/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import colors from "../colors";
5
+ import styles from "./style";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const SIZE_BIG = 'big';
8
+ const SIZE_SMALL = 'small';
9
+ /**
2
10
  * The FloatingActionButton component.
3
11
  * @param {Object} props The component props.
4
12
  * @return {JSX}
5
- */var FloatingActionButton=function FloatingActionButton(props){var background=props.background,children=props.children,className=props.className,disabled=props.disabled,onClick=props.onClick,raised=props.raised,ref=props.ref,size=props.size,type=props.type;var classes=classNames('floating-action-button','ui-material__floating-action-button',styles.button,_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},className,className),styles.buttonSmall,size===SIZE_SMALL),styles.buttonSmall,size===SIZE_SMALL),styles.buttonLarge,size===SIZE_BIG),styles.buttonShadow,raised));return(// eslint-disable-next-line react/button-has-type
6
- React.createElement("button",{className:classes,disabled:disabled,onClick:onClick,ref:ref,style:{background:background},type:type,"data-test-id":props.testId},children));};FloatingActionButton.defaultProps={background:"var(--color-primary, ".concat(colors.primary,")"),className:null,disabled:false,onClick:function onClick(){},raised:true,ref:null,size:SIZE_BIG,testId:null,type:'button'};export default FloatingActionButton;
13
+ */
14
+ const FloatingActionButton = props => {
15
+ const {
16
+ background,
17
+ children,
18
+ className,
19
+ disabled,
20
+ onClick,
21
+ raised,
22
+ ref,
23
+ size,
24
+ type
25
+ } = props;
26
+ const classes = classNames('floating-action-button', 'ui-material__floating-action-button', styles.button, {
27
+ [className]: className,
28
+ [styles.buttonSmall]: size === SIZE_SMALL,
29
+ [styles.buttonSmall]: size === SIZE_SMALL,
30
+ [styles.buttonLarge]: size === SIZE_BIG,
31
+ [styles.buttonShadow]: raised
32
+ });
33
+ return /*#__PURE__*/_jsx("button", {
34
+ className: classes,
35
+ disabled: disabled,
36
+ onClick: onClick,
37
+ ref: ref,
38
+ style: {
39
+ background
40
+ }
41
+ // eslint-disable-next-line react/button-has-type
42
+ ,
43
+ type: type,
44
+ "data-test-id": props.testId,
45
+ children: children
46
+ });
47
+ };
48
+ FloatingActionButton.defaultProps = {
49
+ background: `var(--color-primary, ${colors.primary})`,
50
+ className: null,
51
+ disabled: false,
52
+ onClick: () => {},
53
+ raised: true,
54
+ ref: null,
55
+ size: SIZE_BIG,
56
+ testId: null,
57
+ type: 'button'
58
+ };
59
+ export default FloatingActionButton;
@@ -1 +1,33 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var shadows=themeConfig.shadows;var button=css({borderRadius:'50%',outline:0,overflow:'hidden',padding:0,position:'relative',zIndex:1,':disabled':{cursor:'not-allowed'}}).toString();var buttonSmall=css({height:40,width:40});var buttonLarge=css({height:56,width:56});var buttonShadow=css({boxShadow:shadows.buttons.elevated});export default{button:button,buttonSmall:buttonSmall,buttonLarge:buttonLarge,buttonShadow:buttonShadow};
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ const {
4
+ shadows
5
+ } = themeConfig;
6
+ const button = css({
7
+ borderRadius: '50%',
8
+ outline: 0,
9
+ overflow: 'hidden',
10
+ padding: 0,
11
+ position: 'relative',
12
+ zIndex: 1,
13
+ ':disabled': {
14
+ cursor: 'not-allowed'
15
+ }
16
+ }).toString();
17
+ const buttonSmall = css({
18
+ height: 40,
19
+ width: 40
20
+ });
21
+ const buttonLarge = css({
22
+ height: 56,
23
+ width: 56
24
+ });
25
+ const buttonShadow = css({
26
+ boxShadow: shadows.buttons.elevated
27
+ });
28
+ export default {
29
+ button,
30
+ buttonSmall,
31
+ buttonLarge,
32
+ buttonShadow
33
+ };
@@ -1,3 +1,12 @@
1
- import React from'react';import styles from"./style";/**
1
+ import React from 'react';
2
+ import styles from "./style";
3
+
4
+ /**
2
5
  * @returns {JSX}
3
- */var NavDrawerDivider=function NavDrawerDivider(){return React.createElement("hr",{"aria-hidden":true,className:styles});};export default NavDrawerDivider;
6
+ */
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const NavDrawerDivider = () => /*#__PURE__*/_jsx("hr", {
9
+ "aria-hidden": true,
10
+ className: styles
11
+ });
12
+ export default NavDrawerDivider;