@planningcenter/chat-react-native 4.3.0-rc.10 → 4.3.0-rc.12
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/screens/conversation_select_recipients/components/view_more_link_row.d.ts +2 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js +39 -24
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js.map +1 -1
- package/build/screens/search/components/conversation_result_row.d.ts +8 -0
- package/build/screens/search/components/conversation_result_row.d.ts.map +1 -0
- package/build/screens/search/components/conversation_result_row.js +80 -0
- package/build/screens/search/components/conversation_result_row.js.map +1 -0
- package/build/screens/search/components/conversation_results.d.ts +8 -0
- package/build/screens/search/components/conversation_results.d.ts.map +1 -0
- package/build/screens/search/components/conversation_results.js +77 -0
- package/build/screens/search/components/conversation_results.js.map +1 -0
- package/build/screens/search/components/message_result_row.d.ts +8 -0
- package/build/screens/search/components/message_result_row.d.ts.map +1 -0
- package/build/screens/search/components/message_result_row.js +152 -0
- package/build/screens/search/components/message_result_row.js.map +1 -0
- package/build/screens/search/components/result_row.d.ts +10 -0
- package/build/screens/search/components/result_row.d.ts.map +1 -0
- package/build/screens/search/components/result_row.js +102 -0
- package/build/screens/search/components/result_row.js.map +1 -0
- package/build/screens/search/components/results_section.d.ts +9 -0
- package/build/screens/search/components/results_section.d.ts.map +1 -0
- package/build/screens/search/components/results_section.js +51 -0
- package/build/screens/search/components/results_section.js.map +1 -0
- package/build/screens/search/components/snippet.d.ts +8 -0
- package/build/screens/search/components/snippet.d.ts.map +1 -0
- package/build/screens/search/components/snippet.js +68 -0
- package/build/screens/search/components/snippet.js.map +1 -0
- package/build/utils/client/request_helpers.js +1 -1
- package/build/utils/client/request_helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/client.ts +3 -4
- package/src/screens/conversation_select_recipients/components/view_more_link_row.tsx +12 -3
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +55 -0
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +65 -0
- package/src/screens/search/components/__tests__/result_row.test.tsx +33 -0
- package/src/screens/search/components/conversation_result_row.tsx +36 -0
- package/src/screens/search/components/conversation_results.tsx +39 -0
- package/src/screens/search/components/message_result_row.tsx +48 -0
- package/src/screens/search/components/result_row.tsx +58 -0
- package/src/screens/search/components/results_section.tsx +34 -0
- package/src/screens/search/components/snippet.tsx +37 -0
- package/src/utils/client/__tests__/request_helpers.test.ts +40 -0
- package/src/utils/client/request_helpers.ts +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Text } from '../../../components';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function ResultsSection(t0) {
|
|
6
|
+
const $ = _c(6);
|
|
7
|
+
const {
|
|
8
|
+
title,
|
|
9
|
+
footer,
|
|
10
|
+
children
|
|
11
|
+
} = t0;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== title) {
|
|
14
|
+
t1 = /*#__PURE__*/_jsx(View, {
|
|
15
|
+
style: styles.headingRow,
|
|
16
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
17
|
+
accessibilityRole: "header",
|
|
18
|
+
style: styles.heading,
|
|
19
|
+
children: title
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
$[0] = title;
|
|
23
|
+
$[1] = t1;
|
|
24
|
+
} else {
|
|
25
|
+
t1 = $[1];
|
|
26
|
+
}
|
|
27
|
+
let t2;
|
|
28
|
+
if ($[2] !== children || $[3] !== footer || $[4] !== t1) {
|
|
29
|
+
t2 = /*#__PURE__*/_jsxs(View, {
|
|
30
|
+
children: [t1, children, footer]
|
|
31
|
+
});
|
|
32
|
+
$[2] = children;
|
|
33
|
+
$[3] = footer;
|
|
34
|
+
$[4] = t1;
|
|
35
|
+
$[5] = t2;
|
|
36
|
+
} else {
|
|
37
|
+
t2 = $[5];
|
|
38
|
+
}
|
|
39
|
+
return t2;
|
|
40
|
+
}
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
headingRow: {
|
|
43
|
+
paddingHorizontal: 16,
|
|
44
|
+
paddingTop: 16,
|
|
45
|
+
paddingBottom: 8
|
|
46
|
+
},
|
|
47
|
+
heading: {
|
|
48
|
+
fontWeight: '600'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=results_section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results_section.js","names":["StyleSheet","View","Text","jsx","_jsx","jsxs","_jsxs","ResultsSection","t0","$","_c","title","footer","children","t1","style","styles","headingRow","accessibilityRole","heading","t2","create","paddingHorizontal","paddingTop","paddingBottom","fontWeight"],"sources":["../../../../src/screens/search/components/results_section.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Text } from '../../../components'\n\ninterface ResultsSectionProps {\n title: string\n footer?: ReactNode\n children: ReactNode\n}\n\nexport function ResultsSection({ title, footer, children }: ResultsSectionProps) {\n return (\n <View>\n <View style={styles.headingRow}>\n <Text accessibilityRole=\"header\" style={styles.heading}>\n {title}\n </Text>\n </View>\n {children}\n {footer}\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n headingRow: {\n paddingHorizontal: 16,\n paddingTop: 16,\n paddingBottom: 8,\n },\n heading: {\n fontWeight: '600',\n },\n})\n"],"mappings":";AACA,SAASA,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,IAAI,QAAQ,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQ1C,OAAO,SAAAC,eAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAwB;IAAAC,KAAA;IAAAC,MAAA;IAAAC;EAAA,IAAAL,EAAgD;EAAA,IAAAM,EAAA;EAAA,IAAAL,CAAA,QAAAE,KAAA;IAGzEG,EAAA,gBAAAV,IAAA,CAACH,IAAI;MAAQc,KAAiB,EAAjBC,MAAM,CAAAC,UAAW;MAAAJ,QAAA,eAC5BT,IAAA,CAACF,IAAI;QAAmBgB,iBAAQ,EAAR,QAAQ;QAAQH,KAAc,EAAdC,MAAM,CAAAG,OAAQ;QAAAN,QAAA,EACnDF;MAAK,CACF;IAAC,CACH,CAAC;IAAAF,CAAA,MAAAE,KAAA;IAAAF,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EAAA,IAAAW,EAAA;EAAA,IAAAX,CAAA,QAAAI,QAAA,IAAAJ,CAAA,QAAAG,MAAA,IAAAH,CAAA,QAAAK,EAAA;IALTM,EAAA,gBAAAd,KAAA,CAACL,IAAI;MAAAY,QAAA,GACHC,EAIO,EACND,QAAQ,EACRD,MAAM;IAAA,CACH,CAAC;IAAAH,CAAA,MAAAI,QAAA;IAAAJ,CAAA,MAAAG,MAAA;IAAAH,CAAA,MAAAK,EAAA;IAAAL,CAAA,MAAAW,EAAA;EAAA;IAAAA,EAAA,GAAAX,CAAA;EAAA;EAAA,OARPW,EAQO;AAAA;AAIX,MAAMJ,MAAM,GAAGhB,UAAU,CAACqB,MAAM,CAAC;EAC/BJ,UAAU,EAAE;IACVK,iBAAiB,EAAE,EAAE;IACrBC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE;EACjB,CAAC;EACDL,OAAO,EAAE;IACPM,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SnippetSegment } from '../../../types/resources/search_result';
|
|
2
|
+
interface SnippetProps {
|
|
3
|
+
segments: SnippetSegment[];
|
|
4
|
+
}
|
|
5
|
+
export declare function Snippet({ segments }: SnippetProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function plainSnippetText(segments: SnippetSegment[]): string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=snippet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../../../src/screens/search/components/snippet.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAE5E,UAAU,YAAY;IACpB,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B;AAED,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,YAAY,2CAYjD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAE1D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { Text } from '../../../components/display';
|
|
5
|
+
import { useTheme } from '../../../hooks';
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
export function Snippet(t0) {
|
|
8
|
+
const $ = _c(7);
|
|
9
|
+
const {
|
|
10
|
+
segments
|
|
11
|
+
} = t0;
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
let t1;
|
|
14
|
+
if ($[0] !== segments || $[1] !== styles) {
|
|
15
|
+
let t2;
|
|
16
|
+
if ($[3] !== styles) {
|
|
17
|
+
t2 = (segment, index) => /*#__PURE__*/_jsx(Text, {
|
|
18
|
+
variant: "tertiary",
|
|
19
|
+
style: segment.match && styles.match,
|
|
20
|
+
children: segment.text
|
|
21
|
+
}, index);
|
|
22
|
+
$[3] = styles;
|
|
23
|
+
$[4] = t2;
|
|
24
|
+
} else {
|
|
25
|
+
t2 = $[4];
|
|
26
|
+
}
|
|
27
|
+
t1 = segments.map(t2);
|
|
28
|
+
$[0] = segments;
|
|
29
|
+
$[1] = styles;
|
|
30
|
+
$[2] = t1;
|
|
31
|
+
} else {
|
|
32
|
+
t1 = $[2];
|
|
33
|
+
}
|
|
34
|
+
let t2;
|
|
35
|
+
if ($[5] !== t1) {
|
|
36
|
+
t2 = /*#__PURE__*/_jsx(_Fragment, {
|
|
37
|
+
children: t1
|
|
38
|
+
});
|
|
39
|
+
$[5] = t1;
|
|
40
|
+
$[6] = t2;
|
|
41
|
+
} else {
|
|
42
|
+
t2 = $[6];
|
|
43
|
+
}
|
|
44
|
+
return t2;
|
|
45
|
+
}
|
|
46
|
+
export function plainSnippetText(segments) {
|
|
47
|
+
return segments.map(segment => segment.text).join('');
|
|
48
|
+
}
|
|
49
|
+
const useStyles = () => {
|
|
50
|
+
const $ = _c(2);
|
|
51
|
+
const {
|
|
52
|
+
colors
|
|
53
|
+
} = useTheme();
|
|
54
|
+
let t0;
|
|
55
|
+
if ($[0] !== colors.interaction) {
|
|
56
|
+
t0 = StyleSheet.create({
|
|
57
|
+
match: {
|
|
58
|
+
color: colors.interaction
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
$[0] = colors.interaction;
|
|
62
|
+
$[1] = t0;
|
|
63
|
+
} else {
|
|
64
|
+
t0 = $[1];
|
|
65
|
+
}
|
|
66
|
+
return t0;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=snippet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.js","names":["React","StyleSheet","Text","useTheme","jsx","_jsx","Fragment","_Fragment","Snippet","t0","$","_c","segments","styles","useStyles","t1","t2","segment","index","variant","style","match","children","text","map","plainSnippetText","join","colors","interaction","create","color"],"sources":["../../../../src/screens/search/components/snippet.tsx"],"sourcesContent":["import React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Text } from '../../../components/display'\nimport { useTheme } from '../../../hooks'\nimport type { SnippetSegment } from '../../../types/resources/search_result'\n\ninterface SnippetProps {\n segments: SnippetSegment[]\n}\n\nexport function Snippet({ segments }: SnippetProps) {\n const styles = useStyles()\n\n return (\n <>\n {segments.map((segment, index) => (\n <Text key={index} variant=\"tertiary\" style={segment.match && styles.match}>\n {segment.text}\n </Text>\n ))}\n </>\n )\n}\n\nexport function plainSnippetText(segments: SnippetSegment[]) {\n return segments.map(segment => segment.text).join('')\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n match: {\n color: colors.interaction,\n },\n })\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,IAAI,QAAQ,6BAA6B;AAClD,SAASC,QAAQ,QAAQ,gBAAgB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAOzC,OAAO,SAAAC,QAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAiB;IAAAC;EAAA,IAAAH,EAA0B;EAChD,MAAAI,MAAA,GAAeC,SAAS,CAAC,CAAC;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAE,QAAA,IAAAF,CAAA,QAAAG,MAAA;IAAA,IAAAG,EAAA;IAAA,IAAAN,CAAA,QAAAG,MAAA;MAIRG,EAAA,GAAAA,CAAAC,OAAA,EAAAC,KAAA,kBACZb,IAAA,CAACH,IAAI;QAAqBiB,OAAU,EAAV,UAAU;QAAQC,KAA6B,EAA7BH,OAAO,CAAAI,KAAsB,IAAZR,MAAM,CAAAQ,KAAM;QAAAC,QAAA,EACtEL,OAAO,CAAAM;MAAK,GADJL,KAEL,CACP;MAAAR,CAAA,MAAAG,MAAA;MAAAH,CAAA,MAAAM,EAAA;IAAA;MAAAA,EAAA,GAAAN,CAAA;IAAA;IAJAK,EAAA,GAAAH,QAAQ,CAAAY,GAAI,CAACR,EAIb,CAAC;IAAAN,CAAA,MAAAE,QAAA;IAAAF,CAAA,MAAAG,MAAA;IAAAH,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EAAA,IAAAM,EAAA;EAAA,IAAAN,CAAA,QAAAK,EAAA;IALJC,EAAA,gBAAAX,IAAA,CAAAE,SAAA;MAAAe,QAAA,EACGP;IAIC,CACF,CAAC;IAAAL,CAAA,MAAAK,EAAA;IAAAL,CAAA,MAAAM,EAAA;EAAA;IAAAA,EAAA,GAAAN,CAAA;EAAA;EAAA,OANHM,EAMG;AAAA;AAIP,OAAO,SAASS,gBAAgBA,CAACb,QAA0B,EAAE;EAC3D,OAAOA,QAAQ,CAACY,GAAG,CAACP,OAAO,IAAIA,OAAO,CAACM,IAAI,CAAC,CAACG,IAAI,CAAC,EAAE,CAAC;AACvD;AAEA,MAAMZ,SAAS,GAAGA,CAAA;EAAA,MAAAJ,CAAA,GAAAC,EAAA;EAChB;IAAAgB;EAAA,IAAmBxB,QAAQ,CAAC,CAAC;EAAA,IAAAM,EAAA;EAAA,IAAAC,CAAA,QAAAiB,MAAA,CAAAC,WAAA;IAEtBnB,EAAA,GAAAR,UAAU,CAAA4B,MAAO,CAAC;MAAAR,KAAA,EAChB;QAAAS,KAAA,EACEH,MAAM,CAAAC;MACf;IACF,CAAC,CAAC;IAAAlB,CAAA,MAAAiB,MAAA,CAAAC,WAAA;IAAAlB,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OAJKD,EAIL;AAAA,CACH","ignoreList":[]}
|
|
@@ -27,7 +27,7 @@ export const makeRequest = ({
|
|
|
27
27
|
uri = uri.query(combinedQuery);
|
|
28
28
|
}
|
|
29
29
|
const body = ['POST', 'PATCH'].includes(action) ? JSON.stringify(data) : undefined;
|
|
30
|
-
return instrumentedFetch(
|
|
30
|
+
return instrumentedFetch(uri.toString(), {
|
|
31
31
|
method: action,
|
|
32
32
|
headers,
|
|
33
33
|
body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request_helpers.js","names":["_","URI","instrumentedFetch","transformRequestData","transformResponse","makeRequest","action","url","data","headers","uri","query","urlQuery","combinedQuery","Object","entries","sort","reduce","obj","key","value","body","includes","JSON","stringify","undefined","
|
|
1
|
+
{"version":3,"file":"request_helpers.js","names":["_","URI","instrumentedFetch","transformRequestData","transformResponse","makeRequest","action","url","data","headers","uri","query","urlQuery","combinedQuery","Object","entries","sort","reduce","obj","key","value","body","includes","JSON","stringify","undefined","toString","method","then","response","ok","text","t","parse","Promise","reject","STANDARD_META_ATTRIBUTES","concatRecords","records","moreRecords","included","meta","pick","throwErrorIfFieldsMissing","walk","args","fields","Error","fieldTypes","keys","dataTypes","castArray","map","includedTypes","responseTypes","uniq","concat","missingFields","difference","filter","length","friendlyErrors","throwErrorIfQueryParams","noQueryParamsFriendlyErrors","request","passthrough","resolve","ensureFieldsInDev","__DEV__","ensureNoQueryParamsInDev","search","transformGetToPost","rest","include","fieldsArray","Array","isArray","join","fromEntries"],"sources":["../../../src/utils/client/request_helpers.ts"],"sourcesContent":["import _ from 'lodash'\nimport URI from 'urijs'\nimport { instrumentedFetch } from './instrumented_fetch'\nimport { transformRequestData } from './transform_request_data'\nimport transformResponse from './transform_response'\nimport { Accumulator, GetRequest, PostRequest, RequestData, WalkRequest } from './types'\n\nexport type MakeRequestArgs = {\n action: 'GET' | 'POST' | 'PATCH' | 'DELETE'\n url: string\n data?: Partial<RequestData>\n headers: Record<string, string>\n}\n\nexport const makeRequest = ({ action = 'GET', url, data = {}, headers = {} }: MakeRequestArgs) => {\n // break apart url so we can reconstruct the url with the query params\n let uri = new URI(url)\n const query = transformRequestData(data)\n const urlQuery = uri.query(true)\n\n // This likely doesn't matter but will enforce consistent ordering of query params\n const combinedQuery = Object.entries({ ...query, ...urlQuery })\n .sort()\n .reduce((obj, [key, value]) => {\n // @ts-ignore\n obj[key] = value\n return obj\n }, {})\n\n if (action === 'GET') {\n uri = uri.query(combinedQuery)\n }\n\n const body = ['POST', 'PATCH'].includes(action) ? JSON.stringify(data) : undefined\n\n return instrumentedFetch(uri.toString(), {\n method: action,\n headers,\n body,\n }).then(response => {\n if (response.ok) {\n return response.text().then(t => (t === '' ? '' : JSON.parse(t)))\n } else {\n return Promise.reject(response)\n }\n })\n}\n\nconst STANDARD_META_ATTRIBUTES = [\n 'total_count',\n 'count',\n 'prev',\n 'next',\n 'can_order_by',\n 'can_query_by',\n 'can_include',\n 'can_filter',\n 'parent',\n]\n\nexport const concatRecords = (records: Accumulator, moreRecords: Accumulator) => ({\n data: [...records.data, ...moreRecords.data],\n included: [...records.included, ...moreRecords.included],\n // Because custom meta can be computed on a per-page bases,\n // it is safer to remove all custom meta when concatenating multiple pages of data\n meta: _.pick(moreRecords.meta, STANDARD_META_ATTRIBUTES),\n})\n\ntype Walk = (args: MakeRequestArgs | WalkRequest) => Promise<any>\ntype WalkArgs = MakeRequestArgs & {\n data?: {\n fields?: Record<string, any>\n }\n}\n\nexport const throwErrorIfFieldsMissing = async (walk: Walk, args: WalkArgs) => {\n const fields = args?.data?.fields\n\n if (!fields) {\n throw new Error(`Must pass fields for request: ${args.url}`)\n }\n\n const fieldTypes = Object.keys(fields)\n\n const response = await walk(args)\n\n const dataTypes = _(response.data).castArray().map('type').value()\n const includedTypes = _.map(response.included, 'type')\n const responseTypes = _.uniq(dataTypes.concat(includedTypes))\n const missingFields = _.difference(responseTypes, fieldTypes).filter(t => t)\n\n if (missingFields.length > 0) {\n throw new Error(\n `Must include fields for types: ${JSON.stringify(missingFields)} for request ${args.url}`\n )\n }\n\n return transformResponse(response)\n}\n\nexport const friendlyErrors = (walk: Walk, args: WalkArgs) =>\n throwErrorIfQueryParams(args.url)\n .then(() => throwErrorIfFieldsMissing(walk, args))\n .then(transformResponse)\n\nexport const noQueryParamsFriendlyErrors = (request: typeof makeRequest, args: WalkArgs) =>\n throwErrorIfQueryParams(args.url)\n .then(() => request(args))\n .then(transformResponse)\n\nconst passthrough = async <T, R>(walk: (args: T) => Promise<R>, args: T) =>\n Promise.resolve(transformResponse(await walk(args)))\n\nexport const ensureFieldsInDev = __DEV__ ? friendlyErrors : passthrough\n\nexport const ensureNoQueryParamsInDev = __DEV__ ? noQueryParamsFriendlyErrors : passthrough\n\nexport const throwErrorIfQueryParams = (url: string) => {\n if (new URI(url).search().length) {\n throw new Error('Must pass query params as data arg')\n }\n\n return Promise.resolve()\n}\n\nexport const transformGetToPost = (args: GetRequest): PostRequest => {\n const { data, ...rest } = args\n const { fields, include } = data\n const fieldsArray = Object.entries(fields).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [key, value.join(',')]\n }\n\n return [key, value]\n })\n\n return {\n ...rest,\n data: {\n fields: Object.fromEntries(fieldsArray),\n include,\n },\n }\n}\n"],"mappings":"AAAA,OAAOA,CAAC,MAAM,QAAQ;AACtB,OAAOC,GAAG,MAAM,OAAO;AACvB,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,OAAOC,iBAAiB,MAAM,sBAAsB;AAUpD,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,MAAM,GAAG,KAAK;EAAEC,GAAG;EAAEC,IAAI,GAAG,CAAC,CAAC;EAAEC,OAAO,GAAG,CAAC;AAAmB,CAAC,KAAK;EAChG;EACA,IAAIC,GAAG,GAAG,IAAIT,GAAG,CAACM,GAAG,CAAC;EACtB,MAAMI,KAAK,GAAGR,oBAAoB,CAACK,IAAI,CAAC;EACxC,MAAMI,QAAQ,GAAGF,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC;;EAEhC;EACA,MAAME,aAAa,GAAGC,MAAM,CAACC,OAAO,CAAC;IAAE,GAAGJ,KAAK;IAAE,GAAGC;EAAS,CAAC,CAAC,CAC5DI,IAAI,CAAC,CAAC,CACNC,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IAC7B;IACAF,GAAG,CAACC,GAAG,CAAC,GAAGC,KAAK;IAChB,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;EAER,IAAIZ,MAAM,KAAK,KAAK,EAAE;IACpBI,G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EACrB,CAAC,CAAC;EAEF,OAAO;IACL,GAAGoD,IAAI;IACPhE,IAAI,EAAE;MACJsC,MAAM,EAAEhC,MAAM,CAACgE,WAAW,CAACJ,WAAW,CAAC;MACvCD;IACF;EACF,CAAC;AACH,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.12",
|
|
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": "54ba2e2583cf283c4154fe96045ca7c5e5088fd5"
|
|
88
88
|
}
|
|
@@ -59,8 +59,7 @@ describe('get', () => {
|
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
expect(fetchSpy).toHaveBeenCalledWith(
|
|
62
|
-
|
|
63
|
-
APP_BASE_URL + '/records?fields[Record]=id&per_page=100&where[id]=1',
|
|
62
|
+
APP_BASE_URL + '/records?fields%5BRecord%5D=id&per_page=100&where%5Bid%5D=1',
|
|
64
63
|
expect.any(Object)
|
|
65
64
|
)
|
|
66
65
|
})
|
|
@@ -75,7 +74,7 @@ describe('get', () => {
|
|
|
75
74
|
})
|
|
76
75
|
|
|
77
76
|
it('walks pagination when walk = true', async () => {
|
|
78
|
-
const expectUrl = APP_BASE_URL + '/records?fields
|
|
77
|
+
const expectUrl = APP_BASE_URL + '/records?fields%5BRecord%5D=id&per_page=1'
|
|
79
78
|
const nextUrl = expectUrl + '&offset=1'
|
|
80
79
|
|
|
81
80
|
MockServer.get(url, { ...DefaultFixtures.records(), links: { next: nextUrl } }, 200, {
|
|
@@ -92,7 +91,7 @@ describe('get', () => {
|
|
|
92
91
|
})
|
|
93
92
|
|
|
94
93
|
it('does not overwrite params in `url` when walking', async () => {
|
|
95
|
-
const expectUrl = APP_BASE_URL + '/records?fields
|
|
94
|
+
const expectUrl = APP_BASE_URL + '/records?fields%5BRecord%5D=id'
|
|
96
95
|
const nextUrl = expectUrl + '&offset=1&per_page=1'
|
|
97
96
|
MockServer.get(url, { ...DefaultFixtures.records(), links: { next: nextUrl } }, 200, {
|
|
98
97
|
once: true,
|
|
@@ -4,15 +4,24 @@ import { TextButton } from '../../../components'
|
|
|
4
4
|
interface ViewMoreLinkRowProps {
|
|
5
5
|
onPress: () => void
|
|
6
6
|
accessibilityHint: string
|
|
7
|
+
expanded?: boolean
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const ViewMoreLinkRow = ({
|
|
10
|
+
export const ViewMoreLinkRow = ({
|
|
11
|
+
accessibilityHint,
|
|
12
|
+
expanded = false,
|
|
13
|
+
onPress,
|
|
14
|
+
}: ViewMoreLinkRowProps) => {
|
|
10
15
|
const styles = useRowStyles()
|
|
11
16
|
|
|
12
17
|
return (
|
|
13
18
|
<View style={[styles.row]}>
|
|
14
|
-
<TextButton
|
|
15
|
-
|
|
19
|
+
<TextButton
|
|
20
|
+
onPress={onPress}
|
|
21
|
+
accessibilityHint={accessibilityHint}
|
|
22
|
+
accessibilityState={{ expanded }}
|
|
23
|
+
>
|
|
24
|
+
{expanded ? 'View less' : 'View more'}
|
|
16
25
|
</TextButton>
|
|
17
26
|
</View>
|
|
18
27
|
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { ConversationSearchResultResource } from '../../../../types'
|
|
4
|
+
import { ConversationResults } from '../conversation_results'
|
|
5
|
+
|
|
6
|
+
const buildResults = (count: number, prefix = 'Conversation') =>
|
|
7
|
+
Array.from({ length: count }, (_, index) => ({
|
|
8
|
+
type: 'conversation' as const,
|
|
9
|
+
id: `${prefix}-${index + 1}`,
|
|
10
|
+
title: `${prefix} ${index + 1}`,
|
|
11
|
+
url: `/conversations/${index + 1}`,
|
|
12
|
+
extra: { avatar: { previewAvatarUrls: [] } },
|
|
13
|
+
})) satisfies ConversationSearchResultResource[]
|
|
14
|
+
|
|
15
|
+
describe('ConversationResults', () => {
|
|
16
|
+
it('caps at five rows until View more is pressed, then offers View less', () => {
|
|
17
|
+
const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
18
|
+
|
|
19
|
+
expect(view.getByText('Conversation 5')).toBeTruthy()
|
|
20
|
+
expect(view.queryByText('Conversation 6')).toBeNull()
|
|
21
|
+
|
|
22
|
+
fireEvent.press(view.getByText('View more'))
|
|
23
|
+
|
|
24
|
+
expect(view.getByText('Conversation 6')).toBeTruthy()
|
|
25
|
+
expect(view.getByText('View less')).toBeTruthy()
|
|
26
|
+
expect(view.queryByText('View more')).toBeNull()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('renders no footer for five or fewer results', () => {
|
|
30
|
+
const view = render(<ConversationResults results={buildResults(4)} onSelect={jest.fn()} />)
|
|
31
|
+
|
|
32
|
+
expect(view.getByText('Conversation 4')).toBeTruthy()
|
|
33
|
+
expect(view.queryByText('View more')).toBeNull()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('stays expanded when the parent re-renders with a new results array', () => {
|
|
37
|
+
const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
38
|
+
fireEvent.press(view.getByText('View more'))
|
|
39
|
+
|
|
40
|
+
view.rerender(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
41
|
+
|
|
42
|
+
expect(view.getByText('Conversation 6')).toBeTruthy()
|
|
43
|
+
expect(view.getByText('View less')).toBeTruthy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('passes the pressed result to onSelect', () => {
|
|
47
|
+
const onSelect = jest.fn()
|
|
48
|
+
const results = buildResults(2)
|
|
49
|
+
const view = render(<ConversationResults results={results} onSelect={onSelect} />)
|
|
50
|
+
|
|
51
|
+
fireEvent.press(view.getByText('Conversation 2'))
|
|
52
|
+
|
|
53
|
+
expect(onSelect).toHaveBeenCalledWith(results[1])
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { MessageSearchResultResource } from '../../../../types/resources/search_result'
|
|
4
|
+
import { formatDatePreview } from '../../../../utils/date'
|
|
5
|
+
import { defaultTheme } from '../../../../utils/theme'
|
|
6
|
+
import { MessageResultRow } from '../message_result_row'
|
|
7
|
+
|
|
8
|
+
const result: MessageSearchResultResource = {
|
|
9
|
+
id: '42',
|
|
10
|
+
type: 'message',
|
|
11
|
+
title: 'Worship Team',
|
|
12
|
+
url: '/conversations/7?message_id=42',
|
|
13
|
+
extra: {
|
|
14
|
+
conversationId: 7,
|
|
15
|
+
authorName: 'Ada Lovelace',
|
|
16
|
+
snippet: [
|
|
17
|
+
{ text: '…planning the ', match: false },
|
|
18
|
+
{ text: 'budget', match: true },
|
|
19
|
+
{ text: ' meeting for next week', match: false },
|
|
20
|
+
],
|
|
21
|
+
createdAt: '2026-03-04T15:30:00Z',
|
|
22
|
+
avatar: {
|
|
23
|
+
customAvatarType: null,
|
|
24
|
+
customAvatarKey: null,
|
|
25
|
+
customAvatarColor: null,
|
|
26
|
+
customAvatarImageUrl: null,
|
|
27
|
+
previewAvatarUrls: [],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const interactionColor = defaultTheme('light').colors.interaction
|
|
33
|
+
|
|
34
|
+
describe('MessageResultRow', () => {
|
|
35
|
+
it('renders the title, author, snippet, and date', () => {
|
|
36
|
+
const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
37
|
+
|
|
38
|
+
expect(view.getByText('Worship Team')).toBeTruthy()
|
|
39
|
+
expect(view.getByText('Ada Lovelace:', { exact: false })).toBeTruthy()
|
|
40
|
+
expect(view.getByText('…planning the ')).toBeTruthy()
|
|
41
|
+
expect(view.getByText('budget')).toBeTruthy()
|
|
42
|
+
expect(view.getByText(' meeting for next week')).toBeTruthy()
|
|
43
|
+
expect(view.getByText(formatDatePreview(result.extra.createdAt))).toBeTruthy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('colors matched segments with the interaction color', () => {
|
|
47
|
+
const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
48
|
+
|
|
49
|
+
expect(view.getByText('budget')).toHaveStyle({ color: interactionColor })
|
|
50
|
+
expect(view.getByText('…planning the ')).not.toHaveStyle({ color: interactionColor })
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('exposes the row as a button with a composed label and reports presses', () => {
|
|
54
|
+
const onPress = jest.fn()
|
|
55
|
+
const date = formatDatePreview(result.extra.createdAt)
|
|
56
|
+
const view = render(<MessageResultRow result={result} onPress={onPress} />)
|
|
57
|
+
|
|
58
|
+
const row = view.getByRole('button', {
|
|
59
|
+
name: `Worship Team, Ada Lovelace: …planning the budget meeting for next week, ${date}`,
|
|
60
|
+
})
|
|
61
|
+
fireEvent.press(row)
|
|
62
|
+
|
|
63
|
+
expect(onPress).toHaveBeenCalledWith(result)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Text } from 'react-native'
|
|
4
|
+
import { useAtFontScaleBreakpoint } from '../../../../hooks/use_at_font_scale_breakpoint'
|
|
5
|
+
import { ResultRow } from '../result_row'
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../../hooks/use_at_font_scale_breakpoint')
|
|
8
|
+
|
|
9
|
+
const mockUseAtFontScaleBreakpoint = jest.mocked(useAtFontScaleBreakpoint)
|
|
10
|
+
|
|
11
|
+
describe('ResultRow', () => {
|
|
12
|
+
it('lays children out in a row below the font scale breakpoint', () => {
|
|
13
|
+
mockUseAtFontScaleBreakpoint.mockReturnValue(false)
|
|
14
|
+
const view = render(
|
|
15
|
+
<ResultRow accessibilityLabel="Row" onPress={jest.fn()} alignItems="center">
|
|
16
|
+
<Text>child</Text>
|
|
17
|
+
</ResultRow>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
expect(view.getByRole('button')).toHaveStyle({ flexDirection: 'row', alignItems: 'center' })
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('stacks children at the font scale breakpoint', () => {
|
|
24
|
+
mockUseAtFontScaleBreakpoint.mockReturnValue(true)
|
|
25
|
+
const view = render(
|
|
26
|
+
<ResultRow accessibilityLabel="Row" onPress={jest.fn()} alignItems="center">
|
|
27
|
+
<Text>child</Text>
|
|
28
|
+
</ResultRow>
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
expect(view.getByRole('button')).toHaveStyle({ flexDirection: 'column', alignItems: 'stretch' })
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native'
|
|
2
|
+
import { ConversationAvatar, Heading } from '../../../components'
|
|
3
|
+
import { useScalableNumberOfLines, useTheme } from '../../../hooks'
|
|
4
|
+
import type { ConversationSearchResultResource } from '../../../types'
|
|
5
|
+
import { ResultRow } from './result_row'
|
|
6
|
+
|
|
7
|
+
interface ConversationResultRowProps {
|
|
8
|
+
result: ConversationSearchResultResource
|
|
9
|
+
onPress: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ConversationResultRow({ result, onPress }: ConversationResultRowProps) {
|
|
13
|
+
const styles = useStyles()
|
|
14
|
+
const numberOfLines = useScalableNumberOfLines(1)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ResultRow accessibilityLabel={result.title} onPress={onPress} alignItems="center">
|
|
18
|
+
<ConversationAvatar conversation={result.extra.avatar} size="lg" />
|
|
19
|
+
<Heading variant="h3" numberOfLines={numberOfLines} style={styles.title}>
|
|
20
|
+
{result.title}
|
|
21
|
+
</Heading>
|
|
22
|
+
</ResultRow>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const useStyles = () => {
|
|
27
|
+
const { colors } = useTheme()
|
|
28
|
+
|
|
29
|
+
return StyleSheet.create({
|
|
30
|
+
title: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
fontSize: 16,
|
|
33
|
+
color: colors.textColorDefaultPrimary,
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import type { ConversationSearchResultResource } from '../../../types'
|
|
3
|
+
import { ViewMoreLinkRow } from '../../conversation_select_recipients/components/view_more_link_row'
|
|
4
|
+
import { ConversationResultRow } from './conversation_result_row'
|
|
5
|
+
import { ResultsSection } from './results_section'
|
|
6
|
+
|
|
7
|
+
const COLLAPSED_COUNT = 5
|
|
8
|
+
|
|
9
|
+
interface ConversationResultsProps {
|
|
10
|
+
results: ConversationSearchResultResource[]
|
|
11
|
+
onSelect: (result: ConversationSearchResultResource) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ConversationResults({ results, onSelect }: ConversationResultsProps) {
|
|
15
|
+
const [expanded, setExpanded] = useState(false)
|
|
16
|
+
const visible = expanded ? results : results.slice(0, COLLAPSED_COUNT)
|
|
17
|
+
|
|
18
|
+
if (results.length === 0) return null
|
|
19
|
+
|
|
20
|
+
const footer = results.length > COLLAPSED_COUNT && (
|
|
21
|
+
<ViewMoreLinkRow
|
|
22
|
+
expanded={expanded}
|
|
23
|
+
onPress={() => setExpanded(!expanded)}
|
|
24
|
+
accessibilityHint={
|
|
25
|
+
expanded
|
|
26
|
+
? `Shows the first ${COLLAPSED_COUNT} conversation results`
|
|
27
|
+
: `Shows all ${results.length} conversation results`
|
|
28
|
+
}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ResultsSection title="Conversations" footer={footer}>
|
|
34
|
+
{visible.map(result => (
|
|
35
|
+
<ConversationResultRow key={result.id} result={result} onPress={() => onSelect(result)} />
|
|
36
|
+
))}
|
|
37
|
+
</ResultsSection>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { ConversationAvatar, Text } from '../../../components/display'
|
|
4
|
+
import { useScalableNumberOfLines } from '../../../hooks'
|
|
5
|
+
import type { MessageSearchResultResource } from '../../../types/resources/search_result'
|
|
6
|
+
import { platformFontWeightMedium } from '../../../utils'
|
|
7
|
+
import { formatDatePreview } from '../../../utils/date'
|
|
8
|
+
import { ResultRow } from './result_row'
|
|
9
|
+
import { plainSnippetText, Snippet } from './snippet'
|
|
10
|
+
|
|
11
|
+
interface MessageResultRowProps {
|
|
12
|
+
result: MessageSearchResultResource
|
|
13
|
+
onPress: (result: MessageSearchResultResource) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function MessageResultRow({ result, onPress }: MessageResultRowProps) {
|
|
17
|
+
const { authorName, avatar, snippet, createdAt } = result.extra
|
|
18
|
+
const titleNumberOfLines = useScalableNumberOfLines(1)
|
|
19
|
+
const previewNumberOfLines = useScalableNumberOfLines(2)
|
|
20
|
+
const date = formatDatePreview(createdAt)
|
|
21
|
+
const accessibilityLabel = `${result.title}, ${authorName}: ${plainSnippetText(snippet)}, ${date}`
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ResultRow accessibilityLabel={accessibilityLabel} onPress={() => onPress(result)}>
|
|
25
|
+
<ConversationAvatar conversation={avatar} size="lg" />
|
|
26
|
+
<View style={styles.body}>
|
|
27
|
+
<Text numberOfLines={titleNumberOfLines} style={styles.title}>
|
|
28
|
+
{result.title}
|
|
29
|
+
</Text>
|
|
30
|
+
<Text variant="tertiary" numberOfLines={previewNumberOfLines}>
|
|
31
|
+
{authorName}: <Snippet segments={snippet} />
|
|
32
|
+
</Text>
|
|
33
|
+
</View>
|
|
34
|
+
<Text variant="footnote">{date}</Text>
|
|
35
|
+
</ResultRow>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
body: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
rowGap: 2,
|
|
43
|
+
},
|
|
44
|
+
title: {
|
|
45
|
+
fontSize: 16,
|
|
46
|
+
fontWeight: platformFontWeightMedium,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import { useAtFontScaleBreakpoint, useTheme } from '../../../hooks'
|
|
4
|
+
import { platformPressedOpacityStyle } from '../../../utils'
|
|
5
|
+
|
|
6
|
+
interface ResultRowProps {
|
|
7
|
+
accessibilityLabel: string
|
|
8
|
+
onPress: () => void
|
|
9
|
+
alignItems?: 'flex-start' | 'center'
|
|
10
|
+
children: ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ResultRow({
|
|
14
|
+
accessibilityLabel,
|
|
15
|
+
onPress,
|
|
16
|
+
alignItems = 'flex-start',
|
|
17
|
+
children,
|
|
18
|
+
}: ResultRowProps) {
|
|
19
|
+
const { colors } = useTheme()
|
|
20
|
+
const atFontScaleBreakpoint = useAtFontScaleBreakpoint()
|
|
21
|
+
const styles = useStyles()
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Pressable
|
|
25
|
+
accessibilityRole="button"
|
|
26
|
+
accessibilityLabel={accessibilityLabel}
|
|
27
|
+
onPress={onPress}
|
|
28
|
+
style={({ pressed }) => [
|
|
29
|
+
styles.row,
|
|
30
|
+
atFontScaleBreakpoint ? styles.stacked : { alignItems },
|
|
31
|
+
pressed && platformPressedOpacityStyle,
|
|
32
|
+
]}
|
|
33
|
+
android_ripple={{ color: colors.androidRippleNeutral, borderless: false, foreground: true }}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</Pressable>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const useStyles = () => {
|
|
41
|
+
const { colors } = useTheme()
|
|
42
|
+
|
|
43
|
+
return StyleSheet.create({
|
|
44
|
+
row: {
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
gap: 8,
|
|
47
|
+
paddingVertical: 12,
|
|
48
|
+
paddingHorizontal: 16,
|
|
49
|
+
borderBottomWidth: 1,
|
|
50
|
+
borderBottomColor: colors.borderColorDefaultDim,
|
|
51
|
+
},
|
|
52
|
+
stacked: {
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
alignItems: 'stretch',
|
|
55
|
+
borderBottomColor: colors.borderColorDefaultDark,
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { Text } from '../../../components'
|
|
4
|
+
|
|
5
|
+
interface ResultsSectionProps {
|
|
6
|
+
title: string
|
|
7
|
+
footer?: ReactNode
|
|
8
|
+
children: ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ResultsSection({ title, footer, children }: ResultsSectionProps) {
|
|
12
|
+
return (
|
|
13
|
+
<View>
|
|
14
|
+
<View style={styles.headingRow}>
|
|
15
|
+
<Text accessibilityRole="header" style={styles.heading}>
|
|
16
|
+
{title}
|
|
17
|
+
</Text>
|
|
18
|
+
</View>
|
|
19
|
+
{children}
|
|
20
|
+
{footer}
|
|
21
|
+
</View>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const styles = StyleSheet.create({
|
|
26
|
+
headingRow: {
|
|
27
|
+
paddingHorizontal: 16,
|
|
28
|
+
paddingTop: 16,
|
|
29
|
+
paddingBottom: 8,
|
|
30
|
+
},
|
|
31
|
+
heading: {
|
|
32
|
+
fontWeight: '600',
|
|
33
|
+
},
|
|
34
|
+
})
|