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AAO,EAAE;YAClC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;SACpD;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC/B,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;SAC1C;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACH,yBAAC;AAAD,CAAC,AAhTD,CACU,KAAK,CAAC,SAAS,GA+SxB","sourcesContent":["import * as React from 'react';\nimport { KeyCodes, css, initializeComponentRef } from '../../Utilities';\nimport { Autofill } from '../../Autofill';\nimport { IInputProps } from '../../Pickers';\nimport * as stylesImport from './BaseExtendedPicker.scss';\nimport { IBaseExtendedPickerProps, IBaseExtendedPicker } from './BaseExtendedPicker.types';\nimport { IBaseFloatingPickerProps, BaseFloatingPicker } from '../../FloatingPicker';\nimport { BaseSelectedItemsList, IBaseSelectedItemsListProps } from '../../SelectedItemsList';\nimport { FocusZone, FocusZoneDirection } from '../../FocusZone';\nimport { Selection, SelectionMode, SelectionZone } from '../../Selection';\nconst styles: any = stylesImport;\n\nexport interface IBaseExtendedPickerState<T> {\n queryString: string | null;\n selectedItems: T[] | null;\n suggestionItems: T[] | null;\n}\n\nexport class BaseExtendedPicker<T, P extends IBaseExtendedPickerProps<T>>\n extends React.Component<P, IBaseExtendedPickerState<T>>\n implements IBaseExtendedPicker<T> {\n public floatingPicker = React.createRef<BaseFloatingPicker<T, IBaseFloatingPickerProps<T>>>();\n public selectedItemsList = React.createRef<BaseSelectedItemsList<T, IBaseSelectedItemsListProps<T>>>();\n\n protected root = React.createRef<HTMLDivElement>();\n protected input = React.createRef<Autofill>();\n protected selection: Selection;\n protected floatingPickerProps: IBaseFloatingPickerProps<T>;\n protected selectedItemsListProps: IBaseSelectedItemsListProps<T>;\n\n constructor(basePickerProps: P) {\n super(basePickerProps);\n\n initializeComponentRef(this);\n this.selection = new Selection({ onSelectionChanged: () => this.onSelectionChange() });\n\n this.state = {\n queryString: '',\n // TODO: determine whether this can be removed\n // eslint-disable-next-line react/no-unused-state\n suggestionItems: this.props.suggestionItems ? (this.props.suggestionItems as T[]) : null,\n selectedItems: this.props.defaultSelectedItems\n ? (this.props.defaultSelectedItems as T[])\n : this.props.selectedItems\n ? (this.props.selectedItems as T[])\n : null,\n };\n\n this.floatingPickerProps = this.props.floatingPickerProps;\n this.selectedItemsListProps = this.props.selectedItemsListProps;\n }\n\n public get items(): any {\n return this.state.selectedItems ?? this.selectedItemsList.current?.items ?? null;\n }\n\n public componentDidMount(): void {\n this.forceUpdate();\n }\n\n public UNSAFE_componentWillReceiveProps(newProps: P): void {\n if (newProps.floatingPickerProps) {\n this.floatingPickerProps = newProps.floatingPickerProps;\n }\n\n if (newProps.selectedItemsListProps) {\n this.selectedItemsListProps = newProps.selectedItemsListProps;\n }\n\n if (newProps.selectedItems) {\n this.setState({ selectedItems: newProps.selectedItems });\n }\n }\n\n public focus(): void {\n if (this.input.current) {\n this.input.current.focus();\n }\n }\n\n public clearInput(): void {\n if (this.input.current) {\n this.input.current.clear();\n }\n }\n\n public get inputElement(): HTMLInputElement | null {\n return this.input.current && this.input.current.inputElement;\n }\n\n public get highlightedItems(): T[] {\n return this.selectedItemsList.current ? this.selectedItemsList.current.highlightedItems() : [];\n }\n\n public render(): JSX.Element {\n const { className, inputProps, disabled, focusZoneProps } = this.props;\n const activeDescendant =\n this.floatingPicker.current && this.floatingPicker.current.currentSelectedSuggestionIndex !== -1\n ? 'sug-' + this.floatingPicker.current.currentSelectedSuggestionIndex\n : undefined;\n const isExpanded = this.floatingPicker.current ? this.floatingPicker.current.isSuggestionsShown : false;\n\n return (\n <div\n ref={this.root}\n className={css('ms-BasePicker ms-BaseExtendedPicker', className ? className : '')}\n onKeyDown={this.onBackspace}\n onCopy={this.onCopy}\n >\n <FocusZone direction={FocusZoneDirection.bidirectional} {...focusZoneProps}>\n <SelectionZone selection={this.selection} selectionMode={SelectionMode.multiple}>\n <div className={css('ms-BasePicker-text', styles.pickerText)} role={'list'}>\n {this.props.headerComponent}\n {this.renderSelectedItemsList()}\n {this.canAddItems() && (\n <Autofill\n {...(inputProps as IInputProps)}\n className={css('ms-BasePicker-input', styles.pickerInput)}\n ref={this.input}\n onFocus={this.onInputFocus}\n onClick={this.onInputClick}\n onInputValueChange={this.onInputChange}\n aria-activedescendant={activeDescendant}\n aria-owns={isExpanded ? 'suggestion-list' : undefined}\n aria-expanded={isExpanded}\n aria-haspopup=\"true\"\n role=\"combobox\"\n disabled={disabled}\n onPaste={this.onPaste}\n />\n )}\n </div>\n </SelectionZone>\n </FocusZone>\n {this.renderFloatingPicker()}\n </div>\n );\n }\n\n protected onSelectionChange = (): void => {\n this.forceUpdate();\n };\n\n protected canAddItems(): boolean {\n const { itemLimit } = this.props;\n return itemLimit === undefined || this.items.length < itemLimit;\n }\n\n protected renderFloatingPicker(): JSX.Element {\n const FloatingPicker: React.ComponentType<IBaseFloatingPickerProps<T>> = this.props.onRenderFloatingPicker;\n return (\n <FloatingPicker\n componentRef={this.floatingPicker}\n onChange={this._onSuggestionSelected}\n onSuggestionsHidden={this._onSuggestionsShownOrHidden}\n onSuggestionsShown={this._onSuggestionsShownOrHidden}\n inputElement={this.input.current ? this.input.current.inputElement : undefined}\n selectedItems={this.items}\n suggestionItems={this.props.suggestionItems ? this.props.suggestionItems : undefined}\n {...this.floatingPickerProps}\n />\n );\n }\n\n protected renderSelectedItemsList(): JSX.Element {\n const SelectedItems: React.ComponentType<IBaseSelectedItemsListProps<T>> = this.props.onRenderSelectedItems;\n return (\n <SelectedItems\n componentRef={this.selectedItemsList}\n selection={this.selection}\n selectedItems={this.props.selectedItems ? this.props.selectedItems : undefined}\n onItemsDeleted={this.props.selectedItems ? this.props.onItemsRemoved : undefined}\n {...this.selectedItemsListProps}\n />\n );\n }\n\n protected onInputChange = (value: string, composing?: boolean): void => {\n // We don't want to update the picker's suggestions when the input is still being composed\n if (!composing) {\n this.setState({ queryString: value });\n if (this.floatingPicker.current) {\n this.floatingPicker.current.onQueryStringChanged(value);\n }\n }\n };\n\n protected onInputFocus = (ev: React.FocusEvent<HTMLInputElement | Autofill>): void => {\n if (this.selectedItemsList.current) {\n this.selectedItemsList.current.unselectAll();\n }\n\n if (this.props.inputProps && this.props.inputProps.onFocus) {\n this.props.inputProps.onFocus(ev as React.FocusEvent<HTMLInputElement>);\n }\n };\n\n protected onInputClick = (ev: React.MouseEvent<HTMLInputElement | Autofill>): void => {\n if (this.selectedItemsList.current) {\n this.selectedItemsList.current.unselectAll();\n }\n\n if (this.floatingPicker.current && this.inputElement) {\n // Update the value if the input value is empty or is different than the current inputText from the floatingPicker\n const shoudUpdateValue =\n this.inputElement.value === '' || this.inputElement.value !== this.floatingPicker.current.inputText;\n this.floatingPicker.current.showPicker(shoudUpdateValue);\n }\n };\n\n // This is protected because we may expect the backspace key to work differently in a different kind of picker.\n // This lets the subclass override it and provide it's own onBackspace. For an example see the BasePickerListBelow\n protected onBackspace = (ev: React.KeyboardEvent<HTMLElement>): void => {\n if (ev.which !== KeyCodes.backspace) {\n return;\n }\n\n if (this.selectedItemsList.current && this.items.length) {\n if (\n this.input.current &&\n !this.input.current.isValueSelected &&\n this.input.current.inputElement === document.activeElement &&\n (this.input.current as Autofill).cursorLocation === 0\n ) {\n if (this.floatingPicker.current) {\n this.floatingPicker.current.hidePicker();\n }\n ev.preventDefault();\n this.selectedItemsList.current.removeItemAt(this.items.length - 1);\n this._onSelectedItemsChanged();\n } else if (this.selectedItemsList.current.hasSelectedItems()) {\n if (this.floatingPicker.current) {\n this.floatingPicker.current.hidePicker();\n }\n ev.preventDefault();\n this.selectedItemsList.current.removeSelectedItems();\n this._onSelectedItemsChanged();\n }\n }\n };\n\n protected onCopy = (ev: React.ClipboardEvent<HTMLElement>): void => {\n if (this.selectedItemsList.current) {\n // Pass it down into the selected items list\n this.selectedItemsList.current.onCopy(ev);\n }\n };\n\n protected onPaste = (ev: React.ClipboardEvent<Autofill | HTMLInputElement>): void => {\n if (this.props.onPaste) {\n const inputText = ev.clipboardData.getData('Text');\n ev.preventDefault();\n this.props.onPaste(inputText);\n }\n };\n\n protected _onSuggestionSelected = (item: T): void => {\n const currentRenderedQueryString = this.props.currentRenderedQueryString;\n const queryString = this.state.queryString;\n if (currentRenderedQueryString === undefined || currentRenderedQueryString === queryString) {\n const processedItem: T | PromiseLike<T> | null = this.props.onItemSelected\n ? (this.props.onItemSelected as any)(item)\n : item;\n\n if (processedItem === null) {\n return;\n }\n\n const processedItemObject: T = processedItem as T;\n const processedItemPromiseLike: PromiseLike<T> = processedItem as PromiseLike<T>;\n\n let newItem: T;\n if (processedItemPromiseLike && processedItemPromiseLike.then) {\n processedItemPromiseLike.then((resolvedProcessedItem: T) => {\n newItem = resolvedProcessedItem;\n this._addProcessedItem(newItem);\n });\n } else {\n newItem = processedItemObject;\n this._addProcessedItem(newItem);\n }\n }\n };\n\n protected _onSelectedItemsChanged = (): void => {\n this.focus();\n };\n\n /**\n * The floating picker is the source of truth for if the menu has been opened or not.\n *\n * Because this isn't tracked inside the state of this component, we need to\n * force an update here to keep the rendered output that depends on the picker being open\n * in sync with the state\n *\n * Called when the suggestions is shown or closed\n */\n private _onSuggestionsShownOrHidden = () => {\n this.forceUpdate();\n };\n\n private _addProcessedItem(newItem: T) {\n // If this is a controlled component, call the on item selected callback\n // Otherwise add it to the selectedItemsList\n if (this.props.onItemAdded) {\n this.props.onItemAdded(newItem);\n }\n\n if (this.selectedItemsList.current) {\n this.selectedItemsList.current.addItems([newItem]);\n }\n\n if (this.input.current) {\n this.input.current.clear();\n }\n\n if (this.floatingPicker.current) {\n this.floatingPicker.current.hidePicker();\n }\n\n this.focus();\n }\n}\n"]}
\No newline at end of file