@coorpacademy/components 10.22.24 → 10.22.26

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 (95) hide show
  1. package/es/atom/choice/index.native.js +4 -4
  2. package/es/atom/choice/index.native.js.map +1 -1
  3. package/es/atom/select-modal/index.native.js +1 -1
  4. package/es/atom/select-modal/index.native.js.map +1 -1
  5. package/es/hoc/modal/select/index.native.js.map +1 -1
  6. package/es/molecule/answer/index.native.js +85 -0
  7. package/es/molecule/answer/index.native.js.map +1 -0
  8. package/es/molecule/answer/prop-types.js +22 -3
  9. package/es/molecule/answer/prop-types.js.map +1 -1
  10. package/es/molecule/questions/mobile/draggable/index.native.js +8 -29
  11. package/es/molecule/questions/mobile/draggable/index.native.js.map +1 -1
  12. package/es/molecule/questions/mobile/switch/index.native.js +57 -54
  13. package/es/molecule/questions/mobile/switch/index.native.js.map +1 -1
  14. package/es/molecule/questions/mobile/template/index.native.js +18 -23
  15. package/es/molecule/questions/mobile/template/index.native.js.map +1 -1
  16. package/es/molecule/questions/types.js +2 -0
  17. package/{lib/types/styles.d.js.map → es/molecule/questions/types.js.map} +1 -1
  18. package/es/organism/review-congrats/index.js +3 -1
  19. package/es/organism/review-congrats/index.js.map +1 -1
  20. package/es/organism/review-congrats/style.css +5 -0
  21. package/es/organism/review-slide/index.js +7 -11
  22. package/es/organism/review-slide/index.js.map +1 -1
  23. package/es/organism/review-slide/index.native.js +213 -0
  24. package/es/organism/review-slide/index.native.js.map +1 -0
  25. package/es/organism/review-slide/prop-types.js +4 -3
  26. package/es/organism/review-slide/prop-types.js.map +1 -1
  27. package/es/organism/review-slide/style.css +4 -0
  28. package/es/organism/review-stacked-slides/index.native.js +34 -0
  29. package/es/organism/review-stacked-slides/index.native.js.map +1 -0
  30. package/es/organism/review-stacked-slides/prop-types.js +9 -8
  31. package/es/organism/review-stacked-slides/prop-types.js.map +1 -1
  32. package/es/template/app-review/player/index.native.js +33 -230
  33. package/es/template/app-review/player/index.native.js.map +1 -1
  34. package/es/template/app-review/player/prop-types.js.map +1 -1
  35. package/es/template/app-review/player/style.css +7 -0
  36. package/es/template/app-review/template-context.js +3 -1
  37. package/es/template/app-review/template-context.js.map +1 -1
  38. package/es/types/styles.js +2 -0
  39. package/es/types/{styles.d.js.map → styles.js.map} +1 -1
  40. package/es/util/proptypes.js +2 -2
  41. package/es/util/proptypes.js.map +1 -1
  42. package/lib/atom/choice/index.native.js +4 -4
  43. package/lib/atom/choice/index.native.js.map +1 -1
  44. package/lib/atom/select-modal/index.native.js +1 -1
  45. package/lib/atom/select-modal/index.native.js.map +1 -1
  46. package/lib/hoc/modal/select/index.native.js.map +1 -1
  47. package/lib/molecule/answer/index.native.js +94 -0
  48. package/lib/molecule/answer/index.native.js.map +1 -0
  49. package/lib/molecule/answer/prop-types.js +25 -3
  50. package/lib/molecule/answer/prop-types.js.map +1 -1
  51. package/lib/molecule/questions/mobile/draggable/index.native.js +8 -31
  52. package/lib/molecule/questions/mobile/draggable/index.native.js.map +1 -1
  53. package/lib/molecule/questions/mobile/switch/index.native.js +64 -62
  54. package/lib/molecule/questions/mobile/switch/index.native.js.map +1 -1
  55. package/lib/molecule/questions/mobile/template/index.native.js +18 -23
  56. package/lib/molecule/questions/mobile/template/index.native.js.map +1 -1
  57. package/lib/molecule/questions/types.js +2 -0
  58. package/lib/{types/app-review.d.js.map → molecule/questions/types.js.map} +1 -1
  59. package/lib/organism/review-congrats/index.js +3 -1
  60. package/lib/organism/review-congrats/index.js.map +1 -1
  61. package/lib/organism/review-congrats/style.css +5 -0
  62. package/lib/organism/review-slide/index.js +7 -11
  63. package/lib/organism/review-slide/index.js.map +1 -1
  64. package/lib/organism/review-slide/index.native.js +232 -0
  65. package/lib/organism/review-slide/index.native.js.map +1 -0
  66. package/lib/organism/review-slide/prop-types.js +6 -5
  67. package/lib/organism/review-slide/prop-types.js.map +1 -1
  68. package/lib/organism/review-slide/style.css +4 -0
  69. package/lib/organism/review-stacked-slides/index.native.js +47 -0
  70. package/lib/organism/review-stacked-slides/index.native.js.map +1 -0
  71. package/lib/organism/review-stacked-slides/prop-types.js +8 -7
  72. package/lib/organism/review-stacked-slides/prop-types.js.map +1 -1
  73. package/lib/template/app-review/player/index.native.js +36 -233
  74. package/lib/template/app-review/player/index.native.js.map +1 -1
  75. package/lib/template/app-review/player/prop-types.js.map +1 -1
  76. package/lib/template/app-review/player/style.css +7 -0
  77. package/lib/template/app-review/template-context.js +3 -1
  78. package/lib/template/app-review/template-context.js.map +1 -1
  79. package/lib/types/styles.js +2 -0
  80. package/{es/types/app-review.d.js.map → lib/types/styles.js.map} +1 -1
  81. package/lib/util/proptypes.js +5 -5
  82. package/lib/util/proptypes.js.map +1 -1
  83. package/package.json +2 -2
  84. package/es/molecule/questions/qcm/index.native.js +0 -50
  85. package/es/molecule/questions/qcm/index.native.js.map +0 -1
  86. package/es/types/app-review.d.js +0 -2
  87. package/es/types/progression-engine.d.js +0 -2
  88. package/es/types/progression-engine.d.js.map +0 -1
  89. package/es/types/styles.d.js +0 -2
  90. package/lib/molecule/questions/qcm/index.native.js +0 -62
  91. package/lib/molecule/questions/qcm/index.native.js.map +0 -1
  92. package/lib/types/app-review.d.js +0 -2
  93. package/lib/types/progression-engine.d.js +0 -2
  94. package/lib/types/progression-engine.d.js.map +0 -1
  95. package/lib/types/styles.d.js +0 -2
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _react = _interopRequireDefault(require("react"));
7
+
8
+ var _index = _interopRequireDefault(require("../questions/mobile/switch/index.native"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const convertType = modelType => {
13
+ switch (modelType) {
14
+ case 'freeText':
15
+ return 'basic';
16
+
17
+ case 'dropDown':
18
+ return 'template';
19
+
20
+ default:
21
+ return modelType;
22
+ }
23
+ };
24
+
25
+ const convertToChoices = (answers = []) => answers.map((answer, index) => ({
26
+ _id: `${index}`,
27
+ label: answer.title,
28
+ value: answer.title,
29
+ onPress: answer.onClick || answer.onChange,
30
+ selected: answer.selected,
31
+ media: answer.image ? {
32
+ type: 'img',
33
+ src: [{
34
+ url: answer.image
35
+ }]
36
+ } : undefined,
37
+ // ---- custom properties for template choice
38
+ type: answer.type,
39
+ name: answer.name,
40
+ items: answer.options && answer.options.map(({
41
+ name,
42
+ selected,
43
+ value
44
+ }) => ({
45
+ text: name,
46
+ selected,
47
+ value,
48
+ _id: name
49
+ }))
50
+ }));
51
+
52
+ const Answer = props => {
53
+ const {
54
+ model: {
55
+ answers,
56
+ onChange,
57
+ template,
58
+ type,
59
+ onSliderChange,
60
+ minLabel,
61
+ maxLabel,
62
+ title
63
+ }
64
+ } = props;
65
+ const switchProps = {
66
+ type: convertType(type)
67
+ };
68
+
69
+ if (type === 'freeText') {
70
+ switchProps.onInputValueChange = onChange;
71
+ }
72
+
73
+ if (type === 'qcm' || type === 'qcmDrag' || type === 'qcmGraphic' || type === 'template') {
74
+ switchProps.choices = convertToChoices(answers);
75
+ }
76
+
77
+ if (type === 'template') {
78
+ switchProps.template = template;
79
+ }
80
+
81
+ if (type === 'slider') {
82
+ switchProps.onSliderChange = onSliderChange;
83
+ switchProps.min = minLabel ? Number.parseInt(minLabel.split(' ')[0]) : 0;
84
+ switchProps.max = maxLabel ? Number.parseInt(maxLabel.split(' ')[0]) : 1;
85
+ switchProps.value = title ? Number.parseInt(title.split(' ')[0]) : 0;
86
+ switchProps.unit = minLabel ? minLabel.split(' ')[1] : '';
87
+ }
88
+
89
+ return /*#__PURE__*/_react.default.createElement(_index.default, switchProps);
90
+ };
91
+
92
+ var _default = Answer;
93
+ exports.default = _default;
94
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/molecule/answer/index.native.tsx"],"names":["convertType","modelType","convertToChoices","answers","map","answer","index","_id","label","title","value","onPress","onClick","onChange","selected","media","image","type","src","url","undefined","name","items","options","text","Answer","props","model","template","onSliderChange","minLabel","maxLabel","switchProps","onInputValueChange","choices","min","Number","parseInt","split","max","unit"],"mappings":";;;;;AAAA;;AAEA;;;;AAGA,MAAMA,WAAW,GAAIC,SAAD,IAAqD;AACvE,UAAQA,SAAR;AACE,SAAK,UAAL;AACE,aAAO,OAAP;;AACF,SAAK,UAAL;AACE,aAAO,UAAP;;AACF;AACE,aAAOA,SAAP;AANJ;AAQD,CATD;;AAWA,MAAMC,gBAAgB,GAAG,CAACC,OAAkC,GAAG,EAAtC,KACvBA,OAAO,CAACC,GAAR,CAAY,CAACC,MAAD,EAASC,KAAT,MAAoB;AAC9BC,EAAAA,GAAG,EAAG,GAAED,KAAM,EADgB;AAE9BE,EAAAA,KAAK,EAAEH,MAAM,CAACI,KAFgB;AAG9BC,EAAAA,KAAK,EAAEL,MAAM,CAACI,KAHgB;AAI9BE,EAAAA,OAAO,EAAEN,MAAM,CAACO,OAAP,IAAkBP,MAAM,CAACQ,QAJJ;AAK9BC,EAAAA,QAAQ,EAAET,MAAM,CAACS,QALa;AAM9BC,EAAAA,KAAK,EAAEV,MAAM,CAACW,KAAP,GACH;AACEC,IAAAA,IAAI,EAAE,KADR;AAEEC,IAAAA,GAAG,EAAE,CAAC;AAACC,MAAAA,GAAG,EAAEd,MAAM,CAACW;AAAb,KAAD;AAFP,GADG,GAKHI,SAX0B;AAY9B;AACAH,EAAAA,IAAI,EAAEZ,MAAM,CAACY,IAbiB;AAc9BI,EAAAA,IAAI,EAAEhB,MAAM,CAACgB,IAdiB;AAe9BC,EAAAA,KAAK,EACHjB,MAAM,CAACkB,OAAP,IACAlB,MAAM,CAACkB,OAAP,CAAenB,GAAf,CAAmB,CAAC;AAACiB,IAAAA,IAAD;AAAOP,IAAAA,QAAP;AAAiBJ,IAAAA;AAAjB,GAAD,MAA8B;AAC/Cc,IAAAA,IAAI,EAAEH,IADyC;AAE/CP,IAAAA,QAF+C;AAG/CJ,IAAAA,KAH+C;AAI/C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A,WAAW,CAACtB,KAAZ,GAAoBD,KAAK,GAAG2B,MAAM,CAACC,QAAP,CAAgB5B,KAAK,CAAC6B,KAAN,CAAY,GAAZ,EAAiB,CAAjB,CAAhB,CAAH,GAA0C,CAAnE;AACAN,IAAAA,WAAW,CAACQ,IAAZ,GAAmBV,QAAQ,GAAGA,QAAQ,CAACQ,KAAT,CAAe,GAAf,EAAoB,CAApB,CAAH,GAA4B,EAAvD;AACD;;AAED,sBAAO,6BAAC,cAAD,EAAYN,WAAZ,CAAP;AACD,CA9BD;;eAgCeP,M","sourcesContent":["import React from 'react';\nimport {Choice, QuestionType} from '../questions/types';\nimport Switch, {Props as SwitchProps} from '../questions/mobile/switch/index.native';\nimport {Props} from './prop-types';\n\nconst convertType = (modelType: Props['model']['type']): QuestionType => {\n switch (modelType) {\n case 'freeText':\n return 'basic';\n case 'dropDown':\n return 'template';\n default:\n return modelType;\n }\n};\n\nconst convertToChoices = (answers: Props['model']['answers'] = []): Choice[] =>\n answers.map((answer, index) => ({\n _id: `${index}`,\n label: answer.title,\n value: answer.title,\n onPress: answer.onClick || answer.onChange,\n selected: answer.selected,\n media: answer.image\n ? {\n type: 'img',\n src: [{url: answer.image}]\n }\n : undefined,\n // ---- custom properties for template choice\n type: answer.type,\n name: answer.name,\n items:\n answer.options &&\n answer.options.map(({name, selected, value}) => ({\n text: name,\n selected,\n value,\n _id: name\n }))\n }));\n\nconst Answer = (props: Props) => {\n const {\n model: {answers, onChange, template, type, onSliderChange, minLabel, maxLabel, title}\n } = props;\n\n const switchProps: SwitchProps = {\n type: convertType(type)\n };\n\n if (type === 'freeText') {\n switchProps.onInputValueChange = onChange;\n }\n\n if (type === 'qcm' || type === 'qcmDrag' || type === 'qcmGraphic' || type === 'template') {\n switchProps.choices = convertToChoices(answers);\n }\n\n if (type === 'template') {\n switchProps.template = template;\n }\n\n if (type === 'slider') {\n switchProps.onSliderChange = onSliderChange;\n switchProps.min = minLabel ? Number.parseInt(minLabel.split(' ')[0]) : 0;\n switchProps.max = maxLabel ? Number.parseInt(maxLabel.split(' ')[0]) : 1;\n switchProps.value = title ? Number.parseInt(title.split(' ')[0]) : 0;\n switchProps.unit = minLabel ? minLabel.split(' ')[1] : '';\n }\n\n return <Switch {...switchProps} />;\n};\n\nexport default Answer;\n"],"file":"index.native.js"}
@@ -38,12 +38,34 @@ const MediaViewPropTypes = {
38
38
  media: _propTypes.default.oneOfType([videoPropType, imgPropType, audioPropType])
39
39
  };
40
40
  exports.MediaViewPropTypes = MediaViewPropTypes;
41
- var _default = {
41
+
42
+ const SelectOptionsPropTypes = _propTypes.default.shape({
43
+ name: _propTypes.default.string,
44
+ selected: _propTypes.default.bool,
45
+ validOption: _propTypes.default.bool,
46
+ value: _propTypes.default.string
47
+ });
48
+
49
+ const AnswerPropTypes = _propTypes.default.shape({
50
+ title: _propTypes.default.string.isRequired,
51
+ 'aria-label': _propTypes.default.string,
52
+ onClick: _propTypes.default.func,
53
+ onChange: _propTypes.default.func,
54
+ selected: _propTypes.default.bool,
55
+ image: _propTypes.default.string,
56
+ options: _propTypes.default.arrayOf(SelectOptionsPropTypes),
57
+ type: _propTypes.default.oneOf(['text', 'select']),
58
+ name: _propTypes.default.string
59
+ });
60
+
61
+ const propTypes = {
42
62
  model: _propTypes.default.shape({
43
- type: _propTypes.default.oneOf(['qcmDrag', 'qcm', 'qcmGraphic', 'freeText', 'dropDown', 'slider', 'template']).isRequired
44
- }),
63
+ type: _propTypes.default.oneOf(['qcmDrag', 'qcm', 'qcmGraphic', 'freeText', 'dropDown', 'slider', 'template']).isRequired,
64
+ answer: _propTypes.default.arrayOf(AnswerPropTypes)
65
+ }).isRequired,
45
66
  help: _propTypes.default.string,
46
67
  media: MediaViewPropTypes.media
47
68
  };
69
+ var _default = propTypes;
48
70
  exports.default = _default;
49
71
  //# sourceMappingURL=prop-types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/molecule/answer/prop-types.js"],"names":["TYPE_IMAGE","TYPE_VIDEO","TYPE_AUDIO","isType","name","PropTypes","oneOf","videoPropType","shape","VideoPlayerPropTypes","type","isRequired","imgPropType","url","string","audioPropType","mediaUrl","MediaViewPropTypes","media","oneOfType","model","help"],"mappings":";;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,UAAU,GAAG,KAAnB;;AACA,MAAMC,UAAU,GAAG,OAAnB;;AACA,MAAMC,UAAU,GAAG,OAAnB;;;AAEP,MAAMC,MAAM,GAAGC,IAAI,IAAIC,mBAAUC,KAAV,CAAgB,CAACF,IAAD,CAAhB,CAAvB;;AAEA,MAAMG,aAAa,GAAGF,mBAAUG,KAAV,uBACjBC,mBADiB;AAEpBC,EAAAA,IAAI,EAAEP,MAAM,CAACF,UAAD,CAAN,CAAmBU;AAFL,GAAtB;;AAKA,MAAMC,WAAW,GAAGP,mBAAUG,KAAV,CAAgB;AAClCE,EAAAA,IAAI,EAAEP,MAAM,CAACH,UAAD,CAAN,CAAmBW,UADS;AAElCE,EAAAA,GAAG,EAAER,mBAAUS,MAAV,CAAiBH;AAFY,CAAhB,CAApB;;AAKA,MAAMI,aAAa,GAAGV,mBAAUG,KAAV,CAAgB;AACpCE,EAAAA,IAAI,EAAEP,MAAM,CAACD,UAAD,CAAN,CAAmBS,UADW;AAEpCK,EAAAA,QAAQ,EAAEX,mBAAUS,MAAV,CAAiBH;AAFS,CAAhB,CAAtB;;AAKO,MAAMM,kBAAkB,GAAG;AAChCC,EAAAA,KAAK,EAAEb,mBAAUc,SAAV,CAAoB,CAACZ,aAAD,EAAgBK,WAAhB,EAA6BG,aAA7B,CAApB;AADyB,CAA3B;;eAIQ;AACbK,EAAAA,KAAK,EAAEf,mBAAUG,KAAV,CAAgB;AACrBE,IAAAA,IAAI,EAAEL,mBAAUC,KAAV,CAAgB,CACpB,SADoB,EAEpB,KAFoB,EAGpB,YAHoB,EAIpB,UAJoB,EAKpB,UALoB,EAMpB,QANoB,EAOpB,UAPoB,CAAhB,EAQHK;AATkB,GAAhB,CADM;AAYbU,EAAAA,IAAI,EAAEhB,mBAAUS,MAZH;AAabI,EAAAA,KAAK,EAAED,kBAAkB,CAACC;AAbb,C","sourcesContent":["import PropTypes from 'prop-types';\nimport VideoPlayerPropTypes from '../video-player/prop-types';\n\nexport const TYPE_IMAGE = 'img';\nexport const TYPE_VIDEO = 'video';\nexport const TYPE_AUDIO = 'audio';\n\nconst isType = name => PropTypes.oneOf([name]);\n\nconst videoPropType = PropTypes.shape({\n ...VideoPlayerPropTypes,\n type: isType(TYPE_VIDEO).isRequired\n});\n\nconst imgPropType = PropTypes.shape({\n type: isType(TYPE_IMAGE).isRequired,\n url: PropTypes.string.isRequired\n});\n\nconst audioPropType = PropTypes.shape({\n type: isType(TYPE_AUDIO).isRequired,\n mediaUrl: PropTypes.string.isRequired\n});\n\nexport const MediaViewPropTypes = {\n media: PropTypes.oneOfType([videoPropType, imgPropType, audioPropType])\n};\n\nexport default {\n model: PropTypes.shape({\n type: PropTypes.oneOf([\n 'qcmDrag',\n 'qcm',\n 'qcmGraphic',\n 'freeText',\n 'dropDown',\n 'slider',\n 'template'\n ]).isRequired\n }),\n help: PropTypes.string,\n media: MediaViewPropTypes.media\n};\n"],"file":"prop-types.js"}
1
+ {"version":3,"sources":["../../../src/molecule/answer/prop-types.ts"],"names":["TYPE_IMAGE","TYPE_VIDEO","TYPE_AUDIO","isType","name","PropTypes","oneOf","videoPropType","shape","VideoPlayerPropTypes","type","isRequired","imgPropType","url","string","audioPropType","mediaUrl","MediaViewPropTypes","media","oneOfType","SelectOptionsPropTypes","selected","bool","validOption","value","AnswerPropTypes","title","onClick","func","onChange","image","options","arrayOf","propTypes","model","answer","help"],"mappings":";;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,UAAU,GAAG,KAAnB;;AACA,MAAMC,UAAU,GAAG,OAAnB;;AACA,MAAMC,UAAU,GAAG,OAAnB;;;AAEP,MAAMC,MAAM,GAAIC,IAAD,IAAkBC,mBAAUC,KAAV,CAAgB,CAACF,IAAD,CAAhB,CAAjC;;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AAA,OAAO,EAAE1B,mBAAU2B,OAAV,CAAkBZ,sBAAlB,CAP6B;AAQtCV,EAAAA,IAAI,EAAEL,mBAAUC,KAAV,CAAgB,CAAC,MAAD,EAAS,QAAT,CAAhB,CARgC;AAStCF,EAAAA,IAAI,EAAEC,mBAAUS;AATsB,CAAhB,CAAxB;;AAYA,MAAMmB,SAAS,GAAG;AAChBC,EAAAA,KAAK,EAAE7B,mBAAUG,KAAV,CAAgB;AACrBE,IAAAA,IAAI,EAAEL,mBAAUC,KAAV,CAAgB,CACpB,SADoB,EAEpB,KAFoB,EAGpB,YAHoB,EAIpB,UAJoB,EAKpB,UALoB,EAMpB,QANoB,EAOpB,UAPoB,CAAhB,EAQHK,UATkB;AAUrBwB,IAAAA,MAAM,EAAE9B,mBAAU2B,OAAV,CAAkBP,eAAlB;AAVa,GAAhB,EAWJd,UAZa;AAahByB,EAAAA,IAAI,EAAE/B,mBAAUS,MAbA;AAchBI,EAAAA,KAAK,EAAED,kBAAkB,CAACC;AAdV,CAAlB;eAmDee,S","sourcesContent":["import PropTypes from 'prop-types';\nimport VideoPlayerPropTypes from '../video-player/prop-types';\n\nexport const TYPE_IMAGE = 'img';\nexport const TYPE_VIDEO = 'video';\nexport const TYPE_AUDIO = 'audio';\n\nconst isType = (name: string) => PropTypes.oneOf([name]);\n\nconst videoPropType = PropTypes.shape({\n ...VideoPlayerPropTypes,\n type: isType(TYPE_VIDEO).isRequired\n});\n\nconst imgPropType = PropTypes.shape({\n type: isType(TYPE_IMAGE).isRequired,\n url: PropTypes.string.isRequired\n});\n\nconst audioPropType = PropTypes.shape({\n type: isType(TYPE_AUDIO).isRequired,\n mediaUrl: PropTypes.string.isRequired\n});\n\nexport const MediaViewPropTypes = {\n media: PropTypes.oneOfType([videoPropType, imgPropType, audioPropType])\n};\n\nconst SelectOptionsPropTypes = PropTypes.shape({\n name: PropTypes.string,\n selected: PropTypes.bool,\n validOption: PropTypes.bool,\n value: PropTypes.string\n});\n\nconst AnswerPropTypes = PropTypes.shape({\n title: PropTypes.string.isRequired,\n 'aria-label': PropTypes.string,\n onClick: PropTypes.func,\n onChange: PropTypes.func,\n selected: PropTypes.bool,\n image: PropTypes.string,\n options: PropTypes.arrayOf(SelectOptionsPropTypes),\n type: PropTypes.oneOf(['text', 'select']),\n name: PropTypes.string\n});\n\nconst propTypes = {\n model: PropTypes.shape({\n type: PropTypes.oneOf([\n 'qcmDrag',\n 'qcm',\n 'qcmGraphic',\n 'freeText',\n 'dropDown',\n 'slider',\n 'template'\n ]).isRequired,\n answer: PropTypes.arrayOf(AnswerPropTypes)\n }).isRequired,\n help: PropTypes.string,\n media: MediaViewPropTypes.media\n};\n\ntype SelectOptions = {\n name: string;\n selected: boolean;\n validOption: boolean;\n value: string;\n};\n\ntype Answer = {\n title?: string;\n 'aria-label'?: string;\n onClick?: () => void;\n onChange?: (value: string) => void;\n selected?: boolean;\n image?: string;\n options?: SelectOptions[];\n type?: 'text' | 'select';\n name?: string;\n};\n\nexport type Props = {\n model: {\n type: 'qcmDrag' | 'qcm' | 'qcmGraphic' | 'freeText' | 'dropDown' | 'slider' | 'template';\n answers?: Answer[];\n template?: string;\n onChange?: (value: string | number) => void;\n onSliderChange?: (value: number) => void;\n minLabel?: string;\n maxLabel?: string;\n title?: string;\n };\n help: string;\n media: any;\n};\n\nexport default propTypes;\n"],"file":"prop-types.js"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.default = exports.extractSelectedChoices = void 0;
4
+ exports.default = void 0;
5
5
 
6
6
  var _react = _interopRequireWildcard(require("react"));
7
7
 
@@ -52,7 +52,6 @@ const DropZone = props => {
52
52
  const {
53
53
  onPress
54
54
  } = props;
55
- const handlePress = (0, _react.useCallback)(item => () => onPress(item), [onPress]);
56
55
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
57
56
  (0, _react.useEffect)(() => {
58
57
  const _stylesheet = createDropZoneStyle(theme);
@@ -73,7 +72,7 @@ const DropZone = props => {
73
72
  squeezed: true,
74
73
  isSelected: true,
75
74
  testID: `choice-${item._id}`,
76
- onPress: handlePress(item),
75
+ onPress: onPress(item),
77
76
  questionType: "qcmDrag"
78
77
  }, item.label));
79
78
  const hasNoSelectedChoices = mappedSortedChoices.length === 0;
@@ -85,7 +84,6 @@ const DropZone = props => {
85
84
  };
86
85
 
87
86
  const createStyleSheet = theme => _reactNative.StyleSheet.create({
88
- container: {},
89
87
  pickableChoices: {
90
88
  flexDirection: 'row',
91
89
  flexWrap: 'wrap'
@@ -93,24 +91,7 @@ const createStyleSheet = theme => _reactNative.StyleSheet.create({
93
91
  choice: {
94
92
  margin: theme.spacing.micro
95
93
  }
96
- }); // this algo could be improve using a single reduce fuction
97
-
98
-
99
- const extractSelectedChoices = (availableChoices, userChoices) => {
100
- const selectedChoices = userChoices.reduce((accumulator, currentValue) => {
101
- const foundItem = availableChoices.find(availableChoice => availableChoice.label === currentValue);
102
-
103
- if (foundItem) {
104
- return [...accumulator, foundItem];
105
- }
106
-
107
- return accumulator;
108
- }, []);
109
- const notSelectedChoices = availableChoices.filter(availableChoice => !userChoices.includes(availableChoice.label));
110
- return [selectedChoices, notSelectedChoices];
111
- };
112
-
113
- exports.extractSelectedChoices = extractSelectedChoices;
94
+ });
114
95
 
115
96
  const QuestionDraggable = props => {
116
97
  const templateContext = (0, _templateContext.useTemplateContext)();
@@ -128,32 +109,28 @@ const QuestionDraggable = props => {
128
109
  return null;
129
110
  }
130
111
 
131
- const handlePress = item => () => props.onPress(item);
132
-
133
112
  const {
134
113
  choices,
135
114
  onPress,
136
- testID,
137
- userChoices
115
+ testID
138
116
  } = props;
139
- const [selectedChoices, notSelectedChoices] = extractSelectedChoices(choices, userChoices);
140
- const mappedunselectedChoices = notSelectedChoices.map((item, index) => /*#__PURE__*/_react.default.createElement(_index.default, {
117
+ const selectedChoices = choices.filter(item => item.selected);
118
+ const pickableChoices = choices.filter(item => !item.selected).map((item, index) => /*#__PURE__*/_react.default.createElement(_index.default, {
141
119
  style: styleSheet.choice,
142
120
  key: item._id,
143
121
  squeezed: true,
144
122
  testID: `choice-${item._id}-unselected`,
145
- onPress: handlePress(item),
123
+ onPress: onPress(item),
146
124
  questionType: "qcmDrag"
147
125
  }, item.label));
148
126
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
149
- style: styleSheet.container,
150
127
  testID: testID
151
128
  }, /*#__PURE__*/_react.default.createElement(DropZone, {
152
129
  choices: selectedChoices,
153
130
  onPress: onPress
154
131
  }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
155
132
  style: styleSheet.pickableChoices
156
- }, mappedunselectedChoices));
133
+ }, pickableChoices));
157
134
  };
158
135
 
159
136
  var _default = QuestionDraggable;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/molecule/questions/mobile/draggable/index.native.tsx"],"names":["createDropZoneStyle","theme","StyleSheet","create","choice","margin","spacing","micro","dropZone","flexWrap","flexDirection","borderStyle","borderWidth","padding","borderColor","colors","gray","light","backgroundColor","extra","borderRadius","radius","common","marginBottom","tiny","emptyContent","justifyContent","alignContent","alignItems","height","text","color","medium","DropZone","props","templateContext","translations","onPress","handlePress","item","styleSheet","setStylesheet","_stylesheet","choices","mappedSortedChoices","map","_id","label","hasNoSelectedChoices","length","selectSomethingBelow","createStyleSheet","container","pickableChoices","extractSelectedChoices","availableChoices","userChoices","selectedChoices","reduce","accumulator","currentValue","foundItem","find","availableChoice","notSelectedChoices","filter","includes","QuestionDraggable","testID","mappedunselectedChoices","index"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAUA,MAAMA,mBAAmB,GAAIC,KAAD,IAC1BC,wBAAWC,MAAX,CAAkB;AAChBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,MAAM,EAAEJ,KAAK,CAACK,OAAN,CAAcC;AADhB,GADQ;AAIhBC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,QAAQ,EAAE,MADF;AAERC,IAAAA,aAAa,EAAE,KAFP;AAGR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CAACnB,GAAnB,CAAuB,CAACN,IAAD,EAAO+B,KAAP,kBACrD,6BAAC,cAAD;AACE,IAAA,KAAK,EAAE9B,UAAU,CAACpC,MADpB;AAEE,IAAA,GAAG,EAAEmC,IAAI,CAACO,GAFZ;AAGE,IAAA,QAAQ,MAHV;AAIE,IAAA,MAAM,EAAG,UAASP,IAAI,CAACO,GAAI,aAJ7B;AAKE,IAAA,OAAO,EAAER,WAAW,CAACC,IAAD,CALtB;AAME,IAAA,YAAY,EAAC;AANf,KAQGA,IAAI,CAACQ,KARR,CAD8B,CAAhC;AAaA,sBACE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEP,UAAU,CAACY,SAAxB;AAAmC,IAAA,MAAM,EAAEgB;AAA3C,kBACE,6BAAC,QAAD;AAAU,IAAA,OAAO,EAAEX,eAAnB;AAAoC,IAAA,OAAO,EAAEpB;AAA7C,IADF,eAEE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEG,UAAU,CAACa;AAAxB,KAA0CgB,uBAA1C,CAFF,CADF;AAMD,CAvCD;;eAyCeF,iB","sourcesContent":["import React, {useCallback, useEffect, useState} from 'react';\nimport {View, StyleSheet, Text} from 'react-native';\nimport QuestionChoice from '../../../../atom/choice/index.native';\nimport {useTemplateContext} from '../../../../template/app-review/template-context';\nimport {Theme} from '../../../../variables/theme.native';\n\nimport type {Choice} from '../../../../types/progression-engine';\n\nexport interface DropZoneProps {\n choices: Array<Choice>;\n onPress: (item: Choice) => void;\n}\n\nconst createDropZoneStyle = (theme: Theme) =>\n StyleSheet.create({\n choice: {\n margin: theme.spacing.micro\n },\n dropZone: {\n flexWrap: 'wrap',\n flexDirection: 'row',\n borderStyle: 'dashed',\n borderWidth: 2,\n padding: theme.spacing.micro,\n borderColor: theme.colors.gray.light,\n backgroundColor: theme.colors.gray.extra,\n borderRadius: theme.radius.common,\n marginBottom: theme.spacing.tiny\n },\n emptyContent: {\n justifyContent: 'center',\n alignContent: 'center',\n alignItems: 'center',\n height: 60\n },\n text: {\n color: theme.colors.gray.medium\n }\n });\n\nconst DropZone = (props: DropZoneProps) => {\n const templateContext = useTemplateContext();\n const {theme, translations} = templateContext;\n const {onPress} = props;\n\n const handlePress = useCallback((item: Choice) => () => onPress(item), [onPress]);\n const [styleSheet, setStylesheet] = useState<any | null>(null);\n\n useEffect(() => {\n const _stylesheet = createDropZoneStyle(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n if (!styleSheet) {\n return null;\n }\n\n const {choices} = props;\n const mappedSortedChoices = choices.map(item => (\n <QuestionChoice\n style={styleSheet.choice}\n key={item._id}\n squeezed\n isSelected\n testID={`choice-${item._id}`}\n onPress={handlePress(item)}\n questionType=\"qcmDrag\"\n >\n {item.label}\n </QuestionChoice>\n ));\n\n const hasNoSelectedChoices = mappedSortedChoices.length === 0;\n\n return (\n <View style={[styleSheet.dropZone, hasNoSelectedChoices && styleSheet.emptyContent]}>\n {hasNoSelectedChoices ? (\n <Text style={styleSheet.text}>{translations.selectSomethingBelow}</Text>\n ) : null}\n\n {!hasNoSelectedChoices && mappedSortedChoices}\n </View>\n );\n};\n\nexport interface Props {\n choices: Array<Choice>;\n userChoices: Array<string>;\n testID?: string;\n onPress: (item: Choice) => void;\n}\n\nconst createStyleSheet = (theme: Theme) =>\n StyleSheet.create({\n container: {},\n pickableChoices: {\n flexDirection: 'row',\n flexWrap: 'wrap'\n },\n choice: {\n margin: theme.spacing.micro\n }\n });\n\n// this algo could be improve using a single reduce fuction\nexport const extractSelectedChoices = (\n availableChoices: Array<Choice>,\n userChoices: Array<string>\n): Array<Array<Choice>> => {\n const selectedChoices: Array<Choice> = userChoices.reduce(\n (accumulator: Array<Choice>, currentValue) => {\n const foundItem = availableChoices.find(\n availableChoice => availableChoice.label === currentValue\n );\n if (foundItem) {\n return [...accumulator, foundItem];\n }\n return accumulator;\n },\n []\n );\n\n const notSelectedChoices = availableChoices.filter(\n availableChoice => !userChoices.includes(availableChoice.label)\n );\n\n return [selectedChoices, notSelectedChoices];\n};\n\nconst QuestionDraggable = (props: Props) => {\n const templateContext = useTemplateContext();\n const {theme} = templateContext;\n\n const [styleSheet, setStylesheet] = useState<any | null>(null);\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n if (!styleSheet) {\n return null;\n }\n\n const handlePress = (item: Choice) => () => props.onPress(item);\n\n const {choices, onPress, testID, userChoices} = props;\n const [selectedChoices, notSelectedChoices] = extractSelectedChoices(choices, userChoices);\n\n const mappedunselectedChoices = notSelectedChoices.map((item, index) => (\n <QuestionChoice\n style={styleSheet.choice}\n key={item._id}\n squeezed\n testID={`choice-${item._id}-unselected`}\n onPress={handlePress(item)}\n questionType=\"qcmDrag\"\n >\n {item.label}\n </QuestionChoice>\n ));\n\n return (\n <View style={styleSheet.container} testID={testID}>\n <DropZone choices={selectedChoices} onPress={onPress} />\n <View style={styleSheet.pickableChoices}>{mappedunselectedChoices}</View>\n </View>\n );\n};\n\nexport default QuestionDraggable;\n"],"file":"index.native.js"}
1
+ {"version":3,"sources":["../../../../../src/molecule/questions/mobile/draggable/index.native.tsx"],"names":["createDropZoneStyle","theme","StyleSheet","create","choice","margin","spacing","micro","dropZone","flexWrap","flexDirection","borderStyle","borderWidth","padding","borderColor","colors","gray","light","backgroundColor","extra","borderRadius","radius","common","marginBottom","tiny","emptyContent","justifyContent","alignContent","alignItems","height","text","color","medium","DropZone","props","templateContext","translations","onPress","styleSheet","setStylesheet","_stylesheet","choices","mappedSortedChoices","map","item","_id","label","hasNoSelectedChoices","length","selectSomethingBelow","createStyleSheet","pickableChoices","QuestionDraggable","testID","selectedChoices","filter","selected","index"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAUA,MAAMA,mBAAmB,GAAIC,KAAD,IAC1BC,wBAAWC,MAAX,CAAkB;AAChBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,MAAM,EAAEJ,KAAK,CAACK,OAAN,CAAcC;AADhB,GADQ;A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EAAaC,aAAb,IAA8B,qBAAqB,IAArB,CAApC;AAEA,wBAAU,MAAM;AACd,UAAMC,WAAW,GAAGU,gBAAgB,CAACjD,KAAD,CAApC;;AACAsC,IAAAA,aAAa,CAACC,WAAD,CAAb;AACD,GAHD,EAGG,CAACvC,KAAD,CAHH;;AAKA,MAAI,CAACqC,UAAL,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,QAAM;AAACG,IAAAA,OAAD;AAAUJ,IAAAA,OAAV;AAAmBgB,IAAAA;AAAnB,MAA6BnB,KAAnC;AACA,QAAMoB,eAAe,GAAGb,OAAO,CAACc,MAAR,CAAeX,IAAI,IAAIA,IAAI,CAACY,QAA5B,CAAxB;AAEA,QAAML,eAAe,GAAGV,OAAO,CAC5Bc,MADqB,CACdX,IAAI,IAAI,CAACA,IAAI,CAACY,QADA,EAErBb,GAFqB,CAEjB,CAACC,IAAD,EAAOa,KAAP,kBACH,6BAAC,cAAD;AACE,IAAA,KAAK,EAAEnB,UAAU,CAAClC,MADpB;AAEE,IAAA,GAAG,EAAEwC,IAAI,CAACC,GAFZ;AAGE,IAAA,QAAQ,MAHV;AAIE,IAAA,MAAM,EAAG,UAASD,IAAI,CAACC,GAAI,aAJ7B;AAKE,IAAA,OAAO,EAAER,OAAO,CAACO,IAAD,CALlB;AAME,IAAA,YAAY,EAAC;AANf,KAQGA,IAAI,CAACE,KARR,CAHoB,CAAxB;AAeA,sBACE,6BAAC,iBAAD;AAAM,IAAA,MAAM,EAAEO;AAAd,kBACE,6BAAC,QAAD;AAAU,IAAA,OAAO,EAAEC,eAAnB;AAAoC,IAAA,OAAO,EAAEjB;AAA7C,IADF,eAEE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEC,UAAU,CAACa;AAAxB,KAA0CA,eAA1C,CAFF,CADF;AAMD,CAvCD;;eAyCeC,iB","sourcesContent":["import React, {useEffect, useState} from 'react';\nimport {View, StyleSheet, Text} from 'react-native';\nimport QuestionChoice from '../../../../atom/choice/index.native';\nimport {useTemplateContext} from '../../../../template/app-review/template-context';\nimport {Theme} from '../../../../variables/theme.native';\n\nimport type {Choice} from '../../types';\n\nexport interface DropZoneProps {\n choices: Array<Choice>;\n onPress: (item: Choice) => () => void;\n}\n\nconst createDropZoneStyle = (theme: Theme) =>\n StyleSheet.create({\n choice: {\n margin: theme.spacing.micro\n },\n dropZone: {\n flexWrap: 'wrap',\n flexDirection: 'row',\n borderStyle: 'dashed',\n borderWidth: 2,\n padding: theme.spacing.micro,\n borderColor: theme.colors.gray.light,\n backgroundColor: theme.colors.gray.extra,\n borderRadius: theme.radius.common,\n marginBottom: theme.spacing.tiny\n },\n emptyContent: {\n justifyContent: 'center',\n alignContent: 'center',\n alignItems: 'center',\n height: 60\n },\n text: {\n color: theme.colors.gray.medium\n }\n });\n\nconst DropZone = (props: DropZoneProps) => {\n const templateContext = useTemplateContext();\n const {theme, translations} = templateContext;\n const {onPress} = props;\n\n const [styleSheet, setStylesheet] = useState<any | null>(null);\n\n useEffect(() => {\n const _stylesheet = createDropZoneStyle(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n if (!styleSheet) {\n return null;\n }\n\n const {choices} = props;\n const mappedSortedChoices = choices.map(item => (\n <QuestionChoice\n style={styleSheet.choice}\n key={item._id}\n squeezed\n isSelected\n testID={`choice-${item._id}`}\n onPress={onPress(item)}\n questionType=\"qcmDrag\"\n >\n {item.label}\n </QuestionChoice>\n ));\n\n const hasNoSelectedChoices = mappedSortedChoices.length === 0;\n\n return (\n <View style={[styleSheet.dropZone, hasNoSelectedChoices && styleSheet.emptyContent]}>\n {hasNoSelectedChoices ? (\n <Text style={styleSheet.text}>{translations.selectSomethingBelow}</Text>\n ) : null}\n\n {!hasNoSelectedChoices && mappedSortedChoices}\n </View>\n );\n};\n\nexport interface Props {\n choices: Array<Choice>;\n testID?: string;\n onPress: (item: Choice) => () => void;\n}\n\nconst createStyleSheet = (theme: Theme) =>\n StyleSheet.create({\n pickableChoices: {\n flexDirection: 'row',\n flexWrap: 'wrap'\n },\n choice: {\n margin: theme.spacing.micro\n }\n });\n\nconst QuestionDraggable = (props: Props) => {\n const templateContext = useTemplateContext();\n const {theme} = templateContext;\n\n const [styleSheet, setStylesheet] = useState<any | null>(null);\n\n useEffect(() => {\n const _stylesheet = createStyleSheet(theme);\n setStylesheet(_stylesheet);\n }, [theme]);\n\n if (!styleSheet) {\n return null;\n }\n\n const {choices, onPress, testID} = props;\n const selectedChoices = choices.filter(item => item.selected);\n\n const pickableChoices = choices\n .filter(item => !item.selected)\n .map((item, index) => (\n <QuestionChoice\n style={styleSheet.choice}\n key={item._id}\n squeezed\n testID={`choice-${item._id}-unselected`}\n onPress={onPress(item)}\n questionType=\"qcmDrag\"\n >\n {item.label}\n </QuestionChoice>\n ));\n\n return (\n <View testID={testID}>\n <DropZone choices={selectedChoices} onPress={onPress} />\n <View style={styleSheet.pickableChoices}>{pickableChoices}</View>\n </View>\n );\n};\n\nexport default QuestionDraggable;\n"],"file":"index.native.js"}
@@ -9,15 +9,13 @@ var _reactNative = require("react-native");
9
9
 
10
10
  var _index = _interopRequireDefault(require("../../../../atom/choice/index.native"));
11
11
 
12
- var _index2 = _interopRequireDefault(require("../../../../atom/space/index.native"));
12
+ var _index2 = _interopRequireDefault(require("../draggable/index.native"));
13
13
 
14
- var _index3 = _interopRequireDefault(require("../draggable/index.native"));
14
+ var _index3 = _interopRequireDefault(require("../template/index.native"));
15
15
 
16
- var _index4 = _interopRequireDefault(require("../template/index.native"));
16
+ var _index4 = _interopRequireDefault(require("../slider/index.native"));
17
17
 
18
- var _index5 = _interopRequireDefault(require("../slider/index.native"));
19
-
20
- var _index6 = _interopRequireDefault(require("../../free-text/index.native"));
18
+ var _index5 = _interopRequireDefault(require("../../free-text/index.native"));
21
19
 
22
20
  var _templateContext = require("../../../../template/app-review/template-context");
23
21
 
@@ -36,20 +34,30 @@ const styleSheet = _reactNative.StyleSheet.create({
36
34
  },
37
35
  card: {
38
36
  flex: 1
37
+ },
38
+ choices: {// backgroundColor: '#967' // flex-debug
39
+ },
40
+ choice: {
41
+ paddingVertical: 5
39
42
  }
40
43
  });
41
44
 
42
45
  const Switch = props => {
43
46
  const templateContext = (0, _templateContext.useTemplateContext)();
44
47
  const {
45
- analytics
48
+ analytics,
49
+ store
46
50
  } = templateContext;
51
+ const {
52
+ focusedSelectId,
53
+ handleBlur,
54
+ handleFocus
55
+ } = store;
47
56
  const {
48
57
  type,
49
58
  template,
50
59
  isDisabled,
51
- items,
52
- userChoices,
60
+ choices = [],
53
61
  min,
54
62
  max,
55
63
  unit,
@@ -58,23 +66,24 @@ const Switch = props => {
58
66
  onSliderChange,
59
67
  onItemPress,
60
68
  onItemInputChange,
61
- onInputValueChange,
62
- focusedSelectId,
63
- handleFocus,
64
- handleBlur
69
+ onInputValueChange
65
70
  } = props;
66
-
67
- const isSelected = choice => userChoices && userChoices.includes(choice.label);
68
-
69
- const handleItemPress = item => () => {
70
- if (onItemPress) {
71
- onItemPress(item);
71
+ const handleChoicePress = (0, _react.useCallback)(choice => () => {
72
+ if (choice.onPress) {
73
+ // e.g. app-review
74
+ choice.onPress();
75
+ } else if (onItemPress) {
76
+ // e.g. learner
77
+ onItemPress(choice);
72
78
  }
73
- };
74
-
75
- const handleItemInputChange = (0, _react.useCallback)((item, _value) => {
76
- if (onItemInputChange) {
77
- onItemInputChange(item, _value);
79
+ }, [onItemPress]);
80
+ const handleItemInputChange = (0, _react.useCallback)((choice, _value) => {
81
+ if (choice.onPress) {
82
+ // e.g. app-review
83
+ choice.onPress(_value);
84
+ } else if (onItemInputChange) {
85
+ // e.g. learner
86
+ onItemInputChange(choice, _value);
78
87
  }
79
88
  }, [onItemInputChange]);
80
89
  const handleSlidingComplete = (0, _react.useCallback)(_value => {
@@ -91,35 +100,32 @@ const Switch = props => {
91
100
  switch (type) {
92
101
  case 'qcm':
93
102
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
94
- testID: "question-choices"
95
- }, items.map((item, index) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
96
- key: `question-choice-${item._id}`
97
- }, index > 0 ? /*#__PURE__*/_react.default.createElement(_index2.default, null) : null, /*#__PURE__*/_react.default.createElement(_index.default, {
98
- onPress: handleItemPress(item),
103
+ testID: "question-choices",
104
+ style: styleSheet.choices
105
+ }, choices.map((choice, index) => /*#__PURE__*/_react.default.createElement(_index.default, {
106
+ key: `question-choice-${choice._id}`,
107
+ onPress: handleChoicePress(choice),
99
108
  isDisabled: isDisabled,
100
- isSelected: isSelected(item),
101
- testID: `question-choice-${item._id}`,
109
+ isSelected: choice.selected,
110
+ testID: `question-choice-${choice._id}`,
111
+ style: styleSheet.choice,
102
112
  questionType: type
103
- }, item.label))));
113
+ }, choice.label)));
104
114
 
105
115
  case 'qcmGraphic':
106
116
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
107
- testID: "question-choices"
108
- }, items.map((item, index) => {
109
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
110
- key: `question-choice-row-${item._id}`
111
- }, index > 0 ? /*#__PURE__*/_react.default.createElement(_index2.default, null) : null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
112
- style: styleSheet.cards
113
- }, /*#__PURE__*/_react.default.createElement(_index.default, {
114
- onPress: handleItemPress(item),
115
- media: item.media,
116
- isDisabled: isDisabled,
117
- isSelected: isSelected(item),
118
- testID: `question-choice-${item._id}`,
119
- style: styleSheet.card,
120
- questionType: type
121
- }, item.label), /*#__PURE__*/_react.default.createElement(_index2.default, null)));
122
- }));
117
+ testID: "question-choices",
118
+ style: styleSheet.choices
119
+ }, choices.map((choice, index) => /*#__PURE__*/_react.default.createElement(_index.default, {
120
+ key: `question-choice-${choice._id}`,
121
+ onPress: handleChoicePress(choice),
122
+ media: choice.media,
123
+ isDisabled: isDisabled,
124
+ isSelected: choice.selected,
125
+ testID: `question-choice-${choice._id}`,
126
+ style: styleSheet.choice,
127
+ questionType: type
128
+ }, choice.label)));
123
129
 
124
130
  case 'slider':
125
131
  {
@@ -127,7 +133,7 @@ const Switch = props => {
127
133
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
128
134
  }
129
135
 
130
- return /*#__PURE__*/_react.default.createElement(_index5.default, {
136
+ return /*#__PURE__*/_react.default.createElement(_index4.default, {
131
137
  min: min,
132
138
  max: max,
133
139
  unit: unit,
@@ -140,16 +146,17 @@ const Switch = props => {
140
146
 
141
147
  case 'template':
142
148
  if (handleBlur === undefined || handleFocus === undefined || focusedSelectId === undefined) {
149
+ // eslint-disable-next-line no-console
150
+ console.warn('type template must implement handleFocus etc within Context.store');
143
151
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
144
152
  }
145
153
 
146
154
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
147
155
  testID: "question-choices"
148
- }, /*#__PURE__*/_react.default.createElement(_index4.default, {
156
+ }, /*#__PURE__*/_react.default.createElement(_index3.default, {
149
157
  isDisabled: isDisabled,
150
158
  template: template || '',
151
- items: items,
152
- userChoices: userChoices,
159
+ choices: choices,
153
160
  onInputChange: handleItemInputChange,
154
161
  handleBlur: handleBlur,
155
162
  handleFocus: handleFocus,
@@ -157,16 +164,11 @@ const Switch = props => {
157
164
  }));
158
165
 
159
166
  case 'qcmDrag':
160
- if (!onItemPress) {
161
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
162
- }
163
-
164
167
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
165
168
  testID: "question-draggable"
166
- }, /*#__PURE__*/_react.default.createElement(_index3.default, {
167
- choices: items,
168
- userChoices: userChoices,
169
- onPress: onItemPress
169
+ }, /*#__PURE__*/_react.default.createElement(_index2.default, {
170
+ choices: choices,
171
+ onPress: handleChoicePress
170
172
  }));
171
173
 
172
174
  case 'basic':
@@ -174,7 +176,7 @@ const Switch = props => {
174
176
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
175
177
  }
176
178
 
177
- return /*#__PURE__*/_react.default.createElement(_index6.default, {
179
+ return /*#__PURE__*/_react.default.createElement(_index5.default, {
178
180
  fullWidth: true,
179
181
  onChange: onInputValueChange,
180
182
  testID: "question-input-text",
@@ -183,7 +185,7 @@ const Switch = props => {
183
185
  });
184
186
 
185
187
  default:
186
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
188
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Unhandled type: ", type));
187
189
  }
188
190
  };
189
191
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/molecule/questions/mobile/switch/index.native.tsx"],"names":["styleSheet","StyleSheet","create","cards","flexDirection","alignItems","card","flex","Switch","props","templateContext","analytics","type","template","isDisabled","items","userChoices","min","max","unit","value","step","onSliderChange","onItemPress","onItemInputChange","onInputValueChange","focusedSelectId","handleFocus","handleBlur","isSelected","choice","includes","label","handleItemPress","item","handleItemInputChange","_value","handleSlidingComplete","logEvent","ANALYTICS_EVENT_TYPE","SLIDE","id","questionType","map","index","_id","media","undefined"],"mappings":";;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAyBA,MAAMA,UAAU,GAAGC,wBAAWC,MAAX,CAAkB;AACnCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,aAAa,EAAE,KADV;AAELC,IAAAA,UAAU,EAAE;AAFP,GAD4B;AAKnCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AADF;AAL6B,CAAlB,CAAnB;;AAUA,MAAMC,MAAM,GAAIC,KAAD,IAAkB;AAC/B,QAAMC,eAAe,GAAG,0CAAxB;AACA,QAAM;AAACC,IAAAA;AAAD,MAAcD,eAApB;AAEA,QAAM;AACJE,IAAAA,IADI;AAEJC,IAAAA,QAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,KAJI;AAKJC,IAAAA,WALI;AAMJC,IAAAA,GANI;AAOJC,IAAAA,GAPI;AAQJC,IAAAA,IARI;AASJC,IAAAA,KATI;AAUJ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,MAAM,EAAC,qBAHT;AAIE,QAAA,YAAY,EAAC,OAJf;AAKE,QAAA,UAAU,EAAEX;AALd,QADF;;AASF;AACE,0BAAO,6BAAC,iBAAD,OAAP;AA3GJ;AA6GD,CArKD;;eAuKeN,M","sourcesContent":["import React, {useCallback} from 'react';\nimport {View, StyleSheet} from 'react-native';\n\nimport QuestionChoice from '../../../../atom/choice/index.native';\nimport Space from '../../../../atom/space/index.native';\nimport QuestionDraggable from '../draggable/index.native';\nimport QuestionTemplate from '../template/index.native';\nimport QuestionSlider from '../slider/index.native';\nimport FreeText from '../../free-text/index.native';\n\nimport {useTemplateContext} from '../../../../template/app-review/template-context';\nimport {ANALYTICS_EVENT_TYPE} from '../../../../variables/analytics';\n\nimport {FocusedSelectId, HandleBlur, HandleFocus} from '../../../../types/app-review';\nimport type {QuestionType, Choice} from '../../../../types/progression-engine';\n\nexport interface Props {\n type: QuestionType;\n isDisabled?: boolean;\n template?: string;\n items: Array<Choice>;\n userChoices: Array<string>;\n onItemPress?: (item: Choice) => void;\n onSliderChange?: (value: number) => void;\n min?: number;\n max?: number;\n unit?: string;\n step?: number;\n value?: number;\n onItemInputChange?: (item: Choice, value: string) => void;\n onInputValueChange?: (value: string) => void;\n focusedSelectId?: FocusedSelectId;\n handleFocus?: HandleFocus;\n handleBlur?: HandleBlur;\n}\n\nconst styleSheet = StyleSheet.create({\n cards: {\n flexDirection: 'row',\n alignItems: 'stretch'\n },\n card: {\n flex: 1\n }\n});\n\nconst Switch = (props: Props) => {\n const templateContext = useTemplateContext();\n const {analytics} = templateContext;\n\n const {\n type,\n template,\n isDisabled,\n items,\n userChoices,\n min,\n max,\n unit,\n value,\n step,\n onSliderChange,\n onItemPress,\n onItemInputChange,\n onInputValueChange,\n focusedSelectId,\n handleFocus,\n handleBlur\n } = props;\n\n const isSelected = (choice: Choice): boolean => userChoices && userChoices.includes(choice.label);\n\n const handleItemPress = (item: Choice) => () => {\n if (onItemPress) {\n onItemPress(item);\n }\n };\n\n const handleItemInputChange = useCallback(\n (item: Choice, _value: string) => {\n if (onItemInputChange) {\n onItemInputChange(item, _value);\n }\n },\n [onItemInputChange]\n );\n\n const handleSlidingComplete = useCallback(\n _value => {\n analytics &&\n analytics.logEvent(ANALYTICS_EVENT_TYPE.SLIDE, {\n id: 'slider',\n questionType: 'slider'\n });\n\n if (onSliderChange) {\n onSliderChange(_value);\n }\n },\n [analytics, onSliderChange]\n );\n\n switch (type) {\n case 'qcm':\n return (\n <View testID=\"question-choices\">\n {items.map((item, index) => (\n <View key={`question-choice-${item._id}`}>\n {index > 0 ? <Space /> : null}\n <QuestionChoice\n onPress={handleItemPress(item)}\n isDisabled={isDisabled}\n isSelected={isSelected(item)}\n testID={`question-choice-${item._id}`}\n questionType={type}\n >\n {item.label}\n </QuestionChoice>\n </View>\n ))}\n </View>\n );\n case 'qcmGraphic':\n return (\n <View testID=\"question-choices\">\n {items.map((item, index) => {\n return (\n <View key={`question-choice-row-${item._id}`}>\n {index > 0 ? <Space /> : null}\n <View style={styleSheet.cards}>\n <QuestionChoice\n onPress={handleItemPress(item)}\n media={item.media}\n isDisabled={isDisabled}\n isSelected={isSelected(item)}\n testID={`question-choice-${item._id}`}\n style={styleSheet.card}\n questionType={type}\n >\n {item.label}\n </QuestionChoice>\n <Space />\n </View>\n </View>\n );\n })}\n </View>\n );\n case 'slider': {\n if (min === undefined || max === undefined) {\n return <View />;\n }\n\n return (\n <QuestionSlider\n min={min}\n max={max}\n unit={unit}\n value={value}\n step={step}\n onSlidingComplete={handleSlidingComplete}\n testID=\"question-slider\"\n />\n );\n }\n case 'template':\n if (handleBlur === undefined || handleFocus === undefined || focusedSelectId === undefined) {\n return <View />;\n }\n\n return (\n <View testID=\"question-choices\">\n <QuestionTemplate\n isDisabled={isDisabled}\n template={template || ''}\n items={items}\n userChoices={userChoices}\n onInputChange={handleItemInputChange}\n handleBlur={handleBlur}\n handleFocus={handleFocus}\n focusedSelectId={focusedSelectId}\n />\n </View>\n );\n case 'qcmDrag':\n if (!onItemPress) {\n return <View />;\n }\n\n return (\n <View testID=\"question-draggable\">\n <QuestionDraggable choices={items} userChoices={userChoices} onPress={onItemPress} />\n </View>\n );\n case 'basic':\n if (!onInputValueChange) {\n return <View />;\n }\n\n return (\n <FreeText\n fullWidth\n onChange={onInputValueChange}\n testID=\"question-input-text\"\n questionType=\"basic\"\n isDisabled={isDisabled}\n />\n );\n default:\n return <View />;\n }\n};\n\nexport default Switch;\n"],"file":"index.native.js"}
1
+ {"version":3,"sources":["../../../../../src/molecule/questions/mobile/switch/index.native.tsx"],"names":["styleSheet","StyleSheet","create","cards","flexDirection","alignItems","card","flex","choices","choice","paddingVertical","Switch","props","templateContext","analytics","store","focusedSelectId","handleBlur","handleFocus","type","template","isDisabled","min","max","unit","value","step","onSliderChange","onItemPress","onItemInputChange","onInputValueChange","handleChoicePress","onPress","handleItemInputChange","_value","handleSlidingComplete","logEvent","ANALYTICS_EVENT_TYPE","SLIDE","id","questionType","map","index","_id","selected","label","media","undefined","console","warn"],"mappings":";;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAqBA,MAAMA,UAAU,GAAGC,wBAAWC,MAAX,CAAkB;AACnCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,aAAa,EAAE,KADV;AAELC,IAAAA,UAAU,EAAE;AAFP,GAD4B;AAKnCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AADF,GAL6B;AAQnCC,EAAAA,OAAO,EAAE,CACP;AADO,GAR0B;AAWnCC,EAAAA,MAAM,EAAE;AACNC,IAAAA,eAAe,EAAE;AADX;AAX2B,CAAlB,CAAnB;;AAgBA,MAAMC,MAAM,GAAIC,KAAD,IAAkB;AAC/B,QAAMC,eAAe,GAAG,0CAAxB;AACA,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA;AAAZ,MAAqBF,eAA3B;AACA,QAAM;AAACG,IAAAA,eAAD;AAAkBC,IAAAA,UA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AA,SAAS,MADX;AAEE,QAAA,QAAQ,EAAEA,kBAFZ;AAGE,QAAA,MAAM,EAAC,qBAHT;AAIE,QAAA,YAAY,EAAC,OAJf;AAKE,QAAA,UAAU,EAAET;AALd,QADF;;AASF;AACE,0BACE,6BAAC,iBAAD,qBACE,6BAAC,iBAAD,4BAAuBF,IAAvB,CADF,CADF;AAhGJ;AAsGD,CApKD;;eAsKeR,M","sourcesContent":["import React, {useCallback} from 'react';\nimport {View, StyleSheet, Text} from 'react-native';\n\nimport QuestionChoice from '../../../../atom/choice/index.native';\nimport QuestionDraggable from '../draggable/index.native';\nimport QuestionTemplate from '../template/index.native';\nimport QuestionSlider from '../slider/index.native';\nimport FreeText from '../../free-text/index.native';\n\nimport {useTemplateContext} from '../../../../template/app-review/template-context';\nimport {ANALYTICS_EVENT_TYPE} from '../../../../variables/analytics';\n\nimport type {QuestionType, Choice} from '../../types';\n\nexport type Props = {\n type: QuestionType;\n isDisabled?: boolean;\n template?: string;\n choices?: Array<Choice>;\n min?: number;\n max?: number;\n unit?: string;\n step?: number;\n value?: number;\n onInputValueChange?: (value: string) => void;\n onSliderChange?: (value: number) => void;\n // --- mobile learner only\n onItemInputChange?: (item: Choice, value: string) => void;\n onItemPress?: (item: Choice) => void;\n};\n\nconst styleSheet = StyleSheet.create({\n cards: {\n flexDirection: 'row',\n alignItems: 'stretch'\n },\n card: {\n flex: 1\n },\n choices: {\n // backgroundColor: '#967' // flex-debug\n },\n choice: {\n paddingVertical: 5\n }\n});\n\nconst Switch = (props: Props) => {\n const templateContext = useTemplateContext();\n const {analytics, store} = templateContext;\n const {focusedSelectId, handleBlur, handleFocus} = store;\n\n const {\n type,\n template,\n isDisabled,\n choices = [],\n min,\n max,\n unit,\n value,\n step,\n onSliderChange,\n onItemPress,\n onItemInputChange,\n onInputValueChange\n } = props;\n\n const handleChoicePress = useCallback(\n (choice: Choice) => () => {\n if (choice.onPress) {\n // e.g. app-review\n choice.onPress();\n } else if (onItemPress) {\n // e.g. learner\n onItemPress(choice);\n }\n },\n [onItemPress]\n );\n\n const handleItemInputChange = useCallback(\n (choice: Choice, _value: string) => {\n if (choice.onPress) {\n // e.g. app-review\n choice.onPress(_value);\n } else if (onItemInputChange) {\n // e.g. learner\n onItemInputChange(choice, _value);\n }\n },\n [onItemInputChange]\n );\n\n const handleSlidingComplete = useCallback(\n _value => {\n analytics &&\n analytics.logEvent(ANALYTICS_EVENT_TYPE.SLIDE, {\n id: 'slider',\n questionType: 'slider'\n });\n\n if (onSliderChange) {\n onSliderChange(_value);\n }\n },\n [analytics, onSliderChange]\n );\n\n switch (type) {\n case 'qcm':\n return (\n <View testID=\"question-choices\" style={styleSheet.choices}>\n {choices.map((choice, index) => (\n <QuestionChoice\n key={`question-choice-${choice._id}`}\n onPress={handleChoicePress(choice)}\n isDisabled={isDisabled}\n isSelected={choice.selected}\n testID={`question-choice-${choice._id}`}\n style={styleSheet.choice}\n questionType={type}\n >\n {choice.label}\n </QuestionChoice>\n ))}\n </View>\n );\n case 'qcmGraphic':\n return (\n <View testID=\"question-choices\" style={styleSheet.choices}>\n {choices.map((choice, index) => (\n <QuestionChoice\n key={`question-choice-${choice._id}`}\n onPress={handleChoicePress(choice)}\n media={choice.media}\n isDisabled={isDisabled}\n isSelected={choice.selected}\n testID={`question-choice-${choice._id}`}\n style={styleSheet.choice}\n questionType={type}\n >\n {choice.label}\n </QuestionChoice>\n ))}\n </View>\n );\n case 'slider': {\n if (min === undefined || max === undefined) {\n return <View />;\n }\n\n return (\n <QuestionSlider\n min={min}\n max={max}\n unit={unit}\n value={value}\n step={step}\n onSlidingComplete={handleSlidingComplete}\n testID=\"question-slider\"\n />\n );\n }\n case 'template':\n if (handleBlur === undefined || handleFocus === undefined || focusedSelectId === undefined) {\n // eslint-disable-next-line no-console\n console.warn('type template must implement handleFocus etc within Context.store');\n return <View />;\n }\n\n return (\n <View testID=\"question-choices\">\n <QuestionTemplate\n isDisabled={isDisabled}\n template={template || ''}\n choices={choices}\n onInputChange={handleItemInputChange}\n handleBlur={handleBlur}\n handleFocus={handleFocus}\n focusedSelectId={focusedSelectId}\n />\n </View>\n );\n case 'qcmDrag':\n return (\n <View testID=\"question-draggable\">\n <QuestionDraggable choices={choices} onPress={handleChoicePress} />\n </View>\n );\n case 'basic':\n if (!onInputValueChange) {\n return <View />;\n }\n\n return (\n <FreeText\n fullWidth\n onChange={onInputValueChange}\n testID=\"question-input-text\"\n questionType=\"basic\"\n isDisabled={isDisabled}\n />\n );\n default:\n return (\n <View>\n <Text>Unhandled type: {type}</Text>\n </View>\n );\n }\n};\n\nexport default Switch;\n"],"file":"index.native.js"}