@compsych-ui-components/react-native 4.0.13 → 4.0.18
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.
- package/package.json +7 -1
- package/src/components/ActionSheet/index.js +1 -1
- package/src/components/ActionSheet/index.js.map +1 -1
- package/src/components/ChatBubble/index.d.ts +12 -0
- package/src/components/ChatBubble/index.js +189 -0
- package/src/components/ChatBubble/index.js.map +1 -0
- package/src/components/ChatInput/index.d.ts +18 -0
- package/src/components/ChatInput/index.js +263 -0
- package/src/components/ChatInput/index.js.map +1 -0
- package/src/components/PromotionCard/index.js +21 -3
- package/src/components/PromotionCard/index.js.map +1 -1
- package/src/components/ServiceCard/index.d.ts +13 -1
- package/src/components/ServiceCard/index.js +47 -14
- package/src/components/ServiceCard/index.js.map +1 -1
- package/src/components/Snackbar/index.js +6 -5
- package/src/components/Snackbar/index.js.map +1 -1
- package/src/index.d.ts +4 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compsych-ui-components/react-native",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.18",
|
|
4
4
|
"description": "ComPsych React Native Design System — components, icons, tokens, and theming",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -23,9 +23,15 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@expo/vector-icons": ">=15.0.0",
|
|
25
25
|
"expo-font": ">=13.0.0",
|
|
26
|
+
"expo-linear-gradient": ">=13.0.0",
|
|
26
27
|
"react": ">=18.0.0",
|
|
27
28
|
"react-native": ">=0.73.0",
|
|
28
29
|
"react-native-svg": ">=15.0.0"
|
|
29
30
|
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"expo-linear-gradient": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
30
36
|
"type": "commonjs"
|
|
31
37
|
}
|
|
@@ -189,9 +189,9 @@ function ActionSheet({ visible, onClose, title, children, primaryAction, seconda
|
|
|
189
189
|
const styles = _reactnative.StyleSheet.create({
|
|
190
190
|
backdrop: {
|
|
191
191
|
position: 'absolute',
|
|
192
|
+
top: 0,
|
|
192
193
|
left: 0,
|
|
193
194
|
right: 0,
|
|
194
|
-
top: 0,
|
|
195
195
|
bottom: 0,
|
|
196
196
|
backgroundColor: 'rgba(0,0,0,0.4)'
|
|
197
197
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/react-native/src/components/ActionSheet/index.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\n\r\nimport {\r\n Modal,\r\n Pressable,\r\n ScrollView,\r\n StyleProp,\r\n StyleSheet,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { Ionicons } from '@expo/vector-icons';\r\n\r\nimport { useTheme } from '../../theme';\r\nimport { Button } from '../Button';\r\nimport { HeaderText } from '../HeaderText';\r\n\r\nexport interface ActionSheetAction {\r\n label: string;\r\n onPress: () => void;\r\n}\r\n\r\nexport interface ActionSheetProps {\r\n visible: boolean;\r\n onClose: () => void;\r\n title?: string;\r\n children?: React.ReactNode;\r\n primaryAction?: ActionSheetAction;\r\n secondaryAction?: ActionSheetAction;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function ActionSheet({\r\n visible,\r\n onClose,\r\n title,\r\n children,\r\n primaryAction,\r\n secondaryAction,\r\n style,\r\n}: ActionSheetProps) {\r\n const { colorRoles: cr, dimensions: dim } = useTheme();\r\n\r\n const dynamicStyles = useMemo(\r\n () => ({\r\n sheetWrapper: {\r\n paddingHorizontal: dim.spacing.padding.sysPadding6,\r\n paddingBottom: dim.spacing.padding.sysPadding6,\r\n },\r\n sheet: {\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n borderRadius: dim.borderRadius.sysRadiusXxl,\r\n },\r\n titleRow: {\r\n paddingHorizontal: dim.spacing.padding.sysPadding16,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n },\r\n closeButton: {\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainer,\r\n },\r\n contentInner: {\r\n padding: dim.spacing.padding.sysPadding16,\r\n },\r\n actions: {\r\n padding: dim.spacing.padding.sysPadding24,\r\n gap: dim.spacing.padding.sysPadding12,\r\n },\r\n }),\r\n [cr, dim],\r\n );\r\n\r\n return (\r\n <Modal\r\n visible={visible}\r\n transparent\r\n animationType=\"slide\"\r\n onRequestClose={onClose}\r\n statusBarTranslucent\r\n >\r\n {/* Backdrop */}\r\n <Pressable style={styles.backdrop} onPress={onClose} accessible={false} />\r\n\r\n {/* Sheet */}\r\n <View\r\n style={[styles.sheetWrapper, dynamicStyles.sheetWrapper, style]}\r\n pointerEvents=\"box-none\"\r\n >\r\n <View style={[styles.sheet, dynamicStyles.sheet]}>\r\n {/* Toolbar */}\r\n <View style={styles.toolbar}>\r\n {/* Grabber */}\r\n <View style={styles.grabberRow}>\r\n <View style={styles.grabber} />\r\n </View>\r\n\r\n {/* Title row */}\r\n <View style={[styles.titleRow, dynamicStyles.titleRow]}>\r\n {/* Invisible spacer to balance the close button */}\r\n <View style={styles.closeButtonSize} />\r\n\r\n <HeaderText\r\n variant=\"titleSmall\"\r\n emphasized\r\n color={cr.surface.surface.sysOnSurface}\r\n style={styles.titleText}\r\n >\r\n {title ?? ''}\r\n </HeaderText>\r\n\r\n {/* Close button */}\r\n <Pressable\r\n onPress={onClose}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Close\"\r\n style={({ pressed }) => [\r\n styles.closeButtonSize,\r\n dynamicStyles.closeButton,\r\n pressed && styles.closePressed,\r\n ]}\r\n >\r\n <Ionicons\r\n name=\"close\"\r\n size={20}\r\n color={cr.surface.surface.sysOnSurface}\r\n />\r\n </Pressable>\r\n </View>\r\n </View>\r\n\r\n {/* Content */}\r\n {children && (\r\n <ScrollView\r\n style={styles.content}\r\n contentContainerStyle={dynamicStyles.contentInner}\r\n showsVerticalScrollIndicator={false}\r\n >\r\n {children}\r\n </ScrollView>\r\n )}\r\n\r\n {/* Actions */}\r\n {(primaryAction || secondaryAction) && (\r\n <View style={dynamicStyles.actions}>\r\n {primaryAction && (\r\n <Button\r\n label={primaryAction.label}\r\n variant=\"filled\"\r\n size=\"xl\"\r\n fullWidth\r\n onPress={primaryAction.onPress}\r\n />\r\n )}\r\n {secondaryAction && (\r\n <Button\r\n label={secondaryAction.label}\r\n variant=\"outlined\"\r\n size=\"xl\"\r\n fullWidth\r\n onPress={secondaryAction.onPress}\r\n />\r\n )}\r\n </View>\r\n )}\r\n </View>\r\n </View>\r\n </Modal>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n backdrop: {\r\n position: 'absolute', left: 0, right: 0, top: 0, bottom: 0,\r\n backgroundColor: 'rgba(0,0,0,0.4)',\r\n },\r\n sheetWrapper: {\r\n flex: 1,\r\n justifyContent: 'flex-end',\r\n },\r\n sheet: {\r\n borderWidth: 1,\r\n borderColor: 'rgba(255,255,255,0.4)',\r\n overflow: 'hidden',\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 4 },\r\n shadowOpacity: 0.1,\r\n shadowRadius: 16,\r\n elevation: 8,\r\n },\r\n toolbar: {\r\n alignItems: 'center',\r\n width: '100%',\r\n },\r\n grabberRow: {\r\n height: 16,\r\n justifyContent: 'flex-end',\r\n alignItems: 'center',\r\n paddingBottom: 0,\r\n paddingTop: 5,\r\n },\r\n grabber: {\r\n width: 36,\r\n height: 5,\r\n borderRadius: 100,\r\n backgroundColor: '#ccc',\r\n },\r\n titleRow: {\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n width: '100%',\r\n },\r\n titleText: {\r\n flex: 1,\r\n textAlign: 'center',\r\n },\r\n closeButtonSize: {\r\n width: 32,\r\n height: 32,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n closePressed: {\r\n opacity: 0.7,\r\n },\r\n content: {\r\n maxHeight: 400,\r\n },\r\n});\r\n"],"names":["ActionSheet","visible","onClose","title","children","primaryAction","secondaryAction","style","colorRoles","cr","dimensions","dim","useTheme","dynamicStyles","useMemo","sheetWrapper","paddingHorizontal","spacing","padding","sysPadding6","paddingBottom","sheet","backgroundColor","surface","surfaceContainer","sysSurfaceContainerLowest","borderRadius","sysRadiusXxl","titleRow","sysPadding16","paddingVertical","sysPadding8","closeButton","sysRadiusFull","sysSurfaceContainer","contentInner","actions","sysPadding24","gap","sysPadding12","Modal","transparent","animationType","onRequestClose","statusBarTranslucent","Pressable","styles","backdrop","onPress","accessible","View","pointerEvents","toolbar","grabberRow","grabber","closeButtonSize","HeaderText","variant","emphasized","color","sysOnSurface","titleText","accessibilityRole","accessibilityLabel","pressed","closePressed","Ionicons","name","size","ScrollView","content","contentContainerStyle","showsVerticalScrollIndicator","Button","label","fullWidth","StyleSheet","create","position","left","right","top","bottom","flex","justifyContent","borderWidth","borderColor","overflow","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","alignItems","paddingTop","flexDirection","textAlign","opacity","maxHeight"],"mappings":";;;;+BAiCgBA;;;eAAAA;;;;+DAjCe;6BAUxB;6BAEkB;uBAEA;wBACF;4BACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBpB,SAASA,YAAY,EAC1BC,OAAO,EACPC,OAAO,EACPC,KAAK,EACLC,QAAQ,EACRC,aAAa,EACbC,eAAe,EACfC,KAAK,EACY;IACjB,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAE,GAAGC,IAAAA,eAAQ;IAEpD,MAAMC,gBAAgBC,IAAAA,cAAO,EAC3B,IAAO,CAAA;YACLC,cAAc;gBACZC,mBAAmBL,IAAIM,OAAO,CAACC,OAAO,CAACC,WAAW;gBAClDC,eAA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OAAO;QAAGC,KAAK;QAAGC,QAAQ;QACzD5D,iBAAiB;IACnB;IACAP,cAAc;QACZoE,MAAM;QACNC,gBAAgB;IAClB;IACA/D,OAAO;QACLgE,aAAa;QACbC,aAAa;QACbC,UAAU;QACVC,aAAa;QACbC,cAAc;YAAEC,OAAO;YAAGC,QAAQ;QAAE;QACpCC,eAAe;QACfC,cAAc;QACdC,WAAW;IACb;IACA1C,SAAS;QACP2C,YAAY;QACZL,OAAO;IACT;IACArC,YAAY;QACVsC,QAAQ;QACRP,gBAAgB;QAChBW,YAAY;QACZ3E,eAAe;QACf4E,YAAY;IACd;IACA1C,SAAS;QACPoC,OAAO;QACPC,QAAQ;QACRjE,cAAc;QACdJ,iBAAiB;IACnB;IACAM,UAAU;QACRqE,eAAe;QACfF,YAAY;QACZX,gBAAgB;QAChBM,OAAO;IACT;IACA7B,WAAW;QACTsB,MAAM;QACNe,WAAW;IACb;IACA3C,iBAAiB;QACfmC,OAAO;QACPC,QAAQ;QACRI,YAAY;QACZX,gBAAgB;IAClB;IACAnB,cAAc;QACZkC,SAAS;IACX;IACA7B,SAAS;QACP8B,WAAW;IACb;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/ActionSheet/index.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\n\r\nimport {\r\n Modal,\r\n Pressable,\r\n ScrollView,\r\n StyleProp,\r\n StyleSheet,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { Ionicons } from '@expo/vector-icons';\r\n\r\nimport { useTheme } from '../../theme';\r\nimport { Button } from '../Button';\r\nimport { HeaderText } from '../HeaderText';\r\n\r\nexport interface ActionSheetAction {\r\n label: string;\r\n onPress: () => void;\r\n}\r\n\r\nexport interface ActionSheetProps {\r\n visible: boolean;\r\n onClose: () => void;\r\n title?: string;\r\n children?: React.ReactNode;\r\n primaryAction?: ActionSheetAction;\r\n secondaryAction?: ActionSheetAction;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function ActionSheet({\r\n visible,\r\n onClose,\r\n title,\r\n children,\r\n primaryAction,\r\n secondaryAction,\r\n style,\r\n}: ActionSheetProps) {\r\n const { colorRoles: cr, dimensions: dim } = useTheme();\r\n\r\n const dynamicStyles = useMemo(\r\n () => ({\r\n sheetWrapper: {\r\n paddingHorizontal: dim.spacing.padding.sysPadding6,\r\n paddingBottom: dim.spacing.padding.sysPadding6,\r\n },\r\n sheet: {\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n borderRadius: dim.borderRadius.sysRadiusXxl,\r\n },\r\n titleRow: {\r\n paddingHorizontal: dim.spacing.padding.sysPadding16,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n },\r\n closeButton: {\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainer,\r\n },\r\n contentInner: {\r\n padding: dim.spacing.padding.sysPadding16,\r\n },\r\n actions: {\r\n padding: dim.spacing.padding.sysPadding24,\r\n gap: dim.spacing.padding.sysPadding12,\r\n },\r\n }),\r\n [cr, dim],\r\n );\r\n\r\n return (\r\n <Modal\r\n visible={visible}\r\n transparent\r\n animationType=\"slide\"\r\n onRequestClose={onClose}\r\n statusBarTranslucent\r\n >\r\n {/* Backdrop */}\r\n <Pressable style={styles.backdrop} onPress={onClose} accessible={false} />\r\n\r\n {/* Sheet */}\r\n <View\r\n style={[styles.sheetWrapper, dynamicStyles.sheetWrapper, style]}\r\n pointerEvents=\"box-none\"\r\n >\r\n <View style={[styles.sheet, dynamicStyles.sheet]}>\r\n {/* Toolbar */}\r\n <View style={styles.toolbar}>\r\n {/* Grabber */}\r\n <View style={styles.grabberRow}>\r\n <View style={styles.grabber} />\r\n </View>\r\n\r\n {/* Title row */}\r\n <View style={[styles.titleRow, dynamicStyles.titleRow]}>\r\n {/* Invisible spacer to balance the close button */}\r\n <View style={styles.closeButtonSize} />\r\n\r\n <HeaderText\r\n variant=\"titleSmall\"\r\n emphasized\r\n color={cr.surface.surface.sysOnSurface}\r\n style={styles.titleText}\r\n >\r\n {title ?? ''}\r\n </HeaderText>\r\n\r\n {/* Close button */}\r\n <Pressable\r\n onPress={onClose}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Close\"\r\n style={({ pressed }) => [\r\n styles.closeButtonSize,\r\n dynamicStyles.closeButton,\r\n pressed && styles.closePressed,\r\n ]}\r\n >\r\n <Ionicons\r\n name=\"close\"\r\n size={20}\r\n color={cr.surface.surface.sysOnSurface}\r\n />\r\n </Pressable>\r\n </View>\r\n </View>\r\n\r\n {/* Content */}\r\n {children && (\r\n <ScrollView\r\n style={styles.content}\r\n contentContainerStyle={dynamicStyles.contentInner}\r\n showsVerticalScrollIndicator={false}\r\n >\r\n {children}\r\n </ScrollView>\r\n )}\r\n\r\n {/* Actions */}\r\n {(primaryAction || secondaryAction) && (\r\n <View style={dynamicStyles.actions}>\r\n {primaryAction && (\r\n <Button\r\n label={primaryAction.label}\r\n variant=\"filled\"\r\n size=\"xl\"\r\n fullWidth\r\n onPress={primaryAction.onPress}\r\n />\r\n )}\r\n {secondaryAction && (\r\n <Button\r\n label={secondaryAction.label}\r\n variant=\"outlined\"\r\n size=\"xl\"\r\n fullWidth\r\n onPress={secondaryAction.onPress}\r\n />\r\n )}\r\n </View>\r\n )}\r\n </View>\r\n </View>\r\n </Modal>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n backdrop: {\r\n position: 'absolute', top: 0, left: 0, right: 0, bottom: 0,\r\n backgroundColor: 'rgba(0,0,0,0.4)',\r\n },\r\n sheetWrapper: {\r\n flex: 1,\r\n justifyContent: 'flex-end',\r\n },\r\n sheet: {\r\n borderWidth: 1,\r\n borderColor: 'rgba(255,255,255,0.4)',\r\n overflow: 'hidden',\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 4 },\r\n shadowOpacity: 0.1,\r\n shadowRadius: 16,\r\n elevation: 8,\r\n },\r\n toolbar: {\r\n alignItems: 'center',\r\n width: '100%',\r\n },\r\n grabberRow: {\r\n height: 16,\r\n justifyContent: 'flex-end',\r\n alignItems: 'center',\r\n paddingBottom: 0,\r\n paddingTop: 5,\r\n },\r\n grabber: {\r\n width: 36,\r\n height: 5,\r\n borderRadius: 100,\r\n backgroundColor: '#ccc',\r\n },\r\n titleRow: {\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n width: '100%',\r\n },\r\n titleText: {\r\n flex: 1,\r\n textAlign: 'center',\r\n },\r\n closeButtonSize: {\r\n width: 32,\r\n height: 32,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n closePressed: {\r\n opacity: 0.7,\r\n },\r\n content: {\r\n maxHeight: 400,\r\n },\r\n});\r\n"],"names":["ActionSheet","visible","onClose","title","children","primaryAction","secondaryAction","style","colorRoles","cr","dimensions","dim","useTheme","dynamicStyles","useMemo","sheetWrapper","paddingHorizontal","spacing","padding","sysPadding6","paddingBottom","sheet","backgroundColor","surface","surfaceContainer","sysSurfaceContainerLowest","borderRadius","sysRadiusXxl","titleRow","sysPadding16","paddingVertical","sysPadding8","closeButton","sysRadiusFull","sysSurfaceContainer","contentInner","actions","sysPadding24","gap","sysPadding12","Modal","transparent","animationType","onRequestClose","statusBarTranslucent","Pressable","styles","backdrop","onPress","accessible","View","pointerEvents","toolbar","grabberRow","grabber","closeButtonSize","HeaderText","variant","emphasized","color","sysOnSurface","titleText","accessibilityRole","accessibilityLabel","pressed","closePressed","Ionicons","name","size","ScrollView","content","contentContainerStyle","showsVerticalScrollIndicator","Button","label","fullWidth","StyleSheet","create","position","top","left","right","bottom","flex","justifyContent","borderWidth","borderColor","overflow","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","alignItems","paddingTop","flexDirection","textAlign","opacity","maxHeight"],"mappings":";;;;+BAiCgBA;;;eAAAA;;;;+DAjCe;6BAUxB;6BAEkB;uBAEA;wBACF;4BACI;;;;;;;;;;;;;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M;oCACLC,OAAOrE,cAAcqE,KAAK;oCAC1BjB,SAAQ;oCACRW,MAAK;oCACLO,SAAS;oCACT3B,SAAS3C,cAAc2C,OAAO;;gCAGjC1C,iCACC,qBAACmE,cAAM;oCACLC,OAAOpE,gBAAgBoE,KAAK;oCAC5BjB,SAAQ;oCACRW,MAAK;oCACLO,SAAS;oCACT3B,SAAS1C,gBAAgB0C,OAAO;;;;;;;;;AASlD;AAEA,MAAMF,SAAS8B,uBAAU,CAACC,MAAM,CAAC;IAC/B9B,UAAU;QACR+B,UAAU;QAAYC,KAAK;QAAGC,MAAM;QAAGC,OAAO;QAAGC,QAAQ;QACzD5D,iBAAiB;IACnB;IACAP,cAAc;QACZoE,MAAM;QACNC,gBAAgB;IAClB;IACA/D,OAAO;QACLgE,aAAa;QACbC,aAAa;QACbC,UAAU;QACVC,aAAa;QACbC,cAAc;YAAEC,OAAO;YAAGC,QAAQ;QAAE;QACpCC,eAAe;QACfC,cAAc;QACdC,WAAW;IACb;IACA1C,SAAS;QACP2C,YAAY;QACZL,OAAO;IACT;IACArC,YAAY;QACVsC,QAAQ;QACRP,gBAAgB;QAChBW,YAAY;QACZ3E,eAAe;QACf4E,YAAY;IACd;IACA1C,SAAS;QACPoC,OAAO;QACPC,QAAQ;QACRjE,cAAc;QACdJ,iBAAiB;IACnB;IACAM,UAAU;QACRqE,eAAe;QACfF,YAAY;QACZX,gBAAgB;QAChBM,OAAO;IACT;IACA7B,WAAW;QACTsB,MAAM;QACNe,WAAW;IACb;IACA3C,iBAAiB;QACfmC,OAAO;QACPC,QAAQ;QACRI,YAAY;QACZX,gBAAgB;IAClB;IACAnB,cAAc;QACZkC,SAAS;IACX;IACA7B,SAAS;QACP8B,WAAW;IACb;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type ChatBubbleVariant = 'incoming' | 'outgoing';
|
|
4
|
+
export interface ChatBubbleProps {
|
|
5
|
+
variant: ChatBubbleVariant;
|
|
6
|
+
message: string;
|
|
7
|
+
timestamp?: string;
|
|
8
|
+
onThumbsUp?: () => void;
|
|
9
|
+
onThumbsDown?: () => void;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
}
|
|
12
|
+
export declare function ChatBubble({ variant, message, timestamp, onThumbsUp, onThumbsDown, style, }: ChatBubbleProps): React.JSX.Element;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ChatBubble", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ChatBubble;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _reactnative = require("react-native");
|
|
14
|
+
const _vectoricons = require("@expo/vector-icons");
|
|
15
|
+
const _theme = require("../../theme");
|
|
16
|
+
const _BodyText = require("../BodyText");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
+
if (typeof WeakMap !== "function") return null;
|
|
19
|
+
var cacheBabelInterop = new WeakMap();
|
|
20
|
+
var cacheNodeInterop = new WeakMap();
|
|
21
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
22
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
+
})(nodeInterop);
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
30
|
+
return {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
35
|
+
if (cache && cache.has(obj)) {
|
|
36
|
+
return cache.get(obj);
|
|
37
|
+
}
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
41
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
+
for(var key in obj){
|
|
43
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
+
if (desc && (desc.get || desc.set)) {
|
|
46
|
+
Object.defineProperty(newObj, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
newObj[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
newObj.default = obj;
|
|
53
|
+
if (cache) {
|
|
54
|
+
cache.set(obj, newObj);
|
|
55
|
+
}
|
|
56
|
+
return newObj;
|
|
57
|
+
}
|
|
58
|
+
function ChatBubble({ variant, message, timestamp, onThumbsUp, onThumbsDown, style }) {
|
|
59
|
+
const { colorRoles: cr, dimensions: dim, iconography: ico } = (0, _theme.useTheme)();
|
|
60
|
+
const isOutgoing = variant === 'outgoing';
|
|
61
|
+
const tokenStyles = (0, _react.useMemo)(()=>({
|
|
62
|
+
bubble: {
|
|
63
|
+
maxWidth: '80%',
|
|
64
|
+
paddingVertical: dim.spacing.padding.sysPadding8,
|
|
65
|
+
paddingHorizontal: dim.spacing.padding.sysPadding12,
|
|
66
|
+
borderRadius: dim.borderRadius.sysRadiusMd
|
|
67
|
+
},
|
|
68
|
+
bubbleIncoming: {
|
|
69
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
70
|
+
borderWidth: dim.borderWidth.sysStrokeThin,
|
|
71
|
+
borderColor: cr.outline.sysOutlineVariant,
|
|
72
|
+
borderBottomLeftRadius: dim.borderRadius.sysRadiusXs
|
|
73
|
+
},
|
|
74
|
+
bubbleOutgoing: {
|
|
75
|
+
backgroundColor: cr.accent.primary.sysPrimary,
|
|
76
|
+
borderBottomRightRadius: dim.borderRadius.sysRadiusXs
|
|
77
|
+
},
|
|
78
|
+
metaRow: {
|
|
79
|
+
flexDirection: 'row',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
gap: dim.spacing.padding.sysPadding8,
|
|
82
|
+
marginTop: dim.spacing.padding.sysPadding4
|
|
83
|
+
},
|
|
84
|
+
reactionBtn: {
|
|
85
|
+
padding: dim.spacing.padding.sysPadding2
|
|
86
|
+
}
|
|
87
|
+
}), [
|
|
88
|
+
cr,
|
|
89
|
+
dim
|
|
90
|
+
]);
|
|
91
|
+
const textColor = isOutgoing ? cr.accent.primary.sysOnPrimary : cr.surface.surface.sysOnSurface;
|
|
92
|
+
const timestampColor = isOutgoing ? 'rgba(255,255,255,0.64)' : cr.surface.surface.sysOnSurfaceVariant;
|
|
93
|
+
const iconColor = cr.surface.surface.sysOnSurfaceVariant;
|
|
94
|
+
const iconSize = ico.sysSizeXs;
|
|
95
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
96
|
+
style: [
|
|
97
|
+
styles.row,
|
|
98
|
+
isOutgoing ? styles.rowOutgoing : styles.rowIncoming,
|
|
99
|
+
style
|
|
100
|
+
],
|
|
101
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
104
|
+
style: [
|
|
105
|
+
tokenStyles.bubble,
|
|
106
|
+
isOutgoing ? tokenStyles.bubbleOutgoing : tokenStyles.bubbleIncoming
|
|
107
|
+
],
|
|
108
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
109
|
+
variant: "medium",
|
|
110
|
+
color: textColor,
|
|
111
|
+
style: styles.messageText,
|
|
112
|
+
children: message
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
116
|
+
style: [
|
|
117
|
+
tokenStyles.metaRow,
|
|
118
|
+
isOutgoing ? styles.metaOutgoing : styles.metaIncoming
|
|
119
|
+
],
|
|
120
|
+
children: [
|
|
121
|
+
timestamp && /*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
122
|
+
variant: "labelSmall",
|
|
123
|
+
color: timestampColor,
|
|
124
|
+
children: timestamp
|
|
125
|
+
}),
|
|
126
|
+
!isOutgoing && (onThumbsUp || onThumbsDown) && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
127
|
+
children: [
|
|
128
|
+
onThumbsUp && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
129
|
+
onPress: onThumbsUp,
|
|
130
|
+
style: ({ pressed })=>[
|
|
131
|
+
tokenStyles.reactionBtn,
|
|
132
|
+
pressed && styles.pressed
|
|
133
|
+
],
|
|
134
|
+
accessibilityRole: "button",
|
|
135
|
+
accessibilityLabel: "Thumbs up",
|
|
136
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
137
|
+
name: "thumbs-up-outline",
|
|
138
|
+
size: iconSize,
|
|
139
|
+
color: iconColor
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
onThumbsDown && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
143
|
+
onPress: onThumbsDown,
|
|
144
|
+
style: ({ pressed })=>[
|
|
145
|
+
tokenStyles.reactionBtn,
|
|
146
|
+
pressed && styles.pressed
|
|
147
|
+
],
|
|
148
|
+
accessibilityRole: "button",
|
|
149
|
+
accessibilityLabel: "Thumbs down",
|
|
150
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
151
|
+
name: "thumbs-down-outline",
|
|
152
|
+
size: iconSize,
|
|
153
|
+
color: iconColor
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const styles = _reactnative.StyleSheet.create({
|
|
165
|
+
row: {
|
|
166
|
+
flexDirection: 'row',
|
|
167
|
+
width: '100%'
|
|
168
|
+
},
|
|
169
|
+
rowIncoming: {
|
|
170
|
+
justifyContent: 'flex-start'
|
|
171
|
+
},
|
|
172
|
+
rowOutgoing: {
|
|
173
|
+
justifyContent: 'flex-end'
|
|
174
|
+
},
|
|
175
|
+
metaIncoming: {
|
|
176
|
+
justifyContent: 'flex-start'
|
|
177
|
+
},
|
|
178
|
+
metaOutgoing: {
|
|
179
|
+
justifyContent: 'flex-end'
|
|
180
|
+
},
|
|
181
|
+
messageText: {
|
|
182
|
+
flexShrink: 1
|
|
183
|
+
},
|
|
184
|
+
pressed: {
|
|
185
|
+
opacity: 0.6
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/ChatBubble/index.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\n\r\nimport {\r\n Pressable,\r\n StyleProp,\r\n StyleSheet,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { Ionicons } from '@expo/vector-icons';\r\n\r\nimport { useTheme } from '../../theme';\r\nimport { BodyText } from '../BodyText';\r\n\r\nexport type ChatBubbleVariant = 'incoming' | 'outgoing';\r\n\r\nexport interface ChatBubbleProps {\r\n variant: ChatBubbleVariant;\r\n message: string;\r\n timestamp?: string;\r\n onThumbsUp?: () => void;\r\n onThumbsDown?: () => void;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function ChatBubble({\r\n variant,\r\n message,\r\n timestamp,\r\n onThumbsUp,\r\n onThumbsDown,\r\n style,\r\n}: ChatBubbleProps) {\r\n const { colorRoles: cr, dimensions: dim, iconography: ico } = useTheme();\r\n\r\n const isOutgoing = variant === 'outgoing';\r\n\r\n const tokenStyles = useMemo(\r\n () => ({\r\n bubble: {\r\n maxWidth: '80%' as const,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n paddingHorizontal: dim.spacing.padding.sysPadding12,\r\n borderRadius: dim.borderRadius.sysRadiusMd,\r\n },\r\n bubbleIncoming: {\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n borderWidth: dim.borderWidth.sysStrokeThin,\r\n borderColor: cr.outline.sysOutlineVariant,\r\n borderBottomLeftRadius: dim.borderRadius.sysRadiusXs,\r\n },\r\n bubbleOutgoing: {\r\n backgroundColor: cr.accent.primary.sysPrimary,\r\n borderBottomRightRadius: dim.borderRadius.sysRadiusXs,\r\n },\r\n metaRow: {\r\n flexDirection: 'row' as const,\r\n alignItems: 'center' as const,\r\n gap: dim.spacing.padding.sysPadding8,\r\n marginTop: dim.spacing.padding.sysPadding4,\r\n },\r\n reactionBtn: {\r\n padding: dim.spacing.padding.sysPadding2,\r\n },\r\n }),\r\n [cr, dim],\r\n );\r\n\r\n const textColor = isOutgoing\r\n ? cr.accent.primary.sysOnPrimary\r\n : cr.surface.surface.sysOnSurface;\r\n const timestampColor = isOutgoing\r\n ? 'rgba(255,255,255,0.64)'\r\n : cr.surface.surface.sysOnSurfaceVariant;\r\n const iconColor = cr.surface.surface.sysOnSurfaceVariant;\r\n const iconSize = ico.sysSizeXs;\r\n\r\n return (\r\n <View\r\n style={[\r\n styles.row,\r\n isOutgoing ? styles.rowOutgoing : styles.rowIncoming,\r\n style,\r\n ]}\r\n >\r\n <View>\r\n {/* Bubble */}\r\n <View\r\n style={[\r\n tokenStyles.bubble,\r\n isOutgoing ? tokenStyles.bubbleOutgoing : tokenStyles.bubbleIncoming,\r\n ]}\r\n >\r\n <BodyText variant=\"medium\" color={textColor} style={styles.messageText}>\r\n {message}\r\n </BodyText>\r\n </View>\r\n\r\n {/* Meta row: timestamp + reactions */}\r\n <View\r\n style={[\r\n tokenStyles.metaRow,\r\n isOutgoing ? styles.metaOutgoing : styles.metaIncoming,\r\n ]}\r\n >\r\n {timestamp && (\r\n <BodyText variant=\"labelSmall\" color={timestampColor}>\r\n {timestamp}\r\n </BodyText>\r\n )}\r\n\r\n {/* Reaction buttons — incoming only */}\r\n {!isOutgoing && (onThumbsUp || onThumbsDown) && (\r\n <>\r\n {onThumbsUp && (\r\n <Pressable\r\n onPress={onThumbsUp}\r\n style={({ pressed }) => [\r\n tokenStyles.reactionBtn,\r\n pressed && styles.pressed,\r\n ]}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Thumbs up\"\r\n >\r\n <Ionicons\r\n name=\"thumbs-up-outline\"\r\n size={iconSize}\r\n color={iconColor}\r\n />\r\n </Pressable>\r\n )}\r\n {onThumbsDown && (\r\n <Pressable\r\n onPress={onThumbsDown}\r\n style={({ pressed }) => [\r\n tokenStyles.reactionBtn,\r\n pressed && styles.pressed,\r\n ]}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Thumbs down\"\r\n >\r\n <Ionicons\r\n name=\"thumbs-down-outline\"\r\n size={iconSize}\r\n color={iconColor}\r\n />\r\n </Pressable>\r\n )}\r\n </>\r\n )}\r\n </View>\r\n </View>\r\n </View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n row: {\r\n flexDirection: 'row',\r\n width: '100%',\r\n },\r\n rowIncoming: {\r\n justifyContent: 'flex-start',\r\n },\r\n rowOutgoing: {\r\n justifyContent: 'flex-end',\r\n },\r\n metaIncoming: {\r\n justifyContent: 'flex-start',\r\n },\r\n metaOutgoing: {\r\n justifyContent: 'flex-end',\r\n },\r\n messageText: {\r\n flexShrink: 1,\r\n },\r\n pressed: {\r\n opacity: 0.6,\r\n },\r\n});\r\n"],"names":["ChatBubble","variant","message","timestamp","onThumbsUp","onThumbsDown","style","colorRoles","cr","dimensions","dim","iconography","ico","useTheme","isOutgoing","tokenStyles","useMemo","bubble","maxWidth","paddingVertical","spacing","padding","sysPadding8","paddingHorizontal","sysPadding12","borderRadius","sysRadiusMd","bubbleIncoming","backgroundColor","surface","surfaceContainer","sysSurfaceContainerLowest","borderWidth","sysStrokeThin","borderColor","outline","sysOutlineVariant","borderBottomLeftRadius","sysRadiusXs","bubbleOutgoing","accent","primary","sysPrimary","borderBottomRightRadius","metaRow","flexDirection","alignItems","gap","marginTop","sysPadding4","reactionBtn","sysPadding2","textColor","sysOnPrimary","sysOnSurface","timestampColor","sysOnSurfaceVariant","iconColor","iconSize","sysSizeXs","View","styles","row","rowOutgoing","rowIncoming","BodyText","color","messageText","metaOutgoing","metaIncoming","Pressable","onPress","pressed","accessibilityRole","accessibilityLabel","Ionicons","name","size","StyleSheet","create","width","justifyContent","flexShrink","opacity"],"mappings":";;;;+BA0BgBA;;;eAAAA;;;;+DA1Be;6BAQxB;6BAEkB;uBAEA;0BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAalB,SAASA,WAAW,EACzBC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,KAAK,EACW;IAChB,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAEC,aAAaC,GAAG,EAAE,GAAGC,IAAAA,eAAQ;IAEtE,MAAMC,aAAab,YAAY;IAE/B,MAAMc,cAAcC,IAAAA,cAAO,EACzB,IAAO,CAAA;YACLC,QAAQ;gBACNC,UAAU;gBACVC,iBAAiBT,IAAIU,OAAO,CAACC,OAAO,CAACC,WAAW;gBAChDC,mBAAmBb,IAAIU,OAAO,CAACC,OAAO,CAACG,YAAY;gBACnDC,cAAcf,IAAIe,YAAY,CAACC,WAAW;YAC5C;YACAC,gBAAgB;gBACdC,iBAA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AAW;kCACnEjE;;;8BAKL,sBAAC0D,iBAAI;oBACHtD,OAAO;wBACLS,YAAY6B,OAAO;wBACnB9B,aAAa+C,OAAOO,YAAY,GAAGP,OAAOQ,YAAY;qBACvD;;wBAEAlE,2BACC,qBAAC8D,kBAAQ;4BAAChE,SAAQ;4BAAaiE,OAAOX;sCACnCpD;;wBAKJ,CAACW,cAAeV,CAAAA,cAAcC,YAAW,mBACxC;;gCACGD,4BACC,qBAACkE,sBAAS;oCACRC,SAASnE;oCACTE,OAAO,CAAC,EAAEkE,OAAO,EAAE,GAAK;4CACtBzD,YAAYmC,WAAW;4CACvBsB,WAAWX,OAAOW,OAAO;yCAC1B;oCACDC,mBAAkB;oCAClBC,oBAAmB;8CAEnB,cAAA,qBAACC,qBAAQ;wCACPC,MAAK;wCACLC,MAAMnB;wCACNQ,OAAOT;;;gCAIZpD,8BACC,qBAACiE,sBAAS;oCACRC,SAASlE;oCACTC,OAAO,CAAC,EAAEkE,OAAO,EAAE,GAAK;4CACtBzD,YAAYmC,WAAW;4CACvBsB,WAAWX,OAAOW,OAAO;yCAC1B;oCACDC,mBAAkB;oCAClBC,oBAAmB;8CAEnB,cAAA,qBAACC,qBAAQ;wCACPC,MAAK;wCACLC,MAAMnB;wCACNQ,OAAOT;;;;;;;;;;AAU3B;AAEA,MAAMI,SAASiB,uBAAU,CAACC,MAAM,CAAC;IAC/BjB,KAAK;QACHjB,eAAe;QACfmC,OAAO;IACT;IACAhB,aAAa;QACXiB,gBAAgB;IAClB;IACAlB,aAAa;QACXkB,gBAAgB;IAClB;IACAZ,cAAc;QACZY,gBAAgB;IAClB;IACAb,cAAc;QACZa,gBAAgB;IAClB;IACAd,aAAa;QACXe,YAAY;IACd;IACAV,SAAS;QACPW,SAAS;IACX;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface ChatAttachment {
|
|
4
|
+
uri: string;
|
|
5
|
+
source?: ImageSourcePropType;
|
|
6
|
+
}
|
|
7
|
+
export interface ChatInputProps {
|
|
8
|
+
value: string;
|
|
9
|
+
onChangeText: (text: string) => void;
|
|
10
|
+
onSend: () => void;
|
|
11
|
+
onAttach?: () => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
attachments?: ChatAttachment[];
|
|
14
|
+
onRemoveAttachment?: (index: number) => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
}
|
|
18
|
+
export declare function ChatInput({ value, onChangeText, onSend, onAttach, placeholder, attachments, onRemoveAttachment, disabled, style, }: ChatInputProps): React.JSX.Element;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ChatInput", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ChatInput;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _reactnative = require("react-native");
|
|
14
|
+
const _vectoricons = require("@expo/vector-icons");
|
|
15
|
+
const _theme = require("../../theme");
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
+
if (typeof WeakMap !== "function") return null;
|
|
18
|
+
var cacheBabelInterop = new WeakMap();
|
|
19
|
+
var cacheNodeInterop = new WeakMap();
|
|
20
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
+
})(nodeInterop);
|
|
23
|
+
}
|
|
24
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
+
return {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
+
if (cache && cache.has(obj)) {
|
|
35
|
+
return cache.get(obj);
|
|
36
|
+
}
|
|
37
|
+
var newObj = {
|
|
38
|
+
__proto__: null
|
|
39
|
+
};
|
|
40
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
+
for(var key in obj){
|
|
42
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
+
if (desc && (desc.get || desc.set)) {
|
|
45
|
+
Object.defineProperty(newObj, key, desc);
|
|
46
|
+
} else {
|
|
47
|
+
newObj[key] = obj[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
if (cache) {
|
|
53
|
+
cache.set(obj, newObj);
|
|
54
|
+
}
|
|
55
|
+
return newObj;
|
|
56
|
+
}
|
|
57
|
+
function ChatInput({ value, onChangeText, onSend, onAttach, placeholder = 'Ask Sol Anything...', attachments, onRemoveAttachment, disabled = false, style }) {
|
|
58
|
+
const { colorRoles: cr, dimensions: dim, iconography: ico } = (0, _theme.useTheme)();
|
|
59
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
60
|
+
const [inputHeight, setInputHeight] = (0, _react.useState)(24);
|
|
61
|
+
const inputRef = (0, _react.useRef)(null);
|
|
62
|
+
const handleContentSizeChange = (0, _react.useCallback)((e)=>{
|
|
63
|
+
const newHeight = Math.max(24, Math.min(120, e.nativeEvent.contentSize.height));
|
|
64
|
+
setInputHeight(newHeight);
|
|
65
|
+
}, []);
|
|
66
|
+
const hasText = value.trim().length > 0;
|
|
67
|
+
const hasAttachments = !!attachments && attachments.length > 0;
|
|
68
|
+
const canSend = (hasText || hasAttachments) && !disabled;
|
|
69
|
+
const tokenStyles = (0, _react.useMemo)(()=>({
|
|
70
|
+
container: {
|
|
71
|
+
borderRadius: dim.borderRadius.sysRadiusLg,
|
|
72
|
+
borderWidth: isFocused ? dim.borderWidth.sysStrokeMedium : dim.borderWidth.sysStrokeThin,
|
|
73
|
+
borderColor: isFocused ? cr.accent.primary.sysPrimary : cr.outline.sysOutlineVariant,
|
|
74
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
75
|
+
paddingVertical: dim.spacing.padding.sysPadding8,
|
|
76
|
+
paddingHorizontal: dim.spacing.padding.sysPadding12,
|
|
77
|
+
gap: dim.spacing.padding.sysPadding8
|
|
78
|
+
},
|
|
79
|
+
attachBtn: {
|
|
80
|
+
width: 32,
|
|
81
|
+
height: 32,
|
|
82
|
+
borderRadius: dim.borderRadius.sysRadiusFull,
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
justifyContent: 'center',
|
|
85
|
+
flexShrink: 0
|
|
86
|
+
},
|
|
87
|
+
sendBtn: {
|
|
88
|
+
width: 32,
|
|
89
|
+
height: 32,
|
|
90
|
+
borderRadius: dim.borderRadius.sysRadiusFull,
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
justifyContent: 'center',
|
|
93
|
+
flexShrink: 0,
|
|
94
|
+
backgroundColor: canSend ? cr.custom.warning.sysWarning : cr.surface.surfaceContainer.sysSurfaceContainerHighest
|
|
95
|
+
},
|
|
96
|
+
attachThumb: {
|
|
97
|
+
width: 48,
|
|
98
|
+
height: 48,
|
|
99
|
+
borderRadius: dim.borderRadius.sysRadiusSm,
|
|
100
|
+
overflow: 'hidden'
|
|
101
|
+
}
|
|
102
|
+
}), [
|
|
103
|
+
cr,
|
|
104
|
+
dim,
|
|
105
|
+
isFocused,
|
|
106
|
+
canSend
|
|
107
|
+
]);
|
|
108
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
109
|
+
style: [
|
|
110
|
+
styles.wrapper,
|
|
111
|
+
disabled && styles.disabled,
|
|
112
|
+
style
|
|
113
|
+
],
|
|
114
|
+
children: [
|
|
115
|
+
hasAttachments && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.ScrollView, {
|
|
116
|
+
horizontal: true,
|
|
117
|
+
showsHorizontalScrollIndicator: false,
|
|
118
|
+
style: styles.attachStrip,
|
|
119
|
+
contentContainerStyle: styles.attachStripContent,
|
|
120
|
+
children: attachments.map((att, i)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
121
|
+
style: styles.attachItem,
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Image, {
|
|
124
|
+
source: att.source ?? {
|
|
125
|
+
uri: att.uri
|
|
126
|
+
},
|
|
127
|
+
style: tokenStyles.attachThumb,
|
|
128
|
+
resizeMode: "cover",
|
|
129
|
+
accessibilityLabel: `Attachment ${i + 1}`
|
|
130
|
+
}),
|
|
131
|
+
onRemoveAttachment && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
132
|
+
onPress: ()=>onRemoveAttachment(i),
|
|
133
|
+
style: styles.removeBtn,
|
|
134
|
+
accessibilityRole: "button",
|
|
135
|
+
accessibilityLabel: `Remove attachment ${i + 1}`,
|
|
136
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
137
|
+
name: "close-circle",
|
|
138
|
+
size: 16,
|
|
139
|
+
color: cr.surface.surface.sysOnSurfaceVariant
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}, i))
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
146
|
+
style: [
|
|
147
|
+
tokenStyles.container,
|
|
148
|
+
styles.inputRow,
|
|
149
|
+
isFocused && {
|
|
150
|
+
// focus ring via transparent primary halo
|
|
151
|
+
shadowColor: cr.accent.primary.sysPrimary,
|
|
152
|
+
shadowOffset: {
|
|
153
|
+
width: 0,
|
|
154
|
+
height: 0
|
|
155
|
+
},
|
|
156
|
+
shadowOpacity: 0.08,
|
|
157
|
+
shadowRadius: 4
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
children: [
|
|
161
|
+
onAttach && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
162
|
+
onPress: onAttach,
|
|
163
|
+
disabled: disabled,
|
|
164
|
+
style: ({ pressed })=>[
|
|
165
|
+
tokenStyles.attachBtn,
|
|
166
|
+
pressed && styles.pressed
|
|
167
|
+
],
|
|
168
|
+
accessibilityRole: "button",
|
|
169
|
+
accessibilityLabel: "Add attachment",
|
|
170
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
171
|
+
name: "add",
|
|
172
|
+
size: ico.sysSizeSm,
|
|
173
|
+
color: disabled ? cr.surface.surface.sysOnSurfaceVariant : cr.surface.surface.sysOnSurface
|
|
174
|
+
})
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.TextInput, {
|
|
177
|
+
ref: inputRef,
|
|
178
|
+
value: value,
|
|
179
|
+
onChangeText: onChangeText,
|
|
180
|
+
placeholder: placeholder,
|
|
181
|
+
placeholderTextColor: cr.surface.surface.sysOnSurfaceVariant,
|
|
182
|
+
editable: !disabled,
|
|
183
|
+
multiline: true,
|
|
184
|
+
scrollEnabled: inputHeight >= 120,
|
|
185
|
+
onContentSizeChange: handleContentSizeChange,
|
|
186
|
+
onFocus: ()=>setIsFocused(true),
|
|
187
|
+
onBlur: ()=>setIsFocused(false),
|
|
188
|
+
style: [
|
|
189
|
+
styles.textInput,
|
|
190
|
+
{
|
|
191
|
+
color: cr.surface.surface.sysOnSurface,
|
|
192
|
+
fontSize: 16,
|
|
193
|
+
lineHeight: 24,
|
|
194
|
+
height: inputHeight
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
accessibilityLabel: placeholder,
|
|
198
|
+
returnKeyType: "default"
|
|
199
|
+
}),
|
|
200
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
201
|
+
onPress: canSend ? onSend : undefined,
|
|
202
|
+
disabled: !canSend,
|
|
203
|
+
style: ({ pressed })=>[
|
|
204
|
+
tokenStyles.sendBtn,
|
|
205
|
+
pressed && canSend && styles.pressed
|
|
206
|
+
],
|
|
207
|
+
accessibilityRole: "button",
|
|
208
|
+
accessibilityLabel: "Send",
|
|
209
|
+
accessibilityState: {
|
|
210
|
+
disabled: !canSend
|
|
211
|
+
},
|
|
212
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
213
|
+
name: "arrow-up",
|
|
214
|
+
size: ico.sysSizeSm,
|
|
215
|
+
color: canSend ? cr.custom.warning.sysOnWarning : cr.surface.surface.sysOnSurfaceVariant
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const styles = _reactnative.StyleSheet.create({
|
|
224
|
+
wrapper: {
|
|
225
|
+
gap: 4
|
|
226
|
+
},
|
|
227
|
+
disabled: {
|
|
228
|
+
opacity: 0.48
|
|
229
|
+
},
|
|
230
|
+
inputRow: {
|
|
231
|
+
flexDirection: 'row',
|
|
232
|
+
alignItems: 'flex-end'
|
|
233
|
+
},
|
|
234
|
+
textInput: {
|
|
235
|
+
flex: 1,
|
|
236
|
+
includeFontPadding: false,
|
|
237
|
+
padding: 0,
|
|
238
|
+
margin: 0
|
|
239
|
+
},
|
|
240
|
+
attachStrip: {
|
|
241
|
+
flexShrink: 0
|
|
242
|
+
},
|
|
243
|
+
attachStripContent: {
|
|
244
|
+
flexDirection: 'row',
|
|
245
|
+
gap: 8,
|
|
246
|
+
paddingHorizontal: 4
|
|
247
|
+
},
|
|
248
|
+
attachItem: {
|
|
249
|
+
position: 'relative'
|
|
250
|
+
},
|
|
251
|
+
removeBtn: {
|
|
252
|
+
position: 'absolute',
|
|
253
|
+
top: -4,
|
|
254
|
+
right: -4,
|
|
255
|
+
backgroundColor: '#fff',
|
|
256
|
+
borderRadius: 8
|
|
257
|
+
},
|
|
258
|
+
pressed: {
|
|
259
|
+
opacity: 0.7
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/ChatInput/index.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\r\n\r\nimport {\r\n Image,\r\n ImageSourcePropType,\r\n NativeSyntheticEvent,\r\n Pressable,\r\n ScrollView,\r\n StyleProp,\r\n StyleSheet,\r\n TextInput,\r\n TextInputContentSizeChangeEventData,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { Ionicons } from '@expo/vector-icons';\r\n\r\nimport { useTheme } from '../../theme';\r\nimport { BodyText } from '../BodyText';\r\n\r\nexport interface ChatAttachment {\r\n uri: string;\r\n source?: ImageSourcePropType;\r\n}\r\n\r\nexport interface ChatInputProps {\r\n value: string;\r\n onChangeText: (text: string) => void;\r\n onSend: () => void;\r\n onAttach?: () => void;\r\n placeholder?: string;\r\n attachments?: ChatAttachment[];\r\n onRemoveAttachment?: (index: number) => void;\r\n disabled?: boolean;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function ChatInput({\r\n value,\r\n onChangeText,\r\n onSend,\r\n onAttach,\r\n placeholder = 'Ask Sol Anything...',\r\n attachments,\r\n onRemoveAttachment,\r\n disabled = false,\r\n style,\r\n}: ChatInputProps) {\r\n const { colorRoles: cr, dimensions: dim, iconography: ico } = useTheme();\r\n const [isFocused, setIsFocused] = useState(false);\r\n const [inputHeight, setInputHeight] = useState(24);\r\n const inputRef = useRef<TextInput>(null);\r\n\r\n const handleContentSizeChange = useCallback(\r\n (e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => {\r\n const newHeight = Math.max(24, Math.min(120, e.nativeEvent.contentSize.height));\r\n setInputHeight(newHeight);\r\n },\r\n [],\r\n );\r\n\r\n const hasText = value.trim().length > 0;\r\n const hasAttachments = !!attachments && attachments.length > 0;\r\n const canSend = (hasText || hasAttachments) && !disabled;\r\n\r\n const tokenStyles = useMemo(\r\n () => ({\r\n container: {\r\n borderRadius: dim.borderRadius.sysRadiusLg,\r\n borderWidth: isFocused\r\n ? dim.borderWidth.sysStrokeMedium\r\n : dim.borderWidth.sysStrokeThin,\r\n borderColor: isFocused\r\n ? cr.accent.primary.sysPrimary\r\n : cr.outline.sysOutlineVariant,\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n paddingHorizontal: dim.spacing.padding.sysPadding12,\r\n gap: dim.spacing.padding.sysPadding8,\r\n },\r\n attachBtn: {\r\n width: 32,\r\n height: 32,\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n alignItems: 'center' as const,\r\n justifyContent: 'center' as const,\r\n flexShrink: 0,\r\n },\r\n sendBtn: {\r\n width: 32,\r\n height: 32,\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n alignItems: 'center' as const,\r\n justifyContent: 'center' as const,\r\n flexShrink: 0,\r\n backgroundColor: canSend\r\n ? cr.custom.warning.sysWarning\r\n : cr.surface.surfaceContainer.sysSurfaceContainerHighest,\r\n },\r\n attachThumb: {\r\n width: 48,\r\n height: 48,\r\n borderRadius: dim.borderRadius.sysRadiusSm,\r\n overflow: 'hidden' as const,\r\n },\r\n }),\r\n [cr, dim, isFocused, canSend],\r\n );\r\n\r\n return (\r\n <View style={[styles.wrapper, disabled && styles.disabled, style]}>\r\n {/* Attachment strip */}\r\n {hasAttachments && (\r\n <ScrollView\r\n horizontal\r\n showsHorizontalScrollIndicator={false}\r\n style={styles.attachStrip}\r\n contentContainerStyle={styles.attachStripContent}\r\n >\r\n {attachments!.map((att, i) => (\r\n <View key={i} style={styles.attachItem}>\r\n <Image\r\n source={att.source ?? { uri: att.uri }}\r\n style={tokenStyles.attachThumb}\r\n resizeMode=\"cover\"\r\n accessibilityLabel={`Attachment ${i + 1}`}\r\n />\r\n {onRemoveAttachment && (\r\n <Pressable\r\n onPress={() => onRemoveAttachment(i)}\r\n style={styles.removeBtn}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel={`Remove attachment ${i + 1}`}\r\n >\r\n <Ionicons\r\n name=\"close-circle\"\r\n size={16}\r\n color={cr.surface.surface.sysOnSurfaceVariant}\r\n />\r\n </Pressable>\r\n )}\r\n </View>\r\n ))}\r\n </ScrollView>\r\n )}\r\n\r\n {/* Input row */}\r\n <View\r\n style={[\r\n tokenStyles.container,\r\n styles.inputRow,\r\n isFocused && {\r\n // focus ring via transparent primary halo\r\n shadowColor: cr.accent.primary.sysPrimary,\r\n shadowOffset: { width: 0, height: 0 },\r\n shadowOpacity: 0.08,\r\n shadowRadius: 4,\r\n },\r\n ]}\r\n >\r\n {/* Attach button */}\r\n {onAttach && (\r\n <Pressable\r\n onPress={onAttach}\r\n disabled={disabled}\r\n style={({ pressed }) => [\r\n tokenStyles.attachBtn,\r\n pressed && styles.pressed,\r\n ]}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Add attachment\"\r\n >\r\n <Ionicons\r\n name=\"add\"\r\n size={ico.sysSizeSm}\r\n color={\r\n disabled\r\n ? cr.surface.surface.sysOnSurfaceVariant\r\n : cr.surface.surface.sysOnSurface\r\n }\r\n />\r\n </Pressable>\r\n )}\r\n\r\n {/* Text field */}\r\n <TextInput\r\n ref={inputRef}\r\n value={value}\r\n onChangeText={onChangeText}\r\n placeholder={placeholder}\r\n placeholderTextColor={cr.surface.surface.sysOnSurfaceVariant}\r\n editable={!disabled}\r\n multiline\r\n scrollEnabled={inputHeight >= 120}\r\n onContentSizeChange={handleContentSizeChange}\r\n onFocus={() => setIsFocused(true)}\r\n onBlur={() => setIsFocused(false)}\r\n style={[\r\n styles.textInput,\r\n {\r\n color: cr.surface.surface.sysOnSurface,\r\n fontSize: 16,\r\n lineHeight: 24,\r\n height: inputHeight,\r\n },\r\n ]}\r\n accessibilityLabel={placeholder}\r\n returnKeyType=\"default\"\r\n />\r\n\r\n {/* Send button */}\r\n <Pressable\r\n onPress={canSend ? onSend : undefined}\r\n disabled={!canSend}\r\n style={({ pressed }) => [\r\n tokenStyles.sendBtn,\r\n pressed && canSend && styles.pressed,\r\n ]}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Send\"\r\n accessibilityState={{ disabled: !canSend }}\r\n >\r\n <Ionicons\r\n name=\"arrow-up\"\r\n size={ico.sysSizeSm}\r\n color={\r\n canSend\r\n ? cr.custom.warning.sysOnWarning\r\n : cr.surface.surface.sysOnSurfaceVariant\r\n }\r\n />\r\n </Pressable>\r\n </View>\r\n </View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n wrapper: {\r\n gap: 4,\r\n },\r\n disabled: {\r\n opacity: 0.48,\r\n },\r\n inputRow: {\r\n flexDirection: 'row',\r\n alignItems: 'flex-end',\r\n },\r\n textInput: {\r\n flex: 1,\r\n includeFontPadding: false,\r\n padding: 0,\r\n margin: 0,\r\n },\r\n attachStrip: {\r\n flexShrink: 0,\r\n },\r\n attachStripContent: {\r\n flexDirection: 'row',\r\n gap: 8,\r\n paddingHorizontal: 4,\r\n },\r\n attachItem: {\r\n position: 'relative',\r\n },\r\n removeBtn: {\r\n position: 'absolute',\r\n top: -4,\r\n right: -4,\r\n backgroundColor: '#fff',\r\n borderRadius: 8,\r\n },\r\n pressed: {\r\n opacity: 0.7,\r\n },\r\n});\r\n"],"names":["ChatInput","value","onChangeText","onSend","onAttach","placeholder","attachments","onRemoveAttachment","disabled","style","colorRoles","cr","dimensions","dim","iconography","ico","useTheme","isFocused","setIsFocused","useState","inputHeight","setInputHeight","inputRef","useRef","handleContentSizeChange","useCallback","e","newHeight","Math","max","min","nativeEvent","contentSize","height","hasText","trim","length","hasAttachments","canSend","tokenStyles","useMemo","container","borderRadius","sysRadiusLg","borderWidth","sysStrokeMedium","sysStrokeThin","borderColor","accent","primary","sysPrimary","outline","sysOutlineVariant","backgroundColor","surface","surfaceContainer","sysSurfaceContainerLowest","paddingVertical","spacing","padding","sysPadding8","paddingHorizontal","sysPadding12","gap","attachBtn","width","sysRadiusFull","alignItems","justifyContent","flexShrink","sendBtn","custom","warning","sysWarning","sysSurfaceContainerHighest","attachThumb","sysRadiusSm","overflow","View","styles","wrapper","ScrollView","horizontal","showsHorizontalScrollIndicator","attachStrip","contentContainerStyle","attachStripContent","map","att","i","attachItem","Image","source","uri","resizeMode","accessibilityLabel","Pressable","onPress","removeBtn","accessibilityRole","Ionicons","name","size","color","sysOnSurfaceVariant","inputRow","shadowColor","shadowOffset","shadowOpacity","shadowRadius","pressed","sysSizeSm","sysOnSurface","TextInput","ref","placeholderTextColor","editable","multiline","scrollEnabled","onContentSizeChange","onFocus","onBlur","textInput","fontSize","lineHeight","returnKeyType","undefined","accessibilityState","sysOnWarning","StyleSheet","create","opacity","flexDirection","flex","includeFontPadding","margin","position","top","right"],"mappings":";;;;+BAsCgBA;;;eAAAA;;;;+DAtC8C;6BAcvD;6BAEkB;uBAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBlB,SAASA,UAAU,EACxBC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRC,cAAc,qBAAqB,EACnCC,WAAW,EACXC,kBAAkB,EAClBC,WAAW,KAAK,EAChBC,KAAK,EACU;IACf,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAEC,aAAaC,GAAG,EAAE,GAAGC,IAAAA,eA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