@magmamath/students-features 1.2.1-rc.9 → 1.2.2-rc.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.
Files changed (95) hide show
  1. package/dist/commonjs/config/dataTestIDs.js +12 -0
  2. package/dist/commonjs/config/dataTestIDs.js.map +1 -0
  3. package/dist/commonjs/features/chatbot/components/Chat/Chat.js +2 -0
  4. package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +1 -1
  5. package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +2 -0
  6. package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
  7. package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js +2 -0
  8. package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
  9. package/dist/commonjs/features/voice/constants.js +3 -13
  10. package/dist/commonjs/features/voice/constants.js.map +1 -1
  11. package/dist/commonjs/features/voice/recording/components/VoiceRecord.js +5 -19
  12. package/dist/commonjs/features/voice/recording/components/VoiceRecord.js.map +1 -1
  13. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +20 -71
  14. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
  15. package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js +2 -2
  16. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js +3 -3
  17. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -1
  18. package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js +0 -5
  19. package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js.map +1 -1
  20. package/dist/commonjs/features/voice/types.js +0 -6
  21. package/dist/commonjs/features/voice/types.js.map +1 -1
  22. package/dist/commonjs/index.js +8 -0
  23. package/dist/commonjs/index.js.map +1 -1
  24. package/dist/module/config/dataTestIDs.js +9 -0
  25. package/dist/module/config/dataTestIDs.js.map +1 -0
  26. package/dist/module/features/chatbot/components/Chat/Chat.js +2 -0
  27. package/dist/module/features/chatbot/components/Chat/Chat.js.map +1 -1
  28. package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +2 -0
  29. package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
  30. package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js +2 -0
  31. package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
  32. package/dist/module/features/voice/constants.js +2 -12
  33. package/dist/module/features/voice/constants.js.map +1 -1
  34. package/dist/module/features/voice/recording/components/VoiceRecord.js +6 -20
  35. package/dist/module/features/voice/recording/components/VoiceRecord.js.map +1 -1
  36. package/dist/module/features/voice/recording/components/VoiceRecordButton.js +22 -73
  37. package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
  38. package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js +2 -2
  39. package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js +3 -3
  40. package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -1
  41. package/dist/module/features/voice/recording/model/VoiceRecord.model.js +0 -5
  42. package/dist/module/features/voice/recording/model/VoiceRecord.model.js.map +1 -1
  43. package/dist/module/features/voice/types.js +1 -5
  44. package/dist/module/features/voice/types.js.map +1 -1
  45. package/dist/module/index.js +1 -0
  46. package/dist/module/index.js.map +1 -1
  47. package/dist/typescript/commonjs/config/dataTestIDs.d.ts +7 -0
  48. package/dist/typescript/commonjs/config/dataTestIDs.d.ts.map +1 -0
  49. package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
  50. package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
  51. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
  52. package/dist/typescript/commonjs/features/voice/constants.d.ts +2 -12
  53. package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -1
  54. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts.map +1 -1
  55. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts +3 -1
  56. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
  57. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +1 -2
  58. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -1
  59. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts +1 -3
  60. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -1
  61. package/dist/typescript/commonjs/features/voice/types.d.ts +0 -4
  62. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
  63. package/dist/typescript/commonjs/index.d.ts +1 -0
  64. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  65. package/dist/typescript/module/config/dataTestIDs.d.ts +7 -0
  66. package/dist/typescript/module/config/dataTestIDs.d.ts.map +1 -0
  67. package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
  68. package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
  69. package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
  70. package/dist/typescript/module/features/voice/constants.d.ts +2 -12
  71. package/dist/typescript/module/features/voice/constants.d.ts.map +1 -1
  72. package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts.map +1 -1
  73. package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts +3 -1
  74. package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
  75. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +1 -2
  76. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -1
  77. package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts +1 -3
  78. package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -1
  79. package/dist/typescript/module/features/voice/types.d.ts +0 -4
  80. package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
  81. package/dist/typescript/module/index.d.ts +1 -0
  82. package/dist/typescript/module/index.d.ts.map +1 -1
  83. package/package.json +1 -1
  84. package/src/config/dataTestIDs.ts +7 -0
  85. package/src/features/chatbot/components/Chat/Chat.tsx +2 -1
  86. package/src/features/chatbot/components/ChatControls/ChatControls.tsx +2 -0
  87. package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +2 -0
  88. package/src/features/voice/constants.ts +2 -13
  89. package/src/features/voice/recording/components/VoiceRecord.tsx +5 -28
  90. package/src/features/voice/recording/components/VoiceRecordButton.tsx +30 -99
  91. package/src/features/voice/recording/components/VoiceRecordDeleteButton.tsx +2 -2
  92. package/src/features/voice/recording/hooks/useVoiceRecorderAnimation.ts +4 -8
  93. package/src/features/voice/recording/model/VoiceRecord.model.ts +0 -7
  94. package/src/features/voice/types.ts +0 -5
  95. package/src/index.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  import { StyleProp, ViewStyle, StyleSheet } from 'react-native'
