@coorpacademy/player-web 4.22.52 → 4.23.0

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 (141) hide show
  1. package/es/index.js +1 -8
  2. package/es/index.js.map +1 -1
  3. package/es/map-state-to-props/answer.js +0 -35
  4. package/es/map-state-to-props/answer.js.map +1 -1
  5. package/es/map-state-to-props/error-popin.js +0 -4
  6. package/es/map-state-to-props/error-popin.js.map +1 -1
  7. package/es/map-state-to-props/header.js +3 -14
  8. package/es/map-state-to-props/header.js.map +1 -1
  9. package/es/map-state-to-props/index.js +0 -6
  10. package/es/map-state-to-props/index.js.map +1 -1
  11. package/es/map-state-to-props/loading.js +0 -1
  12. package/es/map-state-to-props/loading.js.map +1 -1
  13. package/es/map-state-to-props/player.js +0 -13
  14. package/es/map-state-to-props/player.js.map +1 -1
  15. package/es/map-state-to-props/popin-correction.js +0 -25
  16. package/es/map-state-to-props/popin-correction.js.map +1 -1
  17. package/es/map-state-to-props/popin-end.js +6 -35
  18. package/es/map-state-to-props/popin-end.js.map +1 -1
  19. package/es/map-state-to-props/resources.js +4 -10
  20. package/es/map-state-to-props/resources.js.map +1 -1
  21. package/es/map-state-to-props/slide.js +0 -2
  22. package/es/map-state-to-props/slide.js.map +1 -1
  23. package/es/map-state-to-props/test/answer.js +0 -21
  24. package/es/map-state-to-props/test/answer.js.map +1 -1
  25. package/es/map-state-to-props/test/header.js +0 -2
  26. package/es/map-state-to-props/test/header.js.map +1 -1
  27. package/es/map-state-to-props/test/index.js +22 -29
  28. package/es/map-state-to-props/test/index.js.map +1 -1
  29. package/es/map-state-to-props/test/player.js +6 -19
  30. package/es/map-state-to-props/test/player.js.map +1 -1
  31. package/es/map-state-to-props/test/popin-correction.create-header-cta.js +0 -15
  32. package/es/map-state-to-props/test/popin-correction.create-header-cta.js.map +1 -1
  33. package/es/map-state-to-props/test/popin-correction.js +0 -8
  34. package/es/map-state-to-props/test/popin-correction.js.map +1 -1
  35. package/es/map-state-to-props/test/popin-end.js +0 -13
  36. package/es/map-state-to-props/test/popin-end.js.map +1 -1
  37. package/es/map-state-to-props/test/popin-error.js.map +1 -1
  38. package/es/map-state-to-props/test/resources.js +0 -2
  39. package/es/map-state-to-props/test/resources.js.map +1 -1
  40. package/es/run-app.js +0 -2
  41. package/es/run-app.js.map +1 -1
  42. package/es/store.js +0 -4
  43. package/es/store.js.map +1 -1
  44. package/es/test/add-timeout.js.map +1 -1
  45. package/es/test/helpers/css-register.js.map +1 -1
  46. package/es/test/helpers/macro.js +0 -1
  47. package/es/test/helpers/macro.js.map +1 -1
  48. package/es/test/index.js.map +1 -1
  49. package/es/test/init-reducers.js.map +1 -1
  50. package/es/test/locales.js.map +1 -1
  51. package/es/test/run-app.js.map +1 -1
  52. package/es/test/store.js.map +1 -1
  53. package/es/views/index.js.map +1 -1
  54. package/es/views/test/helpers/render.js +0 -2
  55. package/es/views/test/helpers/render.js.map +1 -1
  56. package/es/views/test/helpers/state-to-vnode.js +0 -2
  57. package/es/views/test/helpers/state-to-vnode.js.map +1 -1
  58. package/es/views/test/loading.js.map +1 -1
  59. package/es/views/test/popin-correction.js +0 -6
  60. package/es/views/test/popin-correction.js.map +1 -1
  61. package/es/views/test/popin-end.js.map +1 -1
  62. package/es/views/test/router.js.map +1 -1
  63. package/es/views/test/slide.js +0 -1
  64. package/es/views/test/slide.js.map +1 -1
  65. package/lib/index.js +2 -18
  66. package/lib/index.js.map +1 -1
  67. package/lib/map-state-to-props/answer.js +1 -47
  68. package/lib/map-state-to-props/answer.js.map +1 -1
  69. package/lib/map-state-to-props/error-popin.js +2 -10
  70. package/lib/map-state-to-props/error-popin.js.map +1 -1
  71. package/lib/map-state-to-props/header.js +5 -19
  72. package/lib/map-state-to-props/header.js.map +1 -1
  73. package/lib/map-state-to-props/index.js +1 -19
  74. package/lib/map-state-to-props/index.js.map +1 -1
  75. package/lib/map-state-to-props/loading.js +1 -4
  76. package/lib/map-state-to-props/loading.js.map +1 -1
  77. package/lib/map-state-to-props/player.js +2 -22
  78. package/lib/map-state-to-props/player.js.map +1 -1
  79. package/lib/map-state-to-props/popin-correction.js +1 -32
  80. package/lib/map-state-to-props/popin-correction.js.map +1 -1
  81. package/lib/map-state-to-props/popin-end.js +8 -47
  82. package/lib/map-state-to-props/popin-end.js.map +1 -1
  83. package/lib/map-state-to-props/resources.js +6 -20
  84. package/lib/map-state-to-props/resources.js.map +1 -1
  85. package/lib/map-state-to-props/slide.js +2 -11
  86. package/lib/map-state-to-props/slide.js.map +1 -1
  87. package/lib/map-state-to-props/test/answer.js +1 -37
  88. package/lib/map-state-to-props/test/answer.js.map +1 -1
  89. package/lib/map-state-to-props/test/header.js +1 -12
  90. package/lib/map-state-to-props/test/header.js.map +1 -1
  91. package/lib/map-state-to-props/test/index.js +23 -20
  92. package/lib/map-state-to-props/test/index.js.map +1 -1
  93. package/lib/map-state-to-props/test/player.js +12 -52
  94. package/lib/map-state-to-props/test/player.js.map +1 -1
  95. package/lib/map-state-to-props/test/popin-correction.create-header-cta.js +1 -27
  96. package/lib/map-state-to-props/test/popin-correction.create-header-cta.js.map +1 -1
  97. package/lib/map-state-to-props/test/popin-correction.js +1 -11
  98. package/lib/map-state-to-props/test/popin-correction.js.map +1 -1
  99. package/lib/map-state-to-props/test/popin-end.js +1 -26
  100. package/lib/map-state-to-props/test/popin-end.js.map +1 -1
  101. package/lib/map-state-to-props/test/popin-error.js +1 -6
  102. package/lib/map-state-to-props/test/popin-error.js.map +1 -1
  103. package/lib/map-state-to-props/test/resources.js +1 -11
  104. package/lib/map-state-to-props/test/resources.js.map +1 -1
  105. package/lib/run-app.js +1 -5
  106. package/lib/run-app.js.map +1 -1
  107. package/lib/store.js +1 -11
  108. package/lib/store.js.map +1 -1
  109. package/lib/test/add-timeout.js +1 -4
  110. package/lib/test/add-timeout.js.map +1 -1
  111. package/lib/test/helpers/css-register.js +1 -3
  112. package/lib/test/helpers/css-register.js.map +1 -1
  113. package/lib/test/helpers/macro.js +1 -4
  114. package/lib/test/helpers/macro.js.map +1 -1
  115. package/lib/test/index.js +3 -12
  116. package/lib/test/index.js.map +1 -1
  117. package/lib/test/init-reducers.js +1 -5
  118. package/lib/test/init-reducers.js.map +1 -1
  119. package/lib/test/locales.js +1 -8
  120. package/lib/test/locales.js.map +1 -1
  121. package/lib/test/run-app.js +1 -5
  122. package/lib/test/run-app.js.map +1 -1
  123. package/lib/test/store.js +1 -5
  124. package/lib/test/store.js.map +1 -1
  125. package/lib/views/index.js +2 -9
  126. package/lib/views/index.js.map +1 -1
  127. package/lib/views/test/helpers/render.js +2 -10
  128. package/lib/views/test/helpers/render.js.map +1 -1
  129. package/lib/views/test/helpers/state-to-vnode.js +1 -6
  130. package/lib/views/test/helpers/state-to-vnode.js.map +1 -1
  131. package/lib/views/test/loading.js +1 -5
  132. package/lib/views/test/loading.js.map +1 -1
  133. package/lib/views/test/popin-correction.js +1 -18
  134. package/lib/views/test/popin-correction.js.map +1 -1
  135. package/lib/views/test/popin-end.js +1 -10
  136. package/lib/views/test/popin-end.js.map +1 -1
  137. package/lib/views/test/router.js +1 -8
  138. package/lib/views/test/router.js.map +1 -1
  139. package/lib/views/test/slide.js +3 -23
  140. package/lib/views/test/slide.js.map +1 -1
  141. package/package.json +13 -14
package/es/index.js CHANGED
@@ -7,23 +7,18 @@ import runApp from './run-app';
7
7
  import createStore from './store';
8
8
  import { selectMapStateToVNode } from './map-state-to-props';
9
9
  import { createStateToVNode, views } from './views';
