@gamelearn/arcade-components 0.10.0 → 0.11.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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withoutBackground = exports.voiceOverProps = exports.conversationProps = exports.converOld = void 0;
6
+ exports.conversationPropsNoFeedbackNoRewards = exports.withoutBackground = exports.voiceOverProps = exports.conversationProps = exports.converOld = void 0;
7
7
  var animations = {
8
8
  neutral: {
9
9
  url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/animation/5f06e116f9efdd00112fcc6f/male_missunderstand_1.glb'
@@ -588,4 +588,262 @@ var withoutBackground = {
588
588
  uid: 'kjTHqi'
589
589
  }]
590
590
  };
591
- exports.withoutBackground = withoutBackground;
591
+ exports.withoutBackground = withoutBackground;
592
+ var conversationPropsNoFeedbackNoRewards = {
593
+ lines: [{
594
+ flex: true,
595
+ slots: [{
596
+ emotion: '',
597
+ text: '',
598
+ uid: 'DbKslR',
599
+ talking: false,
600
+ alias: 'paco',
601
+ text_labelId: 'text_0_0_nlrZh8Np',
602
+ alias_labelId: 'alias_0_0_nlrZh2Iq'
603
+ }, {
604
+ emotion: 'neutral',
605
+ text: '',
606
+ uid: null,
607
+ talking: false,
608
+ text_labelId: 'text_0_1_nlrZiNfB',
609
+ alias_labelId: 'alias_0_1_nlrZijhw'
610
+ }, {
611
+ emotion: 'neutral',
612
+ text: '',
613
+ uid: null,
614
+ talking: false,
615
+ text_labelId: 'text_0_2_nlrZiBF3',
616
+ alias_labelId: 'alias_0_2_nlrZiR6G'
617
+ }, {
618
+ emotion: 'neutral',
619
+ text: '',
620
+ uid: null,
621
+ talking: false,
622
+ text_labelId: 'text_0_3_nlrZinJN',
623
+ alias_labelId: 'alias_0_3_nlrZjLWB'
624
+ }, {
625
+ emotion: 'neutral',
626
+ text: 'Hola!',
627
+ uid: 'kjTHqt',
628
+ talking: true,
629
+ alias: 'manolo',
630
+ text_labelId: 'text_0_4_nlrZjUV9',
631
+ alias_labelId: 'alias_0_4_nlrZj81d'
632
+ }],
633
+ audioId: '5f1078861d84860011e179d0',
634
+ hasAlias: true,
635
+ text_labelId: 'text_0_nlrZj4Nr',
636
+ audioId_labelId: 'audioId_0_nlrZkkdo'
637
+ }, {
638
+ flex: true,
639
+ slots: [{
640
+ emotion: '',
641
+ text: '',
642
+ uid: 'DbKslR',
643
+ talking: false,
644
+ alias: 'paco',
645
+ text_labelId: 'text_0_0_nlrZh8Np',
646
+ alias_labelId: 'alias_0_0_nlrZh2Iq'
647
+ }, {
648
+ emotion: 'neutral',
649
+ text: '',
650
+ uid: null,
651
+ talking: false,
652
+ text_labelId: 'text_0_1_nlrZiNfB',
653
+ alias_labelId: 'alias_0_1_nlrZijhw'
654
+ }, {
655
+ emotion: 'neutral',
656
+ text: '',
657
+ uid: null,
658
+ talking: false,
659
+ text_labelId: 'text_0_2_nlrZiBF3',
660
+ alias_labelId: 'alias_0_2_nlrZiR6G'
661
+ }, {
662
+ emotion: 'neutral',
663
+ text: '',
664
+ uid: null,
665
+ talking: false,
666
+ text_labelId: 'text_0_3_nlrZinJN',
667
+ alias_labelId: 'alias_0_3_nlrZjLWB'
668
+ }, {
669
+ emotion: 'neutral',
670
+ text: 'Hola!',
671
+ uid: 'kjTHqi',
672
+ talking: true,
673
+ alias: 'manolo',
674
+ text_labelId: 'text_0_4_nlrZjUV9',
675
+ alias_labelId: 'alias_0_4_nlrZj81d'
676
+ }],
677
+ audioId: '5f1078861d84860011e179d0',
678
+ hasAlias: true,
679
+ text_labelId: 'text_0_nlrZj4Nr',
680
+ audioId_labelId: 'audioId_0_nlrZkkdo'
681
+ }, {
682
+ flex: true,
683
+ slots: [{
684
+ emotion: '',
685
+ text: '',
686
+ uid: 'DbKslR',
687
+ talking: false,
688
+ alias: 'paco',
689
+ text_labelId: 'text_0_0_nlrZh8Np',
690
+ alias_labelId: 'alias_0_0_nlrZh2Iq'
691
+ }, {
692
+ emotion: 'neutral',
693
+ text: '',
694
+ uid: null,
695
+ talking: false,
696
+ text_labelId: 'text_0_1_nlrZiNfB',
697
+ alias_labelId: 'alias_0_1_nlrZijhw'
698
+ }, {
699
+ emotion: 'neutral',
700
+ text: '',
701
+ uid: null,
702
+ talking: false,
703
+ text_labelId: 'text_0_2_nlrZiBF3',
704
+ alias_labelId: 'alias_0_2_nlrZiR6G'
705
+ }, {
706
+ emotion: 'neutral',
707
+ text: '',
708
+ uid: null,
709
+ talking: false,
710
+ text_labelId: 'text_0_3_nlrZinJN',
711
+ alias_labelId: 'alias_0_3_nlrZjLWB'
712
+ }, {
713
+ emotion: 'neutral',
714
+ text: 'Hola!',
715
+ uid: 'kjTHqx',
716
+ talking: true,
717
+ alias: 'manolo',
718
+ text_labelId: 'text_0_4_nlrZjUV9',
719
+ alias_labelId: 'alias_0_4_nlrZj81d'
720
+ }],
721
+ audioId: '5f1078861d84860011e179d0',
722
+ hasAlias: true,
723
+ text_labelId: 'text_0_nlrZj4Nr',
724
+ audioId_labelId: 'audioId_0_nlrZkkdo'
725
+ }, {
726
+ payload: {
727
+ options: [{
728
+ id: 0,
729
+ right: false,
730
+ text: 'Si',
731
+ rewards: [],
732
+ audioId: '',
733
+ text_labelId: 'text_3_0_u4s8j5fa',
734
+ audioId_labelId: 'audioId_3_0_u4s8jyiK'
735
+ }, {
736
+ id: 1,
737
+ right: false,
738
+ text: 'No',
739
+ rewards: [],
740
+ audioId: '',
741
+ text_labelId: 'text_3_1_u4s8jzBF',
742
+ audioId_labelId: 'audioId_3_1_u4s8jaJY'
743
+ }, {
744
+ id: 2,
745
+ right: true,
746
+ text: 'Patata',
747
+ rewards: [],
748
+ audioId: '',
749
+ text_labelId: 'text_3_2_u4s8jA2Z',
750
+ audioId_labelId: 'audioId_3_2_u4s8j23g'
751
+ }],
752
+ required: true,
753
+ question: 'Decisión en conversacion sin feedback ni puntos',
754
+ question_labelId: 'question_3_u4s8i10a'
755
+ },
756
+ decision: true
757
+ }, {
758
+ flex: true,
759
+ slots: [{
760
+ emotion: 'angry',
761
+ text: '',
762
+ uid: 'DbKslR',
763
+ talking: false,
764
+ alias: 'paco',
765
+ text_labelId: 'text_0_0_nlrZh8Np',
766
+ alias_labelId: 'alias_0_0_nlrZh2Iq'
767
+ }, {
768
+ emotion: 'neutral',
769
+ text: '',
770
+ uid: null,
771
+ talking: false,
772
+ text_labelId: 'text_0_1_nlrZiNfB',
773
+ alias_labelId: 'alias_0_1_nlrZijhw'
774
+ }, {
775
+ emotion: 'neutral',
776
+ text: '',
777
+ uid: null,
778
+ talking: false,
779
+ text_labelId: 'text_0_2_nlrZiBF3',
780
+ alias_labelId: 'alias_0_2_nlrZiR6G'
781
+ }, {
782
+ emotion: 'neutral',
783
+ text: '',
784
+ uid: null,
785
+ talking: false,
786
+ text_labelId: 'text_0_3_nlrZinJN',
787
+ alias_labelId: 'alias_0_3_nlrZjLWB'
788
+ }, {
789
+ emotion: 'neutral',
790
+ text: 'Hola!',
791
+ uid: 'kjTHqi',
792
+ talking: true,
793
+ alias: 'manolo',
794
+ text_labelId: 'text_0_4_nlrZjUV9',
795
+ alias_labelId: 'alias_0_4_nlrZj81d'
796
+ }],
797
+ audioId: '5f1078861d84860011e179d0',
798
+ hasAlias: true,
799
+ text_labelId: 'text_0_nlrZj4Nr',
800
+ audioId_labelId: 'audioId_0_nlrZkkdo'
801
+ }],
802
+ background: {
803
+ imgId: '605369a5901f3e00123b81ca',
804
+ imgName: 'b27bb40dcb1189d14012131a35b48a36.jpeg',
805
+ img: {
806
+ url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/image/605369a5901f3e00123b81ca/b27bb40dcb1189d14012131a35b48a36.jpeg'
807
+ }
808
+ },
809
+ characters: [{
810
+ name: 'Testing',
811
+ resourceId: '5f68d7b6a373890011a78a11',
812
+ resource: {
813
+ url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/object/5eff09c2085be00011aae087/pr0238_yacht_001.glb'
814
+ },
815
+ type: 'object',
816
+ uid: 'DbKslR'
817
+ }, {
818
+ name: 'Male senior dark-skinned 01',
819
+ resourceId: '5f5214cec39e26001123797f',
820
+ resource: {
821
+ url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/character/5f5214cec39e26001123797f/ch0112_philip_001.glb',
822
+ animations: animations
823
+ },
824
+ type: 'character',
825
+ uid: 'kjTHqi'
826
+ }, {
827
+ name: 'Female senior light-skinned 01',
828
+ resourceId: '5f5214cec39e26001123797f',
829
+ resource: {
830
+ url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/character/5f60759328beb100113b694c/ch0116_bima_001_rig_v01_llaveronuevo.glb',
831
+ animations: {
832
+ neutral: {
833
+ resource: {}
834
+ }
835
+ }
836
+ },
837
+ type: 'character',
838
+ uid: 'kjTHqt'
839
+ }, {
840
+ name: 'Taxi',
841
+ resourceId: '5f5214cec39e26001123797f',
842
+ resource: {
843
+ url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/object/5e53b649ef1f60000fb9cc1c/draco_pr0065_car_004.glb'
844
+ },
845
+ type: 'object',
846
+ uid: 'kjTHqx'
847
+ }]
848
+ };
849
+ exports.conversationPropsNoFeedbackNoRewards = conversationPropsNoFeedbackNoRewards;
@@ -45,7 +45,8 @@ var DecisionBody = function DecisionBody(_ref) {
45
45
  showingResults = _ref.showingResults,
46
46
  currentSelectedChoice = _ref.currentSelectedChoice,
47
47
  children = _ref.children,
48
- translate = _ref.translate;
48
+ translate = _ref.translate,
49
+ hasRewards = _ref.hasRewards;
49
50
 
50
51
  var _useState = (0, _react.useState)(currentSelectedChoice),
51
52
  _useState2 = _slicedToArray(_useState, 2),
@@ -65,16 +66,21 @@ var DecisionBody = function DecisionBody(_ref) {
65
66
  inherited: inherited,
66
67
  selectedChoice: selectedChoice,
67
68
  selectChoice: !showingResults || inherited && failed ? choose : noop,
68
- options: options
69
+ options: options,
70
+ showingResults: showingResults,
71
+ hasFeedbackDefinedInEditor: currentSelectedChoice.feedback,
72
+ hasRewards: hasRewards
69
73
  };
70
74
 
71
75
  var BasicDecision = function BasicDecision(_ref2) {
72
76
  var defaultChildren = _ref2.children;
73
77
  return /*#__PURE__*/_react.default.createElement("div", {
74
- className: "popup popup__large popup__basicDecision arcade-popup__basicDecision ".concat(showingResults ? 'popup__feedback' : '')
78
+ className: "popup popup__large popup__basicDecision arcade-popup__basicDecision ".concat(showingResults && currentSelectedChoice.feedback ? 'popup__feedback' : '')
75
79
  }, /*#__PURE__*/_react.default.createElement("div", {
76
80
  className: "popup--info"
77
- }, showingResults ? defaultChildren : /*#__PURE__*/_react.default.createElement("span", {
81
+ }, showingResults ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, defaultChildren, !currentSelectedChoice.feedback && hasRewards.length === 0 && /*#__PURE__*/_react.default.createElement("span", {
82
+ className: "popup--info__title"
83
+ }, question !== '' && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, question))) : /*#__PURE__*/_react.default.createElement("span", {
78
84
  className: "popup--info__title"
79
85
  }, question)), /*#__PURE__*/_react.default.createElement("div", {
80
86
  className: "popup__questions"
@@ -136,7 +142,8 @@ DecisionBody.defaultProps = {
136
142
  onBack: noop,
137
143
  inherited: false,
138
144
  failed: false,
139
- children: []
145
+ children: [],
146
+ hasRewards: []
140
147
  };
141
148
  DecisionBody.propTypes = {
142
149
  children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
@@ -161,7 +168,8 @@ DecisionBody.propTypes = {
161
168
  question: _propTypes.default.string,
162
169
  inherited: _propTypes.default.bool,
163
170
  failed: _propTypes.default.bool,
164
- showingResults: _propTypes.default.bool
171
+ showingResults: _propTypes.default.bool,
172
+ hasRewards: _propTypes.default.arrayOf(_propTypes.default.shape())
165
173
  };
166
174
  var _default = DecisionBody;
167
175
  exports.default = _default;
@@ -107,6 +107,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
107
107
  inherited: inherited,
108
108
  showingResults: selectedView === 'results',
109
109
  currentSelectedChoice: resultChoice,
110
+ hasRewards: resultChoice.rewards || [],
110
111
  failed: failed,
111
112
  changeOption: function changeOption(option) {
112
113
  setResultChoice(option);
@@ -159,7 +160,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
159
160
  }
160
161
 
161
162
  return /*#__PURE__*/_react.default.createElement("div", {
162
- className: "conversation--layer ".concat(selectedView === 'results' ? 'conversation--layer__feedback' : '')
163
+ className: "conversation--layer \n ".concat(resultChoice.feedback ? '' : 'conversation--layer__defaultFeedback', " \n ").concat(selectedView === 'results' ? 'conversation--layer__feedback' : '')
163
164
  }, children);
164
165
  };
165
166
 
@@ -186,14 +187,12 @@ var DecisionComponent = function DecisionComponent(_ref) {
186
187
  inherited: inherited,
187
188
  choice: resultChoice,
188
189
  rewards: resultChoice.rewards || [],
189
- addPoints: function addPoints() {},
190
190
  emitEvent: emitEvent
191
191
  }) : null) : /*#__PURE__*/_react.default.createElement(PopupWrapper, null, /*#__PURE__*/_react.default.createElement(_DecisionBody.default, bodyProps, /*#__PURE__*/_react.default.createElement(_Feedback.default, {
192
192
  question: question,
193
193
  inherited: inherited,
194
194
  choice: resultChoice,
195
195
  rewards: resultChoice.rewards || [],
196
- addPoints: function addPoints() {},
197
196
  emitEvent: emitEvent
198
197
  })));
199
198
  };
@@ -23,7 +23,6 @@ var FeedBack = function FeedBack(_ref) {
23
23
  var choice = _ref.choice,
24
24
  inherited = _ref.inherited,
25
25
  rewards = _ref.rewards,
26
- addPoints = _ref.addPoints,
27
26
  emitEvent = _ref.emitEvent;
28
27
  var noFeedBack = choice.feedback === '' || !choice.feedback;
29
28
  var centerRewards = noFeedBack;
@@ -40,13 +39,6 @@ var FeedBack = function FeedBack(_ref) {
40
39
  var noRewards = rewards.filter(function (reward) {
41
40
  return reward.type !== 'grade';
42
41
  }).length === 0;
43
- (0, _react.useEffect)(function () {
44
- if (rewards.filter(function (reward) {
45
- return reward.type === 'grade';
46
- }).length === rewards.length) {
47
- addPoints();
48
- }
49
- }, [addPoints, rewards]);
50
42
  return noFeedBack && noRewards ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null) : /*#__PURE__*/_react.default.createElement(Wrapper, null, !noFeedBack ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
51
43
  className: "conversation--feedback__title"
52
44
  }, "Feedback"), /*#__PURE__*/_react.default.createElement("div", {
@@ -62,7 +54,6 @@ var FeedBack = function FeedBack(_ref) {
62
54
  };
63
55
 
64
56
  FeedBack.defaultProps = {
65
- addPoints: function addPoints() {},
66
57
  rewards: [],
67
58
  choice: {},
68
59
  inherited: false,
@@ -70,7 +61,6 @@ FeedBack.defaultProps = {
70
61
  };
71
62
  FeedBack.propTypes = {
72
63
  inherited: _propTypes.default.bool,
73
- addPoints: _propTypes.default.func,
74
64
  rewards: _propTypes.default.arrayOf(_propTypes.default.shape({})),
75
65
  choice: _propTypes.default.shape({
76
66
  id: _propTypes.default.number,
@@ -13,7 +13,10 @@ var Options = function Options(_ref) {
13
13
  var inherited = _ref.inherited,
14
14
  options = _ref.options,
15
15
  selectedChoice = _ref.selectedChoice,
16
- selectChoice = _ref.selectChoice;
16
+ selectChoice = _ref.selectChoice,
17
+ showingResults = _ref.showingResults,
18
+ hasFeedbackDefinedInEditor = _ref.hasFeedbackDefinedInEditor,
19
+ hasRewards = _ref.hasRewards;
17
20
  return options.filter(function (option) {
18
21
  return option.text;
19
22
  }).map(function (option) {
@@ -24,7 +27,13 @@ var Options = function Options(_ref) {
24
27
  type: "radio",
25
28
  name: option.id,
26
29
  defaultChecked: selectedChoice.id === option.id
27
- }), /*#__PURE__*/_react.default.createElement("label", {
30
+ }), showingResults ? /*#__PURE__*/_react.default.createElement("label", {
31
+ className: "".concat(option.right ? "radio-text-success ".concat(!hasFeedbackDefinedInEditor && hasRewards.length === 0 ? 'radio-icon-success' : '') : "radio-text-fail ".concat(!hasFeedbackDefinedInEditor && hasRewards.length === 0 ? 'radio-icon-fail' : '')),
32
+ htmlFor: option.id,
33
+ onClick: function onClick() {
34
+ selectChoice(option);
35
+ }
36
+ }, option.text) : /*#__PURE__*/_react.default.createElement("label", {
28
37
  htmlFor: option.id,
29
38
  onClick: function onClick() {
30
39
  selectChoice(option);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.decisionProps = void 0;
6
+ exports.decisionPropsWithRadios = exports.decisionProps = void 0;
7
7
 
8
8
  var emitEvent = function emitEvent(_ref) {
9
9
  var type = _ref.type,
@@ -179,4 +179,36 @@ var decisionProps = {
179
179
  question: 'Funciona la decisión',
180
180
  question_labelId: 'question_3_u4s8i10a'
181
181
  };
182
- exports.decisionProps = decisionProps;
182
+ exports.decisionProps = decisionProps;
183
+ var decisionPropsWithRadios = {
184
+ emitEvent: emitEvent,
185
+ options: [{
186
+ id: 0,
187
+ right: false,
188
+ text: 'Si',
189
+ rewards: [],
190
+ audioId: '',
191
+ text_labelId: 'text_3_0_u4s8j5fa',
192
+ audioId_labelId: 'audioId_3_0_u4s8jyiK'
193
+ }, {
194
+ id: 1,
195
+ right: false,
196
+ text: 'No',
197
+ rewards: [],
198
+ audioId: '',
199
+ text_labelId: 'text_3_1_u4s8jzBF',
200
+ audioId_labelId: 'audioId_3_1_u4s8jaJY'
201
+ }, {
202
+ id: 2,
203
+ right: true,
204
+ text: 'Patata',
205
+ rewards: [],
206
+ audioId: '',
207
+ text_labelId: 'text_3_2_u4s8jA2Z',
208
+ audioId_labelId: 'audioId_3_2_u4s8j23g'
209
+ }],
210
+ required: true,
211
+ question: 'Decision sin feedback ni puntos',
212
+ question_labelId: 'question_3_u4s8i10a'
213
+ };
214
+ exports.decisionPropsWithRadios = decisionPropsWithRadios;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "license": "Gamelearn",
4
- "version": "0.10.0",
4
+ "version": "0.11.0",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",
@@ -55,7 +55,7 @@
55
55
  "@babel/cli": "7.12.10",
56
56
  "@babel/preset-env": "7.12.11",
57
57
  "@babel/preset-react": "7.12.10",
58
- "@gamelearn/ui-components-core": "5.18.0",
58
+ "@gamelearn/ui-components-core": "5.21.0",
59
59
  "@react-three/test-renderer": "6.0.6",
60
60
  "@storybook/addon-actions": "6.1.11",
61
61
  "@storybook/addon-essentials": "6.1.11",
@@ -76,4 +76,4 @@
76
76
  "^react-pdf$": "react-pdf/dist/umd/entry.jest"
77
77
  }
78
78
  }
79
- }
79
+ }