@pocketprep/ui-kit 3.4.89 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/@pocketprep/ui-kit.js +14834 -16036
  2. package/dist/@pocketprep/ui-kit.js.map +1 -1
  3. package/dist/@pocketprep/ui-kit.umd.cjs +12 -12
  4. package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/lib/components/Bundles/BundleSearch.vue +41 -11
  7. package/lib/components/Pagination/QuestionReviewPagination.vue +21 -19
  8. package/lib/components/Quiz/Question/ChoicesContainer.vue +95 -129
  9. package/lib/components/Quiz/Question/DropdownExplanation.vue +39 -53
  10. package/lib/components/Quiz/Question/Explanation.vue +47 -57
  11. package/lib/components/Quiz/Question/MatrixChoicesContainer.vue +211 -224
  12. package/lib/components/Quiz/Question/MatrixRadioGroup.vue +5 -4
  13. package/lib/components/Quiz/Question/MobileMatrixChoicesContainer.vue +321 -319
  14. package/lib/components/Quiz/Question/MobileMatrixRadioGroup.vue +7 -6
  15. package/lib/components/Quiz/Question/PassageAndImage.vue +32 -43
  16. package/lib/components/Quiz/Question/PassageAndImageDropdown.vue +32 -43
  17. package/lib/components/Quiz/Question/Paywall.vue +28 -39
  18. package/lib/components/Quiz/Question/QuestionContext.vue +23 -31
  19. package/lib/components/Quiz/Question/StatsSummary.vue +10 -20
  20. package/lib/components/Quiz/Question/Summary.vue +54 -64
  21. package/lib/components/Quiz/Question/composables.ts +71 -0
  22. package/lib/components/Quiz/Question/injectionSymbols.ts +69 -0
  23. package/lib/components/Quiz/Question.vue +788 -988
  24. package/lib/components/Quiz/QuizContainer.vue +36 -34
  25. package/lib/components/Quiz/question.d.ts +4 -4
  26. package/lib/directives.ts +27 -22
  27. package/lib/styles/_breakpoints.scss +6 -12
  28. package/package.json +4 -4
@@ -6,12 +6,12 @@
6
6
  >
7
7
  <div
8
8
  v-dark="isDarkMode"
9
- v-breakpoint:questionEl="breakpoints"
9
+ v-breakpoint="breakpointsWithEl"
10
10
  class="uikit-question-matrix-choices-container__columns"
11
11
  >
12
12
  <div
13
13
  v-dark="isDarkMode"
14
- v-breakpoint:questionEl="breakpoints"
14
+ v-breakpoint="breakpointsWithEl"
15
15
  class="uikit-question-matrix-choices-container__column-row-header"
16
16
  :class="{
17
17
  'uikit-question-matrix-choices-container__column-row-header--two-columns':
@@ -34,7 +34,7 @@
34
34
  v-for="(columnLabel, index) in matrixColumnLabels"
35
35
  :key="index"
36
36
  v-dark="isDarkMode"
37
- v-breakpoint:questionEl="breakpoints"
37
+ v-breakpoint="breakpointsWithEl"
38
38
  v-html="columnLabel"
39
39
  />
40
40
  </div>
@@ -50,7 +50,7 @@
50
50
  (showMatrixAnswers || reviewMode) && isTeachGroupReview,
51
51
  }"
52
52
  v-dark="isDarkMode"
53
- v-breakpoint:questionEl="breakpoints"
53
+ v-breakpoint="breakpointsWithEl"
54
54
  >
55
55
  <div
56
56
  class="uikit-question-matrix-choices-container__choices"
@@ -61,7 +61,7 @@
61
61
  numberOfMatrixColumnLabels === 2,
62
62
  }"
63
63
  v-dark="isDarkMode"
64
- v-breakpoint:questionEl="breakpoints"
64
+ v-breakpoint="breakpointsWithEl"
65
65
  v-for="(rowLabel, rowIndex) in matrixRowLabels"
66
66
  :key="rowIndex"
67
67
  >
@@ -76,7 +76,7 @@
76
76
  question.type === 'Matrix Radio Button' && numberOfMatrixColumnLabels === 2,
77
77
  }"
78
78
  v-dark="isDarkMode"
