@planningcenter/chat-react-native 4.3.0-rc.6 → 4.3.0-rc.7
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/build/components/display/conversation_avatar.d.ts +1 -2
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/types/resources/conversation.d.ts +1 -0
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/types/resources/index.d.ts +1 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +1 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/search_result.d.ts +29 -0
- package/build/types/resources/search_result.d.ts.map +1 -0
- package/build/types/resources/search_result.js +2 -0
- package/build/types/resources/search_result.js.map +1 -0
- package/build/utils/request/get_search_results.d.ts +13 -0
- package/build/utils/request/get_search_results.d.ts.map +1 -0
- package/build/utils/request/get_search_results.js +20 -0
- package/build/utils/request/get_search_results.js.map +1 -0
- package/package.json +2 -2
- package/src/components/display/conversation_avatar.tsx +1 -10
- package/src/types/resources/conversation.ts +9 -0
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/search_result.ts +32 -0
- package/src/utils/__tests__/get_search_results.test.ts +24 -0
- package/src/utils/request/get_search_results.ts +23 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ViewStyle } from 'react-native';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ConversationAvatarData } from '../../types';
|
|
3
3
|
import { type AvatarRootProps } from '../primitive/avatar_primitive';
|
|
4
4
|
import { type IconString } from './icon';
|
|
5
|
-
type ConversationAvatarData = Pick<ConversationResource, 'customAvatarType' | 'customAvatarKey' | 'customAvatarColor' | 'customAvatarImageUrl' | 'previewAvatarUrls'>;
|
|
6
5
|
interface ConversationAvatarProps {
|
|
7
6
|
conversation: ConversationAvatarData;
|
|
8
7
|
size?: AvatarRootProps['size'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_avatar.d.ts","sourceRoot":"","sources":["../../../src/components/display/conversation_avatar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"conversation_avatar.d.ts","sourceRoot":"","sources":["../../../src/components/display/conversation_avatar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACzD,OAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAGrF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAiCxC,UAAU,uBAAuB;IAC/B,YAAY,EAAE,sBAAsB,CAAA;IACpC,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gBAAgB,CAAC,EAAE,UAAU,CAAA;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAA;CACjE;AAED,wBAAgB,kBAAkB,CAAC,EACjC,YAAY,EACZ,IAAW,EACX,YAAoB,EACpB,gBAAmC,EACnC,KAAK,EACL,qBAAqB,GACtB,EAAE,uBAAuB,2CA2BzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_avatar.js","names":["React","AvatarPrimitive","AvatarGroup","EmojiAvatar","IconAvatar","jsx","_jsx","resolveAvatar","conversation","customAvatarType","customAvatarImageUrl","kind","url","customAvatarKey","iconKey","color","customAvatarColor","emoji","sources","previewAvatarUrls","ConversationAvatar","t0","$","_c","size","t1","showFallback","t2","fallbackIconName","t3","style","maxFontSizeMultiplier","undefined","t4","avatar","t5","sizeProps","t6","Mask","children","Image","sourceUri","t7","Root","length","t8","sourceUris"],"sources":["../../../src/components/display/conversation_avatar.tsx"],"sourcesContent":["import React from 'react'\nimport type { ViewStyle } from 'react-native'\nimport type {
|
|
1
|
+
{"version":3,"file":"conversation_avatar.js","names":["React","AvatarPrimitive","AvatarGroup","EmojiAvatar","IconAvatar","jsx","_jsx","resolveAvatar","conversation","customAvatarType","customAvatarImageUrl","kind","url","customAvatarKey","iconKey","color","customAvatarColor","emoji","sources","previewAvatarUrls","ConversationAvatar","t0","$","_c","size","t1","showFallback","t2","fallbackIconName","t3","style","maxFontSizeMultiplier","undefined","t4","avatar","t5","sizeProps","t6","Mask","children","Image","sourceUri","t7","Root","length","t8","sourceUris"],"sources":["../../../src/components/display/conversation_avatar.tsx"],"sourcesContent":["import React from 'react'\nimport type { ViewStyle } from 'react-native'\nimport type { ConversationAvatarData } from '../../types'\nimport AvatarPrimitive, { type AvatarRootProps } from '../primitive/avatar_primitive'\nimport { AvatarGroup } from './avatar_group'\nimport { EmojiAvatar } from './emoji_avatar'\nimport { type IconString } from './icon'\nimport { IconAvatar } from './icon_avatar'\n\ntype ResolvedAvatar =\n | { kind: 'image'; url: string }\n | { kind: 'icon'; iconKey: string; color: string | null }\n | { kind: 'emoji'; emoji: string; color: string | null }\n | { kind: 'group'; sources: string[] | undefined }\n\nfunction resolveAvatar(conversation: ConversationAvatarData): ResolvedAvatar {\n if (conversation.customAvatarType === 'image' && conversation.customAvatarImageUrl) {\n return { kind: 'image', url: conversation.customAvatarImageUrl }\n }\n\n if (conversation.customAvatarType === 'icon' && conversation.customAvatarKey) {\n return {\n kind: 'icon',\n iconKey: conversation.customAvatarKey,\n color: conversation.customAvatarColor ?? null,\n }\n }\n\n if (conversation.customAvatarType === 'emoji' && conversation.customAvatarKey) {\n return {\n kind: 'emoji',\n emoji: conversation.customAvatarKey,\n color: conversation.customAvatarColor ?? null,\n }\n }\n\n return { kind: 'group', sources: conversation.previewAvatarUrls }\n}\n\ninterface ConversationAvatarProps {\n conversation: ConversationAvatarData\n size?: AvatarRootProps['size']\n showFallback?: boolean\n fallbackIconName?: IconString\n style?: ViewStyle\n maxFontSizeMultiplier?: AvatarRootProps['maxFontSizeMultiplier']\n}\n\nexport function ConversationAvatar({\n conversation,\n size = 'lg',\n showFallback = false,\n fallbackIconName = 'general.person',\n style,\n maxFontSizeMultiplier,\n}: ConversationAvatarProps) {\n const avatar = resolveAvatar(conversation)\n const sizeProps = { size, maxFontSizeMultiplier, style }\n\n switch (avatar.kind) {\n case 'image':\n return (\n <AvatarPrimitive.Root {...sizeProps}>\n <AvatarPrimitive.Mask>\n <AvatarPrimitive.Image sourceUri={avatar.url} />\n </AvatarPrimitive.Mask>\n </AvatarPrimitive.Root>\n )\n case 'icon':\n return <IconAvatar iconKey={avatar.iconKey} color={avatar.color} {...sizeProps} />\n case 'emoji':\n return <EmojiAvatar emoji={avatar.emoji} color={avatar.color} {...sizeProps} />\n case 'group':\n return (\n <AvatarGroup\n sourceUris={avatar.sources || []}\n showFallback={showFallback || !avatar.sources || avatar.sources.length === 0}\n fallbackIconName={fallbackIconName}\n {...sizeProps}\n />\n )\n }\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,eAAe,MAAgC,+BAA+B;AACrF,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,WAAW,QAAQ,gBAAgB;AAE5C,SAASC,UAAU,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ1C,SAASC,aAAaA,CAACC,YAAoC,EAAkB;EAC3E,IAAIA,YAAY,CAACC,gBAAgB,KAAK,OAAO,IAAID,YAAY,CAACE,oBAAoB,EAAE;IAClF,OAAO;MAAEC,IAAI,EAAE,OAAO;MAAEC,GAAG,EAAEJ,YAAY,CAACE;IAAqB,CAAC;EAClE;EAEA,IAAIF,YAAY,CAACC,gBAAgB,KAAK,MAAM,IAAID,YAAY,CAACK,eAAe,EAAE;IAC5E,OAAO;MACL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,CAAA,SAAAe,EAAA,IAAAf,CAAA,SAAAoB,EAAA;UAF9EG,EAAA,gBAAAvC,IAAA,CAACJ,WAAW;YACE4C,UAAoB,EAApBT,EAAoB;YAClBX,YAA8D,EAA9DgB,EAA8D;YAC1Dd,gBAAgB,EAAhBA,gBAAgB;YAAA,GAC9BQ;UAAS,CACd,CAAC;UAAAd,CAAA,OAAAM,gBAAA;UAAAN,CAAA,OAAAc,SAAA;UAAAd,CAAA,OAAAe,EAAA;UAAAf,CAAA,OAAAoB,EAAA;UAAApB,CAAA,OAAAuB,EAAA;QAAA;UAAAA,EAAA,GAAAvB,CAAA;QAAA;QAAA,OALFuB,EAKE;MAAA;EAER;AAAC","ignoreList":[]}
|
|
@@ -44,4 +44,5 @@ export interface ConversationResource {
|
|
|
44
44
|
unreadReaction: boolean;
|
|
45
45
|
updatedAt: string;
|
|
46
46
|
}
|
|
47
|
+
export type ConversationAvatarData = Pick<ConversationResource, 'customAvatarType' | 'customAvatarKey' | 'customAvatarColor' | 'customAvatarImageUrl' | 'previewAvatarUrls'>;
|
|
47
48
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,K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AO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IACpD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,aAAa,CAAC,EAAE,qBAAqB,CAAA;IACrC,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,oBAAoB,EAClB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,mBAAmB,CACtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","names":[],"sources":["../../../src/types/resources/conversation.ts"],"sourcesContent":["import type { AnalyticsMetadataResource } from './analytics_metadata'\nimport { ConversationBadgeResource } from './conversation_badge'\nimport { ConversationMembershipResource } from './conversation_membership'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\nimport { ReactionCountResource } from './reaction'\n\nexport interface ConversationPreviewData {\n kind: 'reaction' | 'message'\n authorName: string\n value: ReactionCountResource['value'] | null\n text: string\n createdAt: string\n}\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: Partial<ConversationMembershipResource>\n conversationPreview: ConversationPreviewData | null\n createdAt: string\n deleted?: boolean\n directMessage?: boolean\n disabled?: boolean\n disabledReason?: string | null\n disabledMessage?: string | null\n genderOption?: string | null\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n customAvatarType?: 'image' | 'icon' | 'emoji' | null\n customAvatarKey?: string | null\n customAvatarColor?: string | null\n customAvatarImageUrl?: string | null\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n unreadReaction: boolean\n updatedAt: string\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"conversation.js","names":[],"sources":["../../../src/types/resources/conversation.ts"],"sourcesContent":["import type { AnalyticsMetadataResource } from './analytics_metadata'\nimport { ConversationBadgeResource } from './conversation_badge'\nimport { ConversationMembershipResource } from './conversation_membership'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\nimport { ReactionCountResource } from './reaction'\n\nexport interface ConversationPreviewData {\n kind: 'reaction' | 'message'\n authorName: string\n value: ReactionCountResource['value'] | null\n text: string\n createdAt: string\n}\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: Partial<ConversationMembershipResource>\n conversationPreview: ConversationPreviewData | null\n createdAt: string\n deleted?: boolean\n directMessage?: boolean\n disabled?: boolean\n disabledReason?: string | null\n disabledMessage?: string | null\n genderOption?: string | null\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n customAvatarType?: 'image' | 'icon' | 'emoji' | null\n customAvatarKey?: string | null\n customAvatarColor?: string | null\n customAvatarImageUrl?: string | null\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n unreadReaction: boolean\n updatedAt: string\n}\n\nexport type ConversationAvatarData = Pick<\n ConversationResource,\n | 'customAvatarType'\n | 'customAvatarKey'\n | 'customAvatarColor'\n | 'customAvatarImageUrl'\n | 'previewAvatarUrls'\n>\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/types/resources/index.ts"],"sourcesContent":["export * from './analytics_metadata'\nexport * from './direct_message_affiliations'\nexport * from './direct_message_candidate'\nexport * from './conversation'\nexport * from './conversation_membership'\nexport * from './conversation_validate'\nexport * from './member'\nexport * from './message'\nexport * from './oauth_token'\nexport * from './person'\nexport * from './groups'\nexport * from './app_grant'\nexport * from './services'\nexport * from './organization'\nexport * from './group_membership'\nexport * from './group_resource'\n"],"mappings":"AAAA,cAAc,sBAAsB;AACpC,cAAc,+BAA+B;AAC7C,cAAc,4BAA4B;AAC1C,cAAc,gBAAgB;AAC9B,cAAc,2BAA2B;AACzC,cAAc,yBAAyB;AACvC,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/types/resources/index.ts"],"sourcesContent":["export * from './analytics_metadata'\nexport * from './direct_message_affiliations'\nexport * from './direct_message_candidate'\nexport * from './conversation'\nexport * from './conversation_membership'\nexport * from './conversation_validate'\nexport * from './member'\nexport * from './message'\nexport * from './oauth_token'\nexport * from './person'\nexport * from './groups'\nexport * from './app_grant'\nexport * from './services'\nexport * from './organization'\nexport * from './group_membership'\nexport * from './group_resource'\nexport * from './search_result'\n"],"mappings":"AAAA,cAAc,sBAAsB;AACpC,cAAc,+BAA+B;AAC7C,cAAc,4BAA4B;AAC1C,cAAc,gBAAgB;AAC9B,cAAc,2BAA2B;AACzC,cAAc,yBAAyB;AACvC,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ConversationAvatarData } from './conversation';
|
|
2
|
+
interface BaseSearchResultResource {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SnippetSegment {
|
|
8
|
+
text: string;
|
|
9
|
+
match: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ConversationSearchResultResource extends BaseSearchResultResource {
|
|
12
|
+
type: 'conversation';
|
|
13
|
+
extra: {
|
|
14
|
+
avatar: ConversationAvatarData;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface MessageSearchResultResource extends BaseSearchResultResource {
|
|
18
|
+
type: 'message';
|
|
19
|
+
extra: {
|
|
20
|
+
conversationId: number;
|
|
21
|
+
authorName: string;
|
|
22
|
+
snippet: SnippetSegment[];
|
|
23
|
+
createdAt: string;
|
|
24
|
+
avatar: ConversationAvatarData;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export type SearchResultResource = ConversationSearchResultResource | MessageSearchResultResource;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=search_result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_result.d.ts","sourceRoot":"","sources":["../../../src/types/resources/search_result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAE5D,UAAU,wBAAwB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,gCAAiC,SAAQ,wBAAwB;IAChF,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE;QACL,MAAM,EAAE,sBAAsB,CAAA;KAC/B,CAAA;CACF;AAED,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB;IAC3E,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE;QACL,cAAc,EAAE,MAAM,CAAA;QACtB,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,cAAc,EAAE,CAAA;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,sBAAsB,CAAA;KAC/B,CAAA;CACF;AAED,MAAM,MAAM,oBAAoB,GAAG,gCAAgC,GAAG,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_result.js","names":[],"sources":["../../../src/types/resources/search_result.ts"],"sourcesContent":["import type { ConversationAvatarData } from './conversation'\n\ninterface BaseSearchResultResource {\n id: string\n title: string\n url: string\n}\n\nexport interface SnippetSegment {\n text: string\n match: boolean\n}\n\nexport interface ConversationSearchResultResource extends BaseSearchResultResource {\n type: 'conversation'\n extra: {\n avatar: ConversationAvatarData\n }\n}\n\nexport interface MessageSearchResultResource extends BaseSearchResultResource {\n type: 'message'\n extra: {\n conversationId: number\n authorName: string\n snippet: SnippetSegment[]\n createdAt: string\n avatar: ConversationAvatarData\n }\n}\n\nexport type SearchResultResource = ConversationSearchResultResource | MessageSearchResultResource\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
2
|
+
export declare const getSearchResultsRequestArgs: (term: string) => {
|
|
3
|
+
url: string;
|
|
4
|
+
data: {
|
|
5
|
+
q: string;
|
|
6
|
+
perPage: number;
|
|
7
|
+
fields: {
|
|
8
|
+
SearchResult: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const getSearchResultsQueryKey: (term: string) => import("../..").RequestQueryKey;
|
|
13
|
+
//# sourceMappingURL=get_search_results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_search_results.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM;;;;;;;;;CAavD,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,oCAGpD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api';
|
|
2
|
+
export const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
3
|
+
export const getSearchResultsRequestArgs = term => {
|
|
4
|
+
const url = '/search_results';
|
|
5
|
+
return {
|
|
6
|
+
url,
|
|
7
|
+
data: {
|
|
8
|
+
q: term,
|
|
9
|
+
perPage: SEARCH_RESULTS_PAGE_SIZE,
|
|
10
|
+
fields: {
|
|
11
|
+
SearchResult: ['type', 'title', 'url', 'extra']
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const getSearchResultsQueryKey = term => {
|
|
17
|
+
const requestArgs = getSearchResultsRequestArgs(term);
|
|
18
|
+
return getRequestQueryKey(requestArgs);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get_search_results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.js","names":["getRequestQueryKey","SEARCH_RESULTS_PAGE_SIZE","getSearchResultsRequestArgs","term","url","data","q","perPage","fields","SearchResult","getSearchResultsQueryKey","requestArgs"],"sources":["../../../src/utils/request/get_search_results.ts"],"sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\n\nexport const SEARCH_RESULTS_PAGE_SIZE = 20\n\nexport const getSearchResultsRequestArgs = (term: string) => {\n const url = '/search_results'\n\n return {\n url,\n data: {\n q: term,\n perPage: SEARCH_RESULTS_PAGE_SIZE,\n fields: {\n SearchResult: ['type', 'title', 'url', 'extra'],\n },\n },\n }\n}\n\nexport const getSearchResultsQueryKey = (term: string) => {\n const requestArgs = getSearchResultsRequestArgs(term)\n return getRequestQueryKey(requestArgs)\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AAEjE,OAAO,MAAMC,wBAAwB,GAAG,EAAE;AAE1C,OAAO,MAAMC,2BAA2B,GAAIC,IAAY,IAAK;EAC3D,MAAMC,GAAG,GAAG,iBAAiB;EAE7B,OAAO;IACLA,GAAG;IACHC,IAAI,EAAE;MACJC,CAAC,EAAEH,IAAI;MACPI,OAAO,EAAEN,wBAAwB;MACjCO,MAAM,EAAE;QACNC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;MAChD;IACF;EACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAIP,IAAY,IAAK;EACxD,MAAMQ,WAAW,GAAGT,2BAA2B,CAACC,IAAI,CAAC;EACrD,OAAOH,kBAAkB,CAACW,WAAW,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.3.0-rc.
|
|
3
|
+
"version": "4.3.0-rc.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sf-symbols-typescript": "^2.2.0",
|
|
85
85
|
"typescript": "~6.0.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "0709c9d5b579af4f138ca1fd067b4e7f180768a6"
|
|
88
88
|
}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ViewStyle } from 'react-native'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConversationAvatarData } from '../../types'
|
|
4
4
|
import AvatarPrimitive, { type AvatarRootProps } from '../primitive/avatar_primitive'
|
|
5
5
|
import { AvatarGroup } from './avatar_group'
|
|
6
6
|
import { EmojiAvatar } from './emoji_avatar'
|
|
7
7
|
import { type IconString } from './icon'
|
|
8
8
|
import { IconAvatar } from './icon_avatar'
|
|
9
9
|
|
|
10
|
-
type ConversationAvatarData = Pick<
|
|
11
|
-
ConversationResource,
|
|
12
|
-
| 'customAvatarType'
|
|
13
|
-
| 'customAvatarKey'
|
|
14
|
-
| 'customAvatarColor'
|
|
15
|
-
| 'customAvatarImageUrl'
|
|
16
|
-
| 'previewAvatarUrls'
|
|
17
|
-
>
|
|
18
|
-
|
|
19
10
|
type ResolvedAvatar =
|
|
20
11
|
| { kind: 'image'; url: string }
|
|
21
12
|
| { kind: 'icon'; iconKey: string; color: string | null }
|
|
@@ -46,3 +46,12 @@ export interface ConversationResource {
|
|
|
46
46
|
unreadReaction: boolean
|
|
47
47
|
updatedAt: string
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
export type ConversationAvatarData = Pick<
|
|
51
|
+
ConversationResource,
|
|
52
|
+
| 'customAvatarType'
|
|
53
|
+
| 'customAvatarKey'
|
|
54
|
+
| 'customAvatarColor'
|
|
55
|
+
| 'customAvatarImageUrl'
|
|
56
|
+
| 'previewAvatarUrls'
|
|
57
|
+
>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ConversationAvatarData } from './conversation'
|
|
2
|
+
|
|
3
|
+
interface BaseSearchResultResource {
|
|
4
|
+
id: string
|
|
5
|
+
title: string
|
|
6
|
+
url: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SnippetSegment {
|
|
10
|
+
text: string
|
|
11
|
+
match: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ConversationSearchResultResource extends BaseSearchResultResource {
|
|
15
|
+
type: 'conversation'
|
|
16
|
+
extra: {
|
|
17
|
+
avatar: ConversationAvatarData
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MessageSearchResultResource extends BaseSearchResultResource {
|
|
22
|
+
type: 'message'
|
|
23
|
+
extra: {
|
|
24
|
+
conversationId: number
|
|
25
|
+
authorName: string
|
|
26
|
+
snippet: SnippetSegment[]
|
|
27
|
+
createdAt: string
|
|
28
|
+
avatar: ConversationAvatarData
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SearchResultResource = ConversationSearchResultResource | MessageSearchResultResource
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSearchResultsQueryKey,
|
|
3
|
+
getSearchResultsRequestArgs,
|
|
4
|
+
} from '../request/get_search_results'
|
|
5
|
+
|
|
6
|
+
describe('getSearchResultsRequestArgs', () => {
|
|
7
|
+
it('requests the first page of search results for the term', () => {
|
|
8
|
+
expect(getSearchResultsRequestArgs('potluck')).toEqual({
|
|
9
|
+
url: '/search_results',
|
|
10
|
+
data: {
|
|
11
|
+
q: 'potluck',
|
|
12
|
+
perPage: 20,
|
|
13
|
+
fields: { SearchResult: ['type', 'title', 'url', 'extra'] },
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('getSearchResultsQueryKey', () => {
|
|
20
|
+
it('changes with the term', () => {
|
|
21
|
+
expect(getSearchResultsQueryKey('potluck')).not.toEqual(getSearchResultsQueryKey('picnic'))
|
|
22
|
+
expect(getSearchResultsQueryKey('potluck')).toEqual(getSearchResultsQueryKey('potluck'))
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api'
|
|
2
|
+
|
|
3
|
+
export const SEARCH_RESULTS_PAGE_SIZE = 20
|
|
4
|
+
|
|
5
|
+
export const getSearchResultsRequestArgs = (term: string) => {
|
|
6
|
+
const url = '/search_results'
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
url,
|
|
10
|
+
data: {
|
|
11
|
+
q: term,
|
|
12
|
+
perPage: SEARCH_RESULTS_PAGE_SIZE,
|
|
13
|
+
fields: {
|
|
14
|
+
SearchResult: ['type', 'title', 'url', 'extra'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getSearchResultsQueryKey = (term: string) => {
|
|
21
|
+
const requestArgs = getSearchResultsRequestArgs(term)
|
|
22
|
+
return getRequestQueryKey(requestArgs)
|
|
23
|
+
}
|