10
-
11
10
  const createUpdate = (container, store, options) => _selectMapStateToVNode => {
12
11
  const {
13
12
  getState
14
13
  } = store;
15
-
16
14
  const mapStateToVNode = _selectMapStateToVNode(options, store, views, createStateToVNode);
17
-
18
15
  const mapStateToView = _pipe(mapStateToVNode, vNode => createElement(Provider, options, vNode));
19
-
20
16
  return () => {
21
17
  const state = getState();
22
18
  const view = mapStateToView(state);
23
19
  return render(view, container);
24
20
  };
25
21
  };
26
-
27
22
  const create = options => {
28
23
  const {
29
24
  container
@@ -31,8 +26,8 @@ const create = options => {
31
26
  const store = createStore(options);
32
27
  let update = createUpdate(container, store, options)(selectMapStateToVNode);
33
28
  let unsubscribe = store.subscribe(update);
34
- /* istanbul ignore if */
35
29
 
30
+ /* istanbul ignore if */
36
31
  if (module.hot) {
37
32
  module.hot.accept('./views', () => {
38
33
  unsubscribe();
@@ -41,7 +36,6 @@ const create = options => {
41
36
  unsubscribe = store.subscribe(update);
42
37
  });
43
38
  }
44
-
45
39
  runApp(options, store);
46
40
  const {
47
41
  dispatch
@@ -56,6 +50,5 @@ const create = options => {
56
50
  }
57
51
  };
58
52
  };
59
-
60
53
  export { create };
61
54
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["render","unmountComponentAtNode","createElement","Provider","selectProgression","updateCoaches","runApp","createStore","selectMapStateToVNode","createStateToVNode","views","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","mapStateToView","vNode","state","view","create","update","unsubscribe","subscribe","module","hot","accept","require","default","dispatch","coachState","id"],"sources":["../src/index.js"],"sourcesContent":["import {render, unmountComponentAtNode} from 'react-dom';\nimport {createElement} from 'react';\nimport {pipe} from 'lodash/fp';\nimport {Provider} from '@coorpacademy/components';\nimport {selectProgression, updateCoaches} from '@coorpacademy/player-store';\nimport runApp from './run-app';\nimport createStore from './store';\nimport {selectMapStateToVNode} from './map-state-to-props';\nimport {createStateToVNode, views} from './views';\n\nconst createUpdate = (container, store, options) => _selectMapStateToVNode => {\n const {getState} = store;\n const mapStateToVNode = _selectMapStateToVNode(options, store, views, createStateToVNode);\n const mapStateToView = pipe(mapStateToVNode, vNode => createElement(Provider, options, vNode));\n\n return () => {\n const state = getState();\n const view = mapStateToView(state);\n return render(view, container);\n };\n};\n\nconst create = options => {\n const {container} = options;\n const store = createStore(options);\n\n let update = createUpdate(container, store, options)(selectMapStateToVNode);\n let unsubscribe = store.subscribe(update);\n\n /* istanbul ignore if */\n if (module.hot) {\n module.hot.accept('./views', () => {\n unsubscribe();\n update = createUpdate(container, store, options)(require('./views').default);\n update();\n unsubscribe = store.subscribe(update);\n });\n }\n\n runApp(options, store);\n\n const {dispatch} = store;\n return {\n update: () => update(),\n\n updateCoaches: coachState => dispatch(updateCoaches(coachState)),\n selectProgression: id => dispatch(selectProgression(id)),\n\n unsubscribe: () => {\n unmountComponentAtNode(container);\n return unsubscribe();\n }\n };\n};\n\nexport {create};\n"],"mappings":";AAAA,SAAQA,MAAR,EAAgBC,sBAAhB,QAA6C,WAA7C;AACA,SAAQC,aAAR,QAA4B,OAA5B;AAEA,SAAQC,QAAR,QAAuB,0BAAvB;AACA,SAAQC,iBAAR,EAA2BC,aAA3B,QAA+C,4BAA/C;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,WAAP,MAAwB,SAAxB;AACA,SAAQC,qBAAR,QAAoC,sBAApC;AACA,SAAQC,kBAAR,EAA4BC,KAA5B,QAAwC,SAAxC;;AAEA,MAAMC,YAAY,GAAG,CAACC,SAAD,EAAYC,KAAZ,EAAmBC,OAAnB,KAA+BC,sBAAsB,IAAI;EAC5E,MAAM;IAACC;EAAD,IAAaH,KAAnB;;EACA,MAAMI,eAAe,GAAGF,sBAAsB,CAACD,OAAD,EAAUD,KAAV,EAAiBH,KAAjB,EAAwBD,kBAAxB,CAA9C;;EACA,MAAMS,cAAc,GAAG,MAAKD,eAAL,EAAsBE,KAAK,IAAIjB,aAAa,CAACC,QAAD,EAAWW,OAAX,EAAoBK,KAApB,CAA5C,CAAvB;;EAEA,OAAO,MAAM;IACX,MAAMC,KAAK,GAAGJ,QAAQ,EAAtB;IACA,MAAMK,IAAI,GAAGH,cAAc,CAACE,KAAD,CAA3B;IACA,OAAOpB,MAAM,CAACqB,IAAD,EAAOT,SAAP,CAAb;EACD,CAJD;AAKD,CAVD;;AAYA,MAAMU,MAAM,GAAGR,OAAO,IAAI;EACxB,MAAM;IAACF;EAAD,IAAcE,OAApB;EACA,MAAMD,KAAK,GAAGN,WAAW,CAACO,OAAD,CAAzB;EAEA,IAAIS,MAAM,GAAGZ,YAAY,CAACC,SAAD,EAAYC,KAAZ,EAAmBC,OAAnB,CAAZ,CAAwCN,qBAAxC,CAAb;EACA,IAAIgB,WAAW,GAAGX,KAAK,CAACY,SAAN,CAAgBF,MAAhB,CAAlB;EAEA;;EACA,IAAIG,MAAM,CAACC,GAAX,EAAgB;IACdD,MAAM,CAACC,GAAP,CAAWC,MAAX,CAAkB,SAAlB,EAA6B,MAAM;MACjCJ,WAAW;MACXD,MAAM,GAAGZ,YAAY,CAACC,SAAD,EAAYC,KAAZ,EAAmBC,OAAnB,CAAZ,CAAwCe,OAAO,CAAC,SAAD,CAAP,CAAmBC,OAA3D,CAAT;MACAP,MAAM;MACNC,WAAW,GAAGX,KAAK,CAACY,SAAN,CAAgBF,MAAhB,CAAd;IACD,CALD;EAMD;;EAEDjB,MAAM,CAACQ,OAAD,EAAUD,KAAV,CAAN;EAEA,MAAM;IAACkB;EAAD,IAAalB,KAAnB;EACA,OAAO;IACLU,MAAM,EAAE,MAAMA,MAAM,EADf;IAGLlB,aAAa,EAAE2B,UAAU,IAAID,QAAQ,CAAC1B,aAAa,CAAC2B,UAAD,CAAd,CAHhC;IAIL5B,iBAAiB,EAAE6B,EAAE,IAAIF,QAAQ,CAAC3B,iBAAiB,CAAC6B,EAAD,CAAlB,CAJ5B;IAMLT,WAAW,EAAE,MAAM;MACjBvB,sBAAsB,CAACW,SAAD,CAAtB;MACA,OAAOY,WAAW,EAAlB;IACD;EATI,CAAP;AAWD,CA/BD;;AAiCA,SAAQF,MAAR"}
1
+ {"version":3,"file":"index.js","names":["render","unmountComponentAtNode","createElement","Provider","selectProgression","updateCoaches","runApp","createStore","selectMapStateToVNode","createStateToVNode","views","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","mapStateToView","_pipe","vNode","state","view","create","update","unsubscribe","subscribe","module","hot","accept","require","default","dispatch","coachState","id"],"sources":["../src/index.js"],"sourcesContent":["import {render, unmountComponentAtNode} from 'react-dom';\nimport {createElement} from 'react';\nimport {pipe} from 'lodash/fp';\nimport {Provider} from '@coorpacademy/components';\nimport {selectProgression, updateCoaches} from '@coorpacademy/player-store';\nimport runApp from './run-app';\nimport createStore from './store';\nimport {selectMapStateToVNode} from './map-state-to-props';\nimport {createStateToVNode, views} from './views';\n\nconst createUpdate = (container, store, options) => _selectMapStateToVNode => {\n const {getState} = store;\n const mapStateToVNode = _selectMapStateToVNode(options, store, views, createStateToVNode);\n const mapStateToView = pipe(mapStateToVNode, vNode => createElement(Provider, options, vNode));\n\n return () => {\n const state = getState();\n const view = mapStateToView(state);\n return render(view, container);\n };\n};\n\nconst create = options => {\n const {container} = options;\n const store = createStore(options);\n\n let update = createUpdate(container, store, options)(selectMapStateToVNode);\n let unsubscribe = store.subscribe(update);\n\n /* istanbul ignore if */\n if (module.hot) {\n module.hot.accept('./views', () => {\n unsubscribe();\n update = createUpdate(container, store, options)(require('./views').default);\n update();\n unsubscribe = store.subscribe(update);\n });\n }\n\n runApp(options, store);\n\n const {dispatch} = store;\n return {\n update: () => update(),\n\n updateCoaches: coachState => dispatch(updateCoaches(coachState)),\n selectProgression: id => dispatch(selectProgression(id)),\n\n unsubscribe: () => {\n unmountComponentAtNode(container);\n return unsubscribe();\n }\n };\n};\n\nexport {create};\n"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,sBAAsB,QAAO,WAAW;AACxD,SAAQC,aAAa,QAAO,OAAO;AAEnC,SAAQC,QAAQ,QAAO,0BAA0B;AACjD,SAAQC,iBAAiB,EAAEC,aAAa,QAAO,4BAA4B;AAC3E,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,WAAW,MAAM,SAAS;AACjC,SAAQC,qBAAqB,QAAO,sBAAsB;AAC1D,SAAQC,kBAAkB,EAAEC,KAAK,QAAO,SAAS;AAEjD,MAAMC,YAAY,GAAGA,CAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,KAAKC,sB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MAAM,EAAEA,CAAA,KAAMA,MAAM,CAAC,CAAC;IAEtBnB,aAAa,EAAE4B,UAAU,IAAID,QAAQ,CAAC3B,aAAa,CAAC4B,UAAU,CAAC,CAAC;IAChE7B,iBAAiB,EAAE8B,EAAE,IAAIF,QAAQ,CAAC5B,iBAAiB,CAAC8B,EAAE,CAAC,CAAC;IAExDT,WAAW,EAAEA,CAAA,KAAM;MACjBxB,sBAAsB,CAACW,SAAS,CAAC;MACjC,OAAOa,WAAW,CAAC,CAAC;IACtB;EACF,CAAC;AACH,CAAC;AAED,SAAQF,MAAM","ignoreList":[]}
@@ -18,21 +18,17 @@ import _toInteger from "lodash/fp/toInteger";
18
18
  import _includes from "lodash/fp/includes";
19
19
  import _pipe from "lodash/fp/pipe";
20
20
  import { getChoices, getQuestionType, getAnswerValues, editAnswer } from '@coorpacademy/player-store';
21
-
22
21
  const editAnswerAction = (options, {
23
22
  dispatch
24
23
  }) => _constant(newValue => {
25
24
  return dispatch(editAnswer(newValue));
26
25
  });
27
-
28
26
  const qcmProps = (options, store) => {
29
27
  const getChoices_ = getChoices();
30
28
  const editAnswerAction_ = editAnswerAction(options, store);
31
29
  return (state, slide) => {
32
30
  const answers = getAnswerValues(slide, state);
33
-
34
31
  const _editAnswerAction = editAnswerAction_(state, slide);
35
-
36
32
  const props = {
37
33
  type: 'qcm',
38
34
  answers: _map(choice => ({
@@ -44,7 +40,6 @@ const qcmProps = (options, store) => {
44
40
  return props;
45
41
  };
46
42
  };
47
-
48
43
  const qcmDragProps = (options, store) => {
49
44
  const getChoices_ = getChoices();
50
45
  const editAnswerAction_ = editAnswerAction(options, store);
@@ -54,7 +49,6 @@ const qcmDragProps = (options, store) => {
54
49
  type: 'qcmDrag',
55
50
  answers: _map(choice => {
56
51
  const indexInAnswer = _indexOf(choice.label, answers);
57
-
58
52
  return {
59
53
  title: choice.label,
60
54
  selected: indexInAnswer !== -1,
@@ -65,7 +59,6 @@ const qcmDragProps = (options, store) => {
65
59
  };
66
60
  };
67
61
  };
68
-
69
62
  const qcmGraphicProps = (options, store) => {
70
63
  const getChoices_ = getChoices();
71
64
  const editAnswerAction_ = editAnswerAction(options, store);
@@ -82,12 +75,10 @@ const qcmGraphicProps = (options, store) => {
82
75
  };
83
76
  };
84
77
  };
85
-
86
78
  const updateTemplateAnswer = (_answers, index, max) => value => {
87
79
  const answers = !_answers ? _times(_constant(undefined), max) : _answers;
88
80
  return _map(a => _isNil(a) ? '' : a, _set(index, value, answers));
89
81
  };
90
-
91
82
  const templateTextProps = (options, store) => {
92
83
  const editAnswerAction_ = editAnswerAction(options, store);
93
84
  return (state, slide, choice, index) => {
@@ -104,7 +95,6 @@ const templateTextProps = (options, store) => {
104
95
  };
105
96
  };
106
97
  };
107
-
108
98
  const templateSelectProps = (options, store) => {
109
99
  const editAnswerAction_ = editAnswerAction(options, store);
110
100
  return (state, slide, choice, index) => {
@@ -112,9 +102,7 @@ const templateSelectProps = (options, store) => {
112
102
  translate
113
103
  } = options;
114
104
  const answers = getAnswerValues(slide, state);
115
-
116
105
  const answer = _get(index, answers);
117
-
118
106
  const temporaryOption = {
119
107
  name: translate('Select an answer'),
120
108
  value: '',
@@ -129,9 +117,7 @@ const templateSelectProps = (options, store) => {
129
117
  selected: item.text === answer
130
118
  };
131
119
  });
132
-
133
120
  const maxLength = _get('question.content.choices.length', slide);
134
-
135
121
  return {
136
122
  type: choice.type,
137
123
  name: choice.name,
@@ -141,7 +127,6 @@ const templateSelectProps = (options, store) => {
141
127
  };
142
128
  };
143
129
  };
144
-
145
130
  const templateProps = (options, store) => {
146
131
  const getChoices_ = getChoices();
147
132
  const templateTextProps_ = templateTextProps(options, store);
@@ -154,7 +139,6 @@ const templateProps = (options, store) => {
154
139
  };
155
140
  };
156
141
  };
157
-
158
142
  const basicProps = (options, store) => {
159
143
  const editAnswerAction_ = editAnswerAction(options, store);
160
144
  return (state, slide) => {
@@ -169,29 +153,21 @@ const basicProps = (options, store) => {
169
153
  };
170
154
  };
171
155
  };
172
-
173
156
  const toAnswer = values => {
174
157
  const maxValue = _size(values) - 1;
175
158
  return position => {
176
159
  return _pipe(_multiply(maxValue), _round, _get(_, values), _toString2)(position);
177
160
  };
178
161
  };
179
-
180
162
  const sliderProps = (options, store) => {
181
163
  const editAnswerAction_ = editAnswerAction(options, store);
182
164
  return (state, slide) => {
183
165
  const values = _rangeStep(slide.question.content.step || 1, slide.question.content.min, slide.question.content.max + 1);
184
-
185
166
  const stateValue = _pipe(getAnswerValues, _head)(slide, state);
186
-
187
167
  const currentValue = _toInteger(stateValue);
188
-
189
168
  const indexValue = _indexOf(currentValue, values);
190
-
191
169
  const handleChange = editAnswerAction_(state, slide);
192
-
193
170
  const sliderPosition = _divide(indexValue, _size(values) - 1);
194
-
195
171
  return {
196
172
  type: 'slider',
197
173
  placeholder: slide.question.explanation,
@@ -203,7 +179,6 @@ const sliderProps = (options, store) => {
203
179
  };
204
180
  };
205
181
  };
206
-
207
182
  const createGetAnswerProps = (options, store) => {
208
183
  const qcmProps_ = qcmProps(options, store);
209
184
  const qcmGraphicProps_ = qcmGraphicProps(options, store);
@@ -215,40 +190,30 @@ const createGetAnswerProps = (options, store) => {
215
190
  if (!slide) {
216
191
  return;
217
192
  }
218
-
219
193
  const type = getQuestionType(slide);
220
-
221
194
  switch (type) {
222
195
  case 'qcm':
223
196
  return qcmProps_(state, slide);
224
-
225
197
  case 'qcmGraphic':
226
198
  return qcmGraphicProps_(state, slide);
227
-
228
199
  case 'qcmDrag':
229
200
  return qcmDragProps_(state, slide);
230
-
231
201
  case 'basic':
232
202
  return basicProps_(state, slide);
233
-
234
203
  case 'template':
235
204
  return templateProps_(state, slide);
236
-
237
205
  case 'slider':
238
206
  return sliderProps_(state, slide);
239
-
240
207
  default:
241
208
  throw new Error(`${type} is not an handled question.type`);
242
209
  }
243
210
  };
244
211
  };
245
-
246
212
  const createGetHelp = (options, store) => slide => {
247
213
  const {
248
214
  translate
249
215
  } = options;
250
216
  return _get('question.explanation', slide) || translate('Select something below');
251
217
  };
252
-
253
218
  export { createGetAnswerProps, createGetHelp };
254
219
  //# sourceMappingURL=answer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"answer.js","names":["getChoices","getQuestionType","getAnswerValues","editAnswer","editAnswerAction","options","dispatch","newValue","qcmProps","store","getChoices_","editAnswerAction_","state","slide","answers","_editAnswerAction","props","type","choice","title","label","selected","onClick","qcmDragProps","indexInAnswer","order","qcmGraphicProps","image","updateTemplateAnswer","_answers","index","max","value","undefined","a","templateTextProps","translate","name","placeholder","onChange","templateSelectProps","answer","temporaryOption","validOption","selectOptions","items","map","item","text","maxLength","concat","templateProps","templateTextProps_","templateSelectProps_","template","question","content","basicProps","toAnswer","values","maxValue","position","sliderProps","step","min","stateValue","currentValue","indexValue","handleChange","sliderPosition","explanation","minLabel","unitLabel","maxLabel","createGetAnswerProps","qcmProps_","qcmGraphicProps_","qcmDragProps_","basicProps_","templateProps_","sliderProps_","Error","createGetHelp"],"sources":["../../src/map-state-to-props/answer.js"],"sourcesContent":["import {\n pipe,\n includes,\n toInteger,\n head,\n map,\n get,\n divide,\n multiply,\n __,\n round,\n size,\n constant,\n times,\n set,\n isEmpty,\n isNil,\n rangeStep,\n toString as _toString,\n indexOf\n} from 'lodash/fp';\nimport {getChoices, getQuestionType, getAnswerValues, editAnswer} from '@coorpacademy/player-store';\n\nconst editAnswerAction = (options, {dispatch}) =>\n constant(newValue => {\n return dispatch(editAnswer(newValue));\n });\n\nconst qcmProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n const _editAnswerAction = editAnswerAction_(state, slide);\n\n const props = {\n type: 'qcm',\n answers: map(\n choice => ({\n title: choice.label,\n selected: includes(choice.label, answers),\n onClick: () => _editAnswerAction(choice)\n }),\n getChoices_(slide, state)\n )\n };\n\n return props;\n };\n};\n\nconst qcmDragProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n return {\n type: 'qcmDrag',\n answers: map(choice => {\n const indexInAnswer = indexOf(choice.label, answers);\n return {\n title: choice.label,\n selected: indexInAnswer !== -1,\n order: indexInAnswer,\n onClick: () => editAnswerAction_(state, slide)(choice)\n };\n }, getChoices_(slide, state))\n };\n };\n};\n\nconst qcmGraphicProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n return {\n type: 'qcmGraphic',\n answers: map(\n choice => ({\n title: choice.label,\n image: get('media.src.0.url', choice),\n selected: includes(choice.label, answers),\n onClick: () => editAnswerAction_(state, slide)(choice)\n }),\n getChoices_(slide, state)\n )\n };\n };\n};\n\nconst updateTemplateAnswer = (_answers, index, max) => value => {\n const answers = !_answers ? times(constant(undefined), max) : _answers;\n return map(a => (isNil(a) ? '' : a), set(index, value, answers));\n};\n\nconst templateTextProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide, choice, index) => {\n const {translate} = options;\n const answers = getAnswerValues(slide, state);\n return {\n type: choice.type,\n name: choice.name,\n placeholder: translate('Type here'),\n value: get(index, answers),\n onChange: pipe(updateTemplateAnswer(answers, index), editAnswerAction_(state, slide))\n };\n };\n};\n\nconst templateSelectProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide, choice, index) => {\n const {translate} = options;\n const answers = getAnswerValues(slide, state);\n const answer = get(index, answers);\n const temporaryOption = {\n name: translate('Select an answer'),\n value: '',\n validOption: false,\n selected: true\n };\n const selectOptions = choice.items.map(item => {\n return {\n name: item.text,\n value: item.text,\n validOption: true,\n selected: item.text === answer\n };\n });\n const maxLength = get('question.content.choices.length', slide);\n\n return {\n type: choice.type,\n name: choice.name,\n onChange: pipe(\n updateTemplateAnswer(answers, index, maxLength),\n editAnswerAction_(state, slide)\n ),\n options: isEmpty(answer) ? [temporaryOption].concat(selectOptions) : selectOptions,\n 'aria-label': translate('Select an answer')\n };\n };\n};\n\nconst templateProps = (options, store) => {\n const getChoices_ = getChoices();\n const templateTextProps_ = templateTextProps(options, store);\n const templateSelectProps_ = templateSelectProps(options, store);\n\n return (state, slide) => {\n return {\n type: 'template',\n template: slide.question.content.template,\n answers: getChoices_(slide, state).map((choice, index) =>\n choice.type === 'text'\n ? templateTextProps_(state, slide, choice, index)\n : templateSelectProps_(state, slide, choice, index)\n )\n };\n };\n};\n\nconst basicProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const {translate} = options;\n return {\n type: 'freeText',\n placeholder: translate('Type here'),\n value: pipe(getAnswerValues, head)(slide, state),\n onChange: editAnswerAction_(state, slide)\n };\n };\n};\n\nconst toAnswer = values => {\n const maxValue = size(values) - 1;\n return position => {\n return pipe(multiply(maxValue), round, get(__, values), _toString)(position);\n };\n};\n\nconst sliderProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const values = rangeStep(\n slide.question.content.step || 1,\n slide.question.content.min,\n slide.question.content.max + 1\n );\n\n const stateValue = pipe(getAnswerValues, head)(slide, state);\n const currentValue = toInteger(stateValue);\n\n const indexValue = indexOf(currentValue, values);\n const handleChange = editAnswerAction_(state, slide);\n const sliderPosition = divide(indexValue, size(values) - 1);\n\n return {\n type: 'slider',\n placeholder: slide.question.explanation,\n minLabel: `${slide.question.content.min} ${slide.question.content.unitLabel}`,\n maxLabel: `${slide.question.content.max} ${slide.question.content.unitLabel}`,\n title: `${currentValue} ${slide.question.content.unitLabel}`,\n value: sliderPosition,\n onChange: pipe(toAnswer(values), handleChange)\n };\n };\n};\n\nconst createGetAnswerProps = (options, store) => {\n const qcmProps_ = qcmProps(options, store);\n const qcmGraphicProps_ = qcmGraphicProps(options, store);\n const qcmDragProps_ = qcmDragProps(options, store);\n const basicProps_ = basicProps(options, store);\n const templateProps_ = templateProps(options, store);\n const sliderProps_ = sliderProps(options, store);\n\n return (state, slide) => {\n if (!slide) {\n return;\n }\n const type = getQuestionType(slide);\n switch (type) {\n case 'qcm':\n return qcmProps_(state, slide);\n\n case 'qcmGraphic':\n return qcmGraphicProps_(state, slide);\n\n case 'qcmDrag':\n return qcmDragProps_(state, slide);\n\n case 'basic':\n return basicProps_(state, slide);\n\n case 'template':\n return templateProps_(state, slide);\n\n case 'slider':\n return sliderProps_(state, slide);\n\n default:\n throw new Error(`${type} is not an handled question.type`);\n }\n };\n};\n\nconst createGetHelp = (options, store) => slide => {\n const {translate} = options;\n return get('question.explanation', slide) || translate('Select something below');\n};\n\nexport {createGetAnswerProps, createGetHelp};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAQA,UAAR,EAAoBC,eAApB,EAAqCC,eAArC,EAAsDC,UAAtD,QAAuE,4BAAvE;;AAEA,MAAMC,gBAAgB,GAAG,CAACC,OAAD,EAAU;EAACC;AAAD,CAAV,KACvB,UAASC,QAAQ,IAAI;EACnB,OAAOD,QAAQ,CAACH,UAAU,CAACI,QAAD,CAAX,CAAf;AACD,CAFD,CADF;;AAKA,MAAMC,QAAQ,GAAG,CAACH,OAAD,EAAUI,KAAV,KAAoB;EACnC,MAAMC,WAAW,GAAGV,UAAU,EAA9B;EACA,MAAMW,iBAAiB,GAAGP,gBAAgB,CAACC,OAAD,EAAUI,KAAV,CAA1C;EAEA,OAAO,CAACG,KAAD,EAAQC,KAAR,KAAkB;IACvB,MAAMC,OAAO,GAAGZ,eAAe,CAACW,KAAD,EAAQD,KAAR,CAA/B;;IACA,MAAMG,iBAAiB,GAAGJ,iBAAiB,CAACC,KAAD,EAAQC,KAAR,CAA3C;;IAEA,MAAMG,KAAK,GAAG;MACZC,IAAI,EAAE,KADM;MAEZH,OAAO,EAAE,KACPI,MAAM,KAAK;QACTC,KAAK,EAAED,MAAM,CAACE,KADL;QAETC,QAAQ,EAAE,UAASH,MAAM,CAACE,KAAhB,EAAuBN,OAAvB,C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OAAO+D,gBAAgB,CAAChE,KAAD,EAAQC,KAAR,CAAvB;;MAEF,KAAK,SAAL;QACE,OAAOgE,aAAa,CAACjE,KAAD,EAAQC,KAAR,CAApB;;MAEF,KAAK,OAAL;QACE,OAAOiE,WAAW,CAAClE,KAAD,EAAQC,KAAR,CAAlB;;MAEF,KAAK,UAAL;QACE,OAAOkE,cAAc,CAACnE,KAAD,EAAQC,KAAR,CAArB;;MAEF,KAAK,QAAL;QACE,OAAOmE,YAAY,CAACpE,KAAD,EAAQC,KAAR,CAAnB;;MAEF;QACE,MAAM,IAAIoE,KAAJ,CAAW,GAAEhE,IAAK,kCAAlB,CAAN;IApBJ;EAsBD,CA3BD;AA4BD,CApCD;;AAsCA,MAAMiE,aAAa,GAAG,CAAC7E,OAAD,EAAUI,KAAV,KAAoBI,KAAK,IAAI;EACjD,MAAM;IAACuB;EAAD,IAAc/B,OAApB;EACA,OAAO,KAAI,sBAAJ,EAA4BQ,KAA5B,KAAsCuB,SAAS,CAAC,wBAAD,CAAtD;AACD,CAHD;;AAKA,SAAQsC,oBAAR,EAA8BQ,aAA9B"}
1
+ {"version":3,"file":"answer.js","names":["getChoices","getQuestionType","getAnswerValues","editAnswer","editAnswerAction","options","dispatch","_constant","newValue","qcmProps","store","getChoices_","editAnswerAction_","state","slide","answers","_editAnswerAction","props","type","_map","choice","title","label","selected","_includes","onClick","qcmDragProps","indexInAnswer","_indexOf","order","qcmGraphicProps","image","_get","updateTemplateAnswer","_answers","index","max","value","_times","undefined","a","_isNil","_set","templateTextProps","translate","name","placeholder","onChange","_pipe","templateSelectProps","answer","temporaryOption","validOption","selectOptions","items","map","item","text","maxLength","_isEmpty","concat","templateProps","templateTextProps_","templateSelectProps_","template","question","content","basicProps","_head","toAnswer","values","maxValue","_size","position","_multiply","_round","_","_toString2","sliderProps","_rangeStep","step","min","stateValue","currentValue","_toInteger","indexValue","handleChange","sliderPosition","_divide","explanation","minLabel","unitLabel","maxLabel","createGetAnswerProps","qcmProps_","qcmGraphicProps_","qcmDragProps_","basicProps_","templateProps_","sliderProps_","Error","createGetHelp"],"sources":["../../src/map-state-to-props/answer.js"],"sourcesContent":["import {\n pipe,\n includes,\n toInteger,\n head,\n map,\n get,\n divide,\n multiply,\n __,\n round,\n size,\n constant,\n times,\n set,\n isEmpty,\n isNil,\n rangeStep,\n toString as _toString,\n indexOf\n} from 'lodash/fp';\nimport {getChoices, getQuestionType, getAnswerValues, editAnswer} from '@coorpacademy/player-store';\n\nconst editAnswerAction = (options, {dispatch}) =>\n constant(newValue => {\n return dispatch(editAnswer(newValue));\n });\n\nconst qcmProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n const _editAnswerAction = editAnswerAction_(state, slide);\n\n const props = {\n type: 'qcm',\n answers: map(\n choice => ({\n title: choice.label,\n selected: includes(choice.label, answers),\n onClick: () => _editAnswerAction(choice)\n }),\n getChoices_(slide, state)\n )\n };\n\n return props;\n };\n};\n\nconst qcmDragProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n return {\n type: 'qcmDrag',\n answers: map(choice => {\n const indexInAnswer = indexOf(choice.label, answers);\n return {\n title: choice.label,\n selected: indexInAnswer !== -1,\n order: indexInAnswer,\n onClick: () => editAnswerAction_(state, slide)(choice)\n };\n }, getChoices_(slide, state))\n };\n };\n};\n\nconst qcmGraphicProps = (options, store) => {\n const getChoices_ = getChoices();\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const answers = getAnswerValues(slide, state);\n return {\n type: 'qcmGraphic',\n answers: map(\n choice => ({\n title: choice.label,\n image: get('media.src.0.url', choice),\n selected: includes(choice.label, answers),\n onClick: () => editAnswerAction_(state, slide)(choice)\n }),\n getChoices_(slide, state)\n )\n };\n };\n};\n\nconst updateTemplateAnswer = (_answers, index, max) => value => {\n const answers = !_answers ? times(constant(undefined), max) : _answers;\n return map(a => (isNil(a) ? '' : a), set(index, value, answers));\n};\n\nconst templateTextProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide, choice, index) => {\n const {translate} = options;\n const answers = getAnswerValues(slide, state);\n return {\n type: choice.type,\n name: choice.name,\n placeholder: translate('Type here'),\n value: get(index, answers),\n onChange: pipe(updateTemplateAnswer(answers, index), editAnswerAction_(state, slide))\n };\n };\n};\n\nconst templateSelectProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide, choice, index) => {\n const {translate} = options;\n const answers = getAnswerValues(slide, state);\n const answer = get(index, answers);\n const temporaryOption = {\n name: translate('Select an answer'),\n value: '',\n validOption: false,\n selected: true\n };\n const selectOptions = choice.items.map(item => {\n return {\n name: item.text,\n value: item.text,\n validOption: true,\n selected: item.text === answer\n };\n });\n const maxLength = get('question.content.choices.length', slide);\n\n return {\n type: choice.type,\n name: choice.name,\n onChange: pipe(\n updateTemplateAnswer(answers, index, maxLength),\n editAnswerAction_(state, slide)\n ),\n options: isEmpty(answer) ? [temporaryOption].concat(selectOptions) : selectOptions,\n 'aria-label': translate('Select an answer')\n };\n };\n};\n\nconst templateProps = (options, store) => {\n const getChoices_ = getChoices();\n const templateTextProps_ = templateTextProps(options, store);\n const templateSelectProps_ = templateSelectProps(options, store);\n\n return (state, slide) => {\n return {\n type: 'template',\n template: slide.question.content.template,\n answers: getChoices_(slide, state).map((choice, index) =>\n choice.type === 'text'\n ? templateTextProps_(state, slide, choice, index)\n : templateSelectProps_(state, slide, choice, index)\n )\n };\n };\n};\n\nconst basicProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const {translate} = options;\n return {\n type: 'freeText',\n placeholder: translate('Type here'),\n value: pipe(getAnswerValues, head)(slide, state),\n onChange: editAnswerAction_(state, slide)\n };\n };\n};\n\nconst toAnswer = values => {\n const maxValue = size(values) - 1;\n return position => {\n return pipe(multiply(maxValue), round, get(__, values), _toString)(position);\n };\n};\n\nconst sliderProps = (options, store) => {\n const editAnswerAction_ = editAnswerAction(options, store);\n\n return (state, slide) => {\n const values = rangeStep(\n slide.question.content.step || 1,\n slide.question.content.min,\n slide.question.content.max + 1\n );\n\n const stateValue = pipe(getAnswerValues, head)(slide, state);\n const currentValue = toInteger(stateValue);\n\n const indexValue = indexOf(currentValue, values);\n const handleChange = editAnswerAction_(state, slide);\n const sliderPosition = divide(indexValue, size(values) - 1);\n\n return {\n type: 'slider',\n placeholder: slide.question.explanation,\n minLabel: `${slide.question.content.min} ${slide.question.content.unitLabel}`,\n maxLabel: `${slide.question.content.max} ${slide.question.content.unitLabel}`,\n title: `${currentValue} ${slide.question.content.unitLabel}`,\n value: sliderPosition,\n onChange: pipe(toAnswer(values), handleChange)\n };\n };\n};\n\nconst createGetAnswerProps = (options, store) => {\n const qcmProps_ = qcmProps(options, store);\n const qcmGraphicProps_ = qcmGraphicProps(options, store);\n const qcmDragProps_ = qcmDragProps(options, store);\n const basicProps_ = basicProps(options, store);\n const templateProps_ = templateProps(options, store);\n const sliderProps_ = sliderProps(options, store);\n\n return (state, slide) => {\n if (!slide) {\n return;\n }\n const type = getQuestionType(slide);\n switch (type) {\n case 'qcm':\n return qcmProps_(state, slide);\n\n case 'qcmGraphic':\n return qcmGraphicProps_(state, slide);\n\n case 'qcmDrag':\n return qcmDragProps_(state, slide);\n\n case 'basic':\n return basicProps_(state, slide);\n\n case 'template':\n return templateProps_(state, slide);\n\n case 'slider':\n return sliderProps_(state, slide);\n\n default:\n throw new Error(`${type} is not an handled question.type`);\n }\n };\n};\n\nconst createGetHelp = (options, store) => slide => {\n const {translate} = options;\n return get('question.explanation', slide) || translate('Select something below');\n};\n\nexport {createGetAnswerProps, createGetHelp};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAQA,UAAU,EAAEC,eAAe,EAAEC,eAAe,EAAEC,UAAU,QAAO,4BAA4B;A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AY,CAACtF,KAAK,EAAEC,KAAK,CAAC;MAEnC;QACE,MAAM,IAAIsF,KAAK,CAAC,GAAGlF,IAAI,kCAAkC,CAAC;IAC9D;EACF,CAAC;AACH,CAAC;AAED,MAAMmF,aAAa,GAAGA,CAAChG,OAAO,EAAEK,KAAK,KAAKI,KAAK,IAAI;EACjD,MAAM;IAAC8B;EAAS,CAAC,GAAGvC,OAAO;EAC3B,OAAO2B,IAAA,CAAI,sBAAsB,EAAElB,KAAK,CAAC,IAAI8B,SAAS,CAAC,wBAAwB,CAAC;AAClF,CAAC;AAED,SAAQiD,oBAAoB,EAAEQ,aAAa","ignoreList":[]}
@@ -2,15 +2,12 @@ import _values from "lodash/fp/values";
2
2
  import _pipe from "lodash/fp/pipe";
3
3
  import _get from "lodash/fp/get";
4
4
  import _some from "lodash/fp/some";
5
-
6
5
  const mapStateToErrorPopinProps = ({
7
6
  dispatch
8
7
  }) => {
9
8
  return state => {
10
9
  const isFailure = _pipe(_get('data'), _values, _some('isFailure'))(state);
11
-
12
10
  const isContentFailure = _pipe(_get('data.contents'), _values, _some('isFailure'))(state);
13
-
14
11
  if (isFailure || isContentFailure) return {
15
12
  content: 'An unexpected error has occurred',
16
13
  icon: 'AlertDiamond',
@@ -27,6 +24,5 @@ const mapStateToErrorPopinProps = ({
27
24
  return;
28
25
  };
29
26
  };
30
-
31
27
  export default mapStateToErrorPopinProps;
32
28
  //# sourceMappingURL=error-popin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-popin.js","names":["mapStateToErrorPopinProps","dispatch","state","isFailure","isContentFailure","content","icon","mode","descriptionText","firstButton","largeButton","label","type","handleOnclick","window","location","reload"],"sources":["../../src/map-state-to-props/error-popin.js"],"sourcesContent":["import {some, get, pipe, values} from 'lodash/fp';\n\nconst mapStateToErrorPopinProps = ({dispatch}) => {\n return state => {\n const isFailure = pipe(get('data'), values, some('isFailure'))(state);\n const isContentFailure = pipe(get('data.contents'), values, some('isFailure'))(state);\n if (isFailure || isContentFailure)\n return {\n content: 'An unexpected error has occurred',\n icon: 'AlertDiamond',\n mode: 'alert',\n descriptionText: 'Please reload the page and try again',\n firstButton: {\n largeButton: true,\n label: 'Reload',\n type: 'primary',\n 'aria-label': 'Reload',\n handleOnclick: () => window.location.reload()\n }\n };\n return;\n };\n};\n\nexport default mapStateToErrorPopinProps;\n"],"mappings":";;;;;AAEA,MAAMA,yBAAyB,GAAG,CAAC;EAACC;AAAD,CAAD,KAAgB;EAChD,OAAOC,KAAK,IAAI;IACd,MAAMC,SAAS,GAAG,MAAK,KAAI,MAAJ,CAAL,WAA0B,MAAK,WAAL,CAA1B,EAA6CD,KAA7C,CAAlB;;IACA,MAAME,gBAAgB,GAAG,MAAK,KAAI,eAAJ,CAAL,WAAmC,MAAK,WAAL,CAAnC,EAAsDF,KAAtD,CAAzB;;IACA,IAAIC,SAAS,IAAIC,gBAAjB,EACE,OAAO;MACLC,OAAO,EAAE,kCADJ;MAELC,IAAI,EAAE,cAFD;MAGLC,IAAI,EAAE,OAHD;MAILC,eAAe,EAAE,sCAJZ;MAKLC,WAAW,EAAE;QACXC,WAAW,EAAE,IADF;QAEXC,KAAK,EAAE,QAFI;QAGXC,IAAI,EAAE,SAHK;QAIX,cAAc,QAJH;QAKXC,aAAa,EAAE,MAAMC,MAAM,CAACC,QAAP,CAAgBC,MAAhB;MALV;IALR,CAAP;IAaF;EACD,CAlBD;AAmBD,CApBD;;AAsBA,eAAehB,yBAAf"}
1
+ {"version":3,"file":"error-popin.js","names":["mapStateToErrorPopinProps","dispatch","state","isFailure","_pipe","_get","_values","_some","isContentFailure","content","icon","mode","descriptionText","firstButton","largeButton","label","type","handleOnclick","window","location","reload"],"sources":["../../src/map-state-to-props/error-popin.js"],"sourcesContent":["import {some, get, pipe, values} from 'lodash/fp';\n\nconst mapStateToErrorPopinProps = ({dispatch}) => {\n return state => {\n const isFailure = pipe(get('data'), values, some('isFailure'))(state);\n const isContentFailure = pipe(get('data.contents'), values, some('isFailure'))(state);\n if (isFailure || isContentFailure)\n return {\n content: 'An unexpected error has occurred',\n icon: 'AlertDiamond',\n mode: 'alert',\n descriptionText: 'Please reload the page and try again',\n firstButton: {\n largeButton: true,\n label: 'Reload',\n type: 'primary',\n 'aria-label': 'Reload',\n handleOnclick: () => window.location.reload()\n }\n };\n return;\n };\n};\n\nexport default mapStateToErrorPopinProps;\n"],"mappings":";;;;AAEA,MAAMA,yBAAyB,GAAGA,CAAC;EAACC;AAAQ,CAAC,KAAK;EAChD,OAAOC,KAAK,IAAI;IACd,MAAMC,SAAS,GAAGC,KAAA,CAAKC,IAAA,CAAI,MAAM,CAAC,EAAAC,OAAA,EAAUC,KAAA,CAAK,WAAW,CAAC,CAAC,CAACL,KAAK,CAAC;IACrE,MAAMM,gBAAgB,GAAGJ,KAAA,CAAKC,IAAA,CAAI,eAAe,CAAC,EAAAC,OAAA,EAAUC,KAAA,CAAK,WAAW,CAAC,CAAC,CAACL,KAAK,CAAC;IACrF,IAAIC,SAAS,IAAIK,gBAAgB,EAC/B,OAAO;MACLC,OAAO,EAAE,kCAAkC;MAC3CC,IAAI,EAAE,cAAc;MACpBC,IAAI,EAAE,OAAO;MACbC,eAAe,EAAE,sCAAsC;MACvDC,WAAW,EAAE;QACXC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE,QAAQ;QACfC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,QAAQ;QACtBC,aAAa,EAAEA,CAAA,KAAMC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;MAC9C;IACF,CAAC;IACH;EACF,CAAC;AACH,CAAC;AAED,eAAepB,yBAAyB","ignoreList":[]}
@@ -1,21 +1,15 @@
1
1
  import _indexOf from "lodash/fp/indexOf";
2
2
  import _getOr from "lodash/fp/getOr";
3
3
  import _get from "lodash/fp/get";
4
-
5
- function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
6
-
7
4
  import { getCurrentChapter, getEngine, getLives, getCurrentContent, back } from '@coorpacademy/player-store';
8
-
9
5
  const headerContent = (engineRef, state) => {
10
6
  const content = getCurrentContent(state);
11
-
12
7
  switch (engineRef) {
13
8
  case 'learner':
14
9
  return {
15
10
  title: _getOr('', 'name')(content),
16
11
  details: _get('levelTranslation')(content)
17
12
  };
18
-
19
13
  case 'microlearning':
20
14
  default:
21
15
  return {
@@ -23,29 +17,24 @@ const headerContent = (engineRef, state) => {
23
17
  };
24
18
  }
25
19
  };
26
-
27
20
  const headerSubcontent = (engineRef, state) => {
28
21
  switch (engineRef) {
29
22
  case 'learner':
30
23
  {
31
24
  const chapter = getCurrentChapter(state);
32
25
  const level = getCurrentContent(state);
33
-
34
26
  const chapterIds = _get('chapterIds', level);
35
-
36
27
  const details = chapter && chapterIds ? `${1 + _indexOf(chapter._id, chapterIds)}/${chapterIds.length}` : null;
37
28
  return {
38
29
  title: _getOr('', 'name', chapter),
39
30
  details
40
31
  };
41
32
  }
42
-
43
33
  case 'microlearning':
44
34
  default:
45
35
  return null;
46
36
  }
47
37
  };
48
-
49
38
  const headerProps = (options, {
50
39
  dispatch
51
40
  }) => state => {
@@ -59,9 +48,10 @@ const headerProps = (options, {
59
48
  } = getLives(state);
60
49
  return {
61
50
  type: engineRef,
62
- content: _extends({}, headerContent(engineRef, state), {
51
+ content: {
52
+ ...headerContent(engineRef, state),
63
53
  onClick: () => dispatch(back)
64
- }),
54
+ },
65
55
  subcontent: headerSubcontent(engineRef, state),
66
56
  lives: hide ? false : {
67
57
  count
@@ -69,6 +59,5 @@ const headerProps = (options, {
69
59
  mode: options.mode || 'default'
70
60
  };
71
61
  };
72
-
73
62
  export default headerProps;
74
63
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","names":["getCurrentChapter","getEngine","getLives","getCurrentContent","back","headerContent","engineRef","state","content","title","details","headerSubcontent","chapter","level","chapterIds","_id","length","headerProps","options","dispatch","engine","ref","hide","count","type","onClick","subcontent","lives","mode"],"sources":["../../src/map-state-to-props/header.js"],"sourcesContent":["import {get, getOr, indexOf} from 'lodash/fp';\nimport {\n getCurrentChapter,\n getEngine,\n getLives,\n getCurrentContent,\n back\n} from '@coorpacademy/player-store';\n\nconst headerContent = (engineRef, state) => {\n const content = getCurrentContent(state);\n\n switch (engineRef) {\n case 'learner':\n return {\n title: getOr('', 'name')(content),\n details: get('levelTranslation')(content)\n };\n case 'microlearning':\n default:\n return {\n title: getOr('', 'name')(content)\n };\n }\n};\n\nconst headerSubcontent = (engineRef, state) => {\n switch (engineRef) {\n case 'learner': {\n const chapter = getCurrentChapter(state);\n const level = getCurrentContent(state);\n const chapterIds = get('chapterIds', level);\n const details =\n chapter && chapterIds\n ? `${1 + indexOf(chapter._id, chapterIds)}/${chapterIds.length}`\n : null;\n\n return {\n title: getOr('', 'name', chapter),\n details\n };\n }\n case 'microlearning':\n default:\n return null;\n }\n};\n\nconst headerProps =\n (options, {dispatch}) =>\n state => {\n const engine = getEngine(state);\n const {ref: engineRef} = engine;\n const {hide, count} = getLives(state);\n\n return {\n type: engineRef,\n content: {\n ...headerContent(engineRef, state),\n onClick: () => dispatch(back)\n },\n subcontent: headerSubcontent(engineRef, state),\n lives: hide ? false : {count},\n mode: options.mode || 'default'\n };\n };\n\nexport default headerProps;\n"],"mappings":";;;;;;AACA,SACEA,iBADF,EAEEC,SAFF,EAGEC,QAHF,EAIEC,iBAJF,EAKEC,IALF,QAMO,4BANP;;AAQA,MAAMC,aAAa,GAAG,CAACC,SAAD,EAAYC,KAAZ,KAAsB;EAC1C,MAAMC,OAAO,GAAGL,iBAAiB,CAACI,KAAD,CAAjC;;EAEA,QAAQD,SAAR;IACE,KAAK,SAAL;MACE,OAAO;QACLG,KAAK,EAAE,OAAM,EAAN,EAAU,MAAV,EAAkBD,OAAlB,CADF;QAELE,OAAO,EAAE,KAAI,kBAAJ,EAAw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,GAAG,KAAH,GAAW;MAACC;IAAD,CAPjB;IAQLK,IAAI,EAAEV,OAAO,CAACU,IAAR,IAAgB;EARjB,CAAP;AAUD,CAjBH;;AAmBA,eAAeX,WAAf"}
1
+ {"version":3,"file":"header.js","names":["getCurrentChapter","getEngine","getLives","getCurrentContent","back","headerContent","engineRef","state","content","title","_getOr","details","_get","headerSubcontent","chapter","level","chapterIds","_indexOf","_id","length","headerProps","options","dispatch","engine","ref","hide","count","type","onClick","subcontent","lives","mode"],"sources":["../../src/map-state-to-props/header.js"],"sourcesContent":["import {get, getOr, indexOf} from 'lodash/fp';\nimport {\n getCurrentChapter,\n getEngine,\n getLives,\n getCurrentContent,\n back\n} from '@coorpacademy/player-store';\n\nconst headerContent = (engineRef, state) => {\n const content = getCurrentContent(state);\n\n switch (engineRef) {\n case 'learner':\n return {\n title: getOr('', 'name')(content),\n details: get('levelTranslation')(content)\n };\n case 'microlearning':\n default:\n return {\n title: getOr('', 'name')(content)\n };\n }\n};\n\nconst headerSubcontent = (engineRef, state) => {\n switch (engineRef) {\n case 'learner': {\n const chapter = getCurrentChapter(state);\n const level = getCurrentContent(state);\n const chapterIds = get('chapterIds', level);\n const details =\n chapter && chapterIds\n ? `${1 + indexOf(chapter._id, chapterIds)}/${chapterIds.length}`\n : null;\n\n return {\n title: getOr('', 'name', chapter),\n details\n };\n }\n case 'microlearning':\n default:\n return null;\n }\n};\n\nconst headerProps =\n (options, {dispatch}) =>\n state => {\n const engine = getEngine(state);\n const {ref: engineRef} = engine;\n const {hide, count} = getLives(state);\n\n return {\n type: engineRef,\n content: {\n ...headerContent(engineRef, state),\n onClick: () => dispatch(back)\n },\n subcontent: headerSubcontent(engineRef, state),\n lives: hide ? false : {count},\n mode: options.mode || 'default'\n };\n };\n\nexport default headerProps;\n"],"mappings":";;;AACA,SACEA,iBAAiB,EACjBC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,IAAI,QACC,4BAA4B;AAEnC,MAAMC,aAAa,GAAG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AAEC;EAAK,CAAC,GAAGxB,QAAQ,CAACK,KAAK,CAAC;EAErC,OAAO;IACLoB,IAAI,EAAErB,SAAS;IACfE,OAAO,EAAE;MACP,GAAGH,aAAa,CAACC,SAAS,EAAEC,KAAK,CAAC;MAClCqB,OAAO,EAAEA,CAAA,KAAMN,QAAQ,CAAClB,IAAI;IAC9B,CAAC;IACDyB,UAAU,EAAEhB,gBAAgB,CAACP,SAAS,EAAEC,KAAK,CAAC;IAC9CuB,KAAK,EAAEL,IAAI,GAAG,KAAK,GAAG;MAACC;IAAK,CAAC;IAC7BK,IAAI,EAAEV,OAAO,CAACU,IAAI,IAAI;EACxB,CAAC;AACH,CAAC;AAEH,eAAeX,WAAW","ignoreList":[]}
@@ -9,16 +9,10 @@ import { popinCorrectionStateToProps } from './popin-correction';
9
9
  import popinEndStateToProps from './popin-end';
10
10
  import loadingStateToProps from './loading';
11
11
  import createSlideStateToProps from './slide';
12
-
13
12
  const hasNotProgression = _pipe(getCurrentProgression, _isNil);
14
-
15
13
  const hasNoContent = _pipe(getStepContent, _isNil);
16
-
17
14
  const matchRoute = route => _pipe(getRoute, _isEqual(route));
18
-
19
15
  const matchContentType = contentType => _pipe(getStepContent, _get('type'), _isEqual(contentType));
20
-
21
16
  const matchContentRef = contentType => _pipe(getStepContent, _get('ref'), _isEqual(contentType));
22
-
23
17
  export const selectMapStateToVNode = (options, store, views, createStateToVNode) => _cond([[hasNotProgression, createStateToVNode(views.loading, loadingStateToProps)], [hasNoContent, createStateToVNode(views.loading, loadingStateToProps)], [matchRoute('correction'), createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))], [matchContentRef('extraLife'), createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))], [matchContentType('slide'), createStateToVNode(views.player, createSlideStateToProps(options, store))], [matchContentType('success'), createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))], [matchContentType('failure'), createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))], [_constant(true), createStateToVNode(views.loading, loadingStateToProps)]]);
24
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getStepContent","getCurrentProgression","getRoute","popinCorrectionStateToProps","popinEndStateToProps","loadingStateToProps","createSlideStateToProps","hasNotProgression","hasNoContent","matchRoute","route","matchContentType","contentType","matchContentRef","selectMapStateToVNode","options","store","views","createStateToVNode","loading","popinCorrection","player","popinEnd"],"sources":["../../src/map-state-to-props/index.js"],"sourcesContent":["import {cond, constant, get, isNil, isEqual, pipe} from 'lodash/fp';\nimport {getStepContent, getCurrentProgression, getRoute} from '@coorpacademy/player-store';\nimport {popinCorrectionStateToProps} from './popin-correction';\nimport popinEndStateToProps from './popin-end';\nimport loadingStateToProps from './loading';\nimport createSlideStateToProps from './slide';\n\nconst hasNotProgression = pipe(getCurrentProgression, isNil);\nconst hasNoContent = pipe(getStepContent, isNil);\nconst matchRoute = route => pipe(getRoute, isEqual(route));\nconst matchContentType = contentType => pipe(getStepContent, get('type'), isEqual(contentType));\nconst matchContentRef = contentType => pipe(getStepContent, get('ref'), isEqual(contentType));\n\nexport const selectMapStateToVNode = (options, store, views, createStateToVNode) =>\n cond([\n [hasNotProgression, createStateToVNode(views.loading, loadingStateToProps)],\n [hasNoContent, createStateToVNode(views.loading, loadingStateToProps)],\n [\n matchRoute('correction'),\n createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))\n ],\n [\n matchContentRef('extraLife'),\n createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))\n ],\n [\n matchContentType('slide'),\n createStateToVNode(views.player, createSlideStateToProps(options, store))\n ],\n [\n matchContentType('success'),\n createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))\n ],\n [\n matchContentType('failure'),\n createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))\n ],\n [constant(true), createStateToVNode(views.loading, loadingStateToProps)]\n ]);\n"],"mappings":";;;;;;AACA,SAAQA,cAAR,EAAwBC,qBAAxB,EAA+CC,QAA/C,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AAV,CAAtC,CAFpB,CAXG,EAeH,CACEL,gBAAgB,CAAC,SAAD,CADlB,EAEEO,kBAAkB,CAACD,KAAK,CAACK,QAAP,EAAiBlB,oBAAoB,CAACW,OAAD,EAAUC,KAAV,CAArC,CAFpB,CAfG,EAmBH,CACEL,gBAAgB,CAAC,SAAD,CADlB,EAEEO,kBAAkB,CAACD,KAAK,CAACK,QAAP,EAAiBlB,oBAAoB,CAACW,OAAD,EAAUC,KAAV,CAArC,CAFpB,CAnBG,EAuBH,CAAC,UAAS,IAAT,CAAD,EAAiBE,kBAAkB,CAACD,KAAK,CAACE,OAAP,EAAgBd,mBAAhB,CAAnC,CAvBG,CAAL,CADK"}
1
+ {"version":3,"file":"index.js","names":["getStepContent","getCurrentProgression","getRoute","popinCorrectionStateToProps","popinEndStateToProps","loadingStateToProps","createSlideStateToProps","hasNotProgression","_pipe","_isNil","hasNoContent","matchRoute","route","_isEqual","matchContentType","contentType","_get","matchContentRef","selectMapStateToVNode","options","store","views","createStateToVNode","_cond","loading","popinCorrection","player","popinEnd","_constant"],"sources":["../../src/map-state-to-props/index.js"],"sourcesContent":["import {cond, constant, get, isNil, isEqual, pipe} from 'lodash/fp';\nimport {getStepContent, getCurrentProgression, getRoute} from '@coorpacademy/player-store';\nimport {popinCorrectionStateToProps} from './popin-correction';\nimport popinEndStateToProps from './popin-end';\nimport loadingStateToProps from './loading';\nimport createSlideStateToProps from './slide';\n\nconst hasNotProgression = pipe(getCurrentProgression, isNil);\nconst hasNoContent = pipe(getStepContent, isNil);\nconst matchRoute = route => pipe(getRoute, isEqual(route));\nconst matchContentType = contentType => pipe(getStepContent, get('type'), isEqual(contentType));\nconst matchContentRef = contentType => pipe(getStepContent, get('ref'), isEqual(contentType));\n\nexport const selectMapStateToVNode = (options, store, views, createStateToVNode) =>\n cond([\n [hasNotProgression, createStateToVNode(views.loading, loadingStateToProps)],\n [hasNoContent, createStateToVNode(views.loading, loadingStateToProps)],\n [\n matchRoute('correction'),\n createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))\n ],\n [\n matchContentRef('extraLife'),\n createStateToVNode(views.popinCorrection, popinCorrectionStateToProps(options, store))\n ],\n [\n matchContentType('slide'),\n createStateToVNode(views.player, createSlideStateToProps(options, store))\n ],\n [\n matchContentType('success'),\n createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))\n ],\n [\n matchContentType('failure'),\n createStateToVNode(views.popinEnd, popinEndStateToProps(options, store))\n ],\n [constant(true), createStateToVNode(views.loading, loadingStateToProps)]\n ]);\n"],"mappings":";;;;;;AACA,SAAQA,cAAc,EAAEC,qBAAqB,EAAEC,QAAQ,QAAO,4BAA4B;AAC1F,SAAQC,2BAA2B,QAAO,oBAAoB;AAC9D,OAAOC,oBAAoB,MAAM,aAAa;AAC9C,OAAOC,mBAAmB,MAAM,WAAW;AAC3C,OAAOC,uBAAuB,MAAM,SAAS;AAE7C,MAAMC,iBAAiB,GAAGC,KAAA,CAAKP,qBAAqB,EAAAQ,MAAO,CAAC;AAC5D,MAAMC,YAAY,GAAGF,KAAA,CAAKR,cAAc,EAAAS,MAAO,CAAC;AAChD,MAAME,UAAU,GAAGC,KAAK,IAAIJ,KAAA,CAAKN,QAAQ,EAAEW,QAAA,CAAQD,KAAK,CAAC,CAAC;AAC1D,MAAME,gBAAgB,GAAGC,WAAW,IAAIP,KAAA,CAAKR,cAAc,EAAEgB,IAAA,CAAI,MAAM,CAAC,EAAEH,QAAA,CAAQE,WAAW,CAAC,CAAC;AAC/F,MAAME,eAAe,GAAGF,WAAW,IAAIP,KAAA,CAAKR,cAAc,EAAEgB,IAAA,CAAI,KAAK,CAAC,EAAEH,QAAA,CAAQE,WAAW,CAAC,CAAC;AAE7F,OAAO,MAAMG,qBAAqB,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAEC,kBAAkB,KAC7EC,KAAA,CAAK,CACH,CAAChB,iBAAiB,EAAEe,kBAAkB,CAACD,KAAK,CAACG,OAAO,EAAEnB,mBAAmB,CAAC,CAAC,EAC3E,CAACK,YAAY,EAAEY,kBAAkB,CAACD,KAAK,CAACG,OAAO,EAAEnB,mBAAmB,CAAC,CAAC,EACtE,CACEM,UAAU,CAAC,YAAY,CAAC,EACxBW,kBAAkB,CAACD,KAAK,CAACI,eAAe,EAAEtB,2BAA2B,CAACgB,OAAO,EAAEC,KAAK,CAAC,CAAC,CACvF,EACD,CACEH,eAAe,CAAC,WAAW,CAAC,EAC5BK,kBAAkB,CAACD,KAAK,CAACI,eAAe,EAAEtB,2BAA2B,CAACgB,OAAO,EAAEC,KAAK,CAAC,CAAC,CACvF,EACD,CACEN,gBAAgB,CAAC,OAAO,CAAC,EACzBQ,kBAAkB,CAACD,KAAK,CAACK,MAAM,EAAEpB,uBAAuB,CAACa,OAAO,EAAEC,KAAK,CAAC,CAAC,CAC1E,EACD,CACEN,gBAAgB,CAAC,SAAS,CAAC,EAC3BQ,kBAAkB,CAACD,KAAK,CAACM,QAAQ,EAAEvB,oBAAoB,CAACe,OAAO,EAAEC,KAAK,CAAC,CAAC,CACzE,EACD,CACEN,gBAAgB,CAAC,SAAS,CAAC,EAC3BQ,kBAAkB,CAACD,KAAK,CAACM,QAAQ,EAAEvB,oBAAoB,CAACe,OAAO,EAAEC,KAAK,CAAC,CAAC,CACzE,EACD,CAACQ,SAAA,CAAS,IAAI,CAAC,EAAEN,kBAAkB,CAACD,KAAK,CAACG,OAAO,EAAEnB,mBAAmB,CAAC,CAAC,CACzE,CAAC","ignoreList":[]}
@@ -1,4 +1,3 @@
1
1
  const mapStateToProps = state => ({});
2
-
3
2
  export default mapStateToProps;
4
3
  //# sourceMappingURL=loading.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loading.js","names":["mapStateToProps","state"],"sources":["../../src/map-state-to-props/loading.js"],"sourcesContent":["const mapStateToProps = state => ({});\nexport default mapStateToProps;\n"],"mappings":"AAAA,MAAMA,eAAe,GAAGC,KAAK,KAAK,EAAL,CAA7B;;AACA,eAAeD,eAAf"}
1
+ {"version":3,"file":"loading.js","names":["mapStateToProps","state"],"sources":["../../src/map-state-to-props/loading.js"],"sourcesContent":["const mapStateToProps = state => ({});\nexport default mapStateToProps;\n"],"mappings":"AAAA,MAAMA,eAAe,GAAGC,KAAK,KAAK,CAAC,CAAC,CAAC;AACrC,eAAeD,eAAe","ignoreList":[]}
@@ -11,7 +11,6 @@ const STARS_DIFF = {
11
11
  media: 'starsPerResourceViewed',
12
12
  clue: 'starsPerAskingClue'
13
13
  };
14
-
15
14
  const playerProps = (options, store) => {
16
15
  const createGetAnswerProps_ = createGetAnswerProps(options, store);
17
16
  const getResourcesProps_ = getResourcesProps(options, store);
@@ -27,9 +26,7 @@ const playerProps = (options, store) => {
27
26
  } = store;
28
27
  const engineConfig = getEngineConfig(state);
29
28
  const slide = getCurrentSlide(state);
30
-
31
29
  const slideContext = _get('context', slide);
32
-
33
30
  const currentContent = getCurrentContent(state);
34
31
  const answer = createGetAnswerProps_(state, slide);
35
32
  const mediaQuestion = getQuestionMedia(state);
@@ -38,19 +35,12 @@ const playerProps = (options, store) => {
38
35
  const resources = getResourcesProps_(state, slide);
39
36
  const help = createGetHelp_(slide);
40
37
  const starsDiff = _get(STARS_DIFF[route], engineConfig) || 0;
41
-
42
38
  const clickClueHandler = () => dispatch(selectClue);
43
-
44
39
  const clickSeeClueHandler = () => dispatch(getClue);
45
-
46
40
  const clickBackToAnswerHandler = () => dispatch(selectRoute('answer'));
47
-
48
41
  const clickCTAHandler = () => dispatch(validateAnswer());
49
-
50
42
  const hasClue = _get('hasClue', slide);
51
-
52
43
  const slideLessons = _get('lessons', slide);
53
-
54
44
  const notifyNewMedia = !_isEmpty(slideLessons) && !hasSeenLesson(state);
55
45
  const notifyReviewLesson = !_isEmpty(slideLessons) && hasSeenLesson(state);
56
46
  const contextButton = _get('title', slideContext) ? [{
@@ -88,11 +78,9 @@ const playerProps = (options, store) => {
88
78
  onClick: () => dispatch(startChat())
89
79
  });
90
80
  const headerProps = createHeaderStateToProps_(state);
91
-
92
81
  if (!_includes(route, ROUTES)) {
93
82
  return {};
94
83
  }
95
-
96
84
  const ctaButtonValidate = {
97
85
  submitValue: translate('Validate'),
98
86
  'aria-label': `${translate('Validate')}. ${translate('Submit your Answer')}`,
@@ -137,6 +125,5 @@ const playerProps = (options, store) => {
137
125
  };
138
126
  };
139
127
  };
140
-
141
128
  export default playerProps;
142
129
  //# sourceMappingURL=player.js.map