79
- v-breakpoint:questionEl="breakpoints"
79
+ v-breakpoint="breakpointsWithEl"
80
80
  v-html="rowLabel"
81
81
  />
82
82
  <template
@@ -103,7 +103,7 @@
103
103
  v-for="(columnLabel, columnIndex) in matrixColumnLabels"
104
104
  :key="columnIndex"
105
105
  v-dark="isDarkMode"
106
- v-breakpoint:questionEl="breakpoints"
106
+ v-breakpoint="breakpointsWithEl"
107
107
  >
108
108
  <Checkbox
109
109
  v-if="(showMatrixAnswers || reviewMode) &&
@@ -115,7 +115,7 @@
115
115
  :checkbox-styles="checkboxContainerStyling(rowIndex, columnIndex)"
116
116
  />
117
117
  <div
118
- v-else
118
+ v-else
119
119
  class="uikit-question-matrix-choices-container__clickable-checkbox"
120
120
  :class="{
121
121
  'uikit-question-matrix-choices-container__clickable-checkbox--review':
@@ -126,7 +126,7 @@
126
126
  checkboxClicked(rowIndex, columnIndex)"
127
127
  >
128
128
  <Checkbox
129
- :model-value="matrixCheckboxGrid[rowIndex][columnIndex]"
129
+ :model-value="matrixCheckboxGrid[rowIndex]?.[columnIndex] || false"
130
130
  :is-dark-mode="isDarkMode"
131
131
  :disabled="showMatrixAnswers || reviewMode"
132
132
  :checkbox-styles="checkboxContainerStyling(rowIndex, columnIndex)"
@@ -163,7 +163,6 @@
163
163
  :is-dark-mode="isDarkMode"
164
164
  :disabled="false"
165
165
  :question-el="questionEl"
166
- :breakpoints="breakpoints"
167
166
  @update:modelValue="updateRadioRowSelection(rowIndex, $event)"
168
167
  >
169
168
  <template #optionIcon="{ optionIcon }">
@@ -189,272 +188,260 @@
189
188
  </div>
190
189
  </template>
191
190
 
192
- <script lang="ts">
193
- import { Component, Vue, Prop, Emit, Watch } from 'vue-facing-decorator'
191
+ <script setup lang="ts">
194
192
  import Icon from '../../Icons/Icon.vue'
195
- import PocketButton from '../../Buttons/Button.vue'
196
193
  import Checkbox from '../../Forms/Checkbox.vue'
197
194
  import MatrixRadioGroup from './MatrixRadioGroup.vue'
198
- import { dark, breakpoint } from '../../../directives'
199
- import type { TBreakPointsObject, IRadioOptions, TMatrixChoiceKey } from './../question'
200
- import type { Study } from '@pocketprep/types'
195
+ import { dark as vDark, breakpoint as vBreakpoint } from '../../../directives'
196
+ import { useQuestionContext } from './composables'
197
+ import type { IRadioOptions, TMatrixChoiceKey } from './../question'
201
198
  import BrandColors from '../../../pocketprep-export.module.scss'
199
+ import { ref, computed, onMounted, watch } from 'vue'
200
+
201
+ const emit = defineEmits<{
202
+ 'emitSelectedMatrixChoice': [matrixChoiceKeys: TMatrixChoiceKey[]]
203
+ }>()
204
+
205
+ const {
206
+ // questionEl is used by the breakpoint directive
207
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
208
+ questionEl,
209
+ question,
210
+ isMatrixQuestionCorrect,
211
+ reviewMode,
212
+ isDarkMode,
213
+ breakpointsWithEl,
214
+ showMatrixAnswers,
215
+ matrixAnswerKeys,
216
+ selectedMatrixChoices,
217
+ isTeachGroupReview,
218
+ } = useQuestionContext()
219
+
220
+ const matrixCheckboxGrid = ref<boolean[][] | undefined>(undefined)
221
+ const matrixRadioGrid = ref<IRadioOptions[] | undefined>(undefined)
222
+ const brandColors = BrandColors
223
+
224
+ const defaultCheckboxGrid = computed(() => {
225
+ return matrixChoiceLayout.value?.map(row => {
226
+ const choiceRow = row.map(() => false)
227
+ return choiceRow
228
+ })
229
+ })
202
230
 
