@zohodesk/react-cli 1.1.7 → 1.1.8-exp.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1293 -1251
  6. package/bin/cli.js +497 -497
  7. package/docs/ComposeMinification.md +13 -13
  8. package/docs/CustomChunks.md +29 -26
  9. package/docs/DevServerPort.md +39 -39
  10. package/docs/DevStart.md +18 -18
  11. package/docs/HoverActive.md +12 -12
  12. package/docs/InstallNode.md +28 -28
  13. package/docs/MarkdownParser.md +17 -17
  14. package/docs/ReactLive.md +13 -13
  15. package/docs/SelectorWeight.md +8 -8
  16. package/docs/TODOS.md +10 -10
  17. package/docs/ValueReplacer.md +60 -60
  18. package/docs/VariableConversion.md +729 -729
  19. package/docs/patternFiltering.md +56 -56
  20. package/docs/warnings_while_install.txt +35 -35
  21. package/files/eslintrc.js +62 -62
  22. package/files/prettierrc.js +3 -3
  23. package/lib/common/splitChunks.js +65 -45
  24. package/lib/common/testPattern.js +9 -9
  25. package/lib/configs/webpack.css.umd.config.js +4 -4
  26. package/lib/configs/webpack.dev.config.js +24 -3
  27. package/lib/configs/webpack.docs.config.js +22 -3
  28. package/lib/configs/webpack.impact.config.js +4 -2
  29. package/lib/configs/webpack.prod.config.js +6 -3
  30. package/lib/deprecationLogger.js +41 -0
  31. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  32. package/lib/loaderUtils/getCSSLoaders.js +77 -56
  33. package/lib/loaders/workerLoader.js +9 -9
  34. package/lib/pluginUtils/getDevPlugins.js +8 -7
  35. package/lib/pluginUtils/getProdPlugins.js +6 -6
  36. package/lib/plugins/CustomAttributePlugin.md +35 -35
  37. package/lib/plugins/EFCPlugin.md +6 -6
  38. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  39. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  40. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  41. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  42. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  43. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  44. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  45. package/lib/plugins/ResourceHintsPlugin.js +30 -20
  46. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  47. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  48. package/lib/plugins/SelectorPlugin.js +29 -29
  49. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  50. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  51. package/lib/plugins/VariableConversionCollector.js +59 -59
  52. package/lib/plugins/utils/fileHandling.js +35 -42
  53. package/lib/plugins/variableConvertorUtils.js +9 -9
  54. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  55. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  56. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  57. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  58. package/lib/schemas/index.js +19 -36
  59. package/lib/sh/pre-commit.sh +34 -34
  60. package/lib/sh/reportPublish.sh +45 -45
  61. package/lib/utils/buildstats.html +148 -148
  62. package/lib/utils/cssClassNameGenerate.js +13 -13
  63. package/lib/utils/deprecationSupport.js +123 -0
  64. package/lib/utils/getOptions.js +18 -78
  65. package/lib/utils/resultSchema.json +73 -73
  66. package/npm-shrinkwrap.json +14454 -33393
  67. package/npm8.md +9 -9
  68. package/package.json +123 -123
  69. package/postpublish.js +8 -8
  70. package/result.json +1 -0
  71. package/templates/app/.eslintrc.js +140 -140
  72. package/templates/app/README.md +12 -12
  73. package/templates/app/app/index.html +24 -24
  74. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  75. package/templates/app/app/properties/i18nkeys.json +3 -3
  76. package/templates/app/docs/all.html +69 -69
  77. package/templates/app/mockapi/index.js +18 -18
  78. package/templates/app/package.json +37 -37
  79. package/templates/app/src/actions/SampleActions/index.js +37 -37
  80. package/templates/app/src/actions/index.js +65 -65
  81. package/templates/app/src/appUrls.js +19 -19
  82. package/templates/app/src/components/Alert/Alert.js +134 -134
  83. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  84. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  85. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  86. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  87. package/templates/app/src/components/Sample/SampleList.js +61 -61
  88. package/templates/app/src/components/Slider/Slider.css +41 -41
  89. package/templates/app/src/components/Slider/Slider.js +55 -55
  90. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  91. package/templates/app/src/containers/AppContainer/index.js +96 -96
  92. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  93. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  94. package/templates/app/src/containers/DevTools/index.js +10 -10
  95. package/templates/app/src/containers/Header/index.js +67 -67
  96. package/templates/app/src/containers/Header/index.module.css +43 -43
  97. package/templates/app/src/containers/Redirect/index.js +63 -63
  98. package/templates/app/src/containers/Redirector/index.js +47 -47
  99. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  100. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  101. package/templates/app/src/historyChange.js +5 -5
  102. package/templates/app/src/index.html +10 -10
  103. package/templates/app/src/index.js +24 -24
  104. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  105. package/templates/app/src/reducers/alertData.js +11 -11
  106. package/templates/app/src/reducers/index.js +6 -6
  107. package/templates/app/src/reducers/samples.js +19 -19
  108. package/templates/app/src/store/configureStore.dev.js +51 -51
  109. package/templates/app/src/store/configureStore.js +5 -5
  110. package/templates/app/src/store/configureStore.prod.js +26 -26
  111. package/templates/app/src/util/Common.js +5 -5
  112. package/templates/app/src/util/RequestAPI.js +132 -132
  113. package/templates/docs/all.html +250 -250
  114. package/templates/docs/component.html +179 -179
  115. package/templates/docs/components.html +222 -222
  116. package/templates/docs/css/b.min.css +6 -6
  117. package/templates/docs/css/component.css +42 -42
  118. package/templates/docs/css/componentTest.css +6 -6
  119. package/templates/docs/css/hopscotch.css +585 -585
  120. package/templates/docs/css/markdown.css +202 -202
  121. package/templates/docs/css/style.css +1022 -1022
  122. package/templates/docs/impactReportTemplate.html +154 -154
  123. package/templates/docs/index.html +1502 -1502
  124. package/templates/docs/js/active-line.js +72 -72
  125. package/templates/docs/js/b.min.js +7 -7
  126. package/templates/docs/js/codemirror.js +9680 -9680
  127. package/templates/docs/js/designTokens.js +334 -334
  128. package/templates/docs/js/j.min.js +4 -4
  129. package/templates/docs/js/javascript.js +874 -874
  130. package/templates/docs/js/matchbrackets.js +145 -145
  131. package/unittest/index.html +37 -0
