@gamelearn/arcade-components 0.10.0 → 0.11.1

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.
@@ -120,6 +120,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
120
120
  var flexedPosition = characters.findIndex(function (char) {
121
121
  return char.uid === currentMessage.uid;
122
122
  });
123
+ characters.forEach(function (c) {
124
+ if (c.uid === currentMessage.uid) c.name = currentMessage.alias;
125
+ });
123
126
  currentMessage.position = isFlex ? flexedPosition : notFlexedPosition;
124
127
  }
125
128
  }
@@ -87,7 +87,7 @@ var SlotList = function SlotList(_ref) {
87
87
  slots: slots,
88
88
  flex: flex,
89
89
  currentMessage: currentMessage
90
- }), children ? children : /*#__PURE__*/_react.default.createElement(Slots, null));
90
+ }), children && children.ref ? children : /*#__PURE__*/_react.default.createElement(Slots, null));
91
91
  };
92
92
 
93
93
  SlotList.propTypes = {
@@ -32,12 +32,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
32
32
  var defaultCamPos = [0, 14.63, 16];
33
33
 
34
34
  function Panel(_ref) {
35
+ var _character$resource, _character$resource$a;
36
+
35
37
  var character = _ref.character,
36
38
  active = _ref.active;
37
39
  var cameraRef = (0, _react.useRef)(null);
38
40
  var sceneRef = (0, _react.useRef)(null);
39
41
  var isCharacter = character.type === 'character';
40
- var emotion = isCharacter ? character.resource.animations[character.emotion || 'neutral'] : {};
42
+ var emotion = isCharacter ? (character === null || character === void 0 ? void 0 : (_character$resource = character.resource) === null || _character$resource === void 0 ? void 0 : (_character$resource$a = _character$resource.animations) === null || _character$resource$a === void 0 ? void 0 : _character$resource$a[character.emotion || 'neutral']) || {} : {};
41
43
  var onLoadElement = (0, _react.useCallback)(function (model) {
42
44
  if (cameraRef.current) {
43
45
  var boundingBox = new _three.Box3();
@@ -90,13 +92,13 @@ function Panel(_ref) {
90
92
  ref: sceneRef
91
93
  }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
92
94
  fallback: null
93
- }, /*#__PURE__*/_react.default.createElement(_element.default, {
95
+ }, character.resource.url ? /*#__PURE__*/_react.default.createElement(_element.default, {
94
96
  name: "char_".concat(character.uid),
95
97
  url: character.resource.url,
96
98
  animationUrl: emotion.url,
97
99
  position: [0, 0, 0],
98
100
  onLoad: onLoadElement
99
- })), /*#__PURE__*/_react.default.createElement(_drei.PerspectiveCamera, {
101
+ }) : null), /*#__PURE__*/_react.default.createElement(_drei.PerspectiveCamera, {
100
102
  name: "camera_".concat(character.uid),
101
103
  fov: 35,
102
104
  focus: 10,
@@ -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"
@@ -125,43 +131,5 @@ var DecisionBody = function DecisionBody(_ref) {
125
131
  return /*#__PURE__*/_react.default.createElement(BasicDecision, null, children);
126
132
  };
127
133
 
128
- DecisionBody.defaultProps = {
129
- options: [],
130
- currentSelectedChoice: {},
131
- showingResults: false,
132
- question: '',
133
- changeOption: noop,
134
- onExit: noop,
135
- onNext: noop,
136
- onBack: noop,
137
- inherited: false,
138
- failed: false,
139
- children: []
140
- };
141
- DecisionBody.propTypes = {
142
- children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
143
- options: _propTypes.default.arrayOf(_propTypes.default.shape({
144
- id: _propTypes.default.number,
145
- feedback: _propTypes.default.string,
146
- slot: _propTypes.default.bool,
147
- text: _propTypes.default.string,
148
- rewards: _propTypes.default.arrayOf(_propTypes.default.shape())
149
- })),
150
- currentSelectedChoice: _propTypes.default.shape({
151
- id: _propTypes.default.number,
152
- rewards: _propTypes.default.arrayOf(_propTypes.default.shape()),
153
- feedback: _propTypes.default.string,
154
- slot: _propTypes.default.bool,
155
- text: _propTypes.default.string
156
- }),
157
- changeOption: _propTypes.default.func,
158
- onExit: _propTypes.default.func,
159
- onNext: _propTypes.default.func,
160
- onBack: _propTypes.default.func,
161
- question: _propTypes.default.string,
162
- inherited: _propTypes.default.bool,
163
- failed: _propTypes.default.bool,
164
- showingResults: _propTypes.default.bool
165
- };
166
134
  var _default = DecisionBody;
167
135
  exports.default = _default;
@@ -9,8 +9,6 @@ exports.default = void 0;
9
9
 
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
 
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
12
  var _SlotList = _interopRequireDefault(require("../../conversational-pro-component/components/SlotList"));
15
13
 
16
14
  var _DecisionBody = _interopRequireDefault(require("./DecisionBody"));
@@ -57,7 +55,8 @@ var DecisionComponent = function DecisionComponent(_ref) {
57
55
  var emitEvent = _ref.emitEvent,
58
56
  props = _objectWithoutProperties(_ref, ["emitEvent"]);
59
57
 
60
- var inheritProps = props.inheritProps,
58
+ var _props$inheritProps = props.inheritProps,
59
+ inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
61
60
  required = props.required,
62
61
  question = props.question,
63
62
  onFinish = props.onFinish;
@@ -107,6 +106,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
107
106
  inherited: inherited,
108
107
  showingResults: selectedView === 'results',
109
108
  currentSelectedChoice: resultChoice,
109
+ hasRewards: resultChoice.rewards || [],
110
110
  failed: failed,
111
111
  changeOption: function changeOption(option) {
112
112
  setResultChoice(option);
@@ -159,7 +159,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
159
159
  }
160
160
 
161
161
  return /*#__PURE__*/_react.default.createElement("div", {
162
- className: "conversation--layer ".concat(selectedView === 'results' ? 'conversation--layer__feedback' : '')
162
+ className: "conversation--layer \n ".concat(resultChoice.feedback ? '' : 'conversation--layer__defaultFeedback', " \n ").concat(selectedView === 'results' ? 'conversation--layer__feedback' : '')
163
163
  }, children);
164
164
  };
165
165
 
@@ -186,14 +186,12 @@ var DecisionComponent = function DecisionComponent(_ref) {
186
186
  inherited: inherited,
187
187
  choice: resultChoice,
188
188
  rewards: resultChoice.rewards || [],
189
- addPoints: function addPoints() {},
190
189
  emitEvent: emitEvent
191
190
  }) : null) : /*#__PURE__*/_react.default.createElement(PopupWrapper, null, /*#__PURE__*/_react.default.createElement(_DecisionBody.default, bodyProps, /*#__PURE__*/_react.default.createElement(_Feedback.default, {
192
191
  question: question,
193
192
  inherited: inherited,
194
193
  choice: resultChoice,
195
194
  rewards: resultChoice.rewards || [],
196
- addPoints: function addPoints() {},
197
195
  emitEvent: emitEvent
198
196
  })));
199
197
  };
@@ -201,33 +199,5 @@ var DecisionComponent = function DecisionComponent(_ref) {
201
199
  return /*#__PURE__*/_react.default.createElement(BackgroundWrapper, null, /*#__PURE__*/_react.default.createElement(Body, null));
202
200
  };
203
201
 
204
- DecisionComponent.defaultProps = {
205
- inheritProps: {},
206
- required: false,
207
- onFinish: null,
208
- question: '',
209
- options: []
210
- };
211
- DecisionComponent.propTypes = {
212
- required: _propTypes.default.bool,
213
- onFinish: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.oneOf([null])]),
214
- inheritProps: _propTypes.default.shape({
215
- background: _propTypes.default.string,
216
- flex: _propTypes.default.bool,
217
- voiceOver: _propTypes.default.shape({}),
218
- name: _propTypes.default.string,
219
- text: _propTypes.default.string,
220
- slots: _propTypes.default.arrayOf({})
221
- }),
222
- options: _propTypes.default.arrayOf(_propTypes.default.shape({
223
- id: _propTypes.default.number,
224
- feedback: _propTypes.default.string,
225
- slot: _propTypes.default.bool,
226
- text: _propTypes.default.string,
227
- audioId: _propTypes.default.string,
228
- rewards: _propTypes.default.arrayOf(_propTypes.default.shape())
229
- })),
230
- question: _propTypes.default.string
231
- };
232
202
  var _default = DecisionComponent;
