stream-chat-react-native-core 5.4.1 → 5.4.2-beta.2

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 (57) hide show
  1. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +122 -433
  2. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  3. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +358 -0
  4. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -0
  5. package/lib/commonjs/components/MessageList/MessageList.js +59 -40
  6. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  7. package/lib/commonjs/components/MessageList/NetworkDownIndicator.js +14 -6
  8. package/lib/commonjs/components/MessageList/NetworkDownIndicator.js.map +1 -1
  9. package/lib/commonjs/components/MessageList/hooks/useMessageList.js +4 -3
  10. package/lib/commonjs/components/MessageList/hooks/useMessageList.js.map +1 -1
  11. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +134 -85
  12. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  13. package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +39 -17
  14. package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
  15. package/lib/commonjs/hooks/useAppStateListener.js +9 -15
  16. package/lib/commonjs/hooks/useAppStateListener.js.map +1 -1
  17. package/lib/commonjs/mock-builders/generator/message.js +1 -1
  18. package/lib/commonjs/mock-builders/generator/message.js.map +1 -1
  19. package/lib/commonjs/version.json +1 -1
  20. package/lib/module/components/AttachmentPicker/AttachmentPicker.js +122 -433
  21. package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  22. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +358 -0
  23. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -0
  24. package/lib/module/components/MessageList/MessageList.js +59 -40
  25. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  26. package/lib/module/components/MessageList/NetworkDownIndicator.js +14 -6
  27. package/lib/module/components/MessageList/NetworkDownIndicator.js.map +1 -1
  28. package/lib/module/components/MessageList/hooks/useMessageList.js +4 -3
  29. package/lib/module/components/MessageList/hooks/useMessageList.js.map +1 -1
  30. package/lib/module/contexts/messageInputContext/MessageInputContext.js +134 -85
  31. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  32. package/lib/module/contexts/overlayContext/OverlayProvider.js +39 -17
  33. package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
  34. package/lib/module/hooks/useAppStateListener.js +9 -15
  35. package/lib/module/hooks/useAppStateListener.js.map +1 -1
  36. package/lib/module/mock-builders/generator/message.js +1 -1
  37. package/lib/module/mock-builders/generator/message.js.map +1 -1
  38. package/lib/module/version.json +1 -1
  39. package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts +0 -11
  40. package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts +16 -0
  41. package/lib/typescript/components/MessageList/__tests__/useMessageList.test.d.ts +1 -0
  42. package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts +0 -1
  43. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -1
  44. package/lib/typescript/hooks/__tests__/useAppStateListener.test.d.ts +1 -0
  45. package/package.json +2 -2
  46. package/src/components/AttachmentPicker/AttachmentPicker.tsx +79 -322
  47. package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +245 -0
  48. package/src/components/MessageList/MessageList.tsx +21 -20
  49. package/src/components/MessageList/NetworkDownIndicator.tsx +13 -10
  50. package/src/components/MessageList/__tests__/useMessageList.test.tsx +67 -0
  51. package/src/components/MessageList/hooks/useMessageList.ts +4 -7
  52. package/src/contexts/messageInputContext/MessageInputContext.tsx +27 -25
  53. package/src/contexts/overlayContext/OverlayProvider.tsx +28 -4
  54. package/src/hooks/__tests__/useAppStateListener.test.tsx +41 -0
  55. package/src/hooks/useAppStateListener.ts +9 -12
  56. package/src/mock-builders/generator/message.js +1 -1
  57. package/src/version.json +1 -1
@@ -1,31 +1,25 @@
1
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
1
  Object.defineProperty(exports, "__esModule", {
4
2
  value: true
5
3
  });
6
4
  exports.useAppStateListener = void 0;
7
5
 
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
-
10
6
  var _react = require("react");
11
7
 
12
8
  var _reactNative = require("react-native");
13
9
 