@@ -1,134 +1,134 @@
1
- import React, { Component } from "react";
2
- import PropTypes from "prop-types";
3
- import style from "./Alert.module.css";
4
- import {
5
- TopbandFontIcon,
6
- TicketsFontIcon,
7
- CommonFontIcon,
8
- Button
9
- } from "@zohodesk/components";
10
-
11
- import FreezeLayer from "../FreezeLayer/FreezeLayer";
12
-
13
- export default class Alert extends Component {
14
- constructor(props) {
15
- super(props);
16
- this.documentKeyupHandler = this.documentKeyupHandler.bind(this);
17
- }
18
-
19
- componentDidMount() {
20
- document.addEventListener("keyup", this.documentKeyupHandler);
21
- }
22
-
23
- componentWillUnmount() {
24
- document.removeEventListener("keyup", this.documentKeyupHandler);
25
- }
26
-
27
- documentKeyupHandler(e = {}) {
28
- e && e.preventDefault();
29
- let { onSubmitClick, onCancelClick, isActive } = this.props;
30
- if (e.keyCode === 27 && isActive) {
31
- onCancelClick();
32
- } else if (e.keyCode === 13 && isActive) {
33
- onSubmitClick();
34
- }
35
- }
36
-
37
- render() {
38
- let {
39
- onSubmitClick,
40
- onCancelClick,
41
- alertData,
42
- isActive,
43
- palette,
44
- type
45
- } = this.props;
46
- let {
47
- iconName,
48
- iconSize,
49
- title,
50
- message,
51
- confirmationMessage,
52
- submitText,
53
- cancelText,
54
- isBoldIcon
55
- } = alertData;
56
- return (
57
- <FreezeLayer
58
- zIndex="7"
59
- isActive={isActive}
60
- animationName="fadeIn"
61
- childAnimationName="scaleIn"
62
- align="both"
63
- >
64
- <div className={`${style[palette]}`}>
65
- <div className={style.container}>
66
- <div className={style.header}>
67
- <span className={style.icon}>
68
- {iconName === "splitNew" ? (
69
- <TicketsFontIcon
70
- name={iconName}
71
- size="14"
72
- isBold={isBoldIcon}
73
- />
74
- ) : iconName === "taskDemo" ? (
75
- <TopbandFontIcon
76
- name={iconName}
77
- size={iconSize ? iconSize : "15"}
78
- isBold={isBoldIcon}
79
- />
80
- ) : (
81
- <CommonFontIcon
82
- name={iconName || ""}
83
- size={iconSize ? iconSize : "15"}
84
- isBold={isBoldIcon}
85
- />
86
- )}
87
- </span>
88
- <span className={style.title}>{title}</span>
89
- </div>
90
- <div className={style.middle}>
91
- <div dangerouslySetInnerHTML={{ __html: message }} />
92
- {confirmationMessage && (
93
- <div className={style.text}>{confirmationMessage}</div>
94
- )}
95
- <div className={style.footer}>
96
- <span className={`${style.button}`}>
97
- <Button
98
- text={submitText}
99
- palette={
100
- palette === "success" ? "primaryFilled" : "dangerFilled"
101
- }
102
- onClick={onSubmitClick}
103
- />
104
- </span>
105
- {type === "confirmation" && (
106
- <span className={`${style.button}`}>
107
- <Button
108
- text={cancelText}
109
- palette="secondary"
110
- onClick={onCancelClick}
111
- />
112
- </span>
113
- )}
114
- </div>
115
- </div>
116
- </div>
117
- </div>
118
- </FreezeLayer>
119
- );
120
- }
121
- }
122
-
123
- Alert.propTypes = {
124
- alertData: PropTypes.object,
125
- isActive: PropTypes.bool,
126
- onCancelClick: PropTypes.func,
127
- onSubmitClick: PropTypes.func,
128
- palette: PropTypes.oneOf(["success", "danger"]),
129
- type: PropTypes.oneOf(["alert", "confirmation"])
130
- };
131
- Alert.defaultProps = {
132
- isActive: false,
133
- palette: "danger"
134
- };
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ import style from "./Alert.module.css";
4
+ import {
5
+ TopbandFontIcon,
6
+ TicketsFontIcon,
7
+ CommonFontIcon,
8
+ Button
9
+ } from "@zohodesk/components";
10
+
11
+ import FreezeLayer from "../FreezeLayer/FreezeLayer";
12
+
13
+ export default class Alert extends Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.documentKeyupHandler = this.documentKeyupHandler.bind(this);
17
+ }
18
+
19
+ componentDidMount() {
20
+ document.addEventListener("keyup", this.documentKeyupHandler);
21
+ }
22
+
23
+ componentWillUnmount() {
24
+ document.removeEventListener("keyup", this.documentKeyupHandler);
25
+ }
26
+
27
+ documentKeyupHandler(e = {}) {
28
+ e && e.preventDefault();
29
+ let { onSubmitClick, onCancelClick, isActive } = this.props;
30
+ if (e.keyCode === 27 && isActive) {
31
+ onCancelClick();
32
+ } else if (e.keyCode === 13 && isActive) {
33
+ onSubmitClick();
34
+ }
35
+ }
36
+
37
+ render() {
38
+ let {
39
+ onSubmitClick,
40
+ onCancelClick,
41
+ alertData,
42
+ isActive,
43
+ palette,
44
+ type
45
+ } = this.props;
46
+ let {
47
+ iconName,
48
+ iconSize,
49
+ title,
50
+ message,
51
+ confirmationMessage,
52
+ submitText,
53
+ cancelText,
54
+ isBoldIcon
55
+ } = alertData;
56
+ return (
57
+ <FreezeLayer
58
+ zIndex="7"
59
+ isActive={isActive}
60
+ animationName="fadeIn"
61
+ childAnimationName="scaleIn"
62
+ align="both"
63
+ >
64
+ <div className={`${style[palette]}`}>
65
+ <div className={style.container}>
66
+ <div className={style.header}>
67
+ <span className={style.icon}>
68
+ {iconName === "splitNew" ? (
69
+ <TicketsFontIcon
70
+ name={iconName}
71
+ size="14"
72
+ isBold={isBoldIcon}
73
+ />
74
+ ) : iconName === "taskDemo" ? (
75
+ <TopbandFontIcon
76
+ name={iconName}
77
+ size={iconSize ? iconSize : "15"}
78
+ isBold={isBoldIcon}
79
+ />
80
+ ) : (
81
+ <CommonFontIcon
82
+ name={iconName || ""}
83
+ size={iconSize ? iconSize : "15"}
84
+ isBold={isBoldIcon}
85
+ />
86
+ )}
87
+ </span>
88
+ <span className={style.title}>{title}</span>
89
+ </div>
90
+ <div className={style.middle}>
91
+ <div dangerouslySetInnerHTML={{ __html: message }} />
92
+ {confirmationMessage && (
93
+ <div className={style.text}>{confirmationMessage}</div>
94
+ )}
95
+ <div className={style.footer}>
96
+ <span className={`${style.button}`}>
97
+ <Button
98
+ text={submitText}
99
+ palette={
100
+ palette === "success" ? "primaryFilled" : "dangerFilled"
101
+ }
102
+ onClick={onSubmitClick}
103
+ />
104
+ </span>
105
+ {type === "confirmation" && (
106
+ <span className={`${style.button}`}>
107
+ <Button
108
+ text={cancelText}
109
+ palette="secondary"
110
+ onClick={onCancelClick}
111
+ />
112
+ </span>
113
+ )}
114
+ </div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </FreezeLayer>
119
+ );
120
+ }
121
+ }
122
+
123
+ Alert.propTypes = {
124
+ alertData: PropTypes.object,
125
+ isActive: PropTypes.bool,
126
+ onCancelClick: PropTypes.func,
127
+ onSubmitClick: PropTypes.func,
128
+ palette: PropTypes.oneOf(["success", "danger"]),
129
+ type: PropTypes.oneOf(["alert", "confirmation"])
130
+ };
131
+ Alert.defaultProps = {
132
+ isActive: false,
133
+ palette: "danger"
134
+ };
@@ -1,79 +1,79 @@
1
- .container {
2
- background-color: var(--zd_bg_pure);
3
- border-radius: var(--zd_size2);
4
- width: var(--zd_size430);
5
- }
6
- .header {
7
- text-transform: capitalize;
8
- padding: var(--zd_size12) var(--zd_size20);
9
- box-shadow: 0 0 var(--zd_size3) 0 var(--zd_shadow_smoke36);
10
- display: -webkit-box;
11
- display: -ms-flexbox;
12
- display: flex;
13
- -webkit-box-orient: horizontal;
14
- -webkit-box-direction: normal;
15
- -webkit-flex-direction: row;
16
- -ms-flex-direction: row;
17
- flex-direction: row;
18
- -webkit-box-align: center;
19
- -ms-flex-align: center;
20
- align-items: center;
21
- }
22
- .danger .header {
23
- background-color: var(--zd_bg_danger5);
24
- color: var(--zd_text_danger4);
25
- }
26
- .success .header {
27
- background-color: var(--zd_bg_primarytrans2);
28
- color: var(--zd_text_prime);
29
- }
30
- .icon {
31
- margin-right: var(--zd_size10);
32
- font-size: 0;
33
- }
34
- .danger .icon {
35
- color: var(--zd_text_danger4);
36
- }
37
- .success .icon {
38
- color: var(--zd_text_prime);
39
- }
40
- .title {
41
- -webkit-box-flex: 1;
42
- -ms-flex-positive: 1;
43
- flex-grow: 1;
44
- min-height: 0;
45
- min-width: 0;
46
- white-space: nowrap;
47
- word-wrap: normal;
48
- overflow: hidden;
49
- text-overflow: ellipsis;
50
- font-size: var(--zd_size15);
51
- }
52
-
53
- .middle {
54
- padding: var(--zd_size30) var(--zd_size20) var(--zd_size20);
55
- line-height: var(--zd_size25);
56
- color: var(--zd_text_dark4);
57
- font-size: var(--zd_size15);
58
- word-break: break-word;
59
- }
60
- .text {
61
- margin-top: var(--zd_size20);
62
- }
63
- .footer {
64
- margin-top: var(--zd_size20);
65
- }
66
-
67
- .button {
68
- margin-right: var(--zd_size20);
69
- display: inline-block;
70
- }
71
-
72
- html[dir="rtl"] .button {
73
- margin-right: 0;
74
- margin-left: var(--zd_size20);
75
- }
76
- html[dir="rtl"] .icon {
77
- margin-left: var(--zd_size10);
78
- margin-right: 0;
79
- }
1
+ .container {
2
+ background-color: var(--zd_bg_pure);
3
+ border-radius: var(--zd_size2);
4
+ width: var(--zd_size430);
5
+ }
6
+ .header {
7
+ text-transform: capitalize;
8
+ padding: var(--zd_size12) var(--zd_size20);
9
+ box-shadow: 0 0 var(--zd_size3) 0 var(--zd_shadow_smoke36);
10
+ display: -webkit-box;
11
+ display: -ms-flexbox;
12
+ display: flex;
13
+ -webkit-box-orient: horizontal;
14
+ -webkit-box-direction: normal;
15
+ -webkit-flex-direction: row;
16
+ -ms-flex-direction: row;
17
+ flex-direction: row;
18
+ -webkit-box-align: center;
19
+ -ms-flex-align: center;
20
+ align-items: center;
21
+ }
22
+ .danger .header {
23
+ background-color: var(--zd_bg_danger5);
24
+ color: var(--zd_text_danger4);
25
+ }
26
+ .success .header {
27
+ background-color: var(--zd_bg_primarytrans2);
28
+ color: var(--zd_text_prime);
29
+ }
30
+ .icon {
31
+ margin-right: var(--zd_size10);
32
+ font-size: 0;
33
+ }
34
+ .danger .icon {
35
+ color: var(--zd_text_danger4);
36
+ }
37
+ .success .icon {
38
+ color: var(--zd_text_prime);
39
+ }
40
+ .title {
41
+ -webkit-box-flex: 1;
42
+ -ms-flex-positive: 1;
43
+ flex-grow: 1;
44
+ min-height: 0;
45
+ min-width: 0;
46
+ white-space: nowrap;
47
+ word-wrap: normal;
48
+ overflow: hidden;
49
+ text-overflow: ellipsis;
50
+ font-size: var(--zd_size15);
51
+ }
52
+
53
+ .middle {
54
+ padding: var(--zd_size30) var(--zd_size20) var(--zd_size20);
55
+ line-height: var(--zd_size25);
56
+ color: var(--zd_text_dark4);
57
+ font-size: var(--zd_size15);
58
+ word-break: break-word;
59
+ }
60
+ .text {
61
+ margin-top: var(--zd_size20);
62
+ }
63
+ .footer {
64
+ margin-top: var(--zd_size20);
65
+ }
66
+
67
+ .button {
68
+ margin-right: var(--zd_size20);
69
+ display: inline-block;
70
+ }
71
+
72
+ html[dir="rtl"] .button {
73
+ margin-right: 0;
74
+ margin-left: var(--zd_size20);
75
+ }
76
+ html[dir="rtl"] .icon {
77
+ margin-left: var(--zd_size10);
78
+ margin-right: 0;
79
+ }
@@ -1,37 +1,37 @@
1
- .container {
2
- top: 0;
3
- left: 0;
4
- bottom: 0;
5
- right: 0;
6
- position: absolute;
7
- }
8
- .default {
9
- background-color: rgba(0, 0, 0, 0.7);
10
- }
11
- .dark {
12
- background-color: rgba(0, 0, 0, 0.9);
13
- }
14
- .darkLight {
15
- background-color: var(--zd_bg_dark16);
16
- }
17
- .plain {
18
- background-color: transparent;
19
- }
20
- .snow {
21
- background-color: rgba(30, 38, 51, 0.4);
22
- }
23
- .index3 {
24
- z-index: 3;
25
- }
26
- .index5 {
27
- z-index: 5;
28
- }
29
- .index7 {
30
- z-index: 7;
31
- }
32
- .index10 {
33
- z-index: 10;
34
- }
35
- .delay {
36
- transition-delay: 0.2s;
37
- }
1
+ .container {
2
+ top: 0;
3
+ left: 0;
4
+ bottom: 0;
5
+ right: 0;
6
+ position: absolute;
7
+ }
8
+ .default {
9
+ background-color: rgba(0, 0, 0, 0.7);
10
+ }
11
+ .dark {
12
+ background-color: rgba(0, 0, 0, 0.9);
13
+ }
14
+ .darkLight {
15
+ background-color: var(--zd_bg_dark16);
16
+ }
17
+ .plain {
18
+ background-color: transparent;
19
+ }
20
+ .snow {
21
+ background-color: rgba(30, 38, 51, 0.4);
22
+ }
23
+ .index3 {
24
+ z-index: 3;
25
+ }
26
+ .index5 {
27
+ z-index: 5;
28
+ }
29
+ .index7 {
30
+ z-index: 7;
31
+ }
32
+ .index10 {
33
+ z-index: 10;
34
+ }
35
+ .delay {
36
+ transition-delay: 0.2s;
37
+ }
@@ -1,84 +1,84 @@
1
- import React, { Component } from "react";
2
- import PropTypes from "prop-types";
3
-
4
- import style from "./FreezeLayer.css";
5
- import { Container, Animation } from "@zohodesk/components";
6
- export default class FreezeLayer extends Component {
7
- constructor(props) {
8
- super(props);
9
- this.state = { isActive: props.isActive, isChildActive: false };
10
- this.toggleChild = this.toggleChild.bind(this);
11
- }
12
-
13
- toggleChild() {
14
- this.setState({ isChildActive: !this.state.isChildActive });
15
- }
16
-
17
- render() {
18
- let {
19
- children,
20
- align,
21
- childAnimationName,
22
- palette,
23
- onClick,
24
- animationName,
25
- zIndex,
26
- isActive
27
- } = this.props;
28
- let { isChildActive } = this.state;
29
- return (
30
- <Animation
31
- name={animationName}
32
- isActive={isActive}
33
- onExit={this.toggleChild}
34
- onEntered={this.toggleChild}
35
- delayClassName={childAnimationName ? style.delay : ""}
36
- exitDuration={childAnimationName && 500}
37
- >
38
- <div
39
- className={`
40
- ${style.container} ${style[`index${zIndex}`]} ${style[palette]}
41
- `}
42
- onClick={onClick ? onClick : null}
43
- >
44
- {children && (
45
- <Container alignBox="row" align={align}>
46
- {childAnimationName ? (
47
- <Animation name={childAnimationName} isActive={isChildActive}>
48
- {children}
49
- </Animation>
50
- ) : (
51
- children
52
- )}
53
- </Container>
54
- )}
55
- </div>
56
- </Animation>
57
- );
58
- }
59
- }
60
- FreezeLayer.propTypes = {
61
- align: PropTypes.oneOf(["horizontal", "vertical", "both"]),
62
- animationName: PropTypes.oneOf([
63
- "zoomIn",
64
- "scaleIn",
65
- "fadeIn",
66
- "slideLeft",
67
- "slideDown",
68
- "skewIn",
69
- "default",
70
- "none"
71
- ]),
72
- childAnimationName: PropTypes.string,
73
- children: PropTypes.node,
74
- isActive: PropTypes.bool,
75
- onClick: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
76
- palette: PropTypes.oneOf(["dark", "default", "darkLight", "plain", "snow"]),
77
- zIndex: PropTypes.oneOf(["3", "5", "7", "10"])
78
- };
79
- FreezeLayer.defaultProps = {
80
- animationName: "default",
81
- isActive: false,
82
- palette: "default",
83
- zIndex: "5"
84
- };
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+
4
+ import style from "./FreezeLayer.css";
5
+ import { Container, Animation } from "@zohodesk/components";
6
+ export default class FreezeLayer extends Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.state = { isActive: props.isActive, isChildActive: false };
10
+ this.toggleChild = this.toggleChild.bind(this);
11
+ }
12
+
13
+ toggleChild() {
14
+ this.setState({ isChildActive: !this.state.isChildActive });
15
+ }
16
+
17
+ render() {
18
+ let {
19
+ children,
20
+ align,
21
+ childAnimationName,
22
+ palette,
23
+ onClick,
24
+ animationName,
25
+ zIndex,
26
+ isActive
27
+ } = this.props;
28
+ let { isChildActive } = this.state;
29
+ return (
30
+ <Animation
31
+ name={animationName}
32
+ isActive={isActive}
33
+ onExit={this.toggleChild}
34
+ onEntered={this.toggleChild}
35
+ delayClassName={childAnimationName ? style.delay : ""}
36
+ exitDuration={childAnimationName && 500}
37
+ >
38
+ <div
39
+ className={`
40
+ ${style.container} ${style[`index${zIndex}`]} ${style[palette]}
41
+ `}
42
+ onClick={onClick ? onClick : null}
43
+ >
44
+ {children && (
45
+ <Container alignBox="row" align={align}>
46
+ {childAnimationName ? (
47
+ <Animation name={childAnimationName} isActive={isChildActive}>
48
+ {children}
49
+ </Animation>
50
+ ) : (
51
+ children
52
+ )}
53
+ </Container>
54
+ )}
55
+ </div>
56
+ </Animation>
57
+ );
58
+ }
59
+ }
60
+ FreezeLayer.propTypes = {
61
+ align: PropTypes.oneOf(["horizontal", "vertical", "both"]),
62
+ animationName: PropTypes.oneOf([
63
+ "zoomIn",
64
+ "scaleIn",
65
+ "fadeIn",
66
+ "slideLeft",
67
+ "slideDown",
68
+ "skewIn",
69
+ "default",
70
+ "none"
71
+ ]),
72
+ childAnimationName: PropTypes.string,
73
+ children: PropTypes.node,
74
+ isActive: PropTypes.bool,
75
+ onClick: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
76
+ palette: PropTypes.oneOf(["dark", "default", "darkLight", "plain", "snow"]),
77
+ zIndex: PropTypes.oneOf(["3", "5", "7", "10"])
78
+ };
79
+ FreezeLayer.defaultProps = {
80
+ animationName: "default",
81
+ isActive: false,
82
+ palette: "default",
83
+ zIndex: "5"
84
+ };