233
203
  exports.default = _default;
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
11
9
 
12
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
11
 
@@ -15,39 +13,26 @@ var _RewardsComponent = _interopRequireDefault(require("../../rewards-component/
15
13
 
16
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
15
 
18
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
19
-
20
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
16
  var FeedBack = function FeedBack(_ref) {
23
17
  var choice = _ref.choice,
24
18
  inherited = _ref.inherited,
25
19
  rewards = _ref.rewards,
26
- addPoints = _ref.addPoints,
27
20
  emitEvent = _ref.emitEvent;
28
- var noFeedBack = choice.feedback === '' || !choice.feedback;
29
- var centerRewards = noFeedBack;
30
21
 
31
22
  var Wrapper = function Wrapper(_ref2) {
32
23
  var children = _ref2.children;
33
24
  return inherited ? /*#__PURE__*/_react.default.createElement("div", {
34
- className: "conversation--feedback ".concat(centerRewards ? 'only--rewards' : '')
35
- }, children) : centerRewards ? /*#__PURE__*/_react.default.createElement("div", {
25
+ className: "conversation--feedback ".concat(!choice.feedback ? 'only--rewards' : '')
26
+ }, children) : !choice.feedback ? /*#__PURE__*/_react.default.createElement("div", {
36
27
  className: "popup__basicDecision__only--rewards only--rewards"
37
- }, children) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
28
+ }, children) : children;
38
29
  };
39
30
 
40
31
  var noRewards = rewards.filter(function (reward) {
41
32
  return reward.type !== 'grade';
42
33
  }).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
- 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", {
34
+ if (!choice.feedback && noRewards) return null;
35
+ return /*#__PURE__*/_react.default.createElement(Wrapper, null, !!choice.feedback ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
51
36
  className: "conversation--feedback__title"
52
37
  }, "Feedback"), /*#__PURE__*/_react.default.createElement("div", {
53
38
  className: "conversation--feedback__text"
@@ -61,25 +46,5 @@ var FeedBack = function FeedBack(_ref) {
61
46
  }) : null);
62
47
  };
63
48
 
64
- FeedBack.defaultProps = {
65
- addPoints: function addPoints() {},
66
- rewards: [],
67
- choice: {},
68
- inherited: false,
69
- nodeId: 0
70
- };
71
- FeedBack.propTypes = {
72
- inherited: _propTypes.default.bool,
73
- addPoints: _propTypes.default.func,
74
- rewards: _propTypes.default.arrayOf(_propTypes.default.shape({})),
75
- choice: _propTypes.default.shape({
76
- id: _propTypes.default.number,
77
- rewards: _propTypes.default.arrayOf(_propTypes.default.shape()),
78
- feedback: _propTypes.default.string,
79
- slot: _propTypes.default.bool,
80
- right: _propTypes.default.bool,
81
- text: _propTypes.default.string
82
- })
83
- };
84
49
  var _default = FeedBack;
85
50
  exports.default = _default;
@@ -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.1",
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
+ }