14
10
  var useAppStateListener = function useAppStateListener(onForeground, onBackground) {
15
- var _useState = (0, _react.useState)(_reactNative.AppState.currentState),
16
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
17
- appState = _useState2[0],
18
- setAppState = _useState2[1];
19
-
11
+ var appStateRef = (0, _react.useRef)(_reactNative.AppState.currentState);
20
12
  var handleAppStateChange = (0, _react.useCallback)(function (nextAppState) {
21
- if (appState === 'background' && nextAppState === 'active' && onForeground) {
22
- onForeground();
23
- } else if (appState.match(/active|inactive/) && nextAppState === 'background' && onBackground) {
24
- onBackground();
13
+ var prevAppState = appStateRef.current;
14
+
15
+ if (prevAppState.match(/inactive|background/) && nextAppState === 'active') {
16
+ onForeground == null ? void 0 : onForeground();
17
+ } else if (prevAppState === 'active' && nextAppState.match(/inactive|background/)) {
18
+ onBackground == null ? void 0 : onBackground();
25
19
  }
26
20
 
27
- setAppState(nextAppState);
28
- }, [onBackground, onForeground, appState]);
21
+ appStateRef.current = nextAppState;
22
+ }, [onBackground, onForeground]);
29
23
  (0, _react.useEffect)(function () {
30
24
  var subscription = _reactNative.AppState.addEventListener('change', handleAppStateChange);
31
25
 
@@ -1 +1 @@
1
- {"version":3,"sources":["useAppStateListener.ts"],"names":["useAppStateListener","onForeground","onBackground","AppState","currentState","appState","setAppState","handleAppStateChange","nextAppState","match","subscription","addEventListener","remove","removeEventListener"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,YAAD,EAA4BC,YAA5B,EAA0D;AAC3F,kBAAgC,qBAASC,sBAASC,YAAlB,CAAhC;AAAA;AAAA,MAAOC,QAAP;AAAA,MAAiBC,WAAjB;;AACA,MAAMC,oBAAoB,GAAG,wBAC3B,UAACC,YAAD,EAAkC;AAChC,QAAIH,QAAQ,KAAK,YAAb,IAA6BG,YAAY,KAAK,QAA9C,IAA0DP,YAA9D,EAA4E;AAC1EA,MAAAA,YAAY;AACb,KAFD,MAEO,IACLI,QAAQ,CAACI,KAAT,CAAe,iBAAf,KACAD,YAAY,KAAK,YADjB,IAEAN,YAHK,EAIL;AACAA,MAAAA,YAAY;AACb;;AACDI,IAAAA,WAAW,CAACE,YAAD,CAAX;AACD,GAZ0B,EAa3B,CAACN,YAAD,EAAeD,YAAf,EAA6BI,QAA7B,CAb2B,CAA7B;AAgBA,wBAAU,YAAM;AACd,QAAMK,YAAY,GAAGP,sBAASQ,gBAAT,CAA0B,QAA1B,EAAoCJ,oBAApC,CAArB;;AAEA,WAAO,YAAM;AAGX,UAAIG,YAAJ,YAAIA,YAAY,CAAEE,MAAlB,EAA0B;AACxBF,QAAAA,YAAY,CAACE,MAAb;AACD,OAFD,MAEO;AACLT,8BAASU,mBAAT,CAA6B,QAA7B,EAAuCN,oBAAvC;AACD;AACF,KARD;AASD,GAZD,EAYG,CAACA,oBAAD,CAZH;AAaD,CA/BM","sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nexport const useAppStateListener = (onForeground?: () => void, onBackground?: () => void) => {\n const [appState, setAppState] = useState(AppState.currentState);\n const handleAppStateChange = useCallback(\n (nextAppState: AppStateStatus) => {\n if (appState === 'background' && nextAppState === 'active' && onForeground) {\n onForeground();\n } else if (\n appState.match(/active|inactive/) &&\n nextAppState === 'background' &&\n onBackground\n ) {\n onBackground();\n }\n setAppState(nextAppState);\n },\n [onBackground, onForeground, appState],\n );\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', handleAppStateChange);\n\n return () => {\n // Following if-else logic is to support RN >= 0.65 and RN < 0.65 versions.\n // https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#:~:text=EventEmitter%23removeSubscription%20is%20now%20deprecated.%20(cb6cbd12f8%20by%20%40yungsters)\n if (subscription?.remove) {\n subscription.remove();\n } else {\n AppState.removeEventListener('change', handleAppStateChange);\n }\n };\n }, [handleAppStateChange]);\n};\n"]}
1
+ {"version":3,"sources":["useAppStateListener.ts"],"names":["useAppStateListener","onForeground","onBackground","appStateRef","AppState","currentState","handleAppStateChange","nextAppState","prevAppState","current","match","subscription","addEventListener","remove","removeEventListener"],"mappings":";;;;;AAAA;;AACA;;AAEO,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,YAAD,EAA4BC,YAA5B,EAA0D;AAC3F,MAAMC,WAAW,GAAG,mBAAOC,sBAASC,YAAhB,CAApB;AACA,MAAMC,oBAAoB,GAAG,wBAC3B,UAACC,YAAD,EAAkC;AAChC,QAAMC,YAAY,GAAGL,WAAW,CAACM,OAAjC;;AACA,QAAID,YAAY,CAACE,KAAb,CAAmB,qBAAnB,KAA6CH,YAAY,KAAK,QAAlE,EAA4E;AAC1EN,MAAAA,YAAY,QAAZ,YAAAA,YAAY;AACb,KAFD,MAEO,IAAIO,YAAY,KAAK,QAAjB,IAA6BD,YAAY,CAACG,KAAb,CAAmB,qBAAnB,CAAjC,EAA4E;AACjFR,MAAAA,YAAY,QAAZ,YAAAA,YAAY;AACb;;AACDC,IAAAA,WAAW,CAACM,OAAZ,GAAsBF,YAAtB;AACD,GAT0B,EAU3B,CAACL,YAAD,EAAeD,YAAf,CAV2B,CAA7B;AAaA,wBAAU,YAAM;AACd,QAAMU,YAAY,GAAGP,sBAASQ,gBAAT,CAA0B,QAA1B,EAAoCN,oBAApC,CAArB;;AAEA,WAAO,YAAM;AAGX,UAAIK,YAAJ,YAAIA,YAAY,CAAEE,MAAlB,EAA0B;AACxBF,QAAAA,YAAY,CAACE,MAAb;AACD,OAFD,MAEO;AACLT,8BAASU,mBAAT,CAA6B,QAA7B,EAAuCR,oBAAvC;AACD;AACF,KARD;AASD,GAZD,EAYG,CAACA,oBAAD,CAZH;AAaD,CA5BM","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nexport const useAppStateListener = (onForeground?: () => void, onBackground?: () => void) => {\n const appStateRef = useRef(AppState.currentState);\n const handleAppStateChange = useCallback(\n (nextAppState: AppStateStatus) => {\n const prevAppState = appStateRef.current;\n if (prevAppState.match(/inactive|background/) && nextAppState === 'active') {\n onForeground?.();\n } else if (prevAppState === 'active' && nextAppState.match(/inactive|background/)) {\n onBackground?.();\n }\n appStateRef.current = nextAppState;\n },\n [onBackground, onForeground],\n );\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', handleAppStateChange);\n\n return () => {\n // Following if-else logic is to support RN >= 0.65 and RN < 0.65 versions.\n // https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#:~:text=EventEmitter%23removeSubscription%20is%20now%20deprecated.%20(cb6cbd12f8%20by%20%40yungsters)\n if (subscription?.remove) {\n subscription.remove();\n } else {\n AppState.removeEventListener('change', handleAppStateChange);\n }\n };\n }, [handleAppStateChange]);\n};\n"]}
@@ -16,7 +16,7 @@ var generateMessage = function generateMessage() {
16
16
  var timestamp = options.timestamp || new Date(new Date().getTime() - Math.floor(Math.random() * 100000));
17
17
  return (0, _extends2["default"])({
18
18
  attachments: [],
19
- created_at: timestamp.toString(),
19
+ created_at: timestamp,
20
20
  html: '<p>regular</p>',
21
21
  id: (0, _uuid.v4)(),
22
22
  text: (0, _uuid.v4)(),
@@ -1 +1 @@
1
- {"version":3,"sources":["message.js"],"names":["generateMessage","options","timestamp","Date","getTime","Math","floor","random","attachments","created_at","toString","html","id","text","type","updated_at","user","StreamReactNativeNamespace","generateStaticMessage","seed","date"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAkB;AAAA,MAAjBC,OAAiB,uEAAP,EAAO;AAC/C,MAAMC,SAAS,GACbD,OAAO,CAACC,SAAR,IAAqB,IAAIC,IAAJ,CAAS,IAAIA,IAAJ,GAAWC,OAAX,KAAuBC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgB,MAA3B,CAAhC,CADvB;AAGA;AACEC,IAAAA,WAAW,EAAE,EADf;AAEEC,IAAAA,UAAU,EAAEP,SAAS,CAACQ,QAAV,EAFd;AAGEC,IAAAA,IAAI,EAAE,gBAHR;AAIEC,IAAAA,EAAE,EAAE,eAJN;AAKEC,IAAAA,IAAI,EAAE,eALR;AAMEC,IAAAA,IAAI,EAAE,SANR;AAOEC,IAAAA,UAAU,EAAEb,SAAS,CAACQ,QAAV,EAPd;AAQEM,IAAAA,IAAI,EAAE;AARR,KASKf,OATL;AAWD,CAfM;;;AAiBP,IAAMgB,0BAA0B,GAAG,sCAAnC;;AACO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,IAAD,EAAOlB,OAAP,EAAgBmB,IAAhB;AAAA,SACnCpB,eAAe;AACbS,IAAAA,UAAU,EAAEW,IAAI,IAAI,6BADP;AAEbR,IAAAA,EAAE,EAAE,cAAOO,IAAP,EAAaF,0BAAb,CAFS;AAGbJ,IAAAA,IAAI,EAAEM,IAHO;AAIbJ,IAAAA,UAAU,EAAEK,IAAI,IAAI;AAJP,KAKVnB,OALU,EADoB;AAAA,CAA9B","sourcesContent":["import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\n\nimport { generateUser } from './user';\n\nexport const generateMessage = (options = {}) => {\n const timestamp =\n options.timestamp || new Date(new Date().getTime() - Math.floor(Math.random() * 100000));\n\n return {\n attachments: [],\n created_at: timestamp.toString(),\n html: '<p>regular</p>',\n id: uuidv4(),\n text: uuidv4(),\n type: 'regular',\n updated_at: timestamp.toString(),\n user: generateUser(),\n ...options,\n };\n};\n\nconst StreamReactNativeNamespace = '9b244ee4-7d69-4d7b-ae23-cf89e9f7b035';\nexport const generateStaticMessage = (seed, options, date) =>\n generateMessage({\n created_at: date || '2020-04-27T13:39:49.331742Z',\n id: uuidv5(seed, StreamReactNativeNamespace),\n text: seed,\n updated_at: date || '2020-04-27T13:39:49.331742Z',\n ...options,\n });\n"]}
1
+ {"version":3,"sources":["message.js"],"names":["generateMessage","options","timestamp","Date","getTime","Math","floor","random","attachments","created_at","html","id","text","type","updated_at","toString","user","StreamReactNativeNamespace","generateStaticMessage","seed","date"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAkB;AAAA,MAAjBC,OAAiB,uEAAP,EAAO;AAC/C,MAAMC,SAAS,GACbD,OAAO,CAACC,SAAR,IAAqB,IAAIC,IAAJ,CAAS,IAAIA,IAAJ,GAAWC,OAAX,KAAuBC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgB,MAA3B,CAAhC,CADvB;AAGA;AACEC,IAAAA,WAAW,EAAE,EADf;AAEEC,IAAAA,UAAU,EAAEP,SAFd;AAGEQ,IAAAA,IAAI,EAAE,gBAHR;AAIEC,IAAAA,EAAE,EAAE,eAJN;AAKEC,IAAAA,IAAI,EAAE,eALR;AAMEC,IAAAA,IAAI,EAAE,SANR;AAOEC,IAAAA,UAAU,EAAEZ,SAAS,CAACa,QAAV,EAPd;AAQEC,IAAAA,IAAI,EAAE;AARR,KASKf,OATL;AAWD,CAfM;;;AAiBP,IAAMgB,0BAA0B,GAAG,sCAAnC;;AACO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,IAAD,EAAOlB,OAAP,EAAgBmB,IAAhB;AAAA,SACnCpB,eAAe;AACbS,IAAAA,UAAU,EAAEW,IAAI,IAAI,6BADP;AAEbT,IAAAA,EAAE,EAAE,cAAOQ,IAAP,EAAaF,0BAAb,CAFS;AAGbL,IAAAA,IAAI,EAAEO,IAHO;AAIbL,IAAAA,UAAU,EAAEM,IAAI,IAAI;AAJP,KAKVnB,OALU,EADoB;AAAA,CAA9B","sourcesContent":["import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\n\nimport { generateUser } from './user';\n\nexport const generateMessage = (options = {}) => {\n const timestamp =\n options.timestamp || new Date(new Date().getTime() - Math.floor(Math.random() * 100000));\n\n return {\n attachments: [],\n created_at: timestamp,\n html: '<p>regular</p>',\n id: uuidv4(),\n text: uuidv4(),\n type: 'regular',\n updated_at: timestamp.toString(),\n user: generateUser(),\n ...options,\n };\n};\n\nconst StreamReactNativeNamespace = '9b244ee4-7d69-4d7b-ae23-cf89e9f7b035';\nexport const generateStaticMessage = (seed, options, date) =>\n generateMessage({\n created_at: date || '2020-04-27T13:39:49.331742Z',\n id: uuidv5(seed, StreamReactNativeNamespace),\n text: seed,\n updated_at: date || '2020-04-27T13:39:49.331742Z',\n ...options,\n });\n"]}
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.4.1"
2
+ "version": "5.4.2-beta.2"
3
3
  }