@shopgate/pwa-ui-material 7.30.0-alpha.7 → 7.30.0-alpha.9

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 +51 -2
  2. package/Accordion/components/AccordionContent/spec.js +32 -1
  3. package/Accordion/components/AccordionContent/style.js +9 -1
  4. package/Accordion/index.js +90 -2
  5. package/Accordion/spec.js +39 -1
  6. package/Accordion/style.js +47 -1
  7. package/AppBar/components/Below/index.js +24 -2
  8. package/AppBar/components/Center/index.js +24 -2
  9. package/AppBar/components/Field/index.js +39 -3
  10. package/AppBar/components/Field/style.js +14 -1
  11. package/AppBar/components/Icon/index.js +43 -3
  12. package/AppBar/components/Icon/style.js +14 -1
  13. package/AppBar/components/Left/index.js +24 -2
  14. package/AppBar/components/Right/index.js +24 -2
  15. package/AppBar/components/Title/index.js +37 -3
  16. package/AppBar/components/Title/style.js +11 -1
  17. package/AppBar/index.js +87 -3
  18. package/AppBar/style.js +21 -1
  19. package/BaseDialog/components/Buttons/index.js +28 -2
  20. package/BaseDialog/components/Buttons/spec.js +28 -1
  21. package/BaseDialog/components/Content/index.js +21 -2
  22. package/BaseDialog/components/Content/spec.js +17 -1
  23. package/BaseDialog/components/Title/index.js +29 -2
  24. package/BaseDialog/components/Title/spec.js +17 -1
  25. package/BaseDialog/index.js +39 -2
  26. package/BaseDialog/spec.js +39 -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 +10 -2
  31. package/NavDrawer/components/Divider/spec.js +9 -1
  32. package/NavDrawer/components/Divider/style.js +12 -2
  33. package/NavDrawer/components/Item/index.js +72 -6
  34. package/NavDrawer/components/Item/style.js +49 -1
  35. package/NavDrawer/components/Section/index.js +29 -2
  36. package/NavDrawer/components/Title/index.js +23 -2
  37. package/NavDrawer/components/Title/style.js +8 -1
  38. package/NavDrawer/index.js +132 -10
  39. package/NavDrawer/spec.js +35 -1
  40. package/NavDrawer/style.js +26 -1
  41. package/NavDrawer/transition.js +20 -1
  42. package/SnackBar/index.js +158 -23
  43. package/SnackBar/style.js +64 -2
  44. package/colors.js +4 -1
  45. package/icons/ShareIcon.js +11 -2
  46. package/index.js +5 -1
  47. package/jest.config.js +1 -1
  48. package/package.json +2 -2
