Skip to content

Commit 947f9c6

Browse files
authored
Merge pull request Expensify#41077 from software-mansion-labs/war-in/options-selector-removal
[TS migration] Remove 'OptionsSelector' component
2 parents 76846da + 8cc152c commit 947f9c6

19 files changed

+24
-178
lines changed

src/CONST.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3584,10 +3584,10 @@ const CONST = {
35843584
BACK_BUTTON_NATIVE_ID: 'backButton',
35853585

35863586
/**
3587-
* The maximum count of items per page for OptionsSelector.
3587+
* The maximum count of items per page for SelectionList.
35883588
* When paginate, it multiplies by page number.
35893589
*/
3590-
MAX_OPTIONS_SELECTOR_PAGE_LENGTH: 500,
3590+
MAX_SELECTION_LIST_PAGE_LENGTH: 500,
35913591

35923592
/**
35933593
* Bank account names

src/components/ArrowKeyFocusManager.js

-142
This file was deleted.

src/components/MoneyRequestConfirmationList.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,9 @@ function MoneyRequestConfirmationList({
506506
hideCurrencySymbol
507507
formatAmountOnBlur
508508
prefixContainerStyle={[styles.pv0]}
509-
inputStyle={
510-
[styles.optionRowAmountInput, StyleUtils.getPaddingLeft(StyleUtils.getCharacterPadding(currencySymbol ?? '') + styles.pl1.paddingLeft), amountWidth] as TextStyle[]
511-
}
509+
inputStyle={[styles.optionRowAmountInput, amountWidth] as TextStyle[]}
512510
containerStyle={[styles.textInputContainer]}
511+
touchableInputWrapperStyle={[styles.ml3]}
513512
onAmountChange={(value: string) => onSplitShareChange(participantOption.accountID ?? 0, Number(value))}
514513
maxLength={formattedTotalAmount.length}
515514
/>
@@ -529,8 +528,8 @@ function MoneyRequestConfirmationList({
529528
styles.textLabel,
530529
styles.pv0,
531530
styles.optionRowAmountInput,
532-
styles.pl1.paddingLeft,
533531
styles.textInputContainer,
532+
styles.ml3,
534533
transaction?.comment?.splits,
535534
transaction?.splitShares,
536535
onSplitShareChange,

src/components/SelectionList/BaseSelectionList.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function BaseSelectionList<TItem extends ListItem>(
171171
}, [canSelectMultiple, sections]);
172172

173173
const [slicedSections, ShowMoreButtonInstance] = useMemo(() => {
174-
let remainingOptionsLimit = CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage;
174+
let remainingOptionsLimit = CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage;
175175
const processedSections = getSectionsWithIndexOffset(
176176
sections.map((section) => {
177177
const data = !isEmpty(section.data) && remainingOptionsLimit > 0 ? section.data.slice(0, remainingOptionsLimit) : [];
@@ -184,11 +184,11 @@ function BaseSelectionList<TItem extends ListItem>(
184184
}),
185185
);
186186

187-
const shouldShowMoreButton = flattenedSections.allOptions.length > CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage;
187+
const shouldShowMoreButton = flattenedSections.allOptions.length > CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage;
188188
const showMoreButton = shouldShowMoreButton ? (
189189
<ShowMoreButton
190190
containerStyle={[styles.mt2, styles.mb5]}
191-
currentCount={CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage}
191+
currentCount={CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage}
192192
totalCount={flattenedSections.allOptions.length}
193193
onPress={incrementPage}
194194
/>
@@ -229,7 +229,7 @@ function BaseSelectionList<TItem extends ListItem>(
229229
// If `initiallyFocusedOptionKey` is not passed, we fall back to `-1`, to avoid showing the highlight on the first member
230230
const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
231231
initialFocusedIndex: flattenedSections.allOptions.findIndex((option) => option.keyForList === initiallyFocusedOptionKey),
232-
maxIndex: Math.min(flattenedSections.allOptions.length - 1, CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage - 1),
232+
maxIndex: Math.min(flattenedSections.allOptions.length - 1, CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage - 1),
233233
disabledIndexes: flattenedSections.disabledOptionsIndexes,
234234
isActive: true,
235235
onFocusedIndexChange: (index: number) => {

src/languages/en.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export default {
412412
splitAmounts: 'Split amounts',
413413
whatsItFor: "What's it for?",
414414
},
415-
optionsSelector: {
415+
selectionList: {
416416
nameEmailOrPhoneNumber: 'Name, email, or phone number',
417417
findMember: 'Find a member',
418418
},

src/languages/es.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ export default {
403403
splitAmounts: 'Importes a dividir',
404404
whatsItFor: '¿Para qué es?',
405405
},
406-
optionsSelector: {
406+
selectionList: {
407407
nameEmailOrPhoneNumber: 'Nombre, email o número de teléfono',
408408
findMember: 'Encuentra un miembro',
409409
},

src/libs/OptionsListUtils.ts

-11
Original file line numberDiff line numberDiff line change
@@ -2042,16 +2042,6 @@ function getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetail: Person
20422042
};
20432043
}
20442044

2045-
/**
2046-
* Build the IOUConfirmationOptions for showing participants
2047-
*/
2048-
function getIOUConfirmationOptionsFromParticipants(participants: Array<Participant | ReportUtils.OptionData>, amountText: string): Array<Participant | ReportUtils.OptionData> {
2049-
return participants.map((participant) => ({
2050-
...participant,
2051-
descriptiveText: amountText,
2052-
}));
2053-
}
2054-
20552045
/**
20562046
* Build the options for the New Group view
20572047
*/
@@ -2416,7 +2406,6 @@ export {
24162406
getSearchValueForPhoneOrEmail,
24172407
getPersonalDetailsForAccountIDs,
24182408
getIOUConfirmationOptionsFromPayeePersonalDetail,
2419-
getIOUConfirmationOptionsFromParticipants,
24202409
getSearchText,
24212410
getAllReportErrors,
24222411
getPolicyExpenseReportOption,

src/pages/ChatFinderPage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa
175175
sections={areOptionsInitialized ? sections : CONST.EMPTY_ARRAY}
176176
ListItem={UserListItem}
177177
textInputValue={searchValue}
178-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
178+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
179179
textInputHint={offlineMessage}
180180
onChangeText={setSearchValue}
181181
headerMessage={headerMessage}

src/pages/InviteReportParticipantsPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
204204
canSelectMultiple
205205
sections={sections}
206206
ListItem={InviteMemberListItem}
207-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
207+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
208208
textInputValue={searchTerm}
209209
onChangeText={setSearchTerm}
210210
headerMessage={headerMessage}

src/pages/NewChatPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) {
306306
textInputValue={searchTerm}
307307
textInputHint={isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''}
308308
onChangeText={setSearchTerm}
309-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
309+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
310310
headerMessage={headerMessage}
311311
onSelectRow={createChat}
312312
onConfirm={(e, option) => (selectedOptions.length > 0 ? createGroup() : createChat(option))}

src/pages/RoomInvitePage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function RoomInvitePage({
241241
canSelectMultiple
242242
sections={sections}
243243
ListItem={UserListItem}
244-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
244+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
245245
textInputValue={searchTerm}
246246
onChangeText={(value) => {
247247
SearchInputManager.searchInput = value;

src/pages/RoomMembersPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
290290
<SelectionList
291291
canSelectMultiple
292292
sections={[{data, isDisabled: false}]}
293-
textInputLabel={translate('optionsSelector.findMember')}
293+
textInputLabel={translate('selectionList.findMember')}
294294
disableKeyboardShortcuts={removeMembersConfirmModalVisible}
295295
textInputValue={searchValue}
296296
onChangeText={(value) => {

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
7777
}, [debouncedSearchTerm]);
7878

7979
/**
80-
* Returns the sections needed for the OptionsSelector
80+
* Returns the sections needed for the SelectionList
8181
*
8282
* @returns {Array}
8383
*/
@@ -353,7 +353,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
353353
sections={areOptionsInitialized ? sections : CONST.EMPTY_ARRAY}
354354
ListItem={InviteMemberListItem}
355355
textInputValue={searchTerm}
356-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
356+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
357357
textInputHint={offlineMessage}
358358
onChangeText={setSearchTerm}
359359
shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}

src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
108108
onChangeText={setSearchValue}
109109
textInputValue={searchValue}
110110
headerMessage={searchOptions.headerMessage}
111-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
111+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
112112
textInputHint={isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''}
113113
showLoadingPlaceholder={!didScreenTransitionEnd}
114114
isLoadingNewOptions={!!isSearchingForReports}

src/pages/tasks/TaskAssigneeSelectorModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function TaskAssigneeSelectorModal({reports, task}: TaskAssigneeSelectorModalPro
220220
onChangeText={setSearchValue}
221221
textInputValue={searchValue}
222222
headerMessage={headerMessage}
223-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
223+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
224224
showLoadingPlaceholder={!areOptionsInitialized}
225225
isLoadingNewOptions={!!isSearchingForReports}
226226
/>

src/pages/tasks/TaskShareDestinationSelectorModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function TaskShareDestinationSelectorModal() {
108108
onChangeText={setSearchValue}
109109
textInputValue={searchValue}
110110
headerMessage={options.headerMessage}
111-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
111+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
112112
showLoadingPlaceholder={areOptionsInitialized && debouncedSearchValue.trim() === '' ? options.sections.length === 0 : !didScreenTransitionEnd}
113113
isLoadingNewOptions={!!isSearchingForReports}
114114
textInputHint={textInputHint}

src/pages/workspace/WorkspaceInvitePage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function WorkspaceInvitePage({route, betas, invitedEmailsToAccountIDsDraft, poli
314314
canSelectMultiple
315315
sections={sections}
316316
ListItem={InviteMemberListItem}
317-
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
317+
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
318318
textInputValue={searchTerm}
319319
onChangeText={(value) => {
320320
SearchInputManager.searchInput = value;

src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function WorkspaceWorkflowsApproverPage({policy, personalDetails, isLoadingRepor
176176
/>
177177
<SelectionList
178178
sections={sections}
179-
textInputLabel={translate('optionsSelector.findMember')}
179+
textInputLabel={translate('selectionList.findMember')}
180180
textInputValue={searchTerm}
181181
onChangeText={setSearchTerm}
182182
headerMessage={headerMessage}

src/pages/workspace/workflows/WorkspaceWorkflowsPayerPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
186186
/>
187187
<SelectionList
188188
sections={sections}
189-
textInputLabel={translate('optionsSelector.findMember')}
189+
textInputLabel={translate('selectionList.findMember')}
190190
textInputValue={searchTerm}
191191
onChangeText={setSearchTerm}
192192
headerMessage={headerMessage}

0 commit comments

Comments
 (0)