first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
@@ -0,0 +1,51 @@
import * as React from 'react';
import { SuggestionsControl } from './Suggestions/SuggestionsControl';
import { SuggestionsStore } from './Suggestions/SuggestionsStore';
import type { IBaseFloatingPicker, IBaseFloatingPickerProps } from './BaseFloatingPicker.types';
import type { ISuggestionsControlProps } from './Suggestions/Suggestions.types';
import type { JSXElement } from '@fluentui/utilities';
export interface IBaseFloatingPickerState {
queryString: string;
suggestionsVisible?: boolean;
didBind: boolean;
}
export declare class BaseFloatingPicker<T extends {}, P extends IBaseFloatingPickerProps<T>> extends React.Component<P, IBaseFloatingPickerState> implements IBaseFloatingPicker {
protected selection: Selection;
protected root: React.RefObject<HTMLDivElement | null>;
protected suggestionStore: SuggestionsStore<T>;
protected suggestionsControl: React.RefObject<SuggestionsControl<T> | null>;
protected SuggestionsControlOfProperType: new (props: ISuggestionsControlProps<T>) => SuggestionsControl<T>;
protected currentPromise: PromiseLike<T[]>;
protected isComponentMounted: boolean;
private _async;
constructor(basePickerProps: P);
get inputText(): string;
get suggestions(): any[];
forceResolveSuggestion(): void;
get currentSelectedSuggestionIndex(): number;
get isSuggestionsShown(): boolean;
onQueryStringChanged: (queryString: string) => void;
hidePicker: () => void;
showPicker: (updateValue?: boolean) => void;
componentDidMount(): void;
componentDidUpdate(): void;
componentWillUnmount(): void;
completeSuggestion: () => void;
updateSuggestions(suggestions: T[], forceUpdate?: boolean): void;
render(): JSXElement;
protected renderSuggestions(): JSXElement | null;
protected onSelectionChange(): void;
protected updateValue(updatedValue: string): void;
protected updateSuggestionWithZeroState(): void;
protected updateSuggestionsList(suggestions: T[] | PromiseLike<T[]>): void;
protected onChange(item: T): void;
protected onSuggestionClick: (ev: React.MouseEvent<HTMLElement>, item: T, index: number) => void;
protected onSuggestionRemove: (ev: React.MouseEvent<HTMLElement>, item: T, index: number) => void;
protected onKeyDown: (ev: MouseEvent) => void;
private _updateActiveDescendant;
private _onResolveSuggestions;
private _onValidateInput;
private _updateSuggestionsVisible;
private _bindToInputElement;
private _unbindFromInputElement;
}
@@ -0,0 +1,291 @@
import { __assign, __extends } from "tslib";
import * as React from 'react';
import * as stylesImport from './BaseFloatingPicker.scss';
import { Async, initializeComponentRef, css, KeyCodes } from '../../Utilities';
import { DirectionalHint } from '../../common/DirectionalHint';
import { Callout } from '../../Callout';
import { SuggestionsControl } from './Suggestions/SuggestionsControl';
var styles = stylesImport;
var BaseFloatingPicker = /** @class */ (function (_super) {
__extends(BaseFloatingPicker, _super);
function BaseFloatingPicker(basePickerProps) {
var _this = _super.call(this, basePickerProps) || this;
_this.root = React.createRef();
_this.suggestionsControl = React.createRef();
_this.SuggestionsControlOfProperType = SuggestionsControl;
_this.isComponentMounted = false;
_this.onQueryStringChanged = function (queryString) {
if (queryString !== _this.state.queryString) {
_this.setState({
queryString: queryString,
});
if (_this.props.onInputChanged) {
_this.props.onInputChanged(queryString);
}
_this.updateValue(queryString);
}
};
_this.hidePicker = function () {
var wasShownBeforeUpdate = _this.isSuggestionsShown;
_this.setState({
suggestionsVisible: false,
});
if (_this.props.onSuggestionsHidden && wasShownBeforeUpdate) {
_this.props.onSuggestionsHidden();
}
};
_this.showPicker = function (updateValue) {
if (updateValue === void 0) { updateValue = false; }
var wasShownBeforeUpdate = _this.isSuggestionsShown;
_this.setState({
suggestionsVisible: true,
});
// Update the suggestions if updateValue == true
var value = _this.props.inputElement ? _this.props.inputElement.value : '';
if (updateValue) {
_this.updateValue(value);
}
if (_this.props.onSuggestionsShown && !wasShownBeforeUpdate) {
_this.props.onSuggestionsShown();
}
};
_this.completeSuggestion = function () {
if (_this.suggestionsControl.current && _this.suggestionsControl.current.hasSuggestionSelected()) {
_this.onChange(_this.suggestionsControl.current.currentSuggestion.item);
}
};
_this.onSuggestionClick = function (ev, item, index) {
_this.onChange(item);
_this._updateSuggestionsVisible(false /*shouldShow*/);
};
_this.onSuggestionRemove = function (ev, item, index) {
if (_this.props.onRemoveSuggestion) {
_this.props.onRemoveSuggestion(item);
}
if (_this.suggestionsControl.current) {
_this.suggestionsControl.current.removeSuggestion(index);
}
};
_this.onKeyDown = function (ev) {
if (!_this.state.suggestionsVisible ||
(_this.props.inputElement && !_this.props.inputElement.contains(ev.target))) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
var keyCode = ev.which;
switch (keyCode) {
case KeyCodes.escape:
_this.hidePicker();
ev.preventDefault();
ev.stopPropagation();
break;
case KeyCodes.tab:
case KeyCodes.enter:
if (!ev.shiftKey &&
!ev.ctrlKey &&
_this.suggestionsControl.current &&
_this.suggestionsControl.current.handleKeyDown(keyCode)) {
ev.preventDefault();
ev.stopPropagation();
}
else {
_this._onValidateInput();
}
break;
case KeyCodes.del:
if (_this.props.onRemoveSuggestion &&
_this.suggestionsControl.current &&
_this.suggestionsControl.current.hasSuggestionSelected() &&
_this.suggestionsControl.current.currentSuggestion &&
ev.shiftKey) {
_this.props.onRemoveSuggestion(_this.suggestionsControl.current.currentSuggestion.item);
_this.suggestionsControl.current.removeSuggestion();
_this.forceUpdate();
ev.stopPropagation();
}
break;
case KeyCodes.up:
if (_this.suggestionsControl.current && _this.suggestionsControl.current.handleKeyDown(keyCode)) {
ev.preventDefault();
ev.stopPropagation();
_this._updateActiveDescendant();
}
break;
case KeyCodes.down:
if (_this.suggestionsControl.current && _this.suggestionsControl.current.handleKeyDown(keyCode)) {
ev.preventDefault();
ev.stopPropagation();
_this._updateActiveDescendant();
}
break;
}
};
_this._onValidateInput = function () {
if (_this.state.queryString && _this.props.onValidateInput && _this.props.createGenericItem) {
var itemToConvert = _this.props.createGenericItem(_this.state.queryString, _this.props.onValidateInput(_this.state.queryString));
var convertedItems = _this.suggestionStore.convertSuggestionsToSuggestionItems([itemToConvert]);
_this.onChange(convertedItems[0].item);
}
};
_this._async = new Async(_this);
initializeComponentRef(_this);
_this.suggestionStore = basePickerProps.suggestionsStore;
_this.state = {
queryString: '',
didBind: false,
};
return _this;
}
Object.defineProperty(BaseFloatingPicker.prototype, "inputText", {
get: function () {
return this.state.queryString;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseFloatingPicker.prototype, "suggestions", {
get: function () {
return this.suggestionStore.suggestions;
},
enumerable: false,
configurable: true
});
BaseFloatingPicker.prototype.forceResolveSuggestion = function () {
if (this.suggestionsControl.current && this.suggestionsControl.current.hasSuggestionSelected()) {
this.completeSuggestion();
}
else {
this._onValidateInput();
}
};
Object.defineProperty(BaseFloatingPicker.prototype, "currentSelectedSuggestionIndex", {
get: function () {
return this.suggestionsControl.current ? this.suggestionsControl.current.currentSuggestionIndex : -1;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseFloatingPicker.prototype, "isSuggestionsShown", {
get: function () {
return this.state.suggestionsVisible === undefined ? false : this.state.suggestionsVisible;
},
enumerable: false,
configurable: true
});
BaseFloatingPicker.prototype.componentDidMount = function () {
this._bindToInputElement();
this.isComponentMounted = true;
this._onResolveSuggestions = this._async.debounce(this._onResolveSuggestions, this.props.resolveDelay);
};
BaseFloatingPicker.prototype.componentDidUpdate = function () {
this._bindToInputElement();
};
BaseFloatingPicker.prototype.componentWillUnmount = function () {
this._unbindFromInputElement();
this._async.dispose();
this.isComponentMounted = false;
};
BaseFloatingPicker.prototype.updateSuggestions = function (suggestions, forceUpdate) {
if (forceUpdate === void 0) { forceUpdate = false; }
this.suggestionStore.updateSuggestions(suggestions);
if (forceUpdate) {
this.forceUpdate();
}
};
BaseFloatingPicker.prototype.render = function () {
var className = this.props.className;
return (React.createElement("div", { ref: this.root, className: css('ms-BasePicker ms-BaseFloatingPicker', className ? className : '') }, this.renderSuggestions()));
};
BaseFloatingPicker.prototype.renderSuggestions = function () {
var TypedSuggestionsControl = this.SuggestionsControlOfProperType;
if (this.props.suggestionItems) {
this.suggestionStore.updateSuggestions(this.props.suggestionItems);
}
return this.state.suggestionsVisible ? (React.createElement(Callout, __assign({ className: styles.callout, isBeakVisible: false, gapSpace: 5, target: this.props.inputElement, onDismiss: this.hidePicker, directionalHint: DirectionalHint.bottomLeftEdge, directionalHintForRTL: DirectionalHint.bottomRightEdge, calloutWidth: this.props.calloutWidth ? this.props.calloutWidth : 0 }, this.props.pickerCalloutProps),
React.createElement(TypedSuggestionsControl, __assign({ onRenderSuggestion: this.props.onRenderSuggestionsItem, onSuggestionClick: this.onSuggestionClick, onSuggestionRemove: this.onSuggestionRemove, suggestions: this.suggestionStore.getSuggestions(), componentRef: this.suggestionsControl, completeSuggestion: this.completeSuggestion, shouldLoopSelection: false }, this.props.pickerSuggestionsProps)))) : null;
};
BaseFloatingPicker.prototype.onSelectionChange = function () {
this.forceUpdate();
};
BaseFloatingPicker.prototype.updateValue = function (updatedValue) {
if (updatedValue === '') {
this.updateSuggestionWithZeroState();
}
else {
this._onResolveSuggestions(updatedValue);
}
};
BaseFloatingPicker.prototype.updateSuggestionWithZeroState = function () {
if (this.props.onZeroQuerySuggestion) {
var onEmptyInputFocus = this.props.onZeroQuerySuggestion;
var suggestions = onEmptyInputFocus(this.props.selectedItems);
this.updateSuggestionsList(suggestions);
}
else {
this.hidePicker();
}
};
BaseFloatingPicker.prototype.updateSuggestionsList = function (suggestions) {
var _this = this;
// Check to see if the returned value is an array, if it is then just pass it into the next function.
// If the returned value is not an array then check to see if it's a promise or PromiseLike.
// If it is then resolve it asynchronously.
if (Array.isArray(suggestions)) {
this.updateSuggestions(suggestions, true /*forceUpdate*/);
}
else if (suggestions && suggestions.then) {
// Ensure that the promise will only use the callback if it was the most recent one.
this.currentPromise = suggestions;
suggestions.then(function (newSuggestions) {
// Only update if the next promise has not yet resolved and
// the floating picker is still mounted.
if (suggestions === _this.currentPromise && _this.isComponentMounted) {
_this.updateSuggestions(newSuggestions, true /*forceUpdate*/);
}
});
}
};
BaseFloatingPicker.prototype.onChange = function (item) {
if (this.props.onChange) {
this.props.onChange(item);
}
};
BaseFloatingPicker.prototype._updateActiveDescendant = function () {
if (this.props.inputElement && this.suggestionsControl.current && this.suggestionsControl.current.selectedElement) {
var selectedElId = this.suggestionsControl.current.selectedElement.getAttribute('id');
if (selectedElId) {
this.props.inputElement.setAttribute('aria-activedescendant', selectedElId);
}
}
};
BaseFloatingPicker.prototype._onResolveSuggestions = function (updatedValue) {
var suggestions = this.props.onResolveSuggestions(updatedValue, this.props.selectedItems);
this._updateSuggestionsVisible(true /*shouldShow*/);
if (suggestions !== null) {
this.updateSuggestionsList(suggestions);
}
};
BaseFloatingPicker.prototype._updateSuggestionsVisible = function (shouldShow) {
if (shouldShow) {
this.showPicker();
}
else {
this.hidePicker();
}
};
BaseFloatingPicker.prototype._bindToInputElement = function () {
if (this.props.inputElement && !this.state.didBind) {
this.props.inputElement.addEventListener('keydown', this.onKeyDown);
this.setState({ didBind: true });
}
};
BaseFloatingPicker.prototype._unbindFromInputElement = function () {
if (this.props.inputElement && this.state.didBind) {
this.props.inputElement.removeEventListener('keydown', this.onKeyDown);
this.setState({ didBind: false });
}
};
return BaseFloatingPicker;
}(React.Component));
export { BaseFloatingPicker };
//# sourceMappingURL=BaseFloatingPicker.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
export declare const callout = "callout_ad5629e1";
@@ -0,0 +1,5 @@
/* eslint-disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".callout_ad5629e1 .ms-Suggestions-itemButton{padding:0;border:none}.callout_ad5629e1 .ms-Suggestions{min-width:300px}" }]);
export var callout = "callout_ad5629e1";
//# sourceMappingURL=BaseFloatingPicker.scss.js.map
@@ -0,0 +1 @@
{"version":3,"file":"BaseFloatingPicker.scss.js","sourceRoot":"../src/","sources":["components/FloatingPicker/BaseFloatingPicker.scss.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,UAAU,CAAC,CAAC,EAAC,WAAW,EAAC,uHAAuH,EAAC,CAAC,CAAC,CAAC;AACpJ,MAAM,CAAC,IAAM,OAAO,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable */\nimport { loadStyles } from '@microsoft/load-themed-styles';\nloadStyles([{\"rawString\":\".callout_ad5629e1 .ms-Suggestions-itemButton{padding:0;border:none}.callout_ad5629e1 .ms-Suggestions{min-width:300px}\"}]);\nexport const callout = \"callout_ad5629e1\";"]}
@@ -0,0 +1,126 @@
import * as React from 'react';
import { SuggestionsStore } from './Suggestions/SuggestionsStore';
import type { ISuggestionModel, ISuggestionItemProps } from '../../Pickers';
import type { ISuggestionsControlProps } from './Suggestions/Suggestions.types';
import type { IRefObject } from '../../Utilities';
import type { ICalloutProps } from '../Callout/Callout.types';
import type { JSXElement } from '@fluentui/utilities';
export interface IBaseFloatingPicker {
/** Whether the suggestions are shown */
isSuggestionsShown: boolean;
/** On queryString changed */
onQueryStringChanged: (input: string) => void;
/** Hides the picker */
hidePicker: () => void;
/** Shows the picker
* @param updateValue - Optional param to indicate whether to update the query string
*/
showPicker: (updateValue?: boolean) => void;
/** Gets the suggestions */
suggestions: any[];
/** Gets the input text */
inputText: string;
}
export interface IBaseFloatingPickerProps<T> extends React.ClassAttributes<any> {
componentRef?: IRefObject<IBaseFloatingPicker>;
/**
* The suggestions store
*/
suggestionsStore: SuggestionsStore<T>;
/**
* The suggestions to show on zero query, return null if using as a controlled component
*/
onZeroQuerySuggestion?: (selectedItems?: T[]) => T[] | PromiseLike<T[]> | null;
/**
* The input element to listen on events
*/
inputElement?: HTMLInputElement | null;
/**
* Function that specifies how an individual suggestion item will appear.
*/
onRenderSuggestionsItem?: (props: T, itemProps: ISuggestionItemProps<T>) => JSXElement;
/**
* A callback for what should happen when a person types text into the input.
* Returns the already selected items so the resolver can filter them out.
* If used in conjunction with resolveDelay this will only kick off after the delay throttle.
* Return null if using as a controlled component
*/
onResolveSuggestions: (filter: string, selectedItems?: T[]) => T[] | PromiseLike<T[]> | null;
/**
* A callback for when the input has been changed
*/
onInputChanged?: (filter: string) => void;
/**
* The delay time in ms before resolving suggestions, which is kicked off when input has been changed.
* e.g. If a second input change happens within the resolveDelay time, the timer will start over.
* Only until after the timer completes will onResolveSuggestions be called.
*/
resolveDelay?: number;
/**
* A callback for when a suggestion is clicked
*/
onChange?: (item: T) => void;
/**
* ClassName for the picker.
*/
className?: string;
/**
* The properties that will get passed to the Suggestions component.
*/
pickerSuggestionsProps?: IBaseFloatingPickerSuggestionProps;
/**
* The properties that will get passed to the Callout component.
*/
pickerCalloutProps?: ICalloutProps;
/**
* A callback for when an item is removed from the suggestion list
*/
onRemoveSuggestion?: (item: T) => void;
/**
* A function used to validate if raw text entered into the well can be added
*/
onValidateInput?: (input: string) => boolean;
/**
* The text to display while searching for more results in a limited suggestions list
*/
searchingText?: ((props: {
input: string;
}) => string) | string;
/**
* Function that specifies how arbitrary text entered into the well is handled.
*/
createGenericItem?: (input: string, isValid: boolean) => ISuggestionModel<T>;
/**
* The callback that should be called to see if the force resolve command should be shown
*/
showForceResolve?: () => boolean;
/**
* The items that the base picker should currently display as selected.
* If this is provided then the picker will act as a controlled component.
*/
selectedItems?: T[];
/**
* A callback to get text from an item. Used to autofill text in the pickers.
*/
getTextFromItem?: (item: T, currentValue?: string) => string;
/**
* Width for the suggestions callout
*/
calloutWidth?: number;
/**
* The callback that should be called when the suggestions are shown
*/
onSuggestionsShown?: () => void;
/**
* The callback that should be called when the suggestions are hidden
*/
onSuggestionsHidden?: () => void;
/**
* If using as a controlled component, the items to show in the suggestion list
*/
suggestionItems?: T[];
}
/**
* Props which are passed on to the inner Suggestions component
*/
export type IBaseFloatingPickerSuggestionProps = Pick<ISuggestionsControlProps<any>, 'shouldSelectFirstItem' | 'headerItemsProps' | 'footerItemsProps' | 'showRemoveButtons'>;
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=BaseFloatingPicker.types.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,19 @@
import { BaseFloatingPicker } from '../BaseFloatingPicker';
import './PeoplePicker.scss';
import type { IBaseFloatingPickerProps } from '../BaseFloatingPicker.types';
import type { IPersonaProps } from '../../../Persona';
import type { ISuggestionModel } from '../../../Pickers';
/**
* {@docCategory FloatingPeoplePicker}
*/
export interface IPeopleFloatingPickerProps extends IBaseFloatingPickerProps<IPersonaProps> {
}
/**
* {@docCategory FloatingPeoplePicker}
*/
export declare class BaseFloatingPeoplePicker extends BaseFloatingPicker<IPersonaProps, IPeopleFloatingPickerProps> {
}
export declare class FloatingPeoplePicker extends BaseFloatingPeoplePicker {
static defaultProps: any;
}
export declare function createItem(name: string, isValid: boolean): ISuggestionModel<IPersonaProps>;
@@ -0,0 +1,43 @@
import { __assign, __extends } from "tslib";
import { getRTL, getInitials } from '../../../Utilities';
import { BaseFloatingPicker } from '../BaseFloatingPicker';
import { SuggestionItemNormal } from './PeoplePickerItems/SuggestionItemDefault';
import './PeoplePicker.scss';
/**
* {@docCategory FloatingPeoplePicker}
*/
var BaseFloatingPeoplePicker = /** @class */ (function (_super) {
__extends(BaseFloatingPeoplePicker, _super);
function BaseFloatingPeoplePicker() {
return _super !== null && _super.apply(this, arguments) || this;
}
return BaseFloatingPeoplePicker;
}(BaseFloatingPicker));
export { BaseFloatingPeoplePicker };
var FloatingPeoplePicker = /** @class */ (function (_super) {
__extends(FloatingPeoplePicker, _super);
function FloatingPeoplePicker() {
return _super !== null && _super.apply(this, arguments) || this;
}
FloatingPeoplePicker.defaultProps = {
onRenderSuggestionsItem: function (props, itemProps) {
return SuggestionItemNormal(__assign({}, props), __assign({}, itemProps));
},
createGenericItem: createItem,
};
return FloatingPeoplePicker;
}(BaseFloatingPeoplePicker));
export { FloatingPeoplePicker };
export function createItem(name, isValid) {
var personaToConvert = {
key: name,
primaryText: name,
imageInitials: '!',
isValid: isValid,
};
if (!isValid) {
personaToConvert.imageInitials = getInitials(name, getRTL());
}
return personaToConvert;
}
//# sourceMappingURL=FloatingPeoplePicker.js.map
@@ -0,0 +1 @@
{"version":3,"file":"FloatingPeoplePicker.js","sourceRoot":"../src/","sources":["components/FloatingPicker/PeoplePicker/FloatingPeoplePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,qBAAqB,CAAC;AAU7B;;GAEG;AACH;IAA8C,4CAA6D;IAA3G;;IAA6G,CAAC;IAAD,+BAAC;AAAD,CAAC,AAA9G,CAA8C,kBAAkB,GAA8C;;AAE9G;IAA0C,wCAAwB;IAAlE;;IAMA,CAAC;IALe,iCAAY,GAAQ;QAChC,uBAAuB,EAAE,UAAC,KAAoB,EAAE,SAAuC;YACrF,OAAA,oBAAoB,cAAM,KAAK,gBAAS,SAAS,EAAG;QAApD,CAAoD;QACtD,iBAAiB,EAAE,UAAU;KAC9B,CAAC;IACJ,2BAAC;CAAA,AAND,CAA0C,wBAAwB,GAMjE;SANY,oBAAoB;AAQjC,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAgB;IACvD,IAAM,gBAAgB,GAAQ;QAC5B,GAAG,EAAE,IAAI;QACT,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,GAAG;QAClB,OAAO,SAAA;KACR,CAAC;IAEF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,gBAAgB,CAAC,aAAa,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import { getRTL, getInitials } from '../../../Utilities';\nimport { BaseFloatingPicker } from '../BaseFloatingPicker';\nimport { SuggestionItemNormal } from './PeoplePickerItems/SuggestionItemDefault';\nimport './PeoplePicker.scss';\nimport type { IBaseFloatingPickerProps } from '../BaseFloatingPicker.types';\nimport type { IPersonaProps } from '../../../Persona';\nimport type { IBasePickerSuggestionsProps, ISuggestionModel } from '../../../Pickers';\n\n/**\n * {@docCategory FloatingPeoplePicker}\n */\nexport interface IPeopleFloatingPickerProps extends IBaseFloatingPickerProps<IPersonaProps> {}\n\n/**\n * {@docCategory FloatingPeoplePicker}\n */\nexport class BaseFloatingPeoplePicker extends BaseFloatingPicker<IPersonaProps, IPeopleFloatingPickerProps> {}\n\nexport class FloatingPeoplePicker extends BaseFloatingPeoplePicker {\n public static defaultProps: any = {\n onRenderSuggestionsItem: (props: IPersonaProps, itemProps?: IBasePickerSuggestionsProps) =>\n SuggestionItemNormal({ ...props }, { ...itemProps }),\n createGenericItem: createItem,\n };\n}\n\nexport function createItem(name: string, isValid: boolean): ISuggestionModel<IPersonaProps> {\n const personaToConvert: any = {\n key: name,\n primaryText: name,\n imageInitials: '!',\n isValid,\n };\n\n if (!isValid) {\n personaToConvert.imageInitials = getInitials(name, getRTL());\n }\n\n return personaToConvert;\n}\n"]}
@@ -0,0 +1,5 @@
export declare const resultContent = "resultContent_f73be5be";
export declare const resultItem = "resultItem_f73be5be";
export declare const peoplePickerPersona = "peoplePickerPersona_f73be5be";
export declare const peoplePicker = "peoplePicker_f73be5be";
export declare const peoplePickerPersonaContent = "peoplePickerPersonaContent_f73be5be";
@@ -0,0 +1,9 @@
/* eslint-disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".resultContent_f73be5be{display:table-row}.resultContent_f73be5be .resultItem_f73be5be{display:table-cell;vertical-align:bottom}.peoplePickerPersona_f73be5be{width:180px}.peoplePickerPersona_f73be5be .ms-Persona-details{width:100%}.peoplePicker_f73be5be .ms-BasePicker-text{min-height:40px}.peoplePickerPersonaContent_f73be5be{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:7px 12px}" }]);
export var resultContent = "resultContent_f73be5be";
export var resultItem = "resultItem_f73be5be";
export var peoplePickerPersona = "peoplePickerPersona_f73be5be";
export var peoplePicker = "peoplePicker_f73be5be";
export var peoplePickerPersonaContent = "peoplePickerPersonaContent_f73be5be";
//# sourceMappingURL=PeoplePicker.scss.js.map
@@ -0,0 +1 @@
{"version":3,"file":"PeoplePicker.scss.js","sourceRoot":"../src/","sources":["components/FloatingPicker/PeoplePicker/PeoplePicker.scss.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,UAAU,CAAC,CAAC,EAAC,WAAW,EAAC,yiBAAyiB,EAAC,CAAC,CAAC,CAAC;AACtkB,MAAM,CAAC,IAAM,aAAa,GAAG,wBAAwB,CAAC;AACtD,MAAM,CAAC,IAAM,UAAU,GAAG,qBAAqB,CAAC;AAChD,MAAM,CAAC,IAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAClE,MAAM,CAAC,IAAM,YAAY,GAAG,uBAAuB,CAAC;AACpD,MAAM,CAAC,IAAM,0BAA0B,GAAG,qCAAqC,CAAC","sourcesContent":["/* eslint-disable */\nimport { loadStyles } from '@microsoft/load-themed-styles';\nloadStyles([{\"rawString\":\".resultContent_f73be5be{display:table-row}.resultContent_f73be5be .resultItem_f73be5be{display:table-cell;vertical-align:bottom}.peoplePickerPersona_f73be5be{width:180px}.peoplePickerPersona_f73be5be .ms-Persona-details{width:100%}.peoplePicker_f73be5be .ms-BasePicker-text{min-height:40px}.peoplePickerPersonaContent_f73be5be{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:7px 12px}\"}]);\nexport const resultContent = \"resultContent_f73be5be\";\nexport const resultItem = \"resultItem_f73be5be\";\nexport const peoplePickerPersona = \"peoplePickerPersona_f73be5be\";\nexport const peoplePicker = \"peoplePicker_f73be5be\";\nexport const peoplePickerPersonaContent = \"peoplePickerPersonaContent_f73be5be\";"]}
@@ -0,0 +1,7 @@
export declare const personaContainer = "personaContainer_5b3cddaa";
export declare const removeButton = "removeButton_5b3cddaa";
export declare const personaContainerIsSelected = "personaContainerIsSelected_5b3cddaa";
export declare const validationError = "validationError_5b3cddaa";
export declare const itemContent = "itemContent_5b3cddaa";
export declare const personaDetails = "personaDetails_5b3cddaa";
export declare const itemContainer = "itemContainer_5b3cddaa";
@@ -0,0 +1,11 @@
/* eslint-disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".personaContainer_5b3cddaa{border-radius:15px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:" }, { "theme": "neutralLighter", "defaultValue": "#f3f2f1" }, { "rawString": ";margin:4px;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;max-width:300px;vertical-align:middle}.personaContainer_5b3cddaa::-moz-focus-inner{border:0}.personaContainer_5b3cddaa{outline:transparent}.personaContainer_5b3cddaa{position:relative}.ms-Fabric--isFocusVisible .personaContainer_5b3cddaa:focus:after{-webkit-box-sizing:border-box;box-sizing:border-box;content:\"\";position:absolute;top:-2px;right:-2px;bottom:-2px;left:-2px;pointer-events:none;border:1px solid " }, { "theme": "focusBorder", "defaultValue": "#605e5c" }, { "rawString": ";border-radius:0}.personaContainer_5b3cddaa:hover{background:" }, { "theme": "neutralLight", "defaultValue": "#edebe9" }, { "rawString": "}.personaContainer_5b3cddaa:hover .removeButton_5b3cddaa{color:" }, { "theme": "neutralPrimary", "defaultValue": "#323130" }, { "rawString": "}.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa{background:" }, { "theme": "blue", "defaultValue": "#0078d4" }, { "rawString": "}.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa .ms-Persona-primaryText{color:" }, { "theme": "white", "defaultValue": "#ffffff" }, { "rawString": "}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa .ms-Persona-primaryText{color:HighlightText}}.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa .removeButton_5b3cddaa .ms-Button-icon{color:" }, { "theme": "white", "defaultValue": "#ffffff" }, { "rawString": "}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa .removeButton_5b3cddaa .ms-Button-icon{color:HighlightText}}.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa .removeButton_5b3cddaa:hover{color:" }, { "theme": "white", "defaultValue": "#ffffff" }, { "rawString": ";background:" }, { "theme": "themeDark", "defaultValue": "#005a9e" }, { "rawString": "}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.personaContainer_5b3cddaa.personaContainerIsSelected_5b3cddaa{border-color:Highlight;background:Highlight;-ms-high-contrast-adjust:none}}.personaContainer_5b3cddaa.validationError_5b3cddaa .ms-Persona-primaryText{color:" }, { "theme": "redDark", "defaultValue": "#a4262c" }, { "rawString": ";border-bottom:2px dotted " }, { "theme": "redDark", "defaultValue": "#a4262c" }, { "rawString": "}.personaContainer_5b3cddaa.validationError_5b3cddaa .ms-Persona-initials{font-size:20px}.personaContainer_5b3cddaa.validationError_5b3cddaa.personaContainerIsSelected_5b3cddaa{background:" }, { "theme": "redDark", "defaultValue": "#a4262c" }, { "rawString": "}.personaContainer_5b3cddaa.validationError_5b3cddaa.personaContainerIsSelected_5b3cddaa .ms-Persona-primaryText{color:" }, { "theme": "white", "defaultValue": "#ffffff" }, { "rawString": ";border-bottom:2px dotted " }, { "theme": "white", "defaultValue": "#ffffff" }, { "rawString": "}.personaContainer_5b3cddaa.validationError_5b3cddaa.personaContainerIsSelected_5b3cddaa .removeButton_5b3cddaa:hover{background:" }, { "theme": "red", "defaultValue": "#e81123" }, { "rawString": "}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.personaContainer_5b3cddaa{border:1px solid WindowText}}.personaContainer_5b3cddaa .itemContent_5b3cddaa{-webkit-box-flex:0;-ms-flex:0 1 auto;flex:0 1 auto;min-width:0;max-width:100%;overflow-x:hidden}.personaContainer_5b3cddaa .removeButton_5b3cddaa{border-radius:15px;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto;width:28px;height:28px;-ms-flex-preferred-size:28px;flex-basis:28px}.personaContainer_5b3cddaa .removeButton_5b3cddaa:hover{background:" }, { "theme": "neutralTertiaryAlt", "defaultValue": "#c8c6c4" }, { "rawString": ";color:" }, { "theme": "neutralDark", "defaultValue": "#201f1e" }, { "rawString": "}.personaContainer_5b3cddaa .personaDetails_5b3cddaa{-webkit-box-flex:0;-ms-flex:0 1 auto;flex:0 1 auto}.itemContainer_5b3cddaa{display:inline-block;vertical-align:top}" }]);
export var personaContainer = "personaContainer_5b3cddaa";
export var removeButton = "removeButton_5b3cddaa";
export var personaContainerIsSelected = "personaContainerIsSelected_5b3cddaa";
export var validationError = "validationError_5b3cddaa";
export var itemContent = "itemContent_5b3cddaa";
export var personaDetails = "personaDetails_5b3cddaa";
export var itemContainer = "itemContainer_5b3cddaa";
//# sourceMappingURL=PickerItemsDefault.scss.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
import type { IPeoplePickerItemProps } from '../../../../ExtendedPicker';
import type { JSXElement } from '@fluentui/utilities';
export declare const SelectedItemDefault: (props: IPeoplePickerItemProps) => JSXElement;
@@ -0,0 +1,26 @@
import { __assign } from "tslib";
import * as React from 'react';
import { css, getId } from '../../../../Utilities';
import { Persona, PersonaSize, PersonaPresence } from '../../../../Persona';
import { IconButton } from '../../../../Button';
import * as stylesImport from './PickerItemsDefault.scss';
var styles = stylesImport;
export var SelectedItemDefault = function (peoplePickerItemProps) {
var _a, _b;
var item = peoplePickerItemProps.item, onRemoveItem = peoplePickerItemProps.onRemoveItem, index = peoplePickerItemProps.index, selected = peoplePickerItemProps.selected, removeButtonAriaLabel = peoplePickerItemProps.removeButtonAriaLabel;
var itemId = getId();
var onClickIconButton = function (removeItem) {
return function () {
if (removeItem) {
removeItem();
}
};
};
return (React.createElement("div", { className: css('ms-PickerPersona-container', styles.personaContainer, (_a = {}, _a['is-selected ' + styles.personaContainerIsSelected] = selected, _a), (_b = {}, _b['is-invalid ' + styles.validationError] = !item.isValid, _b)), "data-is-focusable": true, "data-is-sub-focuszone": true, "data-selection-index": index, role: 'listitem', "aria-labelledby": 'selectedItemPersona-' + itemId },
React.createElement("div", { className: css('ms-PickerItem-content', styles.itemContent), id: 'selectedItemPersona-' + itemId },
React.createElement(Persona, __assign({}, item, { presence: item.presence !== undefined ? item.presence : PersonaPresence.none,
// eslint-disable-next-line @typescript-eslint/no-deprecated
size: PersonaSize.size28 }))),
React.createElement(IconButton, { onClick: onClickIconButton(onRemoveItem), iconProps: { iconName: 'Cancel', style: { fontSize: '12px' } }, className: css('ms-PickerItem-removeButton', styles.removeButton), ariaLabel: removeButtonAriaLabel })));
};
//# sourceMappingURL=SelectedItemDefault.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SelectedItemDefault.js","sourceRoot":"../src/","sources":["components/FloatingPicker/PeoplePicker/PeoplePickerItems/SelectedItemDefault.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAK1D,IAAM,MAAM,GAAQ,YAAY,CAAC;AAEjC,MAAM,CAAC,IAAM,mBAAmB,GAAkD,UAChF,qBAA6C;;IAErC,IAAA,IAAI,GAA2D,qBAAqB,KAAhF,EAAE,YAAY,GAA6C,qBAAqB,aAAlE,EAAE,KAAK,GAAsC,qBAAqB,MAA3D,EAAE,QAAQ,GAA4B,qBAAqB,SAAjD,EAAE,qBAAqB,GAAK,qBAAqB,sBAA1B,CAA2B;IAE7F,IAAM,MAAM,GAAG,KAAK,EAAE,CAAC;IACvB,IAAM,iBAAiB,GAAG,UAAC,UAAoC;QAC7D,OAAO;YACL,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,SAAS,EAAE,GAAG,CACZ,4BAA4B,EAC5B,MAAM,CAAC,gBAAgB,YACrB,GAAC,cAAc,GAAG,MAAM,CAAC,0BAA0B,IAAG,QAAQ,iBAC9D,GAAC,aAAa,GAAG,MAAM,CAAC,eAAe,IAAG,CAAC,IAAI,CAAC,OAAO,MAC1D,uBACkB,IAAI,2BACA,IAAI,0BACL,KAAK,EAC3B,IAAI,EAAE,UAAU,qBACC,sBAAsB,GAAG,MAAM;QAEhD,6BAAK,SAAS,EAAE,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,sBAAsB,GAAG,MAAM;YACnG,oBAAC,OAAO,eACF,IAAI,IACR,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI;gBAC5E,4DAA4D;gBAC5D,IAAI,EAAE,WAAW,CAAC,MAAM,IACxB,CACE;QACN,oBAAC,UAAU,IACT,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,EACxC,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAC9D,SAAS,EAAE,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,YAAY,CAAC,EACjE,SAAS,EAAE,qBAAqB,GAChC,CACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { css, getId } from '../../../../Utilities';\nimport { Persona, PersonaSize, PersonaPresence } from '../../../../Persona';\nimport { IconButton } from '../../../../Button';\nimport * as stylesImport from './PickerItemsDefault.scss';\nimport type { IPeoplePickerItemProps } from '../../../../ExtendedPicker';\n\nimport type { JSXElement } from '@fluentui/utilities';\n\nconst styles: any = stylesImport;\n\nexport const SelectedItemDefault: (props: IPeoplePickerItemProps) => JSXElement = (\n peoplePickerItemProps: IPeoplePickerItemProps,\n) => {\n const { item, onRemoveItem, index, selected, removeButtonAriaLabel } = peoplePickerItemProps;\n\n const itemId = getId();\n const onClickIconButton = (removeItem: (() => void) | undefined): (() => void) => {\n return (): void => {\n if (removeItem) {\n removeItem();\n }\n };\n };\n\n return (\n <div\n className={css(\n 'ms-PickerPersona-container',\n styles.personaContainer,\n { ['is-selected ' + styles.personaContainerIsSelected]: selected },\n { ['is-invalid ' + styles.validationError]: !item.isValid },\n )}\n data-is-focusable={true}\n data-is-sub-focuszone={true}\n data-selection-index={index}\n role={'listitem'}\n aria-labelledby={'selectedItemPersona-' + itemId}\n >\n <div className={css('ms-PickerItem-content', styles.itemContent)} id={'selectedItemPersona-' + itemId}>\n <Persona\n {...item}\n presence={item.presence !== undefined ? item.presence : PersonaPresence.none}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n size={PersonaSize.size28}\n />\n </div>\n <IconButton\n onClick={onClickIconButton(onRemoveItem)}\n iconProps={{ iconName: 'Cancel', style: { fontSize: '12px' } }}\n className={css('ms-PickerItem-removeButton', styles.removeButton)}\n ariaLabel={removeButtonAriaLabel}\n />\n </div>\n );\n};\n"]}
@@ -0,0 +1,4 @@
import type { IPersonaProps } from '../../../../Persona';
import type { IBasePickerSuggestionsProps } from '../../../../Pickers';
import type { JSXElement } from '@fluentui/utilities';
export declare const SuggestionItemNormal: (persona: IPersonaProps, suggestionProps?: IBasePickerSuggestionsProps) => JSXElement;
@@ -0,0 +1,10 @@
import { __assign } from "tslib";
import * as React from 'react';
import { css } from '../../../../Utilities';
import { Persona, PersonaSize, PersonaPresence } from '../../../../Persona';
import * as stylesImport from '../PeoplePicker.scss';
export var SuggestionItemNormal = function (personaProps, suggestionItemProps) {
return (React.createElement("div", { className: css('ms-PeoplePicker-personaContent', stylesImport.peoplePickerPersonaContent) },
React.createElement(Persona, __assign({ presence: personaProps.presence !== undefined ? personaProps.presence : PersonaPresence.none, size: PersonaSize.size40, className: css('ms-PeoplePicker-Persona', stylesImport.peoplePickerPersona), showSecondaryText: true }, personaProps))));
};
//# sourceMappingURL=SuggestionItemDefault.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SuggestionItemDefault.js","sourceRoot":"../src/","sources":["components/FloatingPicker/PeoplePicker/PeoplePickerItems/SuggestionItemDefault.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AAMrD,MAAM,CAAC,IAAM,oBAAoB,GAGf,UAAC,YAA2B,EAAE,mBAAyD;IACvG,OAAO,CACL,6BAAK,SAAS,EAAE,GAAG,CAAC,gCAAgC,EAAE,YAAY,CAAC,0BAA0B,CAAC;QAC5F,oBAAC,OAAO,aACN,QAAQ,EAAE,YAAY,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAC5F,IAAI,EAAE,WAAW,CAAC,MAAM,EACxB,SAAS,EAAE,GAAG,CAAC,yBAAyB,EAAE,YAAY,CAAC,mBAAmB,CAAC,EAC3E,iBAAiB,EAAE,IAAI,IACnB,YAAY,EAChB,CACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { css } from '../../../../Utilities';\nimport { Persona, PersonaSize, PersonaPresence } from '../../../../Persona';\nimport * as stylesImport from '../PeoplePicker.scss';\nimport type { IPersonaProps } from '../../../../Persona';\nimport type { IBasePickerSuggestionsProps, ISuggestionItemProps } from '../../../../Pickers';\n\nimport type { JSXElement } from '@fluentui/utilities';\n\nexport const SuggestionItemNormal: (\n persona: IPersonaProps,\n suggestionProps?: IBasePickerSuggestionsProps,\n) => JSXElement = (personaProps: IPersonaProps, suggestionItemProps?: ISuggestionItemProps<IPersonaProps>) => {\n return (\n <div className={css('ms-PeoplePicker-personaContent', stylesImport.peoplePickerPersonaContent)}>\n <Persona\n presence={personaProps.presence !== undefined ? personaProps.presence : PersonaPresence.none}\n size={PersonaSize.size40}\n className={css('ms-PeoplePicker-Persona', stylesImport.peoplePickerPersona)}\n showSecondaryText={true}\n {...personaProps}\n />\n </div>\n );\n};\n"]}
@@ -0,0 +1,97 @@
import * as React from 'react';
import type { ISuggestionModel, ISuggestionItemProps } from '../../../Pickers';
import type { IPersonaProps } from '../../../Persona';
import type { IRefObject } from '../../../Utilities';
import type { JSXElement } from '@fluentui/utilities';
export interface ISuggestionsCoreProps<T> extends React.ClassAttributes<any> {
/**
* Gets the component ref.
*/
componentRef?: IRefObject<{}>;
/**
* How the suggestion should look in the suggestion list.
*/
onRenderSuggestion?: (props: T, suggestionItemProps: ISuggestionItemProps<T>) => JSXElement;
/**
* What should occur when a suggestion is clicked
*/
onSuggestionClick: (ev?: React.MouseEvent<HTMLElement>, item?: any, index?: number) => void;
/**
* The list of Suggestions that will be displayed
*/
suggestions: ISuggestionModel<T>[];
/**
* Function to fire when one of the optional remove buttons on a suggestion is clicked.
*/
onSuggestionRemove?: (ev?: React.MouseEvent<HTMLElement>, item?: IPersonaProps, index?: number) => void;
/**
* Screen reader message to read when there are suggestions available.
*/
suggestionsAvailableAlertText?: string;
/**
* An ARIA label for the container that is the parent of the suggestions.
*/
suggestionsContainerAriaLabel?: string;
/**
* the classname of the suggestion item.
*/
suggestionsItemClassName?: string;
/**
* Maximum number of suggestions to show in the full suggestion list.
*/
resultsMaximumNumber?: number;
/**
* Indicates whether to show a button with each suggestion to remove that suggestion.
*/
showRemoveButtons?: boolean;
/**
* Indicates whether to loop around to the top or bottom of the suggestions
* on calling nextSuggestion and previousSuggestion, respectively
*/
shouldLoopSelection: boolean;
}
export interface ISuggestionsControlProps<T> extends React.ClassAttributes<any>, ISuggestionsCoreProps<T> {
/**
* An ARIA label for the container that is the parent of the suggestions header items.
*/
suggestionsHeaderContainerAriaLabel?: string;
/**
* An ARIA label for the container that is the parent of the suggestions footer items.
*/
suggestionsFooterContainerAriaLabel?: string;
/**
* The header items props
*/
headerItemsProps?: ISuggestionsHeaderFooterProps[];
/**
* The footer items props
*/
footerItemsProps?: ISuggestionsHeaderFooterProps[];
/**
* Whether or not the first selectable item in the suggestions list should be selected
*/
shouldSelectFirstItem?: () => boolean;
/**
* The CSS classname of the suggestions list.
*/
className?: string;
/**
* Completes the suggestion
*/
completeSuggestion: () => void;
}
export interface ISuggestionsHeaderFooterProps {
renderItem: () => JSXElement;
onExecute?: () => void;
className?: string;
ariaLabel?: string;
shouldShow: () => boolean;
}
export interface ISuggestionsHeaderFooterItemProps {
componentRef?: IRefObject<{}>;
renderItem: () => JSXElement;
onExecute?: () => void;
isSelected: boolean;
id: string;
className: string | undefined;
}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Suggestions.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Suggestions.types.js","sourceRoot":"../src/","sources":["components/FloatingPicker/Suggestions/Suggestions.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ISuggestionModel, ISuggestionItemProps } from '../../../Pickers';\nimport type { IPersonaProps } from '../../../Persona';\nimport type { IRefObject } from '../../../Utilities';\n\nimport type { JSXElement } from '@fluentui/utilities';\n\nexport interface ISuggestionsCoreProps<T> extends React.ClassAttributes<any> {\n /**\n * Gets the component ref.\n */\n componentRef?: IRefObject<{}>;\n /**\n * How the suggestion should look in the suggestion list.\n */\n\n onRenderSuggestion?: (props: T, suggestionItemProps: ISuggestionItemProps<T>) => JSXElement;\n\n /**\n * What should occur when a suggestion is clicked\n */\n onSuggestionClick: (ev?: React.MouseEvent<HTMLElement>, item?: any, index?: number) => void;\n /**\n * The list of Suggestions that will be displayed\n */\n suggestions: ISuggestionModel<T>[];\n /**\n * Function to fire when one of the optional remove buttons on a suggestion is clicked.\n */\n onSuggestionRemove?: (ev?: React.MouseEvent<HTMLElement>, item?: IPersonaProps, index?: number) => void;\n /**\n * Screen reader message to read when there are suggestions available.\n */\n suggestionsAvailableAlertText?: string;\n /**\n * An ARIA label for the container that is the parent of the suggestions.\n */\n suggestionsContainerAriaLabel?: string;\n /**\n * the classname of the suggestion item.\n */\n suggestionsItemClassName?: string;\n /**\n * Maximum number of suggestions to show in the full suggestion list.\n */\n resultsMaximumNumber?: number;\n /**\n * Indicates whether to show a button with each suggestion to remove that suggestion.\n */\n showRemoveButtons?: boolean;\n /**\n * Indicates whether to loop around to the top or bottom of the suggestions\n * on calling nextSuggestion and previousSuggestion, respectively\n */\n shouldLoopSelection: boolean;\n}\n\nexport interface ISuggestionsControlProps<T> extends React.ClassAttributes<any>, ISuggestionsCoreProps<T> {\n /**\n * An ARIA label for the container that is the parent of the suggestions header items.\n */\n suggestionsHeaderContainerAriaLabel?: string;\n /**\n * An ARIA label for the container that is the parent of the suggestions footer items.\n */\n suggestionsFooterContainerAriaLabel?: string;\n /**\n * The header items props\n */\n headerItemsProps?: ISuggestionsHeaderFooterProps[];\n /**\n * The footer items props\n */\n footerItemsProps?: ISuggestionsHeaderFooterProps[];\n /**\n * Whether or not the first selectable item in the suggestions list should be selected\n */\n shouldSelectFirstItem?: () => boolean;\n /**\n * The CSS classname of the suggestions list.\n */\n className?: string;\n /**\n * Completes the suggestion\n */\n completeSuggestion: () => void;\n}\n\nexport interface ISuggestionsHeaderFooterProps {\n renderItem: () => JSXElement;\n onExecute?: () => void;\n className?: string;\n ariaLabel?: string;\n shouldShow: () => boolean;\n}\n\nexport interface ISuggestionsHeaderFooterItemProps {\n componentRef?: IRefObject<{}>;\n\n renderItem: () => JSXElement;\n onExecute?: () => void;\n isSelected: boolean;\n id: string;\n className: string | undefined;\n}\n"]}
@@ -0,0 +1,88 @@
import * as React from 'react';
import { SuggestionsCore } from './SuggestionsCore';
import type { IButton } from '../../../Button';
import type { ISuggestionModel } from '../../../Pickers';
import type { ISuggestionsHeaderFooterItemProps, ISuggestionsControlProps } from './Suggestions.types';
import type { JSXElement } from '@fluentui/utilities';
export declare enum SuggestionItemType {
header = 0,
suggestion = 1,
footer = 2
}
export interface ISuggestionsControlState<T> {
selectedHeaderIndex: number;
selectedFooterIndex: number;
suggestions: ISuggestionModel<T>[];
}
export declare class SuggestionsHeaderFooterItem extends React.Component<ISuggestionsHeaderFooterItemProps, {}> {
constructor(props: ISuggestionsHeaderFooterItemProps);
render(): JSXElement;
}
/**
* Class when used with SuggestionsStore, renders a suggestions control with customizable headers and footers
*/
export declare class SuggestionsControl<T extends {}> extends React.Component<ISuggestionsControlProps<T>, ISuggestionsControlState<T>> {
protected _forceResolveButton: IButton;
protected _searchForMoreButton: IButton;
protected _selectedElement: React.RefObject<HTMLDivElement | null>;
protected _suggestions: React.RefObject<SuggestionsCore<T> | null>;
private SuggestionsOfProperType;
constructor(suggestionsProps: ISuggestionsControlProps<T>);
componentDidMount(): void;
componentDidUpdate(oldProps: ISuggestionsControlProps<T>): void;
componentWillUnmount(): void;
render(): JSXElement;
get currentSuggestion(): ISuggestionModel<T> | undefined;
get currentSuggestionIndex(): number;
get selectedElement(): HTMLDivElement | undefined;
hasSuggestionSelected(): boolean;
hasSelection(): boolean;
executeSelectedAction(): void;
removeSuggestion(index?: number): void;
/**
* Handles the key down, returns true, if the event was handled, false otherwise
* @param keyCode - The keyCode to handle
*/
handleKeyDown(keyCode: number): boolean;
scrollSelected(): void;
protected renderHeaderItems(): JSXElement | null;
protected renderFooterItems(): JSXElement | null;
protected _renderSuggestions(): JSXElement;
/**
* Selects the next selectable item
*/
protected selectNextItem(itemType: SuggestionItemType, originalItemType?: SuggestionItemType): void;
/**
* Selects the previous selectable item
*/
protected selectPreviousItem(itemType: SuggestionItemType, originalItemType?: SuggestionItemType): void;
/**
* Resets the selected state and selects the first selectable item
*/
protected resetSelectedItem(): void;
/**
* Selects the first item
*/
protected selectFirstItem(): void;
/**
* Selects the last item
*/
protected selectLastItem(): void;
/**
* Selects the next item in the suggestion item type group, given the current index
* If none is able to be selected, returns false, otherwise returns true
* @param itemType - The suggestion item type
* @param currentIndex - The current index, default is -1
*/
private _selectNextItemOfItemType;
/**
* Selects the previous item in the suggestion item type group, given the current index
* If none is able to be selected, returns false, otherwise returns true
* @param itemType - The suggestion item type
* @param currentIndex - The current index. If none is provided, the default is the items length of specified type
*/
private _selectPreviousItemOfItemType;
private _getCurrentIndexForType;
private _getNextItemSectionType;
private _getPreviousItemSectionType;
}
@@ -0,0 +1,391 @@
import { __assign, __extends } from "tslib";
import * as React from 'react';
import { css, KeyCodes, initializeComponentRef } from '../../../Utilities';
import { SuggestionsCore } from './SuggestionsCore';
import * as stylesImport from './SuggestionsControl.scss';
import { hiddenContentStyle, mergeStyles } from '../../../Styling';
var styles = stylesImport;
export var SuggestionItemType;
(function (SuggestionItemType) {
SuggestionItemType[SuggestionItemType["header"] = 0] = "header";
SuggestionItemType[SuggestionItemType["suggestion"] = 1] = "suggestion";
SuggestionItemType[SuggestionItemType["footer"] = 2] = "footer";
})(SuggestionItemType || (SuggestionItemType = {}));
var SuggestionsHeaderFooterItem = /** @class */ (function (_super) {
__extends(SuggestionsHeaderFooterItem, _super);
function SuggestionsHeaderFooterItem(props) {
var _this = _super.call(this, props) || this;
initializeComponentRef(_this);
return _this;
}
SuggestionsHeaderFooterItem.prototype.render = function () {
var _a;
var _b = this.props, renderItem = _b.renderItem, onExecute = _b.onExecute, isSelected = _b.isSelected, id = _b.id, className = _b.className;
return onExecute ? (React.createElement("div", { id: id, onClick: onExecute, className: css('ms-Suggestions-sectionButton', className, styles.actionButton, (_a = {},
_a['is-selected ' + styles.buttonSelected] = isSelected,
_a)) }, renderItem())) : (React.createElement("div", { id: id, className: css('ms-Suggestions-section', className, styles.suggestionsTitle) }, renderItem()));
};
return SuggestionsHeaderFooterItem;
}(React.Component));
export { SuggestionsHeaderFooterItem };
/**
* Class when used with SuggestionsStore, renders a suggestions control with customizable headers and footers
*/
var SuggestionsControl = /** @class */ (function (_super) {
__extends(SuggestionsControl, _super);
function SuggestionsControl(suggestionsProps) {
var _this = _super.call(this, suggestionsProps) || this;
_this._selectedElement = React.createRef();
_this._suggestions = React.createRef();
_this.SuggestionsOfProperType = SuggestionsCore;
initializeComponentRef(_this);
_this.state = {
selectedHeaderIndex: -1,
selectedFooterIndex: -1,
suggestions: suggestionsProps.suggestions,
};
return _this;
}
SuggestionsControl.prototype.componentDidMount = function () {
this.resetSelectedItem();
};
SuggestionsControl.prototype.componentDidUpdate = function (oldProps) {
var _this = this;
this.scrollSelected();
if (oldProps.suggestions && oldProps.suggestions !== this.props.suggestions) {
this.setState({ suggestions: this.props.suggestions }, function () {
_this.resetSelectedItem();
});
}
};
SuggestionsControl.prototype.componentWillUnmount = function () {
var _a;
(_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.deselectAllSuggestions();
};
SuggestionsControl.prototype.render = function () {
var _a = this.props, className = _a.className, headerItemsProps = _a.headerItemsProps, footerItemsProps = _a.footerItemsProps, suggestionsAvailableAlertText = _a.suggestionsAvailableAlertText;
var screenReaderTextStyles = mergeStyles(hiddenContentStyle);
var shouldAlertSuggestionsAvailableText = this.state.suggestions && this.state.suggestions.length > 0 && suggestionsAvailableAlertText;
return (React.createElement("div", { className: css('ms-Suggestions', className ? className : '', styles.root) },
headerItemsProps && this.renderHeaderItems(),
this._renderSuggestions(),
footerItemsProps && this.renderFooterItems(),
shouldAlertSuggestionsAvailableText ? (React.createElement("span", { role: "alert", "aria-live": "polite", className: screenReaderTextStyles }, suggestionsAvailableAlertText)) : null));
};
Object.defineProperty(SuggestionsControl.prototype, "currentSuggestion", {
get: function () {
var _a;
return ((_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.getCurrentItem()) || undefined;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SuggestionsControl.prototype, "currentSuggestionIndex", {
get: function () {
return this._suggestions.current ? this._suggestions.current.currentIndex : -1;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SuggestionsControl.prototype, "selectedElement", {
get: function () {
var _a;
return this._selectedElement.current ? this._selectedElement.current : (_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.selectedElement;
},
enumerable: false,
configurable: true
});
SuggestionsControl.prototype.hasSuggestionSelected = function () {
var _a;
return ((_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.hasSuggestionSelected()) || false;
};
SuggestionsControl.prototype.hasSelection = function () {
var _a = this.state, selectedHeaderIndex = _a.selectedHeaderIndex, selectedFooterIndex = _a.selectedFooterIndex;
return selectedHeaderIndex !== -1 || this.hasSuggestionSelected() || selectedFooterIndex !== -1;
};
SuggestionsControl.prototype.executeSelectedAction = function () {
var _a;
var _b = this.props, headerItemsProps = _b.headerItemsProps, footerItemsProps = _b.footerItemsProps;
var _c = this.state, selectedHeaderIndex = _c.selectedHeaderIndex, selectedFooterIndex = _c.selectedFooterIndex;
if (headerItemsProps && selectedHeaderIndex !== -1 && selectedHeaderIndex < headerItemsProps.length) {
var selectedHeaderItem = headerItemsProps[selectedHeaderIndex];
if (selectedHeaderItem.onExecute) {
selectedHeaderItem.onExecute();
}
}
else if ((_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.hasSuggestionSelected()) {
this.props.completeSuggestion();
}
else if (footerItemsProps && selectedFooterIndex !== -1 && selectedFooterIndex < footerItemsProps.length) {
var selectedFooterItem = footerItemsProps[selectedFooterIndex];
if (selectedFooterItem.onExecute) {
selectedFooterItem.onExecute();
}
}
};
SuggestionsControl.prototype.removeSuggestion = function (index) {
var _a, _b;
(_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.removeSuggestion(index ? index : (_b = this._suggestions.current) === null || _b === void 0 ? void 0 : _b.currentIndex);
};
/**
* Handles the key down, returns true, if the event was handled, false otherwise
* @param keyCode - The keyCode to handle
*/
SuggestionsControl.prototype.handleKeyDown = function (keyCode) {
var _a, _b, _c, _d;
var _e = this.state, selectedHeaderIndex = _e.selectedHeaderIndex, selectedFooterIndex = _e.selectedFooterIndex;
var isKeyDownHandled = false;
if (keyCode === KeyCodes.down) {
if (selectedHeaderIndex === -1 &&
!((_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.hasSuggestionSelected()) &&
selectedFooterIndex === -1) {
this.selectFirstItem();
}
else if (selectedHeaderIndex !== -1) {
this.selectNextItem(SuggestionItemType.header);
isKeyDownHandled = true;
}
else if ((_b = this._suggestions.current) === null || _b === void 0 ? void 0 : _b.hasSuggestionSelected()) {
this.selectNextItem(SuggestionItemType.suggestion);
isKeyDownHandled = true;
}
else if (selectedFooterIndex !== -1) {
this.selectNextItem(SuggestionItemType.footer);
isKeyDownHandled = true;
}
}
else if (keyCode === KeyCodes.up) {
if (selectedHeaderIndex === -1 &&
!((_c = this._suggestions.current) === null || _c === void 0 ? void 0 : _c.hasSuggestionSelected()) &&
selectedFooterIndex === -1) {
this.selectLastItem();
}
else if (selectedHeaderIndex !== -1) {
this.selectPreviousItem(SuggestionItemType.header);
isKeyDownHandled = true;
}
else if ((_d = this._suggestions.current) === null || _d === void 0 ? void 0 : _d.hasSuggestionSelected()) {
this.selectPreviousItem(SuggestionItemType.suggestion);
isKeyDownHandled = true;
}
else if (selectedFooterIndex !== -1) {
this.selectPreviousItem(SuggestionItemType.footer);
isKeyDownHandled = true;
}
}
else if (keyCode === KeyCodes.enter || keyCode === KeyCodes.tab) {
if (this.hasSelection()) {
this.executeSelectedAction();
isKeyDownHandled = true;
}
}
return isKeyDownHandled;
};
// TODO get the element to scroll into view properly regardless of direction.
SuggestionsControl.prototype.scrollSelected = function () {
if (this._selectedElement.current) {
this._selectedElement.current.scrollIntoView(false);
}
};
SuggestionsControl.prototype.renderHeaderItems = function () {
var _this = this;
var _a = this.props, headerItemsProps = _a.headerItemsProps, suggestionsHeaderContainerAriaLabel = _a.suggestionsHeaderContainerAriaLabel;
var selectedHeaderIndex = this.state.selectedHeaderIndex;
return headerItemsProps ? (React.createElement("div", { className: css('ms-Suggestions-headerContainer', styles.suggestionsContainer), id: "suggestionHeader-list", role: "list", "aria-label": suggestionsHeaderContainerAriaLabel }, headerItemsProps.map(function (headerItemProps, index) {
var isSelected = selectedHeaderIndex !== -1 && selectedHeaderIndex === index;
return headerItemProps.shouldShow() ? (React.createElement("div", { ref: isSelected ? _this._selectedElement : undefined, id: 'sug-header' + index, key: 'sug-header' + index, role: "listitem", "aria-label": headerItemProps.ariaLabel },
React.createElement(SuggestionsHeaderFooterItem, { id: 'sug-header-item' + index, isSelected: isSelected, renderItem: headerItemProps.renderItem, onExecute: headerItemProps.onExecute, className: headerItemProps.className }))) : null;
}))) : null;
};
SuggestionsControl.prototype.renderFooterItems = function () {
var _this = this;
var _a = this.props, footerItemsProps = _a.footerItemsProps, suggestionsFooterContainerAriaLabel = _a.suggestionsFooterContainerAriaLabel;
var selectedFooterIndex = this.state.selectedFooterIndex;
return footerItemsProps ? (React.createElement("div", { className: css('ms-Suggestions-footerContainer', styles.suggestionsContainer), id: "suggestionFooter-list", role: "list", "aria-label": suggestionsFooterContainerAriaLabel }, footerItemsProps.map(function (footerItemProps, index) {
var isSelected = selectedFooterIndex !== -1 && selectedFooterIndex === index;
return footerItemProps.shouldShow() ? (React.createElement("div", { ref: isSelected ? _this._selectedElement : undefined, id: 'sug-footer' + index, key: 'sug-footer' + index, role: "listitem", "aria-label": footerItemProps.ariaLabel },
React.createElement(SuggestionsHeaderFooterItem, { id: 'sug-footer-item' + index, isSelected: isSelected, renderItem: footerItemProps.renderItem, onExecute: footerItemProps.onExecute, className: footerItemProps.className }))) : null;
}))) : null;
};
SuggestionsControl.prototype._renderSuggestions = function () {
var TypedSuggestions = this.SuggestionsOfProperType;
return React.createElement(TypedSuggestions, __assign({ ref: this._suggestions }, this.props, { suggestions: this.state.suggestions }));
};
/**
* Selects the next selectable item
*/
SuggestionsControl.prototype.selectNextItem = function (itemType, originalItemType) {
// If the recursive calling has not found a selectable item in the other suggestion item type groups
// And the method is being called again with the original item type,
// Select the first selectable item of this suggestion item type group (could be the currently selected item)
if (itemType === originalItemType) {
this._selectNextItemOfItemType(itemType);
return;
}
var startedItemType = originalItemType !== undefined ? originalItemType : itemType;
// Try to set the selection to the next selectable item, of the same suggestion item type group
// If this is the original item type, use the current index
var selectionChanged = this._selectNextItemOfItemType(itemType, startedItemType === itemType ? this._getCurrentIndexForType(itemType) : undefined);
// If the selection did not change, try to select from the next suggestion type group
if (!selectionChanged) {
this.selectNextItem(this._getNextItemSectionType(itemType), startedItemType);
}
};
/**
* Selects the previous selectable item
*/
SuggestionsControl.prototype.selectPreviousItem = function (itemType, originalItemType) {
// If the recursive calling has not found a selectable item in the other suggestion item type groups
// And the method is being called again with the original item type,
// Select the last selectable item of this suggestion item type group (could be the currently selected item)
if (itemType === originalItemType) {
this._selectPreviousItemOfItemType(itemType);
return;
}
var startedItemType = originalItemType !== undefined ? originalItemType : itemType;
// Try to set the selection to the previous selectable item, of the same suggestion item type group
var selectionChanged = this._selectPreviousItemOfItemType(itemType, startedItemType === itemType ? this._getCurrentIndexForType(itemType) : undefined);
// If the selection did not change, try to select from the previous suggestion type group
if (!selectionChanged) {
this.selectPreviousItem(this._getPreviousItemSectionType(itemType), startedItemType);
}
};
/**
* Resets the selected state and selects the first selectable item
*/
SuggestionsControl.prototype.resetSelectedItem = function () {
var _a;
this.setState({ selectedHeaderIndex: -1, selectedFooterIndex: -1 });
(_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.deselectAllSuggestions();
// Select the first item if the shouldSelectFirstItem prop is not set or it is set and it returns true
if (this.props.shouldSelectFirstItem === undefined || this.props.shouldSelectFirstItem()) {
this.selectFirstItem();
}
};
/**
* Selects the first item
*/
SuggestionsControl.prototype.selectFirstItem = function () {
if (this._selectNextItemOfItemType(SuggestionItemType.header)) {
return;
}
if (this._selectNextItemOfItemType(SuggestionItemType.suggestion)) {
return;
}
this._selectNextItemOfItemType(SuggestionItemType.footer);
};
/**
* Selects the last item
*/
SuggestionsControl.prototype.selectLastItem = function () {
if (this._selectPreviousItemOfItemType(SuggestionItemType.footer)) {
return;
}
if (this._selectPreviousItemOfItemType(SuggestionItemType.suggestion)) {
return;
}
this._selectPreviousItemOfItemType(SuggestionItemType.header);
};
/**
* Selects the next item in the suggestion item type group, given the current index
* If none is able to be selected, returns false, otherwise returns true
* @param itemType - The suggestion item type
* @param currentIndex - The current index, default is -1
*/
SuggestionsControl.prototype._selectNextItemOfItemType = function (itemType, currentIndex) {
var _a, _b;
if (currentIndex === void 0) { currentIndex = -1; }
if (itemType === SuggestionItemType.suggestion) {
if (this.state.suggestions.length > currentIndex + 1) {
(_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.setSelectedSuggestion(currentIndex + 1);
this.setState({ selectedHeaderIndex: -1, selectedFooterIndex: -1 });
return true;
}
}
else {
var isHeader = itemType === SuggestionItemType.header;
var itemProps = isHeader ? this.props.headerItemsProps : this.props.footerItemsProps;
if (itemProps && itemProps.length > currentIndex + 1) {
for (var i = currentIndex + 1; i < itemProps.length; i++) {
var item = itemProps[i];
if (item.onExecute && item.shouldShow()) {
this.setState({ selectedHeaderIndex: isHeader ? i : -1 });
this.setState({ selectedFooterIndex: isHeader ? -1 : i });
(_b = this._suggestions.current) === null || _b === void 0 ? void 0 : _b.deselectAllSuggestions();
return true;
}
}
}
}
return false;
};
/**
* Selects the previous item in the suggestion item type group, given the current index
* If none is able to be selected, returns false, otherwise returns true
* @param itemType - The suggestion item type
* @param currentIndex - The current index. If none is provided, the default is the items length of specified type
*/
SuggestionsControl.prototype._selectPreviousItemOfItemType = function (itemType, currentIndex) {
var _a, _b;
if (itemType === SuggestionItemType.suggestion) {
var index = currentIndex !== undefined ? currentIndex : this.state.suggestions.length;
if (index > 0) {
(_a = this._suggestions.current) === null || _a === void 0 ? void 0 : _a.setSelectedSuggestion(index - 1);
this.setState({ selectedHeaderIndex: -1, selectedFooterIndex: -1 });
return true;
}
}
else {
var isHeader = itemType === SuggestionItemType.header;
var itemProps = isHeader ? this.props.headerItemsProps : this.props.footerItemsProps;
if (itemProps) {
var index = currentIndex !== undefined ? currentIndex : itemProps.length;
if (index > 0) {
for (var i = index - 1; i >= 0; i--) {
var item = itemProps[i];
if (item.onExecute && item.shouldShow()) {
this.setState({ selectedHeaderIndex: isHeader ? i : -1 });
this.setState({ selectedFooterIndex: isHeader ? -1 : i });
(_b = this._suggestions.current) === null || _b === void 0 ? void 0 : _b.deselectAllSuggestions();
return true;
}
}
}
}
}
return false;
};
SuggestionsControl.prototype._getCurrentIndexForType = function (itemType) {
switch (itemType) {
case SuggestionItemType.header:
return this.state.selectedHeaderIndex;
case SuggestionItemType.suggestion:
return this._suggestions.current.currentIndex;
case SuggestionItemType.footer:
return this.state.selectedFooterIndex;
}
};
SuggestionsControl.prototype._getNextItemSectionType = function (itemType) {
switch (itemType) {
case SuggestionItemType.header:
return SuggestionItemType.suggestion;
case SuggestionItemType.suggestion:
return SuggestionItemType.footer;
case SuggestionItemType.footer:
return SuggestionItemType.header;
}
};
SuggestionsControl.prototype._getPreviousItemSectionType = function (itemType) {
switch (itemType) {
case SuggestionItemType.header:
return SuggestionItemType.footer;
case SuggestionItemType.suggestion:
return SuggestionItemType.header;
case SuggestionItemType.footer:
return SuggestionItemType.suggestion;
}
};
return SuggestionsControl;
}(React.Component));
export { SuggestionsControl };
//# sourceMappingURL=SuggestionsControl.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
export declare const root = "root_ade399af";
export declare const actionButton = "actionButton_ade399af";
export declare const buttonSelected = "buttonSelected_ade399af";
export declare const suggestionsTitle = "suggestionsTitle_ade399af";
export declare const suggestionsSpinner = "suggestionsSpinner_ade399af";
export declare const itemButton = "itemButton_ade399af";
export declare const screenReaderOnly = "screenReaderOnly_ade399af";
@@ -0,0 +1,11 @@
/* eslint-disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".root_ade399af{min-width:260px}.actionButton_ade399af{background:0 0;background-color:transparent;border:0;cursor:pointer;margin:0;padding:0;position:relative;width:100%;font-size:12px}html[dir=ltr] .actionButton_ade399af{text-align:left}html[dir=rtl] .actionButton_ade399af{text-align:right}.actionButton_ade399af:hover{background-color:" }, { "theme": "neutralLighter", "defaultValue": "#f3f2f1" }, { "rawString": ";cursor:pointer}.actionButton_ade399af:active,.actionButton_ade399af:focus{background-color:" }, { "theme": "themeLight", "defaultValue": "#c7e0f4" }, { "rawString": "}.actionButton_ade399af .ms-Button-icon{font-size:16px;width:25px}.actionButton_ade399af .ms-Button-label{margin:0 4px 0 9px}html[dir=rtl] .actionButton_ade399af .ms-Button-label{margin:0 9px 0 4px}.buttonSelected_ade399af{background-color:" }, { "theme": "themeLighter", "defaultValue": "#deecf9" }, { "rawString": "}.buttonSelected_ade399af:hover{background-color:" }, { "theme": "themeLight", "defaultValue": "#c7e0f4" }, { "rawString": ";cursor:pointer}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.buttonSelected_ade399af:hover{background-color:Highlight;color:HighlightText}}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.buttonSelected_ade399af{background-color:Highlight;color:HighlightText;-ms-high-contrast-adjust:none}}.suggestionsTitle_ade399af{font-size:12px}.suggestionsSpinner_ade399af{margin:5px 0;white-space:nowrap;line-height:20px;font-size:12px}html[dir=ltr] .suggestionsSpinner_ade399af{padding-left:14px}html[dir=rtl] .suggestionsSpinner_ade399af{padding-right:14px}html[dir=ltr] .suggestionsSpinner_ade399af{text-align:left}html[dir=rtl] .suggestionsSpinner_ade399af{text-align:right}.suggestionsSpinner_ade399af .ms-Spinner-circle{display:inline-block;vertical-align:middle}.suggestionsSpinner_ade399af .ms-Spinner-label{display:inline-block;margin:0 10px 0 16px;vertical-align:middle}html[dir=rtl] .suggestionsSpinner_ade399af .ms-Spinner-label{margin:0 16px 0 10px}.itemButton_ade399af{height:100%;width:100%;padding:7px 12px}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.itemButton_ade399af{color:WindowText}}.screenReaderOnly_ade399af{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}" }]);
export var root = "root_ade399af";
export var actionButton = "actionButton_ade399af";
export var buttonSelected = "buttonSelected_ade399af";
export var suggestionsTitle = "suggestionsTitle_ade399af";
export var suggestionsSpinner = "suggestionsSpinner_ade399af";
export var itemButton = "itemButton_ade399af";
export var screenReaderOnly = "screenReaderOnly_ade399af";
//# sourceMappingURL=SuggestionsControl.scss.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SuggestionsControl.scss.js","sourceRoot":"../src/","sources":["components/FloatingPicker/Suggestions/SuggestionsControl.scss.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,UAAU,CAAC,CAAC,EAAC,WAAW,EAAC,oVAAoV,EAAC,EAAC,EAAC,OAAO,EAAC,gBAAgB,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,8FAA8F,EAAC,EAAC,EAAC,OAAO,EAAC,YAAY,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,kPAAkP,EAAC,EAAC,EAAC,OAAO,EAAC,cAAc,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,mDAAmD,EAAC,EAAC,EAAC,OAAO,EAAC,YAAY,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,kzCAAkzC,EAAC,CAAC,CAAC,CAAC;AACxyE,MAAM,CAAC,IAAM,IAAI,GAAG,eAAe,CAAC;AACpC,MAAM,CAAC,IAAM,YAAY,GAAG,uBAAuB,CAAC;AACpD,MAAM,CAAC,IAAM,cAAc,GAAG,yBAAyB,CAAC;AACxD,MAAM,CAAC,IAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,IAAM,kBAAkB,GAAG,6BAA6B,CAAC;AAChE,MAAM,CAAC,IAAM,UAAU,GAAG,qBAAqB,CAAC;AAChD,MAAM,CAAC,IAAM,gBAAgB,GAAG,2BAA2B,CAAC","sourcesContent":["/* eslint-disable */\nimport { loadStyles } from '@microsoft/load-themed-styles';\nloadStyles([{\"rawString\":\".root_ade399af{min-width:260px}.actionButton_ade399af{background:0 0;background-color:transparent;border:0;cursor:pointer;margin:0;padding:0;position:relative;width:100%;font-size:12px}html[dir=ltr] .actionButton_ade399af{text-align:left}html[dir=rtl] .actionButton_ade399af{text-align:right}.actionButton_ade399af:hover{background-color:\"},{\"theme\":\"neutralLighter\",\"defaultValue\":\"#f3f2f1\"},{\"rawString\":\";cursor:pointer}.actionButton_ade399af:active,.actionButton_ade399af:focus{background-color:\"},{\"theme\":\"themeLight\",\"defaultValue\":\"#c7e0f4\"},{\"rawString\":\"}.actionButton_ade399af .ms-Button-icon{font-size:16px;width:25px}.actionButton_ade399af .ms-Button-label{margin:0 4px 0 9px}html[dir=rtl] .actionButton_ade399af .ms-Button-label{margin:0 9px 0 4px}.buttonSelected_ade399af{background-color:\"},{\"theme\":\"themeLighter\",\"defaultValue\":\"#deecf9\"},{\"rawString\":\"}.buttonSelected_ade399af:hover{background-color:\"},{\"theme\":\"themeLight\",\"defaultValue\":\"#c7e0f4\"},{\"rawString\":\";cursor:pointer}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.buttonSelected_ade399af:hover{background-color:Highlight;color:HighlightText}}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.buttonSelected_ade399af{background-color:Highlight;color:HighlightText;-ms-high-contrast-adjust:none}}.suggestionsTitle_ade399af{font-size:12px}.suggestionsSpinner_ade399af{margin:5px 0;white-space:nowrap;line-height:20px;font-size:12px}html[dir=ltr] .suggestionsSpinner_ade399af{padding-left:14px}html[dir=rtl] .suggestionsSpinner_ade399af{padding-right:14px}html[dir=ltr] .suggestionsSpinner_ade399af{text-align:left}html[dir=rtl] .suggestionsSpinner_ade399af{text-align:right}.suggestionsSpinner_ade399af .ms-Spinner-circle{display:inline-block;vertical-align:middle}.suggestionsSpinner_ade399af .ms-Spinner-label{display:inline-block;margin:0 10px 0 16px;vertical-align:middle}html[dir=rtl] .suggestionsSpinner_ade399af .ms-Spinner-label{margin:0 16px 0 10px}.itemButton_ade399af{height:100%;width:100%;padding:7px 12px}@media screen and (-ms-high-contrast:active),screen and (forced-colors:active){.itemButton_ade399af{color:WindowText}}.screenReaderOnly_ade399af{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}\"}]);\nexport const root = \"root_ade399af\";\nexport const actionButton = \"actionButton_ade399af\";\nexport const buttonSelected = \"buttonSelected_ade399af\";\nexport const suggestionsTitle = \"suggestionsTitle_ade399af\";\nexport const suggestionsSpinner = \"suggestionsSpinner_ade399af\";\nexport const itemButton = \"itemButton_ade399af\";\nexport const screenReaderOnly = \"screenReaderOnly_ade399af\";"]}
@@ -0,0 +1,34 @@
import * as React from 'react';
import type { ISuggestionModel } from '../../../Pickers';
import type { ISuggestionsCoreProps } from './Suggestions.types';
import type { JSXElement } from '@fluentui/utilities';
/**
* Class when used with SuggestionsStore, renders a basic suggestions control
*/
export declare class SuggestionsCore<T extends {}> extends React.Component<ISuggestionsCoreProps<T>, {}> {
currentIndex: number;
currentSuggestion: ISuggestionModel<T> | undefined;
protected _selectedElement: React.RefObject<HTMLDivElement | null>;
private SuggestionsItemOfProperType;
constructor(suggestionsProps: ISuggestionsCoreProps<T>);
/**
* Increments the selected suggestion index
*/
nextSuggestion(): boolean;
/**
* Decrements the selected suggestion index
*/
previousSuggestion(): boolean;
get selectedElement(): HTMLDivElement | undefined;
getCurrentItem(): ISuggestionModel<T>;
getSuggestionAtIndex(index: number): ISuggestionModel<T>;
hasSuggestionSelected(): boolean;
removeSuggestion(index: number): void;
deselectAllSuggestions(): void;
setSelectedSuggestion(index: number): void;
componentDidUpdate(): void;
render(): JSXElement;
scrollSelected(): void;
private _onClickTypedSuggestionsItem;
private _onRemoveTypedSuggestionsItem;
}
@@ -0,0 +1,142 @@
import { __extends } from "tslib";
import * as React from 'react';
import { initializeComponentRef, css } from '../../../Utilities';
import { SuggestionsItem } from '../../../Pickers';
import * as stylesImport from './SuggestionsCore.scss';
var styles = stylesImport;
/**
* Class when used with SuggestionsStore, renders a basic suggestions control
*/
var SuggestionsCore = /** @class */ (function (_super) {
__extends(SuggestionsCore, _super);
function SuggestionsCore(suggestionsProps) {
var _this = _super.call(this, suggestionsProps) || this;
_this._selectedElement = React.createRef();
_this.SuggestionsItemOfProperType = SuggestionsItem;
_this._onClickTypedSuggestionsItem = function (item, index) {
return function (ev) {
_this.props.onSuggestionClick(ev, item, index);
};
};
_this._onRemoveTypedSuggestionsItem = function (item, index) {
return function (ev) {
var onSuggestionRemove = _this.props.onSuggestionRemove;
onSuggestionRemove(ev, item, index);
ev.stopPropagation();
};
};
initializeComponentRef(_this);
_this.currentIndex = -1;
return _this;
}
/**
* Increments the selected suggestion index
*/
SuggestionsCore.prototype.nextSuggestion = function () {
var suggestions = this.props.suggestions;
if (suggestions && suggestions.length > 0) {
if (this.currentIndex === -1) {
this.setSelectedSuggestion(0);
return true;
}
else if (this.currentIndex < suggestions.length - 1) {
this.setSelectedSuggestion(this.currentIndex + 1);
return true;
}
else if (this.props.shouldLoopSelection && this.currentIndex === suggestions.length - 1) {
this.setSelectedSuggestion(0);
return true;
}
}
return false;
};
/**
* Decrements the selected suggestion index
*/
SuggestionsCore.prototype.previousSuggestion = function () {
var suggestions = this.props.suggestions;
if (suggestions && suggestions.length > 0) {
if (this.currentIndex === -1) {
this.setSelectedSuggestion(suggestions.length - 1);
return true;
}
else if (this.currentIndex > 0) {
this.setSelectedSuggestion(this.currentIndex - 1);
return true;
}
else if (this.props.shouldLoopSelection && this.currentIndex === 0) {
this.setSelectedSuggestion(suggestions.length - 1);
return true;
}
}
return false;
};
Object.defineProperty(SuggestionsCore.prototype, "selectedElement", {
get: function () {
return this._selectedElement.current || undefined;
},
enumerable: false,
configurable: true
});
SuggestionsCore.prototype.getCurrentItem = function () {
return this.props.suggestions[this.currentIndex];
};
SuggestionsCore.prototype.getSuggestionAtIndex = function (index) {
return this.props.suggestions[index];
};
SuggestionsCore.prototype.hasSuggestionSelected = function () {
return this.currentIndex !== -1 && this.currentIndex < this.props.suggestions.length;
};
SuggestionsCore.prototype.removeSuggestion = function (index) {
this.props.suggestions.splice(index, 1);
};
SuggestionsCore.prototype.deselectAllSuggestions = function () {
if (this.currentIndex > -1 && this.props.suggestions[this.currentIndex]) {
this.props.suggestions[this.currentIndex].selected = false;
this.currentIndex = -1;
this.forceUpdate();
}
};
SuggestionsCore.prototype.setSelectedSuggestion = function (index) {
var suggestions = this.props.suggestions;
if (index > suggestions.length - 1 || index < 0) {
this.currentIndex = 0;
this.currentSuggestion.selected = false;
this.currentSuggestion = suggestions[0];
this.currentSuggestion.selected = true;
}
else {
if (this.currentIndex > -1 && suggestions[this.currentIndex]) {
suggestions[this.currentIndex].selected = false;
}
suggestions[index].selected = true;
this.currentIndex = index;
this.currentSuggestion = suggestions[index];
}
this.forceUpdate();
};
SuggestionsCore.prototype.componentDidUpdate = function () {
this.scrollSelected();
};
SuggestionsCore.prototype.render = function () {
var _this = this;
var _a = this.props, onRenderSuggestion = _a.onRenderSuggestion, suggestionsItemClassName = _a.suggestionsItemClassName, resultsMaximumNumber = _a.resultsMaximumNumber, showRemoveButtons = _a.showRemoveButtons, suggestionsContainerAriaLabel = _a.suggestionsContainerAriaLabel;
var TypedSuggestionsItem = this.SuggestionsItemOfProperType;
var suggestions = this.props.suggestions;
if (resultsMaximumNumber) {
suggestions = suggestions.slice(0, resultsMaximumNumber);
}
return (React.createElement("div", { className: css('ms-Suggestions-container', styles.suggestionsContainer), id: "suggestion-list", role: "listbox", "aria-label": suggestionsContainerAriaLabel }, suggestions.map(function (suggestion, index) { return (React.createElement("div", { ref: suggestion.selected || index === _this.currentIndex ? _this._selectedElement : undefined, key: suggestion.item.key ? suggestion.item.key : index, id: 'sug-' + index },
React.createElement(TypedSuggestionsItem, { id: 'sug-item' + index, suggestionModel: suggestion, RenderSuggestion: onRenderSuggestion, onClick: _this._onClickTypedSuggestionsItem(suggestion.item, index), className: suggestionsItemClassName, showRemoveButton: showRemoveButtons, onRemoveItem: _this._onRemoveTypedSuggestionsItem(suggestion.item, index), isSelectedOverride: index === _this.currentIndex }))); })));
};
// TODO get the element to scroll into view properly regardless of direction.
SuggestionsCore.prototype.scrollSelected = function () {
var _a;
if (((_a = this._selectedElement.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) !== undefined) {
this._selectedElement.current.scrollIntoView(false);
}
};
return SuggestionsCore;
}(React.Component));
export { SuggestionsCore };
//# sourceMappingURL=SuggestionsCore.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
export declare const suggestionsContainer = "suggestionsContainer_44c59fda";
@@ -0,0 +1,5 @@
/* eslint-disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".suggestionsContainer_44c59fda{overflow-y:auto;overflow-x:hidden;max-height:300px}.suggestionsContainer_44c59fda .ms-Suggestion-item:hover{background-color:" }, { "theme": "neutralLighter", "defaultValue": "#f3f2f1" }, { "rawString": ";cursor:pointer}.suggestionsContainer_44c59fda .is-suggested{background-color:" }, { "theme": "themeLighter", "defaultValue": "#deecf9" }, { "rawString": "}.suggestionsContainer_44c59fda .is-suggested:hover{background-color:" }, { "theme": "themeLight", "defaultValue": "#c7e0f4" }, { "rawString": ";cursor:pointer}" }]);
export var suggestionsContainer = "suggestionsContainer_44c59fda";
//# sourceMappingURL=SuggestionsCore.scss.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SuggestionsCore.scss.js","sourceRoot":"../src/","sources":["components/FloatingPicker/Suggestions/SuggestionsCore.scss.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,UAAU,CAAC,CAAC,EAAC,WAAW,EAAC,8JAA8J,EAAC,EAAC,EAAC,OAAO,EAAC,gBAAgB,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,gFAAgF,EAAC,EAAC,EAAC,OAAO,EAAC,cAAc,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,uEAAuE,EAAC,EAAC,EAAC,OAAO,EAAC,YAAY,EAAC,cAAc,EAAC,SAAS,EAAC,EAAC,EAAC,WAAW,EAAC,kBAAkB,EAAC,CAAC,CAAC,CAAC;AACviB,MAAM,CAAC,IAAM,oBAAoB,GAAG,+BAA+B,CAAC","sourcesContent":["/* eslint-disable */\nimport { loadStyles } from '@microsoft/load-themed-styles';\nloadStyles([{\"rawString\":\".suggestionsContainer_44c59fda{overflow-y:auto;overflow-x:hidden;max-height:300px}.suggestionsContainer_44c59fda .ms-Suggestion-item:hover{background-color:\"},{\"theme\":\"neutralLighter\",\"defaultValue\":\"#f3f2f1\"},{\"rawString\":\";cursor:pointer}.suggestionsContainer_44c59fda .is-suggested{background-color:\"},{\"theme\":\"themeLighter\",\"defaultValue\":\"#deecf9\"},{\"rawString\":\"}.suggestionsContainer_44c59fda .is-suggested:hover{background-color:\"},{\"theme\":\"themeLight\",\"defaultValue\":\"#c7e0f4\"},{\"rawString\":\";cursor:pointer}\"}]);\nexport const suggestionsContainer = \"suggestionsContainer_44c59fda\";"]}
@@ -0,0 +1,16 @@
import type { ISuggestionModel } from '../../../Pickers';
export type SuggestionsStoreOptions<T> = {
getAriaLabel?: (item: T) => string;
};
export declare class SuggestionsStore<T> {
suggestions: ISuggestionModel<T>[];
private getAriaLabel?;
constructor(options?: SuggestionsStoreOptions<T>);
updateSuggestions(newSuggestions: T[]): void;
getSuggestions(): ISuggestionModel<T>[];
getSuggestionAtIndex(index: number): ISuggestionModel<T>;
removeSuggestion(index: number): void;
convertSuggestionsToSuggestionItems(suggestions: Array<ISuggestionModel<T> | T>): ISuggestionModel<T>[];
private _isSuggestionModel;
private _ensureSuggestionModel;
}
@@ -0,0 +1,50 @@
var SuggestionsStore = /** @class */ (function () {
function SuggestionsStore(options) {
var _this = this;
this._isSuggestionModel = function (value) {
return value.item !== undefined;
};
this._ensureSuggestionModel = function (suggestion) {
if (_this._isSuggestionModel(suggestion)) {
return suggestion;
}
else {
return {
item: suggestion,
selected: false,
ariaLabel: _this.getAriaLabel !== undefined
? _this.getAriaLabel(suggestion)
: suggestion.name ||
suggestion.text ||
// eslint-disable-next-line @typescript-eslint/no-deprecated
suggestion.primaryText,
};
}
};
this.suggestions = [];
this.getAriaLabel = options && options.getAriaLabel;
}
SuggestionsStore.prototype.updateSuggestions = function (newSuggestions) {
if (newSuggestions && newSuggestions.length > 0) {
this.suggestions = this.convertSuggestionsToSuggestionItems(newSuggestions);
}
else {
this.suggestions = [];
}
};
SuggestionsStore.prototype.getSuggestions = function () {
return this.suggestions;
};
SuggestionsStore.prototype.getSuggestionAtIndex = function (index) {
return this.suggestions[index];
};
SuggestionsStore.prototype.removeSuggestion = function (index) {
this.suggestions.splice(index, 1);
};
SuggestionsStore.prototype.convertSuggestionsToSuggestionItems = function (suggestions) {
return Array.isArray(suggestions) ? suggestions.map(this._ensureSuggestionModel) : [];
};
return SuggestionsStore;
}());
export { SuggestionsStore };
//# sourceMappingURL=SuggestionsStore.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SuggestionsStore.js","sourceRoot":"../src/","sources":["components/FloatingPicker/Suggestions/SuggestionsStore.ts"],"names":[],"mappings":"AAOA;IAIE,0BAAY,OAAoC;QAAhD,iBAGC;QA0BO,uBAAkB,GAAG,UAAC,KAA8B;YAC1D,OAA6B,KAAM,CAAC,IAAI,KAAK,SAAS,CAAC;QACzD,CAAC,CAAC;QAEM,2BAAsB,GAAG,UAAC,UAAmC;YACnE,IAAI,KAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,OAAO,UAAU,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE,KAAK;oBACf,SAAS,EACP,KAAI,CAAC,YAAY,KAAK,SAAS;wBAC7B,CAAC,CAAC,KAAI,CAAC,YAAY,CAAC,UAAU,CAAC;wBAC/B,CAAC,CAAE,UAA0B,CAAC,IAAI;4BAChB,UAAW,CAAC,IAAI;4BAChC,4DAA4D;4BAC5C,UAAW,CAAC,WAAW;iBAC9C,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;QAhDA,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;IACtD,CAAC;IAEM,4CAAiB,GAAxB,UAAyB,cAAmB;QAC1C,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,mCAAmC,CAAC,cAAc,CAAC,CAAC;QAC9E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;IAEM,yCAAc,GAArB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,+CAAoB,GAA3B,UAA4B,KAAa;QACvC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAEM,2CAAgB,GAAvB,UAAwB,KAAa;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAEM,8DAAmC,GAA1C,UAA2C,WAA2C;QACpF,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxF,CAAC;IAuBH,uBAAC;AAAD,CAAC,AAtDD,IAsDC","sourcesContent":["import type { ISuggestionModel, ITag } from '../../../Pickers';\nimport type { IPersonaProps } from '../../../Persona';\n\nexport type SuggestionsStoreOptions<T> = {\n getAriaLabel?: (item: T) => string;\n};\n\nexport class SuggestionsStore<T> {\n public suggestions: ISuggestionModel<T>[];\n private getAriaLabel?: (item: T) => string;\n\n constructor(options?: SuggestionsStoreOptions<T>) {\n this.suggestions = [];\n this.getAriaLabel = options && options.getAriaLabel;\n }\n\n public updateSuggestions(newSuggestions: T[]): void {\n if (newSuggestions && newSuggestions.length > 0) {\n this.suggestions = this.convertSuggestionsToSuggestionItems(newSuggestions);\n } else {\n this.suggestions = [];\n }\n }\n\n public getSuggestions(): ISuggestionModel<T>[] {\n return this.suggestions;\n }\n\n public getSuggestionAtIndex(index: number): ISuggestionModel<T> {\n return this.suggestions[index];\n }\n\n public removeSuggestion(index: number): void {\n this.suggestions.splice(index, 1);\n }\n\n public convertSuggestionsToSuggestionItems(suggestions: Array<ISuggestionModel<T> | T>): ISuggestionModel<T>[] {\n return Array.isArray(suggestions) ? suggestions.map(this._ensureSuggestionModel) : [];\n }\n\n private _isSuggestionModel = (value: ISuggestionModel<T> | T): value is ISuggestionModel<T> => {\n return (<ISuggestionModel<T>>value).item !== undefined;\n };\n\n private _ensureSuggestionModel = (suggestion: ISuggestionModel<T> | T): ISuggestionModel<T> => {\n if (this._isSuggestionModel(suggestion)) {\n return suggestion;\n } else {\n return {\n item: suggestion,\n selected: false,\n ariaLabel:\n this.getAriaLabel !== undefined\n ? this.getAriaLabel(suggestion)\n : (suggestion as any as ITag).name ||\n (<IPersonaProps>suggestion).text ||\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n (<IPersonaProps>suggestion).primaryText,\n };\n }\n };\n}\n"]}
@@ -0,0 +1,7 @@
export * from './BaseFloatingPicker';
export * from './BaseFloatingPicker.types';
export * from './PeoplePicker/FloatingPeoplePicker';
export * from './Suggestions/SuggestionsStore';
export * from './Suggestions/SuggestionsControl';
export * from './Suggestions/SuggestionsCore';
export * from './Suggestions/Suggestions.types';
+8
View File
@@ -0,0 +1,8 @@
export * from './BaseFloatingPicker';
export * from './BaseFloatingPicker.types';
export * from './PeoplePicker/FloatingPeoplePicker';
export * from './Suggestions/SuggestionsStore';
export * from './Suggestions/SuggestionsControl';
export * from './Suggestions/SuggestionsCore';
export * from './Suggestions/Suggestions.types';
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/FloatingPicker/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './BaseFloatingPicker';\nexport * from './BaseFloatingPicker.types';\nexport * from './PeoplePicker/FloatingPeoplePicker';\nexport * from './Suggestions/SuggestionsStore';\nexport * from './Suggestions/SuggestionsControl';\nexport * from './Suggestions/SuggestionsCore';\nexport * from './Suggestions/Suggestions.types';\n"]}