package/SnackBar/index.js CHANGED
@@ -1,33 +1,168 @@
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 _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,{Component}from'react';import PropTypes from'prop-types';import{config}from'react-spring';import{Spring}from'react-spring/renderprops.cjs';import Ellipsis from'@shopgate/pwa-common/components/Ellipsis';import styles from"./style";var defaultToast={};/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { config } from 'react-spring';
5
+ import { Spring } from 'react-spring/renderprops.cjs';
6
+ import Ellipsis from '@shopgate/pwa-common/components/Ellipsis';
7
+ import styles from "./style";
8
+ const defaultToast = {};
9
+
10
+ /**
2
11
  * The SnackBar component.
3
- */var SnackBar=/*#__PURE__*/function(_Component){/**
12
+ */
13
+ class SnackBar extends Component {
14
+ /**
4
15
  * @param {Object} props The component props.
5
- */function SnackBar(props){var _this2;_classCallCheck(this,SnackBar);_this2=_callSuper(this,SnackBar,[props]);_defineProperty(_this2,"timer",null);_defineProperty(_this2,"handleAction",function(){clearTimeout(_this2.timer);_this2.props.toasts[0].action();_this2.hide();});_defineProperty(_this2,"handleEntered",function(){_this2.timer=setTimeout(_this2.hide,_this2.props.toasts[0].duration||2500);});_defineProperty(_this2,"handleRest",function(){if(_this2.state.visible){_this2.handleEntered();return;}_this2.props.removeToast();});_defineProperty(_this2,"hide",function(){_this2.setState({visible:false});});/**
6
- * Calculates the required amount of rows for the snack bar.
7
- * @param {string} message The snack bar message.
8
- * @param {string} actionLabel The snack bar action label.
9
- * @return {number}
10
- */_defineProperty(_this2,"calcRows",function(message,actionLabel){/**
11
- * Calculates the amount of rows for a passed text.
12
- * @param {string} text The input text.
16
+ */
17
+ constructor(props) {
18
+ super(props);
19
+ this.timer = null;
20
+ this.handleAction = () => {
21
+ clearTimeout(this.timer);
22
+ this.props.toasts[0].action();
23
+ this.hide();
24
+ };
25
+ this.handleEntered = () => {
26
+ this.timer = setTimeout(this.hide, this.props.toasts[0].duration || 2500);
27
+ };
28
+ this.handleRest = () => {
29
+ if (this.state.visible) {
30
+ this.handleEntered();
31
+ return;
32
+ }
33
+ this.props.removeToast();
34
+ };
35
+ this.hide = () => {
36
+ this.setState({
37
+ visible: false
38
+ });
39
+ };
40
+ /**
41
+ * Calculates the required amount of rows for the snack bar.
42
+ * @param {string} message The snack bar message.
43
+ * @param {string} actionLabel The snack bar action label.
13
44
  * @return {number}
14
- */var calc=function calc(text){return Math.max(2,Math.ceil(text.length/40));};/**
15
- * First calculate the required amount of rows for the message. Then append the action label
16
- * once per line and calculate the rows again. Since the action label occupies an own column,
17
- * we'll get an approximated number for the required rows.
18
- */return calc("".concat(message).concat(actionLabel.repeat(calc(message))));});_this2.state={visible:true};return _this2;}/**
45
+ */
46
+ this.calcRows = (message, actionLabel) => {
47
+ /**
48
+ * Calculates the amount of rows for a passed text.
49
+ * @param {string} text The input text.
50
+ * @return {number}
51
+ */
52
+ const calc = text => Math.max(2, Math.ceil(text.length / 40));
53
+ /**
54
+ * First calculate the required amount of rows for the message. Then append the action label
55
+ * once per line and calculate the rows again. Since the action label occupies an own column,
56
+ * we'll get an approximated number for the required rows.
57
+ */
58
+ return calc(`${message}${actionLabel.repeat(calc(message))}`);
59
+ };
60
+ this.state = {
61
+ visible: true
62
+ };
63
+ }
64
+
65
+ /**
19
66
  * @param {Object} nextProps The next component props.
20
- */_inherits(SnackBar,_Component);return _createClass(SnackBar,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){var hasToast=nextProps.toasts.length>0;this.setState({visible:hasToast});}/**
67
+ */
68
+ UNSAFE_componentWillReceiveProps(nextProps) {
69
+ const hasToast = nextProps.toasts.length > 0;
70
+ this.setState({
71
+ visible: hasToast
72
+ });
73
+ }
74
+
75
+ /**
21
76
  * @param {Object} nextProps The next component props.
22
77
  * @param {Object} nextState The next component state.
23
78
  * @returns {boolean}
24
- */},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps,nextState){return this.state.visible!==nextState.visible;}},{key:"snack",get:/**
79
+ */
80
+ shouldComponentUpdate(nextProps, nextState) {
81
+ return this.state.visible !== nextState.visible;
82
+ }
83
+ /**
25
84
  * Returns the first snack from the state.
26
85
  * @returns {Object}
27
- */function get(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var snack=this.props.toasts.length?this.props.toasts[0]:defaultToast;return _extends({},snack,{message:__(snack.message||'',snack.messageParams||{}),actionLabel:__(snack.actionLabel||'')});}},{key:"render",value:/**
86
+ */
87
+ get snack() {
88
+ const {
89
+ __
90
+ } = this.context.i18n();
91
+ const snack = this.props.toasts.length ? this.props.toasts[0] : defaultToast;
92
+ return {
93
+ ...snack,
94
+ message: __(snack.message || '', snack.messageParams || {}),
95
+ actionLabel: __(snack.actionLabel || '')
96
+ };
97
+ }
98
+ /**
28
99
  * @returns {JSX}
29
- */function render(){var _this3=this;var visible=this.state.visible;var _this$snack=this.snack,_this$snack$action=_this$snack.action,action=_this$snack$action===void 0?null:_this$snack$action,_this$snack$actionLab=_this$snack.actionLabel,actionLabel=_this$snack$actionLab===void 0?null:_this$snack$actionLab,_this$snack$message=_this$snack.message,message=_this$snack$message===void 0?null:_this$snack$message;// Action exits without actionLabel. Handle the whole box
30
- var boxProps=_extends({},action&&!actionLabel&&{onClick:this.handleAction});// Calculate the required amount of rows and the height of the snack bar.
31
- var rows=this.calcRows(message,actionLabel);var snackBarHeight=40+rows*20;return React.createElement("div",{className:"".concat(styles.container," ui-material__snack-bar"),style:{'--snack-bar-height':"".concat(snackBarHeight,"px")}},React.createElement(Spring,{from:{top:snackBarHeight},to:{top:0},config:config.stiff,reverse:!visible,force:true,onRest:this.handleRest},function(props){return(// eslint-disable-next-line max-len
32
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
33
- React.createElement("div",{className:styles.wrapper,style:props,"data-footer-inset-update-ignore":"true",onClick:_this3.hide},React.createElement("div",_extends({className:styles.box},boxProps),React.createElement(Ellipsis,{rows:rows},React.createElement("span",{className:styles.label,"aria-live":"assertive",role:"status"},message)),action&&actionLabel&&React.createElement("button",{className:styles.button,onClick:_this3.handleAction,type:"button","aria-hidden":true},actionLabel))));}));}}]);}(Component);_defineProperty(SnackBar,"defaultProps",{toasts:null});_defineProperty(SnackBar,"contextTypes",{i18n:PropTypes.func});export default SnackBar;
100
+ */
101
+ render() {
102
+ const {
103
+ visible
104
+ } = this.state;
105
+ const {
106
+ action = null,
107
+ actionLabel = null,
108
+ message = null
109
+ } = this.snack;
110
+
111
+ // Action exits without actionLabel. Handle the whole box
112
+ const boxProps = {
113
+ ...(action && !actionLabel && {
114
+ onClick: this.handleAction
115
+ })
116
+ };
117
+
118
+ // Calculate the required amount of rows and the height of the snack bar.
119
+ const rows = this.calcRows(message, actionLabel);
120
+ const snackBarHeight = 40 + rows * 20;
121
+ return /*#__PURE__*/React.createElement("div", {
122
+ className: `${styles.container} ui-material__snack-bar`,
123
+ style: {
124
+ '--snack-bar-height': `${snackBarHeight}px`
125
+ }
126
+ }, /*#__PURE__*/React.createElement(Spring, {
127
+ from: {
128
+ top: snackBarHeight
129
+ },
130
+ to: {
131
+ top: 0
132
+ },
133
+ config: config.stiff,
134
+ reverse: !visible,
135
+ force: true,
136
+ onRest: this.handleRest
137
+ }, props =>
138
+ /*#__PURE__*/
139
+ // eslint-disable-next-line max-len
140
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
141
+ React.createElement("div", {
142
+ className: styles.wrapper,
143
+ style: props,
144
+ "data-footer-inset-update-ignore": "true",
145
+ onClick: this.hide
146
+ }, /*#__PURE__*/React.createElement("div", _extends({
147
+ className: styles.box
148
+ }, boxProps), /*#__PURE__*/React.createElement(Ellipsis, {
149
+ rows: rows
150
+ }, /*#__PURE__*/React.createElement("span", {
151
+ className: styles.label,
152
+ "aria-live": "assertive",
153
+ role: "status"
154
+ }, message)), action && actionLabel && /*#__PURE__*/React.createElement("button", {
155
+ className: styles.button,
156
+ onClick: this.handleAction,
157
+ type: "button",
158
+ "aria-hidden": true
159
+ }, actionLabel)))));
160
+ }
161
+ }
162
+ SnackBar.defaultProps = {
163
+ toasts: null
164
+ };
165
+ SnackBar.contextTypes = {
166
+ i18n: PropTypes.func
167
+ };
168
+ export default SnackBar;
package/SnackBar/style.js CHANGED
@@ -1,2 +1,64 @@
1
- import{css}from'glamor';import Color from'color';import{themeColors,themeShadows}from'@shopgate/pwa-common/helpers/config';var backgroundColor=themeColors.lightDark;var buttonColor=themeColors.accent;var buttonColorContrast=Color(buttonColor).contrast(Color(backgroundColor));// Button color can be anything. Fall back to white if accent is too dark.
2
- var safeButtonColor=buttonColorContrast>4?buttonColor:themeColors.light;var container=css({position:'fixed',height:'var(--snack-bar-height, 80px)',bottom:'max(var(--footer-height), var(--safe-area-inset-bottom))',transition:'bottom 0.3s ease',overflow:'hidden',zIndex:6,width:'100%'});var wrapper=css({top:'var(--snack-bar-height, 80px)',display:'flex',justifyContent:'center',left:0,position:'absolute',width:'100%',zIndex:6});var box=css({alignItems:'center',background:backgroundColor,borderRadius:3,boxShadow:themeShadows.toast,color:themeColors.light,display:'flex',fontSize:'0.875rem',justifyContent:'space-between',letterSpacing:0.5,margin:16,maxWidth:344,minHeight:48,padding:'6px 16px',width:'100%'});var label=css({lineHeight:1.4,margin:'6px 0',overflow:'hidden'}).toString();var button=css({color:safeButtonColor,fontWeight:500,height:36,letterSpacing:'inherit',margin:'0 -8px 0 8px',outline:0,padding:'0 8px',textTransform:'uppercase'});export default{container:container,wrapper:wrapper,box:box,label:label,button:button};
1
+ import { css } from 'glamor';
2
+ import Color from 'color';
3
+ import { themeColors, themeShadows } from '@shopgate/pwa-common/helpers/config';
4
+ const backgroundColor = themeColors.lightDark;
5
+ const buttonColor = themeColors.accent;
6
+ const buttonColorContrast = Color(buttonColor).contrast(Color(backgroundColor));
7
+ // Button color can be anything. Fall back to white if accent is too dark.
8
+ const safeButtonColor = buttonColorContrast > 4 ? buttonColor : themeColors.light;
9
+ const container = css({
10
+ position: 'fixed',
11
+ height: 'var(--snack-bar-height, 80px)',
12
+ bottom: 'max(var(--footer-height), var(--safe-area-inset-bottom))',
13
+ transition: 'bottom 0.3s ease',
14
+ overflow: 'hidden',
15
+ zIndex: 6,
16
+ width: '100%'
17
+ });
18
+ const wrapper = css({
19
+ top: 'var(--snack-bar-height, 80px)',
20
+ display: 'flex',
21
+ justifyContent: 'center',
22
+ left: 0,
23
+ position: 'absolute',
24
+ width: '100%',
25
+ zIndex: 6
26
+ });
27
+ const box = css({
28
+ alignItems: 'center',
29
+ background: backgroundColor,
30
+ borderRadius: 3,
31
+ boxShadow: themeShadows.toast,
32
+ color: themeColors.light,
33
+ display: 'flex',
34
+ fontSize: '0.875rem',
35
+ justifyContent: 'space-between',
36
+ letterSpacing: 0.5,
37
+ margin: 16,
38
+ maxWidth: 344,
39
+ minHeight: 48,
40
+ padding: '6px 16px',
41
+ width: '100%'
42
+ });
43
+ const label = css({
44
+ lineHeight: 1.4,
45
+ margin: '6px 0',
46
+ overflow: 'hidden'
47
+ }).toString();
48
+ const button = css({
49
+ color: safeButtonColor,
50
+ fontWeight: 500,
51
+ height: 36,
52
+ letterSpacing: 'inherit',
53
+ margin: '0 -8px 0 8px',
54
+ outline: 0,
55
+ padding: '0 8px',
56
+ textTransform: 'uppercase'
57
+ });
58
+ export default {
59
+ container,
60
+ wrapper,
61
+ box,
62
+ label,
63
+ button
64
+ };
package/colors.js CHANGED
@@ -1,3 +1,6 @@
1
1
  /**
2
2
  * @TODO COLORS CHECK
3
- */export default{primary:'#303f9f'};
3
+ */
4
+ export default {
5
+ primary: '#303f9f'
6
+ };
@@ -1,5 +1,14 @@
1
- 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);}import React from'react';import Icon from'@shopgate/pwa-common/components/Icon';import{themeConfig}from'@shopgate/pwa-common/helpers/config';/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@shopgate/pwa-common/components/Icon';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+
6
+ /**
2
7
  * The Share icon component.
3
8
  * @param {Object} props The icon component properties.
4
9
  * @returns {JSX}
5
- */var ShareIcon=function ShareIcon(props){return React.createElement(Icon,_extends({content:themeConfig.icons.share},props));};export default ShareIcon;
10
+ */
11
+ const ShareIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
12
+ content: themeConfig.icons.share
13
+ }, props));
14
+ export default ShareIcon;
package/index.js CHANGED
@@ -1 +1,5 @@
1
- export{default as Accordion}from"./Accordion";export{default as AppBar}from"./AppBar";export{default as FloatingActionButton}from"./FloatingActionButton";export{default as NavDrawer}from"./NavDrawer";export{default as SnackBar}from"./SnackBar";
1
+ export { default as Accordion } from "./Accordion";
2
+ export { default as AppBar } from "./AppBar";
3
+ export { default as FloatingActionButton } from "./FloatingActionButton";
4
+ export { default as NavDrawer } from "./NavDrawer";
5
+ export { default as SnackBar } from "./SnackBar";
package/jest.config.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Require the default configuration.
2
- module.exports=require('@shopgate/pwa-unit-test/jest.config');
2
+ module.exports = require('@shopgate/pwa-unit-test/jest.config');
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-material",
3
- "version": "7.30.0-alpha.7",
3
+ "version": "7.30.0-alpha.9",
4
4
  "description": "Shopgate's material design UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "devDependencies": {
8
- "@shopgate/pwa-common": "7.30.0-alpha.7",
8
+ "@shopgate/pwa-common": "7.30.0-alpha.9",
9
9
  "react": "~16.14.0",
10
10
  "react-dom": "~16.14.0",
11
11
  "redux": "^4.2.1"