@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,37 +1,37 @@
1
- import { generateAPITypes } from "../../util/Common";
2
- import requestAPI from "../../util/RequestAPI";
3
-
4
- export function getSampleList(isForce = true) {
5
- return {
6
- types: generateAPITypes("SAMPLE_LIST"),
7
- shouldCallAPI: state => {
8
- if (!isForce) {
9
- const { sampleDataList = [] } = state;
10
- return sampleDataList.length === 0;
11
- }
12
- return true;
13
- },
14
- callAPI: state =>
15
- requestAPI(`${mockServerURL}/api/v1/sampleapi`, {})
16
- .get()
17
- .then(res => {
18
- return res;
19
- })
20
- };
21
- }
22
-
23
- export function addSample(payload) {
24
- return {
25
- types: generateAPITypes("ADD_SAMPLE"),
26
- callAPI: state => {
27
- return new Promise((resolve, reject) => {
28
- let url = `${mockServerURL}/api/v1/addSample`;
29
- requestAPI(url, {})
30
- .post("", payload)
31
- .then(res => {
32
- resolve(res);
33
- });
34
- });
35
- }
36
- };
37
- }
1
+ import { generateAPITypes } from "../../util/Common";
2
+ import requestAPI from "../../util/RequestAPI";
3
+
4
+ export function getSampleList(isForce = true) {
5
+ return {
6
+ types: generateAPITypes("SAMPLE_LIST"),
7
+ shouldCallAPI: state => {
8
+ if (!isForce) {
9
+ const { sampleDataList = [] } = state;
10
+ return sampleDataList.length === 0;
11
+ }
12
+ return true;
13
+ },
14
+ callAPI: state =>
15
+ requestAPI(`${mockServerURL}/api/v1/sampleapi`, {})
16
+ .get()
17
+ .then(res => {
18
+ return res;
19
+ })
20
+ };
21
+ }
22
+
23
+ export function addSample(payload) {
24
+ return {
25
+ types: generateAPITypes("ADD_SAMPLE"),
26
+ callAPI: state => {
27
+ return new Promise((resolve, reject) => {
28
+ let url = `${mockServerURL}/api/v1/addSample`;
29
+ requestAPI(url, {})
30
+ .post("", payload)
31
+ .then(res => {
32
+ resolve(res);
33
+ });
34
+ });
35
+ }
36
+ };
37
+ }
@@ -1,65 +1,65 @@
1
- import {
2
- push as routerPush,
3
- replace as routerReplace
4
- } from "redux-router-middleware";
5
-
6
- export function push(obj, isHref) {
7
- //obj.pathname = isHref ? obj.pathname : URL_PREFIX + obj.pathname;
8
- return (dispatch, getState) => {
9
- let state = getState();
10
- dispatch(routerPush(obj));
11
- };
12
- }
13
-
14
- export function replace(obj) {
15
- return (dispatch, getState) => {
16
- let state = getState();
17
- if (
18
- !state.routing.location ||
19
- obj.href !== state.routing.location.pathname
20
- ) {
21
- let locationState =
22
- state.routing.location && state.routing.location.state;
23
- if (!obj.state && locationState) {
24
- obj.state = {};
25
- Object.assign(obj.state, locationState);
26
- }
27
- dispatch(routerReplace(obj));
28
- }
29
- };
30
- }
31
-
32
- export function showAlert(data) {
33
- return {
34
- type: "ALERT_SHOW",
35
- data
36
- };
37
- }
38
-
39
- export function hideAlert() {
40
- return {
41
- type: "ALERT_HIDE"
42
- };
43
- }
44
-
45
- export const alertAction = (() => {
46
- let ob = { resolve: null, reject: null };
47
- function showConfirmBox(data) {
48
- return dispatch =>
49
- new Promise((res, rej) => {
50
- ob.resolve = () => {
51
- dispatch(hideAlert());
52
- res();
53
- };
54
- ob.reject = () => {
55
- dispatch(hideAlert());
56
- rej();
57
- };
58
- dispatch(showAlert(data));
59
- });
60
- }
61
- return {
62
- ob,
63
- showConfirmBox
64
- };
65
- })();
1
+ import {
2
+ push as routerPush,
3
+ replace as routerReplace
4
+ } from "redux-router-middleware";
5
+
6
+ export function push(obj, isHref) {
7
+ //obj.pathname = isHref ? obj.pathname : URL_PREFIX + obj.pathname;
8
+ return (dispatch, getState) => {
9
+ let state = getState();
10
+ dispatch(routerPush(obj));
11
+ };
12
+ }
13
+
14
+ export function replace(obj) {
15
+ return (dispatch, getState) => {
16
+ let state = getState();
17
+ if (
18
+ !state.routing.location ||
19
+ obj.href !== state.routing.location.pathname
20
+ ) {
21
+ let locationState =
22
+ state.routing.location && state.routing.location.state;
23
+ if (!obj.state && locationState) {
24
+ obj.state = {};
25
+ Object.assign(obj.state, locationState);
26
+ }
27
+ dispatch(routerReplace(obj));
28
+ }
29
+ };
30
+ }
31
+
32
+ export function showAlert(data) {
33
+ return {
34
+ type: "ALERT_SHOW",
35
+ data
36
+ };
37
+ }
38
+
39
+ export function hideAlert() {
40
+ return {
41
+ type: "ALERT_HIDE"
42
+ };
43
+ }
44
+
45
+ export const alertAction = (() => {
46
+ let ob = { resolve: null, reject: null };
47
+ function showConfirmBox(data) {
48
+ return dispatch =>
49
+ new Promise((res, rej) => {
50
+ ob.resolve = () => {
51
+ dispatch(hideAlert());
52
+ res();
53
+ };
54
+ ob.reject = () => {
55
+ dispatch(hideAlert());
56
+ rej();
57
+ };
58
+ dispatch(showAlert(data));
59
+ });
60
+ }
61
+ return {
62
+ ob,
63
+ showConfirmBox
64
+ };
65
+ })();
@@ -1,19 +1,19 @@
1
- import { URL_PREFIX } from "./util/Common";
2
-
3
- export default function getUrls(isDomainMapped) {
4
- let urls = [
5
- {
6
- name: "root",
7
- pattern: "/"
8
- },
9
- {
10
- name: "sampleList",
11
- pattern: "/sample"
12
- }
13
- ];
14
-
15
- return urls.map(url => {
16
- url.pattern = `${URL_PREFIX}${url.pattern}`;
17
- return url;
18
- });
19
- }
1
+ import { URL_PREFIX } from "./util/Common";
2
+
3
+ export default function getUrls(isDomainMapped) {
4
+ let urls = [
5
+ {
6
+ name: "root",
7
+ pattern: "/"
8
+ },
9
+ {
10
+ name: "sampleList",
11
+ pattern: "/sample"
12
+ }
13
+ ];
14
+
15
+ return urls.map(url => {
16
+ url.pattern = `${URL_PREFIX}${url.pattern}`;
17
+ return url;
18
+ });
19
+ }
@@ -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
+ }