2
2
  import { VoiceRecordButton } from './VoiceRecordButton'
3
3
  import React, { useEffect } from 'react'
4
- import { BORDER_RADIUS, COLORS, SPACING } from '@magmamath/react-native-ui'
4
+ import { COLORS, SPACING } from '@magmamath/react-native-ui'
5
5
  import { VoiceRecordDeleteButton } from './VoiceRecordDeleteButton'
6
6
  import { VoiceRecordDivider } from './VoiceRecordDivider'
7
7
  import { VoiceRecordTimer } from './VoiceRecordTimer'
@@ -10,8 +10,6 @@ import { VoiceRecordModel } from '../model/VoiceRecord.model'
10
10
  import { useVoiceRecorder } from '../hooks/useVoiceRecorder'
11
11
  import { useVoiceRecorderAnimation } from '../hooks/useVoiceRecorderAnimation'
12
12
  import { useUnit } from 'effector-react'
13
- import { RecordButtonVariant } from '../../types'
14
- import { VOICE_RECORD_SHAWODS } from '../../constants'
15
13
 
16
14
  type VoiceRecordProps = {
17
15
  style?: StyleProp<ViewStyle>
@@ -22,8 +20,7 @@ export const VoiceRecord = ({ style, model }: VoiceRecordProps) => {
22
20
  const { recorderState } = useVoiceRecorder(model)
23
21
  const [isExpanded, isDisabled] = useUnit([model.$isExpanded, model.$isButtonDisabled])
24
22
 
25
- const recordButtonVariant = model.recordButtonVariant
26
- const { containerAnimatedStyle } = useVoiceRecorderAnimation(isExpanded, recordButtonVariant)
23
+ const { containerAnimatedStyle } = useVoiceRecorderAnimation(isExpanded)
27
24
 
28
25
  useEffect(() => {
29
26
  return () => {
@@ -32,23 +29,12 @@ export const VoiceRecord = ({ style, model }: VoiceRecordProps) => {
32
29
  }, [model])
33
30
 
34
31
  return (
35
- <Animated.View
36
- style={[
37
- styles.container,
38
- recordButtonVariant === RecordButtonVariant.ADVANCED && styles.advancedVariantContainer,
39
- { boxShadow: VOICE_RECORD_SHAWODS[recordButtonVariant] },
40
- style,
41
- containerAnimatedStyle,
42
- ]}
43
- >
32
+ <Animated.View style={[styles.container, style, containerAnimatedStyle]}>
44
33
  <VoiceRecordButton model={model} />
45
34
  {isExpanded && (
46
35
  <Animated.View entering={FadeIn} exiting={FadeOut} style={styles.expendedContainer}>
47
36
  <VoiceRecordTimer
48
- style={[
49
- styles.timer,
50
- recordButtonVariant === RecordButtonVariant.ADVANCED && styles.advancedVariantTimer,
51
- ]}
37
+ style={styles.timer}
52
38
  model={model}
53
39
  recordingFileDurationMs={recorderState.durationMillis}
54
40
  />
@@ -67,21 +53,12 @@ const styles = StyleSheet.create({
67
53
  paddingBottom: 6,
68
54
  backgroundColor: COLORS.NEUTRAL_3,
69
55
  borderRadius: 32,
70
- },
71
- advancedVariantContainer: {
72
- borderRadius: BORDER_RADIUS[300],
73
- padding: 0,
56
+ boxShadow: '0 1px 3px 0 rgba(51, 51, 51, 0.10), 0 0 1px 0 rgba(51, 51, 51, 0.40)',
74
57
  overflow: 'hidden',
75
58
  },
76
59
  timer: {
77
60
  marginTop: SPACING[400],
78
61
  },
79
- defaultTimer: {
80
- marginTop: SPACING[300],
81
- },
82
- advancedVariantTimer: {
83
- marginTop: SPACING[150],
84
- },
85
62
  expendedContainer: {
86
63
  alignItems: 'center',
87
64
  },
@@ -1,35 +1,25 @@
1
- import React from 'react'
1
+ import React, { useMemo } from 'react'
2
2
  import {
3
- BORDER_RADIUS,
4
3
  Button,
5
4
  ButtonColor,
6
5
  ButtonSize,
7
6
  ButtonStyle,
8
7
  ButtonVariant,
9
- CheckIcon,
10
- COLORS,
11
8
  IS_WEB,
12
- MicrophoneIcon,
13
9
  } from '@magmamath/react-native-ui'
14
- import { Pressable, StyleSheet, View } from 'react-native'
10
+ import { Pressable } from 'react-native'
11
+ import { MicrophoneIcon, CheckIcon } from '@magmamath/react-native-ui'
15
12
  import { VoiceRecordModel } from '../model/VoiceRecord.model'
16
13
  import { useUnit } from 'effector-react'
17
- import { VOICE_RECORD_SHAWODS, VoiceRecorderState } from '../../constants'
14
+ import { VoiceRecorderState } from '../../constants'
18
15
  import { useText } from '../../../../shared/translation'
19
- import { RecordButtonVariant } from '../../types'
20
16
 
21
17
  type VoiceRecordButtonProps = {
18
+ style?: ButtonStyle
22
19
  model: VoiceRecordModel
23
20
  }
24
21
 
25
- const defaultButtonStyles: ButtonStyle = {
26
- button: {
27
- width: 50,
28
- height: 50,
29
- },
30
- }
31
-
32
- export const VoiceRecordButton = ({ model }: VoiceRecordButtonProps) => {
22
+ export const VoiceRecordButton = ({ style, model }: VoiceRecordButtonProps) => {
33
23
  const t = useText()
34
24
 
35
25
  const availableInputs = useUnit(model.recorderModel.$availableInputs)
@@ -37,97 +27,38 @@ export const VoiceRecordButton = ({ model }: VoiceRecordButtonProps) => {
37
27
  const isButtonDisabled = useUnit(model.$isButtonDisabled)
38
28
  const isInitializing = useUnit(model.initializeRecording.pending)
39
29
 
40
- const isRecording = voiceRecordState === VoiceRecorderState.RECORDING
41
- const isIdle = voiceRecordState === VoiceRecorderState.IDLE
42
- const hasInputs = availableInputs.length > 0
30
+ const combinedStyles = useMemo((): ButtonStyle => {
31
+ return {
32
+ button: [{ width: 50, height: 50 }, style?.button],
33
+ container: [style?.container],
34
+ text: [style?.text],
35
+ }
36
+ }, [style])
43
37
 
44
38
  return (
45
39
  <Pressable
46
40
  onPressIn={(e) => {
47
- if (hasInputs) return
41
+ if (availableInputs.length) return
48
42
  e.preventDefault()
49
43
  model.notification.warning(t('voice.noMicrophoneFound'))
50
44
  }}
51
- pointerEvents={!hasInputs || isInitializing ? 'box-only' : 'auto'}
52
- style={[isButtonDisabled ? styles.disabledCursor : undefined]}
45
+ pointerEvents={!availableInputs.length || isInitializing ? 'box-only' : 'auto'}
53
46
  >
54
- {model.recordButtonVariant === RecordButtonVariant.ADVANCED ? (
55
- <AdvancedButton
56
- isRecording={isRecording}
57
- isIdle={isIdle}
58
- disabled={isButtonDisabled}
59
- onPressIn={() => model.recorderButtonHandler()}
60
- />
61
- ) : (
62
- <Button
63
- disabled={isButtonDisabled}
64
- onPressIn={() => model.recorderButtonHandler()}
65
- style={defaultButtonStyles}
66
- size={ButtonSize.LARGE}
67
- variant={ButtonVariant.SECONDARY}
68
- colorScheme={ButtonColor.WHITE}
69
- icon={
70
- isRecording ? (
71
- <CheckIcon size={25} />
72
- ) : (
73
- <MicrophoneIcon style={IS_WEB ? { width: 19 } : { minWidth: 23, minHeight: 23 }} />
74
- )
75
- }
76
- />
77
- )}
47
+ <Button
48
+ disabled={isButtonDisabled || !availableInputs.length}
49
+ onPressIn={() => model.recorderButtonHandler()}
50
+ style={combinedStyles}
51
+ size={ButtonSize.LARGE}
52
+ variant={ButtonVariant.SECONDARY}
53
+ colorScheme={ButtonColor.WHITE}
54
+ icon={
55
+ voiceRecordState === VoiceRecorderState.RECORDING ? (
56
+ <CheckIcon size={25} />
57
+ ) : (
58
+ <MicrophoneIcon style={IS_WEB ? { width: 19 } : { minWidth: 23, minHeight: 23 }} />
59
+ )
60
+ }
61
+ />
78
62
  </Pressable>
79
63
  )
80
64
  }
81
-
82
- type AdvancedButtonProps = {
83
- isRecording: boolean
84
- isIdle: boolean
85
- disabled: boolean
86
- onPressIn: () => void
87
- }
88
-
89
- const AdvancedButton = ({ isRecording, isIdle, disabled, onPressIn }: AdvancedButtonProps) => (
90
- <Pressable
91
- style={[styles.advancedButtonContainer, disabled && styles.disabledCursor]}
92
- onPressIn={onPressIn}
93
- disabled={disabled}
94
- >
95
- <View
96
- style={[
97
- styles.advancedIconContainer,
98
- !isIdle && { borderRadius: 32, backgroundColor: COLORS.PRIMARY_BLUE },
99
- ]}
100
- >
101
- {isRecording ? (
102
- <CheckIcon size={18} color={COLORS.NEUTRAL_1} />
103
- ) : (
104
- <MicrophoneIcon
105
- style={{ width: 14, height: 19 }}
106
- color={disabled ? COLORS.NEUTRAL_5 : isIdle ? COLORS.NEUTRAL_9 : COLORS.NEUTRAL_1}
107
- />
108
- )}
109
- </View>
110
- </Pressable>
111
- )
112
-
113
- const styles = StyleSheet.create({
114
- advancedButtonContainer: {
115
- width: 52,
116
- height: 52,
117
- backgroundColor: 'white',
118
- alignItems: 'center',
119
- justifyContent: 'center',
120
- borderRadius: BORDER_RADIUS[300],
121
- boxShadow: VOICE_RECORD_SHAWODS[RecordButtonVariant.ADVANCED],
122
- },
123
- advancedIconContainer: {
124
- width: 36,
125
- height: 36,
126
- borderRadius: BORDER_RADIUS[300],
127
- justifyContent: 'center',
128
- alignItems: 'center',
129
- },
130
- disabledCursor: {
131
- cursor: 'not-allowed' as 'auto',
132
- },
133
- })
@@ -17,8 +17,8 @@ export const VoiceRecordDeleteButton = ({ onPress, isDisabled }: VoiceRecordDele
17
17
 
18
18
  const styles = StyleSheet.create({
19
19
  container: {
20
- width: 32,
21
- height: 32,
20
+ width: 36,
21
+ height: 36,
22
22
  alignItems: 'center',
23
23
  justifyContent: 'center',
24
24
  },
@@ -1,23 +1,19 @@
1
1
  import { useAnimatedStyle, withTiming } from 'react-native-reanimated'
2
2
  import { VOICE_RECORDER_CONTAINER_SIZES } from '../../constants'
3
- import { RecordButtonVariant } from '../../types'
4
3
 
5
- export const useVoiceRecorderAnimation = (
6
- isExpanded: boolean,
7
- recordButtonVariant: RecordButtonVariant,
8
- ) => {
4
+ export const useVoiceRecorderAnimation = (isExpanded: boolean) => {
9
5
  const containerAnimatedStyle = useAnimatedStyle(() => {
10
6
  return {
11
7
  height: withTiming(
12
8
  isExpanded
13
- ? VOICE_RECORDER_CONTAINER_SIZES.EXPANDED[recordButtonVariant]
14
- : VOICE_RECORDER_CONTAINER_SIZES.COLLAPSED[recordButtonVariant],
9
+ ? VOICE_RECORDER_CONTAINER_SIZES.EXPANDED
10
+ : VOICE_RECORDER_CONTAINER_SIZES.COLLAPSED,
15
11
  {
16
12
  duration: 280,
17
13
  },
18
14
  ),
19
15
  }
20
- }, [isExpanded, recordButtonVariant])
16
+ }, [isExpanded])
21
17
 
22
18
  return { containerAnimatedStyle }
23
19
  }
@@ -4,7 +4,6 @@ import { VoiceRecordsCollection } from './VoiceRecordCollection'
4
4
  import { UploaderModel } from './Uploader.model'
5
5
  import { VoiceRecorderState } from '../../constants'
6
6
  import {
7
- RecordButtonVariant,
8
7
  VoiceRecordCollectionItem,
9
8
  VoiceRecorderApi,
10
9
  VoiceRecordNotificationTypes,
@@ -59,8 +58,6 @@ export class VoiceRecordModel {
59
58
  public readonly events: VoiceRecordEvents
60
59
  private shouldDiscardRecording = false
61
60
 
62
- public recordButtonVariant = RecordButtonVariant.DEFAULT
63
-
64
61
  public readonly setCurrentKey = createEvent<string>()
65
62
  public readonly setCurrentRecord = createEvent<any>()
66
63
  public readonly reset = createEvent()
@@ -85,10 +82,6 @@ export class VoiceRecordModel {
85
82
  await this.api.deleteAudioFile(audioFileId)
86
83
  })
87
84
 
88
- public readonly setRecordButtonVariant = createEffect((variant: RecordButtonVariant) => {
89
- this.recordButtonVariant = variant
90
- })
91
-
92
85
  public readonly deleteCurrentRecording = attach({
93
86
  source: this.$currentKey,
94
87
  mapParams: (props: DeleteCurrentRecordingProps | void, currentKey) => ({
@@ -82,8 +82,3 @@ export type VoiceTranscriptionItem = {
82
82
  controller?: AbortController
83
83
  hasDrawing?: boolean
84
84
  }
85
-
86
- export enum RecordButtonVariant {
87
- DEFAULT = 'default',
88
- ADVANCED = 'advanced',
89
- }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { TEST_IDS as FEATURES_TEST_IDS } from './config/dataTestIDs'
1
2
  export { useFeaturesLocalization, setFeaturesLocalization } from './shared/translation'
2
3
  export { generateRandomId } from './lib/helpers/helpers'
3
4
  export * from './features/chatbot'