UNPKG

90.1 kBTypeScriptView Raw
1import { DATA_PORTAL_ATTRIBUTE } from '@fluentui/dom-utilities';
2import { elementContains } from '@fluentui/dom-utilities';
3import { elementContainsAttribute } from '@fluentui/dom-utilities';
4import type { ExtendedCSSStyleSheet } from '@fluentui/merge-styles';
5import { findElementRecursive } from '@fluentui/dom-utilities';
6import { getActiveElement } from '@fluentui/dom-utilities';
7import { getChildren } from '@fluentui/dom-utilities';
8import { getEventTarget } from '@fluentui/dom-utilities';
9import { getParent } from '@fluentui/dom-utilities';
10import { getVirtualParent } from '@fluentui/dom-utilities';
11import type { IProcessedStyleSet } from '@fluentui/merge-styles';
12import { IStyleFunction } from '@fluentui/merge-styles';
13import { IStyleFunctionOrObject } from '@fluentui/merge-styles';
14import type { IStyleSetBase } from '@fluentui/merge-styles';
15import { isVirtualElement } from '@fluentui/dom-utilities';
16import { IVirtualElement } from '@fluentui/dom-utilities';
17import { Omit as Omit_2 } from '@fluentui/merge-styles';
18import { portalContainsElement } from '@fluentui/dom-utilities';
19import * as React_2 from 'react';
20import { setPortalAttribute } from '@fluentui/dom-utilities';
21import { setVirtualParent } from '@fluentui/dom-utilities';
22import { ShadowConfig } from '@fluentui/merge-styles';
23
24/**
25 * Adds a keycode to the list of keys that, when pressed, should cause the focus outlines to be visible.
26 * This can be used to add global shortcut keys that directionally move from section to section within
27 * an app or between focus trap zones.
28 */
29export declare function addDirectionalKeyCode(which: number): void;
30
31/**
32 * Given an array, this function returns a new array where an element has been inserted at the given index.
33 * @param array - The array to operate on
34 * @param index - The index where an element should be inserted
35 * @param itemToAdd - The element to insert
36 */
37export declare function addElementAtIndex<T>(array: T[], index: number, itemToAdd: T): T[];
38
39export declare type AdoptedStylesheetExHook = (stylesheetKey: string, shadowCtx: MergeStylesShadowRootContextValue | undefined, rootMergeStyles: Map<string, ExtendedCSSStyleSheet>, win: Window | undefined) => boolean;
40
41export declare type AdoptedStylesheetHook = (stylesheetKey: string) => boolean;
42
43/**
44 * Same as allowScrollOnElement but does not prevent overscrolling.
45 */
46export declare const allowOverscrollOnElement: (element: HTMLElement | null, events: EventGroup) => void;
47
48/**
49 * Allows the user to scroll within a element,
50 * while preventing the user from scrolling the body
51 */
52export declare const allowScrollOnElement: (element: HTMLElement | null, events: EventGroup) => void;
53
54/**
55 * An array of A tag properties and events.
56 *
57 * @public
58 */
59export declare const anchorProperties: Record<string, number>;
60
61/**
62 * Returns a single function which will call each of the given functions in the context of the
63 * parent.
64 */
65export declare function appendFunction(parent: any, ...functions: any[]): () => void;
66
67/**
68 * Returns a boolean indicating if the two given arrays are equal in length and values.
69 *
70 * @param array1 - First array to compare
71 * @param array2 - Second array to compare
72 * @returns True if the arrays are the same length and have the same values in the same positions, false otherwise.
73 */
74export declare function arraysEqual<T>(array1: T[], array2: T[]): boolean;
75
76/**
77 * Produces a component which internally loads the target component before first mount.
78 * The component passes all props through to the loaded component.
79 *
80 * This overload accepts a module with a default export for the component.
81 */
82export declare function asAsync<TProps extends {}>(options: IAsAsyncOptions<TProps>): React_2.ForwardRefExoticComponent<React_2.PropsWithoutRef<TProps & {
83 asyncPlaceholder?: React_2.ElementType<any> | undefined;
84}> & React_2.RefAttributes<React_2.ElementType<TProps>>>;
85
86/**
87 * AssertNever is a utility function that can be used for exhaustiveness checks in switch statements.
88 *
89 * @public
90 */
91export declare function assertNever(x: never): never;
92
93/**
94 * Makes a resulting merge of a bunch of objects. Pass in the target object followed by 1 or more
95 * objects as arguments and they will be merged sequentially into the target. Note that this will
96 * shallow merge; it will not create new cloned values for target members.
97 *
98 * @public
99 * @param target - Target object to merge following object arguments into.
100 * @param args - One or more objects that will be mixed into the target in the order they are provided.
101 * @returns Resulting merged target.
102 */
103export declare function assign(this: any, target: any, ...args: any[]): any;
104
105/**
106 * Bugs often appear in async code when stuff gets disposed, but async operations don't get canceled.
107 * This Async helper class solves these issues by tying async code to the lifetime of a disposable object.
108 *
109 * Usage: Anything class extending from BaseModel can access this helper via this.async. Otherwise create a
110 * new instance of the class and remember to call dispose() during your code's dispose handler.
111 *
112 * @public
113 */
114export declare class Async {
115 private _timeoutIds;
116 private _immediateIds;
117 private _intervalIds;
118 private _animationFrameIds;
119 private _isDisposed;
120 private _parent;
121 private _onErrorHandler;
122 private _noop;
123 constructor(parent?: object, onError?: (e: any) => void);
124 /**
125 * Dispose function, clears all async operations.
126 */
127 dispose(): void;
128 /**
129 * SetTimeout override, which will auto cancel the timeout during dispose.
130 * @param callback - Callback to execute.
131 * @param duration - Duration in milliseconds.
132 * @returns The setTimeout id.
133 */
134 setTimeout(callback: () => void, duration: number): number;
135 /**
136 * Clears the timeout.
137 * @param id - Id to cancel.
138 */
139 clearTimeout(id: number): void;
140 /**
141 * SetImmediate override, which will auto cancel the immediate during dispose.
142 * @param callback - Callback to execute.
143 * @param targetElement - Optional target element to use for identifying the correct window.
144 * @returns The setTimeout id.
145 */
146 setImmediate(callback: () => void, targetElement?: Element | null): number;
147 /**
148 * Clears the immediate.
149 * @param id - Id to cancel.
150 * @param targetElement - Optional target element to use for identifying the correct window.
151 */
152 clearImmediate(id: number, targetElement?: Element | null): void;
153 /**
154 * SetInterval override, which will auto cancel the timeout during dispose.
155 * @param callback - Callback to execute.
156 * @param duration - Duration in milliseconds.
157 * @returns The setTimeout id.
158 */
159 setInterval(callback: () => void, duration: number): number;
160 /**
161 * Clears the interval.
162 * @param id - Id to cancel.
163 */
164 clearInterval(id: number): void;
165 /**
166 * Creates a function that, when executed, will only call the func function at most once per
167 * every wait milliseconds. Provide an options object to indicate that func should be invoked
168 * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled
169 * function will return the result of the last func call.
170 *
171 * Note: If leading and trailing options are true func will be called on the trailing edge of
172 * the timeout only if the throttled function is invoked more than once during the wait timeout.
173 *
174 * @param func - The function to throttle.
175 * @param wait - The number of milliseconds to throttle executions to. Defaults to 0.
176 * @param options - The options object.
177 * @returns The new throttled function.
178 */
179 throttle<T extends (...args: any[]) => any>(func: T, wait?: number, options?: {
180 leading?: boolean;
181 trailing?: boolean;
182 }): T;
183 /**
184 * Creates a function that will delay the execution of func until after wait milliseconds have
185 * elapsed since the last time it was invoked. Provide an options object to indicate that func
186 * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls
187 * to the debounced function will return the result of the last func call.
188 *
189 * Note: If leading and trailing options are true func will be called on the trailing edge of
190 * the timeout only if the debounced function is invoked more than once during the wait
191 * timeout.
192 *
193 * @param func - The function to debounce.
194 * @param wait - The number of milliseconds to delay.
195 * @param options - The options object.
196 * @returns The new debounced function.
197 */
198 debounce<T extends (...args: any[]) => any>(func: T, wait?: number, options?: {
199 leading?: boolean;
200 maxWait?: number;
201 trailing?: boolean;
202 }): ICancelable<T> & T;
203 requestAnimationFrame(callback: () => void, targetElement?: Element | null): number;
204 cancelAnimationFrame(id: number, targetElement?: Element | null): void;
205 protected _logError(e: any): void;
206}
207
208/**
209 * An array of AUDIO tag properties and events.
210
211 * @public
212 */
213export declare const audioProperties: Record<string, number>;
214
215/**
216 * AutoScroll simply hooks up mouse events given a parent element, and scrolls the container
217 * up/down depending on how close the mouse is to the top/bottom of the container.
218 *
219 * Once you don't want autoscroll any more, just dispose the helper and it will unhook events.
220 *
221 * @public
222 * {@docCategory AutoScroll}
223 */
224export declare class AutoScroll {
225 private _events;
226 private _scrollableParent;
227 private _scrollRect;
228 private _scrollVelocity;
229 private _isVerticalScroll;
230 private _timeoutId?;
231 constructor(element: HTMLElement, win?: Window);
232 dispose(): void;
233 private _onMouseMove;
234 private _onTouchMove;
235 private _computeScrollVelocity;
236 private _startScroll;
237 private _incrementScroll;
238 private _stopScroll;
239}
240
241/**
242 * BaseComponent class, which provides basic helpers for all components.
243 *
244 * @public
245 * {@docCategory BaseComponent}
246 *
247 * @deprecated Do not use. We are moving away from class component.
248 */
249export declare class BaseComponent<TProps extends IBaseProps = {}, TState extends {} = {}> extends React_2.Component<TProps, TState> {
250 /**
251 * @deprecated Use React's error boundaries instead.
252 */
253 static onError: (errorMessage?: string, ex?: any) => void;
254 /**
255 * Controls whether the componentRef prop will be resolved by this component instance. If you are
256 * implementing a passthrough (higher-order component), you would set this to false and pass through
257 * the props to the inner component, allowing it to resolve the componentRef.
258 */
259 protected _skipComponentRefResolution: boolean;
260 private __async;
261 private __events;
262 private __disposables;
263 private __resolves;
264 private __className;
265 /**
266 * BaseComponent constructor
267 * @param props - The props for the component.
268 * @param context - The context for the component.
269 */
270 constructor(props: TProps, context?: any);
271 /**
272 * When the component receives props, make sure the componentRef is updated.
273 */
274 componentDidUpdate(prevProps: TProps, prevState: TState): void;
275 /**
276 * When the component has mounted, update the componentRef.
277 */
278 componentDidMount(): void;
279 /**
280 * If we have disposables, dispose them automatically on unmount.
281 */
282 componentWillUnmount(): void;
283 /**
284 * Gets the object's class name.
285 */
286 get className(): string;
287 /**
288 * Allows subclasses to push things to this._disposables to be auto disposed.
289 */
290 protected get _disposables(): IDisposable[];
291 /**
292 * Gets the async instance associated with the component, created on demand. The async instance gives
293 * subclasses a way to execute setTimeout/setInterval async calls safely, where the callbacks
294 * will be cleared/ignored automatically after unmounting. The helpers within the async object also
295 * preserve the this pointer so that you don't need to "bind" the callbacks.
296 */
297 protected get _async(): Async;
298 /**
299 * Gets the event group instance assocaited with the component, created on demand. The event instance
300 * provides on/off methods for listening to DOM (or regular javascript object) events. The event callbacks
301 * will be automatically disconnected after unmounting. The helpers within the events object also
302 * preserve the this reference so that you don't need to "bind" the callbacks.
303 */
304 protected get _events(): EventGroup;
305 /**
306 * Helper to return a memoized ref resolver function.
307 * @param refName - Name of the member to assign the ref to.
308 * @returns A function instance keyed from the given refname.
309 * @deprecated Use `createRef` from React.createRef.
310 */
311 protected _resolveRef(refName: string): (ref: React_2.ReactNode) => React_2.ReactNode;
312 /**
313 * Updates the componentRef (by calling it with "this" when necessary.)
314 */
315 protected _updateComponentRef(currentProps: IBaseProps, newProps?: IBaseProps): void;
316 /**
317 * Warns when a deprecated props are being used.
318 *
319 * @param deprecationMap - The map of deprecations, where key is the prop name and the value is
320 * either null or a replacement prop name.
321 */
322 protected _warnDeprecations(deprecationMap: ISettingsMap<TProps>): void;
323 /**
324 * Warns when props which are mutually exclusive with each other are both used.
325 *
326 * @param mutuallyExclusiveMap - The map of mutually exclusive props.
327 */
328 protected _warnMutuallyExclusive(mutuallyExclusiveMap: ISettingsMap<TProps>): void;
329 /**
330 * Warns when props are required if a condition is met.
331 *
332 * @param requiredProps - The name of the props that are required when the condition is met.
333 * @param conditionalPropName - The name of the prop that the condition is based on.
334 * @param condition - Whether the condition is met.
335 */
336 protected _warnConditionallyRequiredProps(requiredProps: string[], conditionalPropName: string, condition: boolean): void;
337 private _setComponentRef;
338}
339
340/**
341 * An array of events that are allowed on every html element type.
342 *
343 * @public
344 */
345export declare const baseElementEvents: Record<string, number>;
346
347/**
348 * An array of element attributes which are allowed on every html element type.
349 *
350 * @public
351 */
352export declare const baseElementProperties: Record<string, number>;
353
354/**
355 * An array of BUTTON tag properties and events.
356 *
357 * @public
358 */
359export declare const buttonProperties: Record<string, number>;
360
361/**
362 * Calculates a number's precision based on the number of trailing
363 * zeros if the number does not have a decimal indicated by a negative
364 * precision. Otherwise, it calculates the number of digits after
365 * the decimal point indicated by a positive precision.
366 * @param value - the value to determine the precision of
367 */
368export declare function calculatePrecision(value: number | string): number;
369
370/**
371 * Verifies if an application can use DOM.
372 */
373export declare function canUseDOM(): boolean;
374
375/**
376 * Creates a getClassNames function which calls getStyles given the props, and injects them
377 * into mergeStyleSets.
378 *
379 * Note that the props you pass in on every render should be in the same order and
380 * immutable (numbers, strings, and booleans). This will allow the results to be memoized. Violating
381 * these will cause extra recalcs to occur.
382 */
383export declare function classNamesFunction<TStyleProps extends {}, TStyleSet extends IStyleSetBase>(options?: IClassNamesFunctionOptions): (getStyles: IStyleFunctionOrObject<TStyleProps, TStyleSet> | undefined, styleProps?: TStyleProps) => IProcessedStyleSet<TStyleSet>;
384
385export declare const colGroupProperties: Record<string, number>;
386
387export declare const colProperties: Record<string, number>;
388
389/**
390 * Composes two components which conform to the `IComponentAs` specification; that is, two
391 * components which accept a `defaultRender` prop, which is a 'default' implementation of
392 * a component which accepts the same overall props.
393 *
394 * @public
395 */
396export declare function composeComponentAs<TProps extends {}>(outer: IComponentAs<TProps>, inner: IComponentAs<TProps>): IComponentAs<TProps>;
397
398/**
399 * Composes two 'render functions' to produce a final render function that renders
400 * the outer function, passing the inner function as 'default render'. The inner function
401 * is then passed the original 'default render' prop.
402 * @public
403 */
404export declare function composeRenderFunction<TProps>(outer: IRenderFunction<TProps>, inner: IRenderFunction<TProps>): IRenderFunction<TProps>;
405
406/**
407 * Creates an array of a given size and helper method to populate.
408 *
409 * @public
410 * @param size - Size of array.
411 * @param getItem - Callback to populate given cell index.
412 */
413export declare function createArray<T>(size: number, getItem: (index: number) => T): T[];
414
415/**
416 * Creates a memoizer for a single-value function, backed by a WeakMap.
417 * With a WeakMap, the memoized values are only kept as long as the source objects,
418 * ensuring that there is no memory leak.
419 *
420 * This function assumes that the input values passed to the wrapped function will be
421 * `function` or `object` types. To memoize functions which accept other inputs, use
422 * `memoizeFunction`, which memoizes against arbitrary inputs using a lookup cache.
423 *
424 * @public
425 */
426export declare function createMemoizer<F extends (input: any) => any>(getValue: F): F;
427
428/**
429 * Helper to merge refs from within class components.
430 */
431export declare const createMergedRef: <TType, TValue = null>(value?: TValue | undefined) => (...newRefs: (React_2.Ref<TType | TValue | null> | undefined)[]) => (newValue: TType | TValue | null) => void;
432
433/**
434 * Concatination helper, which can merge class names together. Skips over falsey values.
435 *
436 * @public
437 */
438export declare function css(...args: ICssInput[]): string;
439
440export declare function customizable(scope: string, fields: string[], concatStyles?: boolean): <P>(ComposedComponent: React_2.ComponentType<P>) => any;
441
442export declare class Customizations {
443 private static _suppressUpdates;
444 static reset(): void;
445 /** Apply global Customization settings.
446 * @example Customizations.applySettings(\{ theme: \{...\} \});
447 */
448 static applySettings(settings: ISettings): void;
449 /** Apply Customizations to a particular named scope, like a component.
450 * @example Customizations.applyScopedSettings('Nav', \{ styles: () =\> \{\} \});
451 */
452 static applyScopedSettings(scopeName: string, settings: ISettings): void;
453 static getSettings(properties: string[], scopeName?: string, localSettings?: ICustomizations): any;
454 /** Used to run some code that sets Customizations without triggering an update until the end.
455 * Useful for applying Customizations that don't affect anything currently rendered, or for
456 * applying many customizations at once.
457 * @param suppressUpdate - Do not raise the change event at the end, preventing all updates
458 */
459 static applyBatchedUpdates(code: () => void, suppressUpdate?: boolean): void;
460 static observe(onChange: () => void): void;
461 static unobserve(onChange: () => void): void;
462 private static _raiseChange;
463}
464
465/**
466 * The Customizer component allows for default props to be mixed into components which
467 * are decorated with the customizable() decorator, or use the styled HOC. This enables
468 * injection scenarios like:
469 *
470 * 1. render svg icons instead of the icon font within all buttons
471 * 2. inject a custom theme object into a component
472 *
473 * Props are provided via the settings prop which should be one of the following:
474 * - A json map which contains 1 or more name/value pairs representing injectable props.
475 * - A function that receives the current settings and returns the new ones that apply to the scope
476 *
477 * @public
478 *
479 * @deprecated This component is deprecated for purpose of applying theme to components
480 * as of `@fluentui/react` version 8. Use `ThemeProvider` for applying theme instead.
481 */
482export declare class Customizer extends React_2.Component<ICustomizerProps> {
483 componentDidMount(): void;
484 componentWillUnmount(): void;
485 render(): React_2.ReactElement<{}>;
486 private _onCustomizationChange;
487}
488
489export declare const CustomizerContext: React_2.Context<ICustomizerContext>;
490
491/**
492 * Placing this attribute on scrollable divs optimizes detection to know
493 * if the div is scrollable or not (given we can avoid expensive operations
494 * like getComputedStyle.)
495 *
496 * @public
497 */
498export declare const DATA_IS_SCROLLABLE_ATTRIBUTE = "data-is-scrollable";
499
500export { DATA_PORTAL_ATTRIBUTE }
501
502/**
503 * Utility component for delaying the render of a child component after a given delay. This component
504 * requires a single child component; don't pass in many components. Wrap multiple components in a DIV
505 * if necessary.
506 *
507 * @public
508 * {@docCategory DelayedRender}
509 */
510export declare class DelayedRender extends React_2.Component<IDelayedRenderProps, IDelayedRenderState> {
511 static defaultProps: {
512 delay: number;
513 };
514 private _timeoutId;
515 constructor(props: IDelayedRenderProps);
516 componentDidMount(): void;
517 componentWillUnmount(): void;
518 render(): React_2.ReactElement<{}> | null;
519}
520
521/**
522 * Disables the body scrolling.
523 *
524 * @public
525 */
526export declare function disableBodyScroll(): void;
527
528/**
529 * An array of DIV tag properties and events.
530 *
531 * @public
532 */
533export declare const divProperties: Record<string, number>;
534
535/**
536 * Determines if an element, or any of its children, contain focus.
537 *
538 * @public
539 */
540export declare function doesElementContainFocus(element: HTMLElement): boolean;
541
542export { elementContains }
543
544export { elementContainsAttribute }
545
546/**
547 * Enables the body scrolling.
548 *
549 * @public
550 */
551export declare function enableBodyScroll(): void;
552
553/** An instance of EventGroup allows anything with a handle to it to trigger events on it.
554 * If the target is an HTMLElement, the event will be attached to the element and can be
555 * triggered as usual (like clicking for onClick).
556 * The event can be triggered by calling EventGroup.raise() here. If the target is an
557 * HTMLElement, the event gets raised and is handled by the browser. Otherwise, it gets
558 * handled here in EventGroup, and the handler is called in the context of the parent
559 * (which is passed in in the constructor).
560 *
561 * @public
562 * {@docCategory EventGroup}
563 */
564export declare class EventGroup {
565 private static _uniqueId;
566 private _parent;
567 private _eventRecords;
568 private _id;
569 private _isDisposed;
570 /** For IE8, bubbleEvent is ignored here and must be dealt with by the handler.
571 * Events raised here by default have bubbling set to false and cancelable set to true.
572 * This applies also to built-in events being raised manually here on HTMLElements,
573 * which may lead to unexpected behavior if it differs from the defaults.
574 *
575 */
576 static raise(target: any, eventName: string, eventArgs?: any, bubbleEvent?: boolean, doc?: Document): boolean | undefined;
577 static isObserved(target: any, eventName: string): boolean;
578 /** Check to see if the target has declared support of the given event. */
579 static isDeclared(target: any, eventName: string): boolean;
580 static stopPropagation(event: any): void;
581 private static _isElement;
582 /** parent: the context in which events attached to non-HTMLElements are called */
583 constructor(parent: any);
584 dispose(): void;
585 /** On the target, attach a set of events, where the events object is a name to function mapping. */
586 onAll(target: any, events: {
587 [key: string]: (args?: any) => void;
588 }, useCapture?: boolean): void;
589 /**
590 * On the target, attach an event whose handler will be called in the context of the parent
591 * of this instance of EventGroup.
592 */
593 on(target: any, eventName: string, callback: (args?: any) => void, options?: boolean | AddEventListenerOptions): void;
594 off(target?: any, eventName?: string, callback?: (args?: any) => void, options?: boolean | AddEventListenerOptions): void;
595 /** Trigger the given event in the context of this instance of EventGroup. */
596 raise(eventName: string, eventArgs?: any, bubbleEvent?: boolean): boolean | undefined;
597 /** Declare an event as being supported by this instance of EventGroup. */
598 declare(event: string | string[]): void;
599}
600
601/**
602 * Extends a component's lifetime methods by appending new functions to the existing lifetime functions.
603 */
604export declare function extendComponent<T extends React_2.Component>(parent: T, methods: {
605 [key in keyof T]?: T[key];
606}): void;
607
608/**
609 * Performance helper class for measuring things.
610 *
611 * @public
612 * {@docCategory FabricPerformance}
613 */
614export declare class FabricPerformance {
615 static summary: IPerfSummary;
616 private static _timeoutId;
617 /**
618 * Measures execution time of the given syncronous function. If the same logic is executed multiple times,
619 * each individual measurement will be collected as well the overall numbers.
620 * @param name - The name of this measurement
621 * @param func - The logic to be measured for execution time
622 */
623 static measure(name: string, func: () => void): void;
624 static reset(): void;
625 static setPeriodicReset(): void;
626}
627
628/**
629 * Makes a resulting merge of a bunch of objects, but allows a filter function to be passed in to filter
630 * the resulting merges. This allows for scenarios where you want to merge "everything except that one thing"
631 * or "properties that start with data-". Note that this will shallow merge; it will not create new cloned
632 * values for target members.
633 *
634 * @public
635 * @param isAllowed - Callback to determine if the given propName is allowed in the result.
636 * @param target - Target object to merge following object arguments into.
637 * @param args - One or more objects that will be mixed into the target in the order they are provided.
638 * @returns Resulting merged target.
639 */
640export declare function filteredAssign(isAllowed: (propName: string) => boolean, target: any, ...args: any[]): any;
641
642/**
643 * Helper to find the first item within an array that satisfies the callback.
644 * @param array - Array to search
645 * @param cb - Callback which returns true on matches
646 */
647export declare function find<T>(array: T[], cb: (item: T, index: number) => boolean): T | undefined;
648
649export { findElementRecursive }
650
651/**
652 * Helper to find the index of an item within an array, using a callback to
653 * determine the match.
654 *
655 * @public
656 * @param array - Array to search.
657 * @param cb - Callback which returns true on matches.
658 * @param fromIndex - Optional index to start from (defaults to 0)
659 */
660export declare function findIndex<T>(array: T[], cb: (item: T, index: number) => boolean, fromIndex?: number): number;
661
662/**
663 * Traverses up the DOM for the element with the data-is-scrollable=true attribute, or returns
664 * document.body.
665 *
666 * @public
667 */
668export declare function findScrollableParent(startingElement: HTMLElement | null): HTMLElement | Window | undefined | null;
669
670/**
671 * Produces a proportionally-scaled version of an input content size when fit to a bounding size.
672 * Given a `contentSize` and a `boundsSize`, this function scales `contentSize` proportionally
673 * using either `contain` or `cover` fit behaviors.
674 * Use this function to pre-calculate the layout for the CSS `object-fit` and `background-fit` behaviors.
675 * With `contain`, the output size must be the largest it can be while completely within the `boundsSize`.
676 * With `cover`, the output size must be the smallest it can be while completely around the `boundsSize`.
677 * By default, there is a `maxScale` value of 1, which prevents the `contentSize` from being scaled larger.
678 *
679 * @param options - the options for the bounds fit operation
680 */
681export declare function fitContentToBounds(options: IFitContentToBoundsOptions): ISize;
682
683/**
684 * The available fit modes. These should match the fit modes for CSS.
685 */
686export declare type FitMode = 'contain' | 'cover';
687
688/**
689 * Given an array where each element is of type T or T[], flatten it into an array of T
690 * @param array - The array where each element can optionally also be an array
691 */
692export declare function flatten<T>(array: (T | T[])[]): T[];
693
694/**
695 * Sets focus to an element asynchronously. The focus will be set at the next browser repaint,
696 * meaning it won't cause any extra recalculations. If more than one focusAsync is called during one frame,
697 * only the latest called focusAsync element will actually be focused
698 * @param element - The element to focus
699 */
700export declare function focusAsync(element: HTMLElement | {
701 focus: () => void;
702} | undefined | null): void;
703
704/**
705 * Attempts to focus the first focusable element that is a child or child's child of the rootElement.
706 *
707 * @public
708 * @param rootElement - Element to start the search for a focusable child.
709 * @param bypassHiddenElements - If true, focus will be not be set on hidden elements.
710 * @returns True if focus was set, false if it was not.
711 */
712export declare function focusFirstChild(rootElement: HTMLElement, bypassHiddenElements?: boolean, includeShadowRoots?: boolean): boolean;
713
714/**
715 * Function Component wrapper which enables calling `useFocusRects` hook.
716 * Renders nothing.
717 */
718export declare const FocusRects: React_2.FunctionComponent<{
719 rootRef?: React_2.RefObject<HTMLElement>;
720}>;
721
722export declare const FocusRectsContext: React_2.Context<IFocusRectsContext | undefined>;
723
724export declare const FocusRectsProvider: React_2.FC<FocusRectsProviderProps>;
725
726export declare type FocusRectsProviderProps = {
727 /**
728 * Ref to the root element that this is providing focus rects for.
729 */
730 providerRef: React_2.RefObject<HTMLElement>;
731 /**
732 * Indicates that this is the root of a layer, and should not inherit the providerRef from a parent context.
733 */
734 layerRoot?: boolean;
735};
736
737/**
738 * String format method, used for scenarios where at runtime you
739 * need to evaluate a formatted string given a tokenized string. This
740 * usually only is needed in localization scenarios.
741
742 * @example
743 * ```tsx
744 * "I love {0} every {1}".format("CXP")
745 * ```
746 * will result in a Debug Exception.
747 *
748 * @public
749 */
750export declare function format(s: string, ...values: any[]): string;
751
752/**
753 * An array of FORM tag properties and events.
754 *
755 * @public
756 */
757export declare const formProperties: Record<string, number>;
758
759export { getActiveElement }
760
761export { getChildren }
762
763/**
764 * Determines the distance between two points.
765 *
766 * @public
767 */
768export declare function getDistanceBetweenPoints(point1: Point, point2: Point): number;
769
770/**
771 * Helper to get the document object. Note that in popup window cases, document
772 * might be the wrong document, which is why we look at ownerDocument for the
773 * truth.
774 *
775 * @public
776 */
777export declare function getDocument(rootElement?: HTMLElement | null): Document | undefined;
778
779/**
780 * Finds the element index path from a parent element to a child element.
781 *
782 * If you had this node structure: "A has children [B, C] and C has child D",
783 * the index path from A to D would be [1, 0], or `parent.chidren[1].children[0]`.
784 */
785export declare function getElementIndexPath(fromElement: HTMLElement, toElement: HTMLElement): number[];
786
787export { getEventTarget }
788
789/**
790 * Gets the first focusable element.
791 *
792 * @public
793 */
794export declare function getFirstFocusable(rootElement: HTMLElement, currentElement: HTMLElement, includeElementsInFocusZones?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
795
796/**
797 * Gets the first tabbable element. (The difference between focusable and tabbable is that tabbable elements are
798 * focusable elements that also have tabIndex != -1.)
799 * @param rootElement - The parent element to search beneath.
800 * @param currentElement - The descendant of rootElement to start the search at. This element is the first one checked,
801 * and iteration continues forward. Typical use passes rootElement.firstChild.
802 * @param includeElementsInFocusZones - true if traversal should go into FocusZone descendants.
803 * @param checkNode - Include currentElement in search when true. Defaults to true.
804 * @public
805 */
806export declare function getFirstTabbable(rootElement: HTMLElement, currentElement: HTMLElement, includeElementsInFocusZones?: boolean, checkNode?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
807
808/**
809 * Gets the first visible element that matches the given selector
810 * @param selector - The selector to use to find potential visible elements
811 * @returns The first visible element that matches the selector, otherwise undefined
812 *
813 * @public
814 */
815export declare function getFirstVisibleElementFromSelector(selector: string): Element | undefined;
816
817/**
818 * Finds the closest focusable element via an index path from a parent. See
819 * `getElementIndexPath` for getting an index path from an element to a child.
820 */
821export declare function getFocusableByIndexPath(parent: HTMLElement, path: number[]): HTMLElement | undefined;
822
823/**
824 * Generates a unique id in the global scope (this spans across duplicate copies of the same library.)
825 *
826 * @public
827 */
828export declare function getId(prefix?: string): string;
829
830/**
831 * Regular expressions matching characters to ignore when calculating the initials.
832 */
833/**
834 * Get (up to 2 characters) initials based on display name of the persona.
835 *
836 * @public
837 */
838export declare function getInitials(displayName: string | undefined | null, isRtl: boolean, allowPhoneInitials?: boolean): string;
839
840/**
841 * Gets the language set for the page.
842 * @param persistenceType - Where to persist the value. Default is `sessionStorage` if available.
843 */
844export declare function getLanguage(persistenceType?: 'localStorage' | 'sessionStorage' | 'none'): string | null;
845
846/**
847 * Gets the last focusable element.
848 *
849 * @public
850 */
851export declare function getLastFocusable(rootElement: HTMLElement, currentElement: HTMLElement, includeElementsInFocusZones?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
852
853/**
854 * Gets the last tabbable element. (The difference between focusable and tabbable is that tabbable elements are
855 * focusable elements that also have tabIndex != -1.)
856 * @param rootElement - The parent element to search beneath.
857 * @param currentElement - The descendant of rootElement to start the search at. This element is the first one checked,
858 * and iteration continues in reverse. Typical use passes rootElement.lastChild.
859 * @param includeElementsInFocusZones - true if traversal should go into FocusZone descendants.
860 * @param checkNode - Include currentElement in search when true. Defaults to true.
861 * @public
862 */
863export declare function getLastTabbable(rootElement: HTMLElement, currentElement: HTMLElement, includeElementsInFocusZones?: boolean, checkNode?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
864
865/**
866 * Given an element tagname and user props, filters the props to only allowed props for the given
867 * element type.
868 * @param tagName - Tag name (e.g. "div")
869 * @param props - Props object
870 * @param excludedPropNames - List of props to disallow
871 */
872export declare function getNativeElementProps<TAttributes extends React_2.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
873
874/**
875 * Gets native supported props for an html element provided the allowance set. Use one of the property
876 * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
877 * props set. Note that all data- and aria- prefixed attributes will be allowed.
878 * NOTE: getNativeProps should always be applied first when adding props to a react component. The
879 * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
880 * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
881 * the component after an onClick function is added, then the getNativeProps onClick will override it.
882 *
883 * @public
884 * @param props - The unfiltered input props
885 * @param allowedPropsNames - The array or record of allowed prop names.
886 * @returns The filtered props
887 */
888export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
889
890/**
891 * Traverse to find the next focusable element.
892 * If tabbable is true, the element must have tabIndex != -1.
893 *
894 * @public
895 * @param checkNode - Include currentElement in search when true.
896 */
897export declare function getNextElement(rootElement: HTMLElement, currentElement: HTMLElement | null, checkNode?: boolean, suppressParentTraversal?: boolean, suppressChildTraversal?: boolean, includeElementsInFocusZones?: boolean, allowFocusRoot?: boolean, tabbable?: boolean, bypassHiddenElements?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
898
899export { getParent }
900
901/**
902 * Traverse to find the previous element.
903 * If tabbable is true, the element must have tabIndex != -1.
904 *
905 * @public
906 */
907export declare function getPreviousElement(rootElement: HTMLElement, currentElement: HTMLElement | null, checkNode?: boolean, suppressParentTraversal?: boolean, traverseChildren?: boolean, includeElementsInFocusZones?: boolean, allowFocusRoot?: boolean, tabbable?: boolean, includeShadowRoots?: boolean): HTMLElement | null;
908
909/**
910 * Function to apply default values to a component props object. This function is intended for function components,
911 * to maintain parity with the `defaultProps` feature of class components. It accounts for properties that are
912 * specified, but undefined.
913 * @param defaultProps- An object with default values for various properties
914 * @param propsWithoutDefaults- The props object passed into the component
915 */
916export declare function getPropsWithDefaults<TProps extends {}>(defaultProps: Partial<TProps>, propsWithoutDefaults: TProps): TProps;
917
918/**
919 * Helper to get bounding client rect. Passing in window will get the window size.
920 *
921 * @public
922 */
923export declare function getRect(element: HTMLElement | Window | null, win?: Window): IRectangle | undefined;
924
925/**
926 * @deprecated Unused as of version 8
927 */
928export declare function getResourceUrl(url: string): string;
929
930/**
931 * Gets the rtl state of the page (returns true if in rtl.)
932 */
933export declare function getRTL(theme?: {
934 rtl?: boolean;
935}): boolean;
936
937/**
938 * Returns the given key, but flips right/left arrows if necessary.
939 */
940export declare function getRTLSafeKeyCode(key: number, theme?: {
941 rtl?: boolean;
942}): number;
943
944/**
945 * Calculates the width of a scrollbar for the browser/os.
946 *
947 * @public
948 */
949export declare function getScrollbarWidth(doc?: Document): number;
950
951export { getVirtualParent }
952
953/**
954 * Helper to get the window object. The helper will make sure to use a cached variable
955 * of "window", to avoid overhead and memory leaks in IE11. Note that in popup scenarios the
956 * window object won't match the "global" window object, and for these scenarios, you should
957 * pass in an element hosted within the popup.
958 *
959 * @public
960 */
961export declare function getWindow(rootElement?: Element | null): Window | undefined;
962
963/**
964 * Global settings helper, which stores settings in the global (window) namespace.
965 * If window is not provided, it will store settings in module scope. Provides a
966 * way to observe changes as well when their values change.
967 *
968 * @public
969 * {@docCategory GlobalSettings}
970 */
971export declare class GlobalSettings {
972 static getValue<T>(key: string, defaultValue?: T | (() => T)): T;
973 static setValue<T>(key: string, value: T): T;
974 static addChangeListener(cb: IChangeEventCallback): void;
975 static removeChangeListener(cb: IChangeEventCallback): void;
976}
977
978/**
979 * Detects whether an element's content has horizontal overflow
980 *
981 * @public
982 * @param element - Element to check for overflow
983 * @returns True if element's content overflows
984 */
985export declare function hasHorizontalOverflow(element: HTMLElement): boolean;
986
987export declare type HasMergeStylesShadowRootContextHook = () => boolean;
988
989/**
990 * Detects whether an element's content has overflow in any direction
991 *
992 * @public
993 * @param element - Element to check for overflow
994 * @returns True if element's content overflows
995 */
996export declare function hasOverflow(element: HTMLElement): boolean;
997
998/**
999 * Detects whether an element's content has vertical overflow
1000 *
1001 * @public
1002 * @param element - Element to check for overflow
1003 * @returns True if element's content overflows
1004 */
1005export declare function hasVerticalOverflow(element: HTMLElement): boolean;
1006
1007/**
1008 * Allows you to hoist methods, except those in an exclusion set from a source object into a destination object.
1009 *
1010 * @public
1011 * @param destination - The instance of the object to hoist the methods onto.
1012 * @param source - The instance of the object where the methods are hoisted from.
1013 * @param exclusions - (Optional) What methods to exclude from being hoisted.
1014 * @returns An array of names of methods that were hoisted.
1015 */
1016export declare function hoistMethods(destination: any, source: any, exclusions?: string[]): string[];
1017
1018/**
1019 * Allows you to hoist static functions in components.
1020 * Created for the purpose of fixing broken static functions in classes
1021 * that utilize decorators.
1022 *
1023 * @public
1024 * @param source - The object where the methods are hoisted from.
1025 * @param dest - The object to hoist the methods onto.
1026 * @returns The dest object with methods added
1027 */
1028export declare function hoistStatics<TSource extends Object, TDest>(source: TSource, dest: TDest): TDest;
1029
1030/**
1031 * An array of HTML element properties and events.
1032 *
1033 * @public
1034 */
1035export declare const htmlElementProperties: Record<string, number>;
1036
1037export declare interface IAsAsyncOptions<TProps> {
1038 /**
1039 * Callback which returns a promise resolving an object which exports the component.
1040 */
1041 load: () => Promise<React_2.ElementType<TProps>>;
1042 /**
1043 * Callback executed when async loading is complete.
1044 */
1045 onLoad?: () => void;
1046 /**
1047 * Callback when async loading fails.
1048 */
1049 onError?: (error: Error) => void;
1050}
1051
1052/**
1053 * BaseProps interface.
1054 *
1055 * @public
1056 * {@docCategory IBaseProps}
1057 */
1058export declare interface IBaseProps<T = any> {
1059 componentRef?: IRefObject<T>;
1060}
1061
1062export declare type ICancelable<T extends (...args: any[]) => any> = {
1063 flush: () => ReturnType<T>;
1064 cancel: () => void;
1065 pending: () => boolean;
1066};
1067
1068/**
1069 * Change description used for change callbacks in GlobalSettings.
1070 *
1071 * @public
1072 * {@docCategory IChangeDescription}
1073 */
1074export declare interface IChangeDescription {
1075 key: string;
1076 oldValue: any;
1077 value: any;
1078}
1079
1080/**
1081 * Change event callback.
1082 *
1083 * @public
1084 * {@docCategory IChangeEventCallback}
1085 */
1086export declare interface IChangeEventCallback {
1087 __id__?: string;
1088 (changeDescription?: IChangeDescription): void;
1089}
1090
1091/**
1092 * @deprecated Use `IProcessedStyleSet` from `@fluentui/style-utilities` or `@fluentui/merge-styles` instead.
1093 */
1094export declare type IClassNames<T> = {
1095 [key in keyof T]: string;
1096};
1097
1098export declare interface IClassNamesFunctionOptions {
1099 /**
1100 * Disables class caching for scenarios where styleProp parts mutate frequently.
1101 */
1102 disableCaching?: boolean;
1103 /**
1104 * Size of the cache. It overwrites default cache size when defined.
1105 */
1106 cacheSize?: number;
1107 /**
1108 * Set to true if component base styles are implemented in scss instead of css-in-js.
1109 */
1110 useStaticStyles?: boolean;
1111}
1112
1113/**
1114 * Render function interface for providing overrideable render callbacks.
1115 *
1116 * @public
1117 * {@docCategory IComponentAs}
1118 */
1119export declare type IComponentAs<T> = React_2.ComponentType<IComponentAsProps<T>>;
1120
1121/**
1122 * Properties used by render function interface for providing overrideable render callbacks.
1123 *
1124 * @public
1125 * {@docCategory IComponentAsProps}
1126 */
1127export declare type IComponentAsProps<T> = T & {
1128 defaultRender?: React_2.ComponentType<T>;
1129};
1130
1131/**
1132 * css input type.
1133 *
1134 * @internal
1135 */
1136export declare type ICssInput = string | ISerializableObject | IDictionary | null | undefined | boolean;
1137
1138export declare interface ICustomizableProps {
1139 /**
1140 * Name of scope, which can be targeted using the Customizer.
1141 */
1142 scope: string;
1143 /**
1144 * List of fields which can be customized.
1145 * @defaultvalue [ 'theme', 'styles' ]
1146 */
1147 fields?: string[];
1148}
1149
1150export declare interface ICustomizations {
1151 settings: ISettings;
1152 scopedSettings: {
1153 [key: string]: ISettings;
1154 };
1155 inCustomizerContext?: boolean;
1156}
1157
1158export declare interface ICustomizerContext {
1159 customizations: ICustomizations;
1160}
1161
1162export declare type ICustomizerProps = IBaseProps & Partial<{
1163 /**
1164 * Settings are used as general settings for the React tree below.
1165 * Components can subscribe to receive the settings by using `customizable`.
1166 *
1167 * @example
1168 * ```
1169 * // Settings can be represented by a plain object that contains the key value pairs.
1170 * <Customizer settings={{ color: 'red' }} />
1171 *
1172 * // or a function that receives the current settings and returns the new ones
1173 * <Customizer settings={(currentSettings) => ({ ...currentSettings, color: 'red' })} />
1174 * ```
1175 */
1176 settings: ISettings | ISettingsFunction;
1177 /**
1178 * Scoped settings are settings that are scoped to a specific scope. The
1179 * scope is the name that is passed to the `customizable` function when the
1180 * the component is customized.
1181 *
1182 * @example
1183 * ```
1184 * // Scoped settings can be represented by a plain object that contains the key value pairs.
1185 * const myScopedSettings = {
1186 * Button: { color: 'red' };
1187 * };
1188 * <Customizer scopedSettings={myScopedSettings} />
1189 *
1190 * // or a function that receives the current settings and returns the new ones
1191 * const myScopedSettings = {
1192 * Button: { color: 'red' };
1193 * };
1194 * <Customizer scopedSettings={(currentScopedSettings) => ({ ...currentScopedSettings, ...myScopedSettings })} />
1195 * ```
1196 */
1197 scopedSettings: ISettings | ISettingsFunction;
1198}> & {
1199 children?: React_2.ReactNode;
1200 /**
1201 * Optional transform function for context. Any implementations should take care to return context without
1202 * mutating it.
1203 */
1204 contextTransform?: (context: Readonly<ICustomizerContext>) => ICustomizerContext;
1205};
1206
1207/**
1208 * @internal
1209 */
1210export declare interface IDeclaredEventsByName {
1211 [eventName: string]: boolean;
1212}
1213
1214/**
1215 * DelayedRender component props.
1216 *
1217 * @public
1218 */
1219export declare interface IDelayedRenderProps extends IReactProps<{}> {
1220 /**
1221 * Number of milliseconds to delay rendering children.
1222 */
1223 delay?: number;
1224}
1225
1226/**
1227 * DelayedRender component state.
1228 *
1229 * @internal
1230 */
1231export declare interface IDelayedRenderState {
1232 /**
1233 * Whether the component is rendered or not.
1234 */
1235 isRendered: boolean;
1236}
1237
1238/**
1239 * Dictionary of booleans.
1240 *
1241 * @internal
1242 */
1243export declare interface IDictionary {
1244 [className: string]: boolean;
1245}
1246
1247/**
1248 * Disposable interface.
1249 *
1250 * @public
1251 * {@docCategory IDisposable}
1252 */
1253export declare interface IDisposable {
1254 dispose: () => void;
1255}
1256
1257/**
1258 * @internal
1259 */
1260export declare interface IEventRecord {
1261 target: any;
1262 eventName: string;
1263 parent: any;
1264 callback: (args?: any) => void;
1265 elementCallback?: (...args: any[]) => void;
1266 objectCallback?: (args?: any) => void;
1267 options?: boolean | AddEventListenerOptions;
1268}
1269
1270/**
1271 * @internal
1272 */
1273export declare interface IEventRecordList {
1274 [id: string]: IEventRecord[] | number;
1275 count: number;
1276}
1277
1278/**
1279 * @internal
1280 */
1281export declare interface IEventRecordsByName {
1282 [eventName: string]: IEventRecordList;
1283}
1284
1285/**
1286 * Options for fitting content sizes into bounding sizes.
1287 */
1288export declare interface IFitContentToBoundsOptions {
1289 /**
1290 * The size of the content to fit to the bounds.
1291 * The output will be proportional to this value.
1292 */
1293 contentSize: ISize;
1294 /**
1295 * The size of the bounds.
1296 */
1297 boundsSize: ISize;
1298 /**
1299 * The fit mode to apply, either 'contain' or 'cover'.
1300 */
1301 mode: FitMode;
1302 /**
1303 * An optional maximum scale factor to apply. The default is 1.
1304 * Use Infinity for an unbounded resize.
1305 */
1306 maxScale?: number;
1307}
1308
1309export declare type IFocusRectsContext = {
1310 /**
1311 * Ref to the root element of the provider
1312 */
1313 readonly providerRef: React_2.RefObject<HTMLElement>;
1314 /**
1315 * Array of this and all child provider elements under this one in the React tree.
1316 *
1317 * Tracking all child providers will allow a focus event in the parent to also set focus styling in its descendants.
1318 * This is needed for Combobox, for example, because the focus events happen on the parent context, but the visual
1319 * focus indicator is in the combobox callout. The callout needs to be notified on focus events from the parent.
1320 */
1321 readonly registeredProviders: React_2.RefObject<HTMLElement>[];
1322 /**
1323 * Used by child FocusRectsProviders to register their element with the parent provider.
1324 */
1325 readonly registerProvider: (ref: React_2.RefObject<HTMLElement>) => void;
1326 /**
1327 * Used by child FocusRectsProviders to unregister their element from the parent provider.
1328 */
1329 readonly unregisterProvider: (ref: React_2.RefObject<HTMLElement>) => void;
1330};
1331
1332/**
1333 * An array of IFRAME tag properties and events.
1334 *
1335 * @public
1336 */
1337export declare const iframeProperties: Record<string, number>;
1338
1339/**
1340 * @deprecated Use imgProperties for img elements.
1341 */
1342export declare const imageProperties: Record<string, number>;
1343
1344/**
1345 * An array of IMAGE tag properties and events.
1346 *
1347 * @public
1348 */
1349export declare const imgProperties: Record<string, number>;
1350
1351/**
1352 * Helper to manage componentRef resolution. Internally appends logic to
1353 * lifetime methods to resolve componentRef to the passed in object.
1354 *
1355 * Usage: call initializeComponentRef(this) in the constructor,
1356 */
1357export declare function initializeComponentRef<TProps extends IBaseProps, TState>(obj: React_2.Component<TProps, TState>): void;
1358
1359/**
1360 * Initializes the logic which:
1361 *
1362 * 1. Subscribes keydown and mousedown events. (It will only do it once per window,
1363 * so it's safe to call this method multiple times.)
1364 * 2. When the user presses directional keyboard keys, adds the 'ms-Fabric--isFocusVisible' classname
1365 * to the document body, removes the 'ms-Fabric-isFocusHidden' classname.
1366 * 3. When the user clicks a mouse button, adds the 'ms-Fabric-isFocusHidden' classname to the
1367 * document body, removes the 'ms-Fabric--isFocusVisible' classname.
1368 *
1369 * This logic allows components on the page to conditionally render focus treatments based on
1370 * the existence of global classnames, which simplifies logic overall.
1371 *
1372 * @param window - the window used to add the event listeners
1373 * @deprecated Use useFocusRects hook or FocusRects component instead.
1374 */
1375export declare function initializeFocusRects(window?: Window): void;
1376
1377/**
1378 * An array of INPUT tag properties and events.
1379 *
1380 * @public
1381 */
1382export declare const inputProperties: Record<string, number>;
1383
1384/**
1385 * {@docCategory Selection}
1386 */
1387export declare interface IObjectWithKey {
1388 key?: string | number;
1389}
1390
1391/**
1392 * PerfData interface.
1393 *
1394 * @internal
1395 */
1396export declare interface IPerfData {
1397 duration: number;
1398 timeStamp: number;
1399}
1400
1401/**
1402 * PerfMeasurement interface.
1403 *
1404 * @internal
1405 */
1406export declare interface IPerfMeasurement {
1407 totalDuration: number;
1408 count: number;
1409 all: IPerfData[];
1410}
1411
1412/**
1413 * PerfSummary interface.
1414 *
1415 * @internal
1416 */
1417export declare interface IPerfSummary {
1418 [key: string]: IPerfMeasurement;
1419}
1420
1421/**
1422 * Point interface.
1423 *
1424 * @public
1425 * @deprecated Use `Point` instead.
1426 * {@docCategory Point}
1427 */
1428export declare interface IPoint extends Point {
1429}
1430
1431export declare interface IPropsWithStyles<TStyleProps, TStyleSet extends IStyleSetBase> {
1432 styles?: IStyleFunctionOrObject<TStyleProps, TStyleSet>;
1433}
1434
1435export declare interface IReactProps<T> {
1436 children?: React_2.ReactNode | undefined;
1437 key?: React_2.Key | undefined;
1438 ref?: React_2.LegacyRef<T> | undefined;
1439}
1440
1441/**
1442 * Rectangle interface.
1443 *
1444 * @public
1445 * {@docCategory IRectangle}
1446 */
1447export declare interface IRectangle {
1448 left: number;
1449 top: number;
1450 width: number;
1451 height: number;
1452 right?: number;
1453 bottom?: number;
1454}
1455
1456export declare type IRefObject<T> = React_2.RefObject<T> | RefObject<T> | ((ref: T | null) => void);
1457
1458/**
1459 * An interface representing a component that will not output any DOM, will just render its children and
1460 * pass through items to modify the children.
1461 *
1462 * {@docCategory IRenderComponent}
1463 */
1464export declare interface IRenderComponent<TProps> {
1465 /**
1466 * JSX.Element to return in this component's render() function.
1467 */
1468 children: (props: TProps) => JSX.Element;
1469}
1470
1471/**
1472 * Render function interface for providing overrideable render callbacks.
1473 *
1474 * @public
1475 */
1476export declare interface IRenderFunction<P> {
1477 (props?: P, defaultRender?: (props?: P) => JSX.Element | null): JSX.Element | null;
1478}
1479
1480/**
1481 * Determines whether a component is controlled.
1482 * @param props - Component props
1483 * @param valueProp - Prop containing the controlled value
1484 * @returns true if controlled, false if uncontrolled
1485 */
1486export declare function isControlled<P>(props: P, valueProp: keyof P): boolean;
1487
1488/**
1489 * Returns true if the keycode is a directional keyboard key.
1490 */
1491export declare function isDirectionalKeyCode(which: number): boolean;
1492
1493/**
1494 * {@docCategory Selection}
1495 */
1496export declare interface ISelection<TItem = IObjectWithKey> {
1497 count: number;
1498 mode: SelectionMode_2;
1499 canSelectItem: (item: TItem, index?: number) => boolean;
1500 setChangeEvents(isEnabled: boolean, suppressChange?: boolean): void;
1501 setItems(items: TItem[], shouldClear: boolean): void;
1502 getItems(): TItem[];
1503 getItemIndex?(key: string): number;
1504 getSelection(): TItem[];
1505 getSelectedIndices(): number[];
1506 getSelectedCount(): number;
1507 isRangeSelected(fromIndex: number, count: number): boolean;
1508 isAllSelected(): boolean;
1509 isKeySelected(key: string): boolean;
1510 isIndexSelected(index: number): boolean;
1511 isModal?(): boolean;
1512 setAllSelected(isAllSelected: boolean): void;
1513 setKeySelected(key: string, isSelected: boolean, shouldAnchor: boolean): void;
1514 setIndexSelected(index: number, isSelected: boolean, shouldAnchor: boolean): void;
1515 setRangeSelected?(fromIndex: number, count: number, isSelected: boolean, shouldAnchor: boolean): void;
1516 setModal?(isModal: boolean): void;
1517 selectToKey(key: string, clearSelection?: boolean): void;
1518 selectToIndex(index: number, clearSelection?: boolean): void;
1519 selectToRange?(index: number, count: number, clearSelection?: boolean): void;
1520 toggleAllSelected(): void;
1521 toggleKeySelected(key: string): void;
1522 toggleIndexSelected(index: number): void;
1523 toggleRangeSelected(fromIndex: number, count: number): void;
1524}
1525
1526/**
1527 * {@docCategory Selection}
1528 */
1529export declare interface ISelectionOptions<TItem = IObjectWithKey> {
1530 onSelectionChanged?: () => void;
1531 onItemsChanged?: () => void;
1532 /** Custom logic to generate item keys. Required if `TItem` does not have a `key` property. */
1533 getKey?: (item: TItem, index?: number) => string | number;
1534 canSelectItem?: (item: TItem, index?: number) => boolean;
1535 selectionMode?: SelectionMode_2;
1536 items?: TItem[];
1537}
1538
1539/**
1540 * Selection options with required `getKey` property.
1541 * {@docCategory Selection}
1542 */
1543export declare type ISelectionOptionsWithRequiredGetKey<TItem> = ISelectionOptions<TItem> & Required<Pick<ISelectionOptions<TItem>, 'getKey'>>;
1544
1545/**
1546 * Determines if a given element is a focus sub zone.
1547 *
1548 * @public
1549 */
1550export declare function isElementFocusSubZone(element?: HTMLElement): boolean;
1551
1552/**
1553 * Determines if a given element is a focus zone.
1554 *
1555 * @public
1556 */
1557export declare function isElementFocusZone(element?: HTMLElement): boolean;
1558
1559/**
1560 * Determines if an element can receive focus programmatically or via a mouse click.
1561 * If checkTabIndex is true, additionally checks to ensure the element can be focused with the tab key,
1562 * meaning tabIndex != -1.
1563 *
1564 * @public
1565 */
1566export declare function isElementTabbable(element: HTMLElement, checkTabIndex?: boolean, checkShadowRoot?: boolean): boolean;
1567
1568/**
1569 * Determines if an element is visible.
1570 *
1571 * @public
1572 */
1573export declare function isElementVisible(element: HTMLElement | undefined | null): boolean;
1574
1575/**
1576 * Determines if an element is visible and not hidden
1577 * @param element - Element to check
1578 * @returns Returns true if the given element is visible and not hidden
1579 *
1580 * @public
1581 */
1582export declare function isElementVisibleAndNotHidden(element: HTMLElement | undefined | null, win?: Window): boolean;
1583
1584/**
1585 * Serializable object.
1586 *
1587 * @internal
1588 */
1589export declare interface ISerializableObject {
1590 toString?: () => string;
1591}
1592
1593export declare type ISettings = {
1594 [key: string]: any;
1595};
1596
1597export declare type ISettingsFunction = (settings: ISettings) => ISettings;
1598
1599export declare type ISettingsMap<T> = {
1600 [P in keyof T]?: string;
1601};
1602
1603export declare const IsFocusVisibleClassName = "ms-Fabric--isFocusVisible";
1604
1605export declare const isIE11: () => boolean;
1606
1607/**
1608 * Returns true if and only if the user is on a iOS device.
1609 * Used to determine whether iOS-specific behavior should be applied.
1610 */
1611export declare const isIOS: () => boolean;
1612
1613/**
1614 * {@docCategory ISize}
1615 */
1616export declare interface ISize {
1617 width: number;
1618 height: number;
1619}
1620
1621/**
1622 * Returns true if the user is on a Mac. Caches the result value.
1623 * @param reset - Reset the cached result value (mainly for testing).
1624 */
1625export declare function isMac(reset?: boolean): boolean;
1626
1627export { IStyleFunction }
1628
1629export { IStyleFunctionOrObject }
1630
1631export { isVirtualElement }
1632
1633export { IVirtualElement }
1634
1635export declare interface IWarnControlledUsageParams<P> {
1636 /** ID of the component instance. Used to prevent showing warnings repeatedly. */
1637 componentId: string;
1638 /** Name of the component class. */
1639 componentName: string;
1640 /** Current props to evaluate. */
1641 props: P;
1642 /** Previous props to evaluate (undefined if called in the constructor). */
1643 oldProps?: P;
1644 /** Name of the prop for the controlled value. */
1645 valueProp: keyof P;
1646 /** Name of the prop for the uncontrolled initial value. */
1647 defaultValueProp: keyof P;
1648 /** Name of the change handler prop. */
1649 onChangeProp: keyof P;
1650 /** Name of the read-only prop. */
1651 readOnlyProp?: keyof P;
1652}
1653
1654/**
1655 * Simulated enum for keycodes. These will get inlined by uglify when used much like an enum
1656 *
1657 * @public
1658 * {@docCategory KeyCodes}
1659 */
1660export declare const KeyCodes: {
1661 backspace: 8;
1662 tab: 9;
1663 enter: 13;
1664 shift: 16;
1665 ctrl: 17;
1666 alt: 18;
1667 pauseBreak: 19;
1668 capslock: 20;
1669 escape: 27;
1670 space: 32;
1671 pageUp: 33;
1672 pageDown: 34;
1673 end: 35;
1674 home: 36;
1675 left: 37;
1676 up: 38;
1677 right: 39;
1678 down: 40;
1679 insert: 45;
1680 del: 46;
1681 zero: 48;
1682 one: 49;
1683 two: 50;
1684 three: 51;
1685 four: 52;
1686 five: 53;
1687 six: 54;
1688 seven: 55;
1689 eight: 56;
1690 nine: 57;
1691 colon: 58;
1692 a: 65;
1693 b: 66;
1694 c: 67;
1695 d: 68;
1696 e: 69;
1697 f: 70;
1698 g: 71;
1699 h: 72;
1700 i: 73;
1701 j: 74;
1702 k: 75;
1703 l: 76;
1704 m: 77;
1705 n: 78;
1706 o: 79;
1707 p: 80;
1708 q: 81;
1709 r: 82;
1710 s: 83;
1711 t: 84;
1712 u: 85;
1713 v: 86;
1714 w: 87;
1715 x: 88;
1716 y: 89;
1717 z: 90;
1718 leftWindow: 91;
1719 rightWindow: 92;
1720 select: 93;
1721 zero_numpad: 96;
1722 one_numpad: 97;
1723 two_numpad: 98;
1724 three_numpad: 99;
1725 four_numpad: 100;
1726 five_numpad: 101;
1727 six_numpad: 102;
1728 seven_numpad: 103;
1729 eight_numpad: 104;
1730 nine_numpad: 105;
1731 multiply: 106;
1732 add: 107;
1733 subtract: 109;
1734 decimalPoint: 110;
1735 divide: 111;
1736 f1: 112;
1737 f2: 113;
1738 f3: 114;
1739 f4: 115;
1740 f5: 116;
1741 f6: 117;
1742 f7: 118;
1743 f8: 119;
1744 f9: 120;
1745 f10: 121;
1746 f11: 122;
1747 f12: 123;
1748 numlock: 144;
1749 scrollLock: 145;
1750 semicolon: 186;
1751 equalSign: 187;
1752 comma: 188;
1753 dash: 189;
1754 period: 190;
1755 forwardSlash: 191;
1756 graveAccent: 192;
1757 openBracket: 219;
1758 backSlash: 220;
1759 closeBracket: 221;
1760 singleQuote: 222;
1761};
1762
1763export declare type KeyCodes = number;
1764
1765/**
1766 * An array of LABEL tag properties and events.
1767 *
1768 * @public
1769 */
1770export declare const labelProperties: Record<string, number>;
1771
1772/**
1773 * An array of LI tag properties and events.
1774 *
1775 * @public
1776 */
1777export declare const liProperties: Record<string, number>;
1778
1779/**
1780 * Takes an enum and iterates over each value of the enum (as a string), running the callback on each,
1781 * returning a mapped array.
1782 * @param theEnum - Enum to iterate over
1783 * @param callback - The first parameter the name of the entry, and the second parameter is the value
1784 * of that entry, which is the value you'd normally use when using the enum (usually a number).
1785 */
1786export declare function mapEnumByName<T>(theEnum: any, callback: (name?: string, value?: string | number) => T | undefined): (T | undefined)[] | undefined;
1787
1788/**
1789 * Memoize decorator to be used on class methods. WARNING: the `this` reference
1790 * will be inaccessible within a memoized method, given that a cached method's `this`
1791 * would not be instance-specific.
1792 *
1793 * @public
1794 */
1795export declare function memoize<T extends Function>(_target: any, _key: string, descriptor: TypedPropertyDescriptor<T>): {
1796 configurable: boolean;
1797 get(): T;
1798};
1799
1800/**
1801 * Memoizes a function; when you pass in the same parameters multiple times, it returns a cached result.
1802 * Be careful when passing in objects, you need to pass in the same INSTANCE for caching to work. Otherwise
1803 * it will grow the cache unnecessarily. Also avoid using default values that evaluate functions; passing in
1804 * undefined for a value and relying on a default function will execute it the first time, but will not
1805 * re-evaluate subsequent times which may have been unexpected.
1806 *
1807 * By default, the cache will reset after 100 permutations, to avoid abuse cases where the function is
1808 * unintendedly called with unique objects. Without a reset, the cache could grow infinitely, so we safeguard
1809 * by resetting. To override this behavior, pass a value of 0 to the maxCacheSize parameter.
1810 *
1811 * @public
1812 * @param cb - The function to memoize.
1813 * @param maxCacheSize - Max results to cache. If the cache exceeds this value, it will reset on the next call.
1814 * @param ignoreNullOrUndefinedResult - Flag to decide whether to cache callback result if it is undefined/null.
1815 * If the flag is set to true, the callback result is recomputed every time till the callback result is
1816 * not undefined/null for the first time, and then the non-undefined/null version gets cached.
1817 * @returns A memoized version of the function.
1818 */
1819export declare function memoizeFunction<T extends (...args: any[]) => RetType, RetType>(cb: T, maxCacheSize?: number, ignoreNullOrUndefinedResult?: boolean): T;
1820
1821/**
1822 * Simple deep merge function. Takes all arguments and returns a deep copy of the objects merged
1823 * together in the order provided. If an object creates a circular reference, it will assign the
1824 * original reference.
1825 */
1826export declare function merge<T = {}>(target: Partial<T>, ...args: (Partial<T> | null | undefined | false)[]): T;
1827
1828/**
1829 * ARIA helper to concatenate attributes, returning undefined if all attributes
1830 * are undefined. (Empty strings are not a valid ARIA attribute value.)
1831 *
1832 * @param ariaAttributes - ARIA attributes to merge
1833 */
1834export declare function mergeAriaAttributeValues(...ariaAttributes: (string | undefined | false)[]): string | undefined;
1835
1836/**
1837 * Merge props and customizations giving priority to props over context.
1838 * NOTE: This function will always perform multiple merge operations. Use with caution.
1839 * @param props - New settings to merge in.
1840 * @param parentContext - Context containing current settings.
1841 * @returns Merged customizations.
1842 */
1843export declare function mergeCustomizations(props: ICustomizerProps, parentContext: ICustomizerContext): ICustomizerContext;
1844
1845export declare function mergeScopedSettings(oldSettings?: ISettings, newSettings?: ISettings | ISettingsFunction): ISettings;
1846
1847/**
1848 * Merge new and old settings, giving priority to new settings.
1849 * New settings is optional in which case oldSettings is returned as-is.
1850 * @param oldSettings - Old settings to fall back to.
1851 * @param newSettings - New settings that will be merged over oldSettings.
1852 * @returns Merged settings.
1853 */
1854export declare function mergeSettings(oldSettings?: ISettings, newSettings?: ISettings | ISettingsFunction): ISettings;
1855
1856export declare type MergeStylesContextConsumerProps = {
1857 stylesheetKey: string;
1858 children: (inShadow: boolean) => React_2.ReactElement<any, any>;
1859};
1860
1861export declare type MergeStylesRootContextValue = {
1862 /**
1863 * Map of stylesheets available in the context.
1864 */
1865 stylesheets: Map<string, ExtendedCSSStyleSheet>;
1866 useAdoptedStylesheetEx: AdoptedStylesheetExHook;
1867 useAdoptedStylesheet: AdoptedStylesheetHook;
1868 useShadowConfig: ShadowConfigHook;
1869 useMergeStylesShadowRootContext: MergeStylesShadowRootContetHook;
1870 useHasMergeStylesShadowRootContext: HasMergeStylesShadowRootContextHook;
1871 useMergeStylesRootStylesheets: MergeStylesRootStylesheetsHook;
1872 useWindow: UseWindowHook;
1873 useStyled: UseStyledHook;
1874};
1875
1876/**
1877 * Root context provider for mergeStyles shadow DOM.
1878 * Typically this is placed at the render root of your React application.
1879 */
1880export declare const MergeStylesRootProvider: React_2.FC<MergeStylesRootProviderProps>;
1881
1882export declare type MergeStylesRootProviderProps = {
1883 /**
1884 * Map of stylesheets available in the context.
1885 */
1886 stylesheets?: Map<string, ExtendedCSSStyleSheet>;
1887 /**
1888 * Optional `window` object to use for reading adopted stylesheets.
1889 * Useful for multi-window scenarios.
1890 */
1891 window?: Window;
1892 useAdoptedStylesheetEx?: AdoptedStylesheetExHook;
1893 useAdoptedStylesheet?: AdoptedStylesheetHook;
1894 useShadowConfig?: ShadowConfigHook;
1895 useMergeStylesShadowRootContext?: MergeStylesShadowRootContetHook;
1896 useHasMergeStylesShadowRootContext?: HasMergeStylesShadowRootContextHook;
1897 useMergeStylesRootStylesheets?: MergeStylesRootStylesheetsHook;
1898 useWindow?: UseWindowHook;
1899 useStyled?: UseStyledHook;
1900};
1901
1902declare type MergeStylesRootStylesheetsHook = () => Map<string, ExtendedCSSStyleSheet>;
1903
1904declare type MergeStylesShadowRootContetHook = () => MergeStylesShadowRootContextValue | undefined;
1905
1906export declare const MergeStylesShadowRootContext: React_2.Context<MergeStylesShadowRootContextValue | undefined>;
1907
1908export declare type MergeStylesShadowRootContextValue = {
1909 /**
1910 * Map of stylesheets available in the context.
1911 */
1912 stylesheets: Map<string, CSSStyleSheet>;
1913 /**
1914 * Shadow root for this context.
1915 */
1916 shadowRoot?: ShadowRoot | null;
1917};
1918
1919/**
1920 * Context for a shadow root.
1921 */
1922export declare const MergeStylesShadowRootProvider: React_2.FC<MergeStylesShadowRootProviderProps>;
1923
1924export declare type MergeStylesShadowRootProviderProps = {
1925 /**
1926 * Shadow root for this context.
1927 */
1928 shadowRoot?: ShadowRoot | null;
1929};
1930
1931/**
1932 * The helper functions here will make the target element as modal to screen readers, by placing aria-hidden on elements
1933 * that are siblings to the target element and the target element's ancestors (because aria-hidden gets inherited).
1934 * That way, all other elements on the page are hidden to the screen reader.
1935 */
1936/**
1937 * Call this on a target element to make it modal to screen readers.
1938 * Returns a function that undoes the changes it made.
1939 */
1940export declare function modalize(target: HTMLElement): () => void;
1941
1942/**
1943 * Simple constant function for returning null, used to render empty templates in JSX.
1944 *
1945 * @public
1946 */
1947export declare function nullRender(): JSX.Element | null;
1948
1949/**
1950 * An array of OL tag properties and events.
1951 *
1952 * @public
1953 */
1954export declare const olProperties: Record<string, number>;
1955
1956/**
1957 * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
1958 * props. This ends up faster than using object ...rest or reduce to filter.
1959 *
1960 * This behaves very much like filteredAssign, but does not merge many objects together,
1961 * uses an exclusion object map, and avoids spreads all for optimal performance.
1962 *
1963 * See perf test for background:
1964 * https://jsperf.com/omit-vs-rest-vs-reduce/1
1965 *
1966 * @param obj - The object to clone
1967 * @param exclusions - The array of keys to exclude
1968 */
1969export declare function omit<TObj extends Record<string, any>>(obj: TObj, exclusions: (keyof TObj)[]): TObj;
1970
1971export { Omit_2 as Omit }
1972
1973export declare function on(element: Element | Window | Document, eventName: string, callback: (ev: Event) => void, options?: boolean): () => void;
1974
1975export declare const optionProperties: Record<string, number>;
1976
1977/**
1978 * Point interface.
1979 *
1980 * @public
1981 * {@docCategory Point}
1982 */
1983export declare interface Point {
1984 left?: number;
1985 top?: number;
1986 /** @deprecated Use `left` instead */
1987 x?: number;
1988 /** @deprecated Use `top` instead */
1989 y?: number;
1990}
1991
1992export { portalContainsElement }
1993
1994/**
1995 * Rounds a number to a certain level of precision. Accepts negative precision.
1996 * @param value - The value that is being rounded.
1997 * @param precision - The number of decimal places to round the number to
1998 */
1999export declare function precisionRound(value: number, precision: number, base?: number): number;
2000
2001/** Raises a click event.
2002 * @deprecated Moved to `FocusZone` component since it was the only place internally using this function.
2003 */
2004export declare function raiseClick(target: Element, doc?: Document): void;
2005
2006/**
2007 * Rectangle helper class.
2008 *
2009 * @public
2010 * {@docCategory Rectangle}
2011 */
2012export declare class Rectangle {
2013 top: number;
2014 bottom: number;
2015 left: number;
2016 right: number;
2017 constructor(left?: number, right?: number, top?: number, bottom?: number);
2018 /**
2019 * Calculated automatically by subtracting the right from left
2020 */
2021 get width(): number;
2022 /**
2023 * Calculated automatically by subtracting the bottom from top.
2024 */
2025 get height(): number;
2026 /**
2027 * Tests if another rect is approximately equal to this rect (within 4 decimal places.)
2028 */
2029 equals(rect: Rectangle): boolean;
2030}
2031
2032export declare type RefObject<T> = {
2033 (component: T | null): void;
2034 current: T | null;
2035};
2036
2037/**
2038 * Removes a keycode to the list of keys that, when pressed, should cause the focus outlines to be visible.
2039 * This can be used to remove global shortcut keys that directionally move from section to section within
2040 * an app or between focus trap zones.
2041 */
2042export declare function removeDirectionalKeyCode(which: number): void;
2043
2044/**
2045 * Given an array, it returns a new array that does not contain the item at the given index.
2046 * @param array - The array to operate on
2047 * @param index - The index of the element to remove
2048 */
2049export declare function removeIndex<T>(array: T[], index: number): T[];
2050
2051/**
2052 * Given an array, this function returns a new array where the element at a given index has been replaced.
2053 * @param array - The array to operate on
2054 * @param newElement - The element that will be placed in the new array
2055 * @param index - The index of the element that should be replaced
2056 */
2057export declare function replaceElement<T>(array: T[], newElement: T, index: number): T[];
2058
2059/** Reset controlled usage warnings for testing purposes. */
2060export declare function resetControlledWarnings(): void;
2061
2062/**
2063 * Resets id counter to an (optional) number.
2064 *
2065 * @public
2066 */
2067export declare function resetIds(counter?: number): void;
2068
2069/**
2070 * Reset memoizations.
2071 */
2072export declare function resetMemoizations(): void;
2073
2074/**
2075 * Generates a function to be attached to a React component, which can be called
2076 * as a replacement to RAF. In-flight async calls will be auto canceled if the component
2077 * is unmounting before the async code is executed, preventing bugs where code
2078 * accesses things within the component after being unmounted.
2079 */
2080export declare const safeRequestAnimationFrame: (component: React_2.Component) => (cb: Function) => void;
2081
2082/**
2083 * Generates a function to be attached to a React component, which can be called
2084 * as a replacement to setTimeout. In-flight async calls will be auto canceled if the component
2085 * is unmounting before the async code is executed, preventing bugs where code
2086 * accesses things within the component after being unmounted.
2087 */
2088export declare const safeSetTimeout: (component: React_2.Component) => (cb: Function, duration: number) => void;
2089
2090/**
2091 * {@docCategory Selection}
2092 */
2093declare class Selection_2<TItem = IObjectWithKey> implements ISelection<TItem> {
2094 /** Number of items selected. Do not modify. */
2095 count: number;
2096 readonly mode: SelectionMode_2;
2097 private _getKey;
2098 private _canSelectItem;
2099 private _changeEventSuppressionCount;
2100 private _items;
2101 private _selectedItems;
2102 private _selectedIndices;
2103 private _isAllSelected;
2104 private _exemptedIndices;
2105 private _exemptedCount;
2106 private _keyToIndexMap;
2107 private _anchoredIndex;
2108 private _onSelectionChanged;
2109 private _onItemsChanged;
2110 private _hasChanged;
2111 private _unselectableIndices;
2112 private _unselectableCount;
2113 private _isModal;
2114 /**
2115 * Create a new Selection. If `TItem` does not have a `key` property, you must provide an options
2116 * object with a `getKey` implementation. Providing options is optional otherwise.
2117 * (At most one `options` object is accepted.)
2118 */
2119 constructor(...options: TItem extends IObjectWithKey ? [] | [ISelectionOptions<TItem>] : [ISelectionOptionsWithRequiredGetKey<TItem>]);
2120 canSelectItem(item: TItem, index?: number): boolean;
2121 getKey(item: TItem, index?: number): string;
2122 setChangeEvents(isEnabled: boolean, suppressChange?: boolean): void;
2123 isModal(): boolean;
2124 setModal(isModal: boolean): void;
2125 /**
2126 * Selection needs the items, call this method to set them. If the set
2127 * of items is the same, this will re-evaluate selection and index maps.
2128 * Otherwise, shouldClear should be set to true, so that selection is
2129 * cleared.
2130 */
2131 setItems(items: TItem[], shouldClear?: boolean): void;
2132 getItems(): TItem[];
2133 getSelection(): TItem[];
2134 getSelectedCount(): number;
2135 getSelectedIndices(): number[];
2136 getItemIndex(key: string): number;
2137 isRangeSelected(fromIndex: number, count: number): boolean;
2138 isAllSelected(): boolean;
2139 isKeySelected(key: string): boolean;
2140 isIndexSelected(index: number): boolean;
2141 setAllSelected(isAllSelected: boolean): void;
2142 setKeySelected(key: string, isSelected: boolean, shouldAnchor: boolean): void;
2143 setIndexSelected(index: number, isSelected: boolean, shouldAnchor: boolean): void;
2144 setRangeSelected(fromIndex: number, count: number, isSelected: boolean, shouldAnchor: boolean): void;
2145 selectToKey(key: string, clearSelection?: boolean): void;
2146 selectToRange(fromIndex: number, count: number, clearSelection?: boolean): void;
2147 selectToIndex(index: number, clearSelection?: boolean): void;
2148 toggleAllSelected(): void;
2149 toggleKeySelected(key: string): void;
2150 toggleIndexSelected(index: number): void;
2151 toggleRangeSelected(fromIndex: number, count: number): void;
2152 private _updateCount;
2153 private _setAllSelected;
2154 private _change;
2155}
2156export { Selection_2 as Selection }
2157
2158export declare const SELECTION_CHANGE = "change";
2159
2160export declare const SELECTION_ITEMS_CHANGE = "items-change";
2161
2162/**
2163 * {@docCategory Selection}
2164 */
2165export declare enum SelectionDirection {
2166 horizontal = 0,
2167 vertical = 1
2168}
2169
2170/**
2171 * {@docCategory Selection}
2172 */
2173declare enum SelectionMode_2 {
2174 none = 0,
2175 single = 1,
2176 multiple = 2
2177}
2178export { SelectionMode_2 as SelectionMode }
2179
2180/**
2181 * An array of SELECT tag properties and events.
2182 *
2183 * @public
2184 */
2185export declare const selectProperties: Record<string, number>;
2186
2187/**
2188 * @deprecated Unused as of version 8
2189 */
2190export declare function setBaseUrl(baseUrl: string): void;
2191
2192/**
2193 * Sets the visibility of focus styling.
2194 *
2195 * By default, focus styles (the box surrounding a focused Button, for example) only show up when navigational
2196 * keypresses occur (through Tab, arrows, PgUp/PgDn, Home and End), and are hidden when mouse interactions occur.
2197 * This API provides an imperative way to turn them on/off.
2198 *
2199 * A use case might be when you have a keypress like ctrl-f6 navigate to a particular region on the page,
2200 * and want focus to show up.
2201 *
2202 * @param enabled - Whether to turn focus visibility on or off.
2203 * @param target - Optional target from which to get window in case no `providerElem` has been specified.
2204 * @param registeredProviders - Array of provider refs that are associated with a FocusRectsProvider. If no array
2205 * is passed in, the classnames are attached to the document body that contains `target`.
2206 */
2207export declare function setFocusVisibility(enabled: boolean, target?: Element, registeredProviders?: React_2.RefObject<HTMLElement>[]): void;
2208
2209/**
2210 * Sets the language for the page (by adjusting the lang attribute of the html element).
2211 * @param language - Language to set.
2212 * @param persistenceType - Where to persist the value. Default is `sessionStorage` if available.
2213 */
2214export declare function setLanguage(language: string, persistenceType?: 'localStorage' | 'sessionStorage' | 'none'): void;
2215
2216/**
2217 * Sets the language for the page (by adjusting the lang attribute of the html element).
2218 * @deprecated Use string parameter version.
2219 * @param language - Language to set.
2220 * @param avoidPersisting - If true, don't store the value.
2221 */
2222export declare function setLanguage(language: string, avoidPersisting?: boolean): void;
2223
2224/**
2225 * Test utility for providing a custom weakmap.
2226 *
2227 * @internal
2228 * */
2229export declare function setMemoizeWeakMap(weakMap: any): void;
2230
2231export { setPortalAttribute }
2232
2233/**
2234 * Sets the rtl state of the page (by adjusting the dir attribute of the html element.)
2235 */
2236export declare function setRTL(isRTL: boolean, persistSetting?: boolean): void;
2237
2238/**
2239 * Helper to set ssr mode to simulate no window object returned from getWindow helper.
2240 *
2241 * @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.
2242 */
2243export declare function setSSR(isEnabled: boolean): void;
2244
2245/**
2246 * @deprecated Use ISettings.
2247 */
2248export declare type Settings = ISettings;
2249
2250/**
2251 * @deprecated Use ISettingsFunction.
2252 */
2253export declare type SettingsFunction = ISettingsFunction;
2254
2255export { setVirtualParent }
2256
2257/**
2258 * Configures the warning callback. Passing in undefined will reset it to use the default
2259 * console.warn function.
2260 *
2261 * @public
2262 * @param warningCallback - Callback to override the generated warnings.
2263 */
2264export declare function setWarningCallback(warningCallback?: (message: string) => void): void;
2265
2266export declare type ShadowConfigHook = (stylesheetKey: string, inShadow: boolean, win?: Window) => ShadowConfig;
2267
2268/**
2269 * Compares a to b and b to a.
2270 *
2271 * @public
2272 */
2273export declare function shallowCompare<TA extends any, TB extends any>(a: TA, b: TB): boolean;
2274
2275/**
2276 * Determines if an, or any of its ancestors, sepcificies that it doesn't want focus to wrap
2277 * @param element - element to start searching from
2278 * @param noWrapDataAttribute - the no wrap data attribute to match (either)
2279 * @returns true if focus should wrap, false otherwise
2280 */
2281export declare function shouldWrapFocus(element: HTMLElement, noWrapDataAttribute: 'data-no-vertical-wrap' | 'data-no-horizontal-wrap', doc?: Document): boolean;
2282
2283/**
2284 * The styled HOC wrapper allows you to create a functional wrapper around a given component which will resolve
2285 * getStyles functional props, and mix customized props passed in using concatStyleSets.
2286 *
2287 * @example
2288 * ```tsx
2289 * export const Toggle = styled(
2290 * ToggleBase,
2291 * props => ({ root: { background: 'red' }})
2292 * );
2293 * ```
2294 * @param Component - The unstyled base component to render, which receives styles.
2295 * @param baseStyles - The styles which should be curried with the component.
2296 * @param getProps - A helper which provides default props.
2297 * @param customizable - An object which defines which props can be customized using the Customizer.
2298 * @param pure - A boolean indicating if the component should avoid re-rendering when props haven't changed.
2299 * Note that pure should not be used on components which allow children, or take in complex objects or
2300 * arrays as props which could mutate on every render.
2301 */
2302export declare function styled<TComponentProps extends IPropsWithStyles<TStyleProps, TStyleSet>, TStyleProps, TStyleSet extends IStyleSetBase>(Component: React_2.ComponentClass<TComponentProps> | React_2.FunctionComponent<TComponentProps>, baseStyles: IStyleFunctionOrObject<TStyleProps, TStyleSet>, getProps?: (props: TComponentProps) => Partial<TComponentProps>, customizable?: ICustomizableProps, pure?: boolean): React_2.FunctionComponent<TComponentProps>;
2303
2304export declare function styled<TComponentProps extends IPropsWithStyles<TStyleProps, TStyleSet> & React_2.RefAttributes<TRef>, TStyleProps, TStyleSet extends IStyleSetBase, TRef = unknown>(Component: React_2.ComponentClass<TComponentProps> | React_2.FunctionComponent<TComponentProps>, baseStyles: IStyleFunctionOrObject<TStyleProps, TStyleSet>, getProps?: (props: TComponentProps) => Partial<TComponentProps>, customizable?: ICustomizableProps, pure?: boolean): React_2.ForwardRefExoticComponent<React_2.PropsWithoutRef<TComponentProps> & React_2.RefAttributes<TRef>>;
2305
2306export declare type StyleFunction<TStyleProps, TStyleSet extends IStyleSetBase> = IStyleFunctionOrObject<TStyleProps, TStyleSet> & {
2307 /** Cache for all style functions. */
2308 __cachedInputs__: (IStyleFunctionOrObject<TStyleProps, TStyleSet> | undefined)[];
2309 /** True if no styles prop or styles from Customizer is passed to wrapped component. */
2310 __noStyleOverride__: boolean;
2311 /** Shadow DOM configuration object */
2312 __shadowConfig__?: ShadowConfig;
2313};
2314
2315/**
2316 * An array of TABLE tag properties and events.
2317 *
2318 * @public
2319 */
2320export declare const tableProperties: Record<string, number>;
2321
2322/**
2323 * An array of TD tag properties and events.
2324 *
2325 * @public
2326 */
2327export declare const tdProperties: Record<string, number>;
2328
2329/**
2330 * An array of TEXTAREA tag properties and events.
2331 *
2332 * @public
2333 */
2334export declare const textAreaProperties: Record<string, number>;
2335
2336/**
2337 * An array of TH tag properties and events.
2338 *
2339 * @public
2340 */
2341export declare const thProperties: Record<string, number>;
2342
2343/**
2344 * Convert the given array to a matrix with columnCount number
2345 * of columns.
2346 *
2347 * @public
2348 * @param items - The array to convert
2349 * @param columnCount - The number of columns for the resulting matrix
2350 * @returns A matrix of items
2351 */
2352export declare function toMatrix<T>(items: T[], columnCount: number): T[][];
2353
2354/**
2355 * An array of TR tag properties and events.
2356 *
2357 * @public
2358 */
2359export declare const trProperties: Record<string, number>;
2360
2361/**
2362 * Provides a method for convenience to unhoist hoisted methods.
2363 *
2364 * @public
2365 * @param source - The source object upon which methods were hoisted.
2366 * @param methodNames - An array of method names to unhoist.
2367 */
2368export declare function unhoistMethods(source: any, methodNames: string[]): void;
2369
2370/**
2371 * Use adopted stylesheets in the parent shadow root.
2372 */
2373export declare const useAdoptedStylesheet: AdoptedStylesheetHook;
2374
2375/**
2376 * Optimization for specific cases like nested customizables.
2377 */
2378export declare const useAdoptedStylesheetEx: AdoptedStylesheetExHook;
2379
2380/**
2381 * Hook to get Customizations settings from Customizations singleton or CustomizerContext.
2382 * It will trigger component state update on settings change observed.
2383 */
2384export declare function useCustomizationSettings(properties: string[], scopeName?: string): ISettings;
2385
2386/**
2387 * Initializes the logic which:
2388 *
2389 * 1. Subscribes keydown, keyup, mousedown and pointerdown events. (It will only do it once for the current element of
2390 * the FocusRectsContext providerRef or once per window if no such element is provided via context, so it's safe to
2391 * call this method multiple times.)
2392 * 2. When the user presses triggers a keydown or keyup event via directional keyboard keys, adds the
2393 * 'ms-Fabric--isFocusVisible' classname to the current element of the FocusRectsContext providerRef or the document
2394 * body if no such element is provided via context, and removes the 'ms-Fabric-isFocusHidden' classname.
2395 * 3. When the user triggers a mousedown or pointerdown event, adds the 'ms-Fabric-isFocusHidden' classname to the
2396 * current element of the FocusRectsContext providerRef or the document body if no such element is provided via
2397 * context, and removes the 'ms-Fabric--isFocusVisible' classname.
2398 *
2399 * This logic allows components on the page to conditionally render focus treatments based on
2400 * the existence of global classnames, which simplifies logic overall.
2401 *
2402 * @param rootRef - A Ref object. Focus rectangle can be applied on itself and all its children.
2403 */
2404export declare function useFocusRects(rootRef?: React_2.RefObject<HTMLElement>): void;
2405
2406/**
2407 * Test if a context is available.
2408 * @returns true if there is a context.
2409 */
2410export declare const useHasMergeStylesShadowRootContext: HasMergeStylesShadowRootContextHook;
2411
2412/**
2413 * React currently throws a warning when using `useLayoutEffect` on the server. To get around it,
2414 * this hook calls `useEffect` on the server (no-op) and `useLayoutEffect` in the browser.
2415 *
2416 * Prefer `useEffect` unless you have a specific need to do something after mount and before paint,
2417 * such as to avoid a render flash for certain operations.
2418 *
2419 * Server-side rendering is detected based on `canUseDOM` from `@fluentui/utilities`.
2420 *
2421 * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
2422 * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
2423 */
2424export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
2425
2426export declare const useMergeStylesHooks: () => {
2427 useAdoptedStylesheet: AdoptedStylesheetHook;
2428 useAdoptedStylesheetEx: AdoptedStylesheetExHook;
2429 useShadowConfig: ShadowConfigHook;
2430 useMergeStylesShadowRootContext: MergeStylesShadowRootContetHook;
2431 useHasMergeStylesShadowRootContext: HasMergeStylesShadowRootContextHook;
2432 useMergeStylesRootStylesheets: MergeStylesRootStylesheetsHook;
2433 useWindow: () => Window | undefined;
2434 useStyled: UseStyledHook;
2435};
2436
2437/**
2438 * Get the map of stylesheets available in the context.
2439 */
2440export declare const useMergeStylesRootStylesheets: MergeStylesRootStylesheetsHook;
2441
2442/**
2443 * Get a reference to the shadow root context.
2444 * @returns The context for the shadow root.
2445 */
2446export declare const useMergeStylesShadowRootContext: MergeStylesShadowRootContetHook;
2447
2448/**
2449 * Get a shadow config.
2450 * @param stylesheetKey - Globally unique key
2451 * @param win - Reference to the `window` global.
2452 * @returns ShadowConfig
2453 */
2454export declare const useShadowConfig: ShadowConfigHook;
2455
2456export declare const useStyled: UseStyledHook;
2457
2458export declare type UseStyledHook = (scope: string) => ShadowConfig | undefined;
2459
2460declare type UseWindowHook = () => Window | undefined;
2461
2462/**
2463 * Get all values in an object dictionary
2464 *
2465 * @param obj - The dictionary to get values for
2466 */
2467export declare function values<T>(obj: any): T[];
2468
2469/**
2470 * An array of VIDEO tag properties and events.
2471 *
2472 * @public
2473 */
2474export declare const videoProperties: Record<string, number>;
2475
2476/**
2477 * Sends a warning to console, if the api is present.
2478 *
2479 * @public
2480 * @param message - Warning message.
2481 */
2482export declare function warn(message: string): void;
2483
2484/**
2485 * Warns when props are required if a condition is met.
2486 *
2487 * @public
2488 * @param componentName - The name of the component being used.
2489 * @param props - The props passed into the component.
2490 * @param requiredProps - The name of the props that are required when the condition is met.
2491 * @param conditionalPropName - The name of the prop that the condition is based on.
2492 * @param condition - Whether the condition is met.
2493 */
2494export declare function warnConditionallyRequiredProps<P extends {}>(componentName: string, props: P, requiredProps: string[], conditionalPropName: string, condition: boolean): void;
2495
2496/**
2497 * Check for and warn on the following error conditions with a form component:
2498 * - A value prop is provided (indicated it's being used as controlled) without a change handler,
2499 * and the component is not read-only
2500 * - Both the value and defaultValue props are provided
2501 * - The component is attempting to switch between controlled and uncontrolled
2502 *
2503 * The messages mimic the warnings React gives for these error conditions on input elements.
2504 * The warning will only be displayed once per component ID.
2505 */
2506export declare function warnControlledUsage<P>(params: IWarnControlledUsageParams<P>): void;
2507
2508/**
2509 * Warns when a deprecated props are being used.
2510 *
2511 * @public
2512 * @param componentName - The name of the component being used.
2513 * @param props - The props passed into the component.
2514 * @param deprecationMap - The map of deprecations, where key is the prop name and the value is
2515 * either null or a replacement prop name.
2516 */
2517export declare function warnDeprecations<P extends {}>(componentName: string, props: P, deprecationMap: ISettingsMap<P>): void;
2518
2519/**
2520 * Warns when two props which are mutually exclusive are both being used.
2521 *
2522 * @public
2523 * @param componentName - The name of the component being used.
2524 * @param props - The props passed into the component.
2525 * @param exclusiveMap - A map where the key is a parameter, and the value is the other parameter.
2526 */
2527export declare function warnMutuallyExclusive<P>(componentName: string, props: P, exclusiveMap: ISettingsMap<P>): void;
2528
2529export { }