203
- @Component({
204
- components: {
205
- Icon,
206
- Checkbox,
207
- MatrixRadioGroup,
208
- PocketButton,
209
- },
210
- directives: {
211
- dark,
212
- breakpoint,
213
- },
231
+ const defaultRadioButtonGrid = computed(() => {
232
+ return matrixChoiceLayout.value?.map(row => {
233
+ return {
234
+ choices: row as TMatrixChoiceKey[],
235
+ value: null as TMatrixChoiceKey | null,
236
+ }
237
+ })
214
238
  })
215
- export default class MatrixChoicesContainer extends Vue {
216
- @Prop({ default: false }) reviewMode!: boolean
217
- @Prop({ default: false }) isDarkMode!: boolean
218
- @Prop({ default: null }) questionEl!: Element | null
219
- @Prop({ default: {
220
- 'mobile': 767,
221
- 'tablet-portrait': 1023,
222
- 'tablet-landscape': 1439,
223
- } }) breakpoints!: TBreakPointsObject
224
- @Prop() question!: Study.Class.QuestionJSON
225
- @Prop() matrixChoiceLayout!: string[][]
226
- @Prop({ default: false }) showMatrixAnswers!: boolean
227
- @Prop({ default: false }) isUnanswered!: boolean
228
- @Prop({ default: false }) isMatrixQuestionCorrect!: boolean
229
- @Prop() matrixAnswerKeys!: TMatrixChoiceKey[]
230
- @Prop() matrixDistractorKeys!: TMatrixChoiceKey[]
231
- @Prop() selectedMatrixChoices!: TMatrixChoiceKey[]
232
- @Prop({ default: false }) isTeachGroupReview!: boolean
233
-
234
- matrixCheckboxGrid: boolean[][] | undefined = undefined
235
- matrixRadioGrid: IRadioOptions[] | undefined = undefined
236
- columnIndex = 0
237
- rowIndex = 0
238
- brandColors = BrandColors
239
-
240
- get defaultCheckboxGrid () {
241
- return this.matrixChoiceLayout?.map(row => {
242
- const choiceRow = row.map(() => false)
243
- return choiceRow
244
- })
245
- }
246
239
 
247
- get defaultRadioButtonGrid () {
248
- return this.matrixChoiceLayout?.map(row => {
249
- return {
250
- choices: row as TMatrixChoiceKey[],
251
- value: null as TMatrixChoiceKey | null,
252
- }
253
- })
254
- }
240
+ const matrixChoiceLayout = computed(() => {
241
+ return question.value.matrixChoiceLayout
242
+ })
255
243
 
256
- get matrixRowLabels () {
257
- return this.question.matrixLabels?.rows
258
- }
244
+ const matrixRowLabels = computed(() => {
245
+ return question.value.matrixLabels?.rows
246
+ })
259
247
 
260
- get matrixColumnLabels () {
261
- return this.question.matrixLabels?.columns
262
- }
248
+ const matrixColumnLabels = computed(() => {
249
+ return question.value.matrixLabels?.columns
250
+ })
263
251
 
264
- get numberOfMatrixColumnLabels () {
265
- return this.question.matrixLabels?.columns.length || 0
266
- }
252
+ const numberOfMatrixColumnLabels = computed(() => {
253
+ return question.value.matrixLabels?.columns.length || 0
254
+ })
267
255
 
268
- get matrixColumnLabelsForRows () {
269
- return this.question.matrixLabels?.columnLabelForRows
256
+ const matrixColumnLabelsForRows = computed(() => {
257
+ return question.value.matrixLabels?.columnLabelForRows
258
+ })
259
+
260
+ onMounted(() => {
261
+ if (question.value.type === 'Matrix Checkbox') {
262
+ matrixCheckboxGrid.value = convertSelectedMatrixChoiceToCheckboxGrid()
270
263
  }
264
+
265
+ if (question.value.type === 'Matrix Radio Button') {
266
+ matrixRadioGrid.value = convertSelectedMatrixChoiceToRadioBtnGrid()
267
+ }
268
+ })
271
269
 
272
- mounted () {
273
- if (this.question.type === 'Matrix Checkbox') {
274
- this.matrixCheckboxGrid = this.convertSelectedMatrixChoiceToCheckboxGrid()
270
+ const convertSelectedMatrixChoiceToCheckboxGrid = () => {
271
+ const checkboxGrid = defaultCheckboxGrid.value
272
+ selectedMatrixChoices.value.forEach(choice => {
273
+ const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
274
+ const colIndex = Number(choice.split('_').pop()) - 1
275
+ const row = checkboxGrid && checkboxGrid[rowIndex]
276
+ if (row) {
277
+ row[colIndex] = true
275
278
  }
276
-
277
- if (this.question.type === 'Matrix Radio Button') {
278
- this.matrixRadioGrid = this.convertSelectedMatrixChoiceToRadioBtnGrid()
279
+ })
280
+ return checkboxGrid
281
+ }
282
+
283
+ const convertSelectedMatrixChoiceToRadioBtnGrid = () => {
284
+ const radioBtnGrid = defaultRadioButtonGrid.value
285
+ selectedMatrixChoices.value.forEach(choice => {
286
+ const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
287
+ const row = radioBtnGrid && radioBtnGrid[rowIndex]
288
+ if (row) {
289
+ row.value = choice
279
290
  }
280
- }
291
+ })
292
+ return radioBtnGrid
293
+ }
281
294
 
282
- convertSelectedMatrixChoiceToCheckboxGrid () {
283
- const checkboxGrid = this.defaultCheckboxGrid
284
- this.selectedMatrixChoices.forEach(choice => {
285
- const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
286
- const colIndex = Number(choice.split('_').pop()) - 1
287
- if (checkboxGrid && checkboxGrid[rowIndex]) {
288
- checkboxGrid[rowIndex][colIndex] = true
289
- }
290
- })
291
- return checkboxGrid
292
- }
295
+ const getRadioRowSelection = (rowIndex: number) => {
296
+ return matrixRadioGrid.value?.[rowIndex]?.value
297
+ }
293
298
 
294
- convertSelectedMatrixChoiceToRadioBtnGrid () {
295
- const radioBtnGrid = this.defaultRadioButtonGrid
296
- this.selectedMatrixChoices.forEach(choice => {
297
- const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
298
- if (radioBtnGrid && radioBtnGrid[rowIndex]) {
299
- radioBtnGrid[rowIndex].value = choice
300
- }
301
- })
302
- return radioBtnGrid
303
- }
299
+ const getRadioRowChoices = (rowIndex: number) => {
300
+ const choices = matrixRadioGrid.value?.[rowIndex]?.choices
301
+ return choices
302
+ }
304
303
 
305
- getRadioRowSelection (rowIndex: number) {
306
- return this.matrixRadioGrid?.[rowIndex]?.value
304
+ const updateRadioRowSelection = (rowIndex: number, choiceKey: TMatrixChoiceKey | null) => {
305
+ const row = matrixRadioGrid.value?.[rowIndex]
306
+ if (row) {
307
+ row.value = choiceKey
307
308
  }
309
+ }
308
310
 
309
- getRadioRowChoices (rowIndex: number) {
310
- const choices = this.matrixRadioGrid?.[rowIndex]?.choices
311
- return choices
311
+ const selectedChoiceKey = (rowIndex: number, colIndex: number) => {
312
+ const row = rowIndex += 1
313
+ const column = colIndex += 1
314
+ if (selectedMatrixChoices && matrixAnswerKeys) {
315
+ const matrixSelectedChoiceKey = selectedMatrixChoices.value.find((choice) => {
316
+ const substring = choice.substring(1)
317
+ return substring === `${row}_${column}`
318
+ })
319
+ return matrixSelectedChoiceKey
312
320
  }
321
+ return undefined
322
+ }
313
323
 
314
- updateRadioRowSelection (rowIndex: number, choiceKey: TMatrixChoiceKey) {
315
- const row = this.matrixRadioGrid?.[rowIndex]
316
- if (row) {
317
- row.value = choiceKey
324
+ const correctlySelectedChoice = (rowIndex: number, colIndex: number) => {
325
+ if (selectedMatrixChoices.value && matrixAnswerKeys.value) {
326
+ const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
327
+ if (selectedChoice && selectedChoice.startsWith('a') && matrixAnswerKeys.value.includes(selectedChoice)) {
328
+ return true
318
329
  }
319
330
  }
331
+ return false
332
+ }
320
333
 
321
- selectedChoiceKey (rowIndex: number, colIndex: number) {
322
- const row = rowIndex += 1
323
- const column = colIndex += 1
324
- if (this.selectedMatrixChoices && this.matrixAnswerKeys) {
325
- const matrixSelectedChoiceKey = this.selectedMatrixChoices.find((choice) => {
326
- const substring = choice.substring(1)
327
- return substring === `${row}_${column}`
328
- })
329
- return matrixSelectedChoiceKey
334
+ const incorrectlySelectedChoice = (rowIndex: number, colIndex: number) => {
335
+ if (selectedMatrixChoices.value && matrixAnswerKeys.value) {
336
+ const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
337
+ if (selectedChoice && selectedChoice.startsWith('d')) {
338
+ return true
330
339
  }
331
- return undefined
332
340
  }
341
+ return false
342
+ }
343
+
344
+ const correctAnswerButNotSelected = (rowIndex: number, colIndex: number) => {
345
+ const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
346
+ const answerKey = matrixAnswerKeys.value.find(choice => choice === `a${rowIndex + 1}_${colIndex + 1}`)
347
+ return answerKey && !selectedChoice
348
+ }
333
349
 
334
- correctlySelectedChoice (rowIndex: number, colIndex: number) {
335
- if (this.selectedMatrixChoices && this.matrixAnswerKeys) {
336
- const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
337
- if (selectedChoice && selectedChoice.startsWith('a') && this.matrixAnswerKeys.includes(selectedChoice)) {
338
- return true
339
- }
340
- }
341
- return false
342
- }
350
+ const checkboxContainerStyling = (rowIndex: number, columnIndex: number) => {
351
+ const isReviewMode = showMatrixAnswers.value || reviewMode
343
352
 
344
- incorrectlySelectedChoice (rowIndex: number, colIndex: number) {
345
- if (this.selectedMatrixChoices && this.matrixAnswerKeys) {
346
- const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
347
- if (selectedChoice && selectedChoice.startsWith('d')) {
348
- return true
349
- }
353
+ // check box is correctlySelected
354
+ if (isReviewMode && correctlySelectedChoice(rowIndex, columnIndex)) {
355
+ const borderColor = isDarkMode ? brandColors.jungleGreen : brandColors.cadaverous
356
+ return {
357
+ borderColor: `${borderColor} !important`,
358
+ background: `${borderColor} !important`,
350
359
  }
351
- return false
352
360
  }
353
-
354
- correctAnswerButNotSelected (rowIndex: number, colIndex: number) {
355
- const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
356
- const answerKey = this.matrixAnswerKeys.find(choice => choice === `a${rowIndex + 1}_${colIndex + 1}`)
357
- return answerKey && !selectedChoice
358
- }
359
-
360
- checkboxContainerStyling (rowIndex: number, columnIndex: number) {
361
- const isReviewMode = this.showMatrixAnswers || this.reviewMode
362
- const incorrectlySelectedChoice = this.incorrectlySelectedChoice(rowIndex, columnIndex)
363
-
364
- // check box is correctlySelected
365
- if (isReviewMode && this.correctlySelectedChoice(rowIndex, columnIndex)) {
366
- const borderColor = this.isDarkMode ? this.brandColors.jungleGreen : this.brandColors.cadaverous
367
- return {
368
- borderColor: `${borderColor} !important`,
369
- background: `${borderColor} !important`,
370
- }
371
- }
372
361
 
373
- if (isReviewMode && incorrectlySelectedChoice) {
374
- return {
375
- background: `${this.brandColors.steel} !important`,
376
- border: `1px solid ${this.brandColors.steel} !important`,
377
- }
378
- }
379
-
380
- if (isReviewMode && this.correctAnswerButNotSelected(rowIndex, columnIndex)) {
381
- return {
382
- background: 'transparent !important',
383
- border: `1px solid ${this.brandColors.slate} !important`,
384
- }
362
+ if (isReviewMode && incorrectlySelectedChoice(rowIndex, columnIndex)) {
363
+ return {
364
+ background: `${brandColors.steel} !important`,
365
+ border: `1px solid ${brandColors.steel} !important`,
385
366
  }
386
367
  }
387
368
 
388
- checkboxCheckStyling (rowIndex: number, columnIndex: number) {
389
- const isReviewMode = this.showMatrixAnswers || this.reviewMode
390
- if (isReviewMode && this.correctAnswerButNotSelected(rowIndex, columnIndex)) {
391
- const color = this.isDarkMode ? this.brandColors.jungleGreen : this.brandColors.cadaverous
392
- return {
393
- color: `${color} !important`,
394
- }
369
+ if (isReviewMode && correctAnswerButNotSelected(rowIndex, columnIndex)) {
370
+ return {
371
+ background: 'transparent !important',
372
+ border: `1px solid ${brandColors.slate} !important`,
395
373
  }
396
374
  }
375
+ }
397
376
 
398
- checkboxClicked (rowIndex: number, columnIndex: number) {
399
- if (this.matrixCheckboxGrid && this.matrixCheckboxGrid[rowIndex]) {
400
- this.matrixCheckboxGrid[rowIndex][columnIndex] = !this.matrixCheckboxGrid[rowIndex][columnIndex]
377
+ const checkboxCheckStyling = (rowIndex: number, columnIndex: number) => {
378
+ const isReviewMode = showMatrixAnswers.value || reviewMode
379
+ if (isReviewMode && correctAnswerButNotSelected(rowIndex, columnIndex)) {
380
+ const color = isDarkMode ? brandColors.jungleGreen : brandColors.cadaverous
381
+ return {
382
+ color: `${color} !important`,
401
383
  }
402
384
  }
385
+ }
403
386
 
404
- @Emit('emitSelectedMatrixChoice')
405
- emitSelectedMatrixChoice (matrixChoiceKeys: TMatrixChoiceKey[]) {
406
- return matrixChoiceKeys
387
+ const checkboxClicked = (rowIndex: number, columnIndex: number) => {
388
+ const row = matrixCheckboxGrid.value?.[rowIndex]
389
+ if (row) {
390
+ row[columnIndex] = !row[columnIndex]
407
391
  }
392
+ }
408
393
 
409
- @Watch('matrixCheckboxGrid', { deep: true })
410
- matrixCheckboxGridChange () {
411
- if (this.matrixChoiceLayout && this.matrixCheckboxGrid) {
412
- const selectedCheckboxChoices: TMatrixChoiceKey[] = []
413
-
414
- this.matrixCheckboxGrid.forEach((row, rowIndex) => {
415
- row.forEach((choice, choiceIndex) => {
416
- if (
417
- choice &&
418
- this.matrixChoiceLayout[rowIndex] &&
419
- this.matrixChoiceLayout[rowIndex][choiceIndex]
420
- ) {
421
- const choiceKey = this.matrixChoiceLayout[rowIndex][choiceIndex] as TMatrixChoiceKey
394
+ const emitSelectedMatrixChoice = (matrixChoiceKeys: TMatrixChoiceKey[]) => {
395
+ emit('emitSelectedMatrixChoice', matrixChoiceKeys)
396
+ }
397
+
398
+ watch(matrixCheckboxGrid, () => {
399
+ if (matrixChoiceLayout.value && matrixCheckboxGrid.value) {
400
+ const selectedCheckboxChoices: TMatrixChoiceKey[] = []
401
+
402
+ matrixCheckboxGrid.value?.forEach((row, rowIndex) => {
403
+ row.forEach((choice, choiceIndex) => {
404
+ if (
405
+ choice &&
406
+ matrixChoiceLayout.value?.[rowIndex] &&
407
+ matrixChoiceLayout.value?.[rowIndex]?.[choiceIndex]
408
+ ) {
409
+ const choiceKey = matrixChoiceLayout.value?.[rowIndex]?.[choiceIndex] as TMatrixChoiceKey | null
410
+ if (choiceKey) {
422
411
  selectedCheckboxChoices.push(choiceKey)
423
412
  }
424
- })
425
- })
426
- this.emitSelectedMatrixChoice(selectedCheckboxChoices)
427
- }
413
+ }
414
+ })
415
+ })
416
+ emitSelectedMatrixChoice(selectedCheckboxChoices)
428
417
  }
418
+ }, { deep: true })
429
419
 
430
- @Watch('matrixRadioGrid', { deep: true })
431
- matrixRadioGridChange () {
432
- if (this.matrixChoiceLayout && this.matrixRadioGrid) {
433
- const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
420
+ watch(matrixRadioGrid, () => {
421
+ if (matrixChoiceLayout.value && matrixRadioGrid.value) {
422
+ const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
434
423
 
435
- this.matrixRadioGrid.forEach((row, rowIndex) => {
436
- const choiceKey = row.value
437
- if (choiceKey && this.matrixChoiceLayout[rowIndex]) {
438
- selectedRadioButtonChoices.push(choiceKey)
439
- }
440
- })
441
- this.emitSelectedMatrixChoice(selectedRadioButtonChoices)
442
- }
424
+ matrixRadioGrid.value?.forEach((row, rowIndex) => {
425
+ const choiceKey = row.value
426
+ if (choiceKey && matrixChoiceLayout.value?.[rowIndex]) {
427
+ selectedRadioButtonChoices.push(choiceKey)
428
+ }
429
+ })
430
+ emitSelectedMatrixChoice(selectedRadioButtonChoices)
443
431
  }
432
+ }, { deep: true })
444
433
 
445
- @Watch('selectedMatrixChoices')
446
- selectedMatrixChoicesChange () {
447
- if ((this.reviewMode || this.showMatrixAnswers) && this.question.type === 'Matrix Checkbox') {
448
- const selectedCheckboxGrid = this.convertSelectedMatrixChoiceToCheckboxGrid()
449
- this.matrixCheckboxGrid = selectedCheckboxGrid ? selectedCheckboxGrid : this.defaultCheckboxGrid
450
- }
434
+ watch(selectedMatrixChoices, () => {
435
+ if ((reviewMode || showMatrixAnswers.value) && question.value.type === 'Matrix Checkbox') {
436
+ const selectedCheckboxGrid = convertSelectedMatrixChoiceToCheckboxGrid()
437
+ matrixCheckboxGrid.value = selectedCheckboxGrid ? selectedCheckboxGrid : defaultCheckboxGrid.value
438
+ }
451
439
 
452
- if ((this.reviewMode || this.showMatrixAnswers) && this.question.type === 'Matrix Radio Button') {
453
- const selectedRadioBtnGrid = this.convertSelectedMatrixChoiceToRadioBtnGrid()
454
- this.matrixRadioGrid = selectedRadioBtnGrid
455
- }
440
+ if ((reviewMode || showMatrixAnswers.value) && question.value.type === 'Matrix Radio Button') {
441
+ const selectedRadioBtnGrid = convertSelectedMatrixChoiceToRadioBtnGrid()
442
+ matrixRadioGrid.value = selectedRadioBtnGrid
456
443
  }
457
- }
444
+ })
458
445
 
459
446
  </script>
460
447
 
@@ -1,25 +1,26 @@
1
1
  <script setup lang="ts">
2
2
  import RadioButton from '../../Forms/RadioButton.vue'
3
3
  import { dark as vDark } from '../../../directives'
4
+ import type { TMatrixChoiceKey } from '../question'
4
5
 
5
6
  defineProps<{
6
7
  isDarkMode: boolean
7
- choices: string[]
8
+ choices?: TMatrixChoiceKey[]
8
9
  labels?: string[]
9
10
  showAnswers: boolean
10
11
  disabled: boolean
11
12
  }>()
12
13
 
13
- const selectedChoice = defineModel<string>()
14
+ const selectedChoice = defineModel<TMatrixChoiceKey | null>({ default: null })
14
15
 
15
- const selectChoice = (choiceKey: string) => {
16
+ const selectChoice = (choiceKey: TMatrixChoiceKey) => {
16
17
  selectedChoice.value = choiceKey
17
18
  }
18
19
  </script>
19
20
 
20
21
  <template>
21
22
  <ul
22
- v-if="choices.length"
23
+ v-if="choices && choices.length"
23
24
  class="uikit-matrix-radio-group"
24
25
  :class="{'uikit-matrix-radio-group--disabled': showAnswers}"
25
26
  v-dark="isDarkMode"