@react-aria/utils 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/chain.main.js +26 -0
- package/dist/chain.main.js.map +1 -0
- package/dist/chain.mjs +21 -0
- package/dist/chain.module.js +21 -0
- package/dist/chain.module.js.map +1 -0
- package/dist/domHelpers.main.js +19 -0
- package/dist/domHelpers.main.js.map +1 -0
- package/dist/domHelpers.mjs +13 -0
- package/dist/domHelpers.module.js +13 -0
- package/dist/domHelpers.module.js.map +1 -0
- package/dist/filterDOMProps.main.js +45 -0
- package/dist/filterDOMProps.main.js.map +1 -0
- package/dist/filterDOMProps.mjs +40 -0
- package/dist/filterDOMProps.module.js +40 -0
- package/dist/filterDOMProps.module.js.map +1 -0
- package/dist/focusWithoutScrolling.main.js +72 -0
- package/dist/focusWithoutScrolling.main.js.map +1 -0
- package/dist/focusWithoutScrolling.mjs +67 -0
- package/dist/focusWithoutScrolling.module.js +67 -0
- package/dist/focusWithoutScrolling.module.js.map +1 -0
- package/dist/getOffset.main.js +24 -0
- package/dist/getOffset.main.js.map +1 -0
- package/dist/getOffset.mjs +19 -0
- package/dist/getOffset.module.js +19 -0
- package/dist/getOffset.module.js.map +1 -0
- package/dist/getScrollParent.main.js +28 -0
- package/dist/getScrollParent.main.js.map +1 -0
- package/dist/getScrollParent.mjs +23 -0
- package/dist/getScrollParent.module.js +23 -0
- package/dist/getScrollParent.module.js.map +1 -0
- package/dist/getScrollParents.main.js +30 -0
- package/dist/getScrollParents.main.js.map +1 -0
- package/dist/getScrollParents.mjs +25 -0
- package/dist/getScrollParents.module.js +25 -0
- package/dist/getScrollParents.module.js.map +1 -0
- package/dist/import.mjs +81 -0
- package/dist/isScrollable.main.js +25 -0
- package/dist/isScrollable.main.js.map +1 -0
- package/dist/isScrollable.mjs +20 -0
- package/dist/isScrollable.module.js +20 -0
- package/dist/isScrollable.module.js.map +1 -0
- package/dist/isVirtualEvent.main.js +41 -0
- package/dist/isVirtualEvent.main.js.map +1 -0
- package/dist/isVirtualEvent.mjs +35 -0
- package/dist/isVirtualEvent.module.js +35 -0
- package/dist/isVirtualEvent.module.js.map +1 -0
- package/dist/main.js +138 -0
- package/dist/main.js.map +1 -0
- package/dist/mergeProps.main.js +51 -0
- package/dist/mergeProps.main.js.map +1 -0
- package/dist/mergeProps.mjs +42 -0
- package/dist/mergeProps.module.js +42 -0
- package/dist/mergeProps.module.js.map +1 -0
- package/dist/mergeRefs.main.js +28 -0
- package/dist/mergeRefs.main.js.map +1 -0
- package/dist/mergeRefs.mjs +23 -0
- package/dist/mergeRefs.module.js +23 -0
- package/dist/mergeRefs.module.js.map +1 -0
- package/dist/module.js +81 -0
- package/dist/module.js.map +1 -0
- package/dist/openLink.main.js +155 -0
- package/dist/openLink.main.js.map +1 -0
- package/dist/openLink.mjs +140 -0
- package/dist/openLink.module.js +140 -0
- package/dist/openLink.module.js.map +1 -0
- package/dist/platform.main.js +71 -0
- package/dist/platform.main.js.map +1 -0
- package/dist/platform.mjs +58 -0
- package/dist/platform.module.js +58 -0
- package/dist/platform.module.js.map +1 -0
- package/dist/runAfterTransition.main.js +82 -0
- package/dist/runAfterTransition.main.js.map +1 -0
- package/dist/runAfterTransition.mjs +77 -0
- package/dist/runAfterTransition.module.js +77 -0
- package/dist/runAfterTransition.module.js.map +1 -0
- package/dist/scrollIntoView.main.js +96 -0
- package/dist/scrollIntoView.main.js.map +1 -0
- package/dist/scrollIntoView.mjs +90 -0
- package/dist/scrollIntoView.module.js +90 -0
- package/dist/scrollIntoView.module.js.map +1 -0
- package/dist/types.d.ts +229 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useDeepMemo.main.js +30 -0
- package/dist/useDeepMemo.main.js.map +1 -0
- package/dist/useDeepMemo.mjs +25 -0
- package/dist/useDeepMemo.module.js +25 -0
- package/dist/useDeepMemo.module.js.map +1 -0
- package/dist/useDescription.main.js +59 -0
- package/dist/useDescription.main.js.map +1 -0
- package/dist/useDescription.mjs +54 -0
- package/dist/useDescription.module.js +54 -0
- package/dist/useDescription.module.js.map +1 -0
- package/dist/useDrag1D.main.js +139 -0
- package/dist/useDrag1D.main.js.map +1 -0
- package/dist/useDrag1D.mjs +134 -0
- package/dist/useDrag1D.module.js +134 -0
- package/dist/useDrag1D.module.js.map +1 -0
- package/dist/useEffectEvent.main.js +37 -0
- package/dist/useEffectEvent.main.js.map +1 -0
- package/dist/useEffectEvent.mjs +32 -0
- package/dist/useEffectEvent.module.js +32 -0
- package/dist/useEffectEvent.module.js.map +1 -0
- package/dist/useEvent.main.js +42 -0
- package/dist/useEvent.main.js.map +1 -0
- package/dist/useEvent.mjs +37 -0
- package/dist/useEvent.module.js +37 -0
- package/dist/useEvent.module.js.map +1 -0
- package/dist/useFormReset.main.js +41 -0
- package/dist/useFormReset.main.js.map +1 -0
- package/dist/useFormReset.mjs +36 -0
- package/dist/useFormReset.module.js +36 -0
- package/dist/useFormReset.module.js.map +1 -0
- package/dist/useGlobalListeners.main.js +63 -0
- package/dist/useGlobalListeners.main.js.map +1 -0
- package/dist/useGlobalListeners.mjs +58 -0
- package/dist/useGlobalListeners.module.js +58 -0
- package/dist/useGlobalListeners.module.js.map +1 -0
- package/dist/useId.main.js +93 -0
- package/dist/useId.main.js.map +1 -0
- package/dist/useId.mjs +86 -0
- package/dist/useId.module.js +86 -0
- package/dist/useId.module.js.map +1 -0
- package/dist/useLabels.main.js +44 -0
- package/dist/useLabels.main.js.map +1 -0
- package/dist/useLabels.mjs +39 -0
- package/dist/useLabels.module.js +39 -0
- package/dist/useLabels.module.js.map +1 -0
- package/dist/useLayoutEffect.main.js +27 -0
- package/dist/useLayoutEffect.main.js.map +1 -0
- package/dist/useLayoutEffect.mjs +18 -0
- package/dist/useLayoutEffect.module.js +18 -0
- package/dist/useLayoutEffect.module.js.map +1 -0
- package/dist/useLoadMore.main.js +72 -0
- package/dist/useLoadMore.main.js.map +1 -0
- package/dist/useLoadMore.mjs +67 -0
- package/dist/useLoadMore.module.js +67 -0
- package/dist/useLoadMore.module.js.map +1 -0
- package/dist/useObjectRef.main.js +37 -0
- package/dist/useObjectRef.main.js.map +1 -0
- package/dist/useObjectRef.mjs +32 -0
- package/dist/useObjectRef.module.js +32 -0
- package/dist/useObjectRef.module.js.map +1 -0
- package/dist/useResizeObserver.main.js +43 -0
- package/dist/useResizeObserver.main.js.map +1 -0
- package/dist/useResizeObserver.mjs +38 -0
- package/dist/useResizeObserver.module.js +38 -0
- package/dist/useResizeObserver.module.js.map +1 -0
- package/dist/useSyncRef.main.js +32 -0
- package/dist/useSyncRef.main.js.map +1 -0
- package/dist/useSyncRef.mjs +27 -0
- package/dist/useSyncRef.module.js +27 -0
- package/dist/useSyncRef.module.js.map +1 -0
- package/dist/useUpdateEffect.main.js +38 -0
- package/dist/useUpdateEffect.main.js.map +1 -0
- package/dist/useUpdateEffect.mjs +33 -0
- package/dist/useUpdateEffect.module.js +33 -0
- package/dist/useUpdateEffect.module.js.map +1 -0
- package/dist/useValueEffect.main.js +58 -0
- package/dist/useValueEffect.main.js.map +1 -0
- package/dist/useValueEffect.mjs +53 -0
- package/dist/useValueEffect.module.js +53 -0
- package/dist/useValueEffect.module.js.map +1 -0
- package/dist/useViewportSize.main.js +56 -0
- package/dist/useViewportSize.main.js.map +1 -0
- package/dist/useViewportSize.mjs +51 -0
- package/dist/useViewportSize.module.js +51 -0
- package/dist/useViewportSize.module.js.map +1 -0
- package/package.json +38 -0
- package/src/chain.ts +24 -0
- package/src/domHelpers.ts +14 -0
- package/src/filterDOMProps.ts +76 -0
- package/src/focusWithoutScrolling.ts +96 -0
- package/src/getOffset.ts +19 -0
- package/src/getScrollParent.ts +27 -0
- package/src/getScrollParents.ts +26 -0
- package/src/index.ts +44 -0
- package/src/isScrollable.ts +22 -0
- package/src/isVirtualEvent.ts +58 -0
- package/src/mergeProps.ts +75 -0
- package/src/mergeRefs.ts +32 -0
- package/src/openLink.tsx +183 -0
- package/src/platform.ts +79 -0
- package/src/runAfterTransition.ts +105 -0
- package/src/scrollIntoView.ts +109 -0
- package/src/useDeepMemo.ts +27 -0
- package/src/useDescription.ts +56 -0
- package/src/useDrag1D.ts +190 -0
- package/src/useEffectEvent.ts +26 -0
- package/src/useEvent.ts +37 -0
- package/src/useFormReset.ts +36 -0
- package/src/useGlobalListeners.ts +51 -0
- package/src/useId.ts +108 -0
- package/src/useLabels.ts +48 -0
- package/src/useLayoutEffect.ts +20 -0
- package/src/useLoadMore.ts +82 -0
- package/src/useObjectRef.ts +39 -0
- package/src/useResizeObserver.ts +48 -0
- package/src/useSyncRef.ts +33 -0
- package/src/useUpdateEffect.ts +36 -0
- package/src/useValueEffect.ts +64 -0
- package/src/useViewportSize.ts +63 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, { ForwardedRef, MutableRefObject, ReactNode, HTMLAttributes, EffectCallback, Dispatch, RefObject as _RefObject1 } from "react";
|
|
2
|
+
import { AriaLabelingProps, DOMProps, LinkDOMProps, FocusableElement, Href, RouterOptions, Orientation, RefObject } from "@react-types/shared";
|
|
3
|
+
export const useLayoutEffect: typeof React.useLayoutEffect;
|
|
4
|
+
/**
|
|
5
|
+
* If a default is not provided, generate an id.
|
|
6
|
+
* @param defaultId - Default component id.
|
|
7
|
+
*/
|
|
8
|
+
export function useId(defaultId?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Merges two ids.
|
|
11
|
+
* Different ids will trigger a side-effect and re-render components hooked up with `useId`.
|
|
12
|
+
*/
|
|
13
|
+
export function mergeIds(idA: string, idB: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Used to generate an id, and after render, check if that id is rendered so we know
|
|
16
|
+
* if we can use it in places such as labelledby.
|
|
17
|
+
* @param depArray - When to recalculate if the id is in the DOM.
|
|
18
|
+
*/
|
|
19
|
+
export function useSlotId(depArray?: ReadonlyArray<any>): string;
|
|
20
|
+
/**
|
|
21
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
22
|
+
*/
|
|
23
|
+
export function chain(...callbacks: any[]): (...args: any[]) => void;
|
|
24
|
+
export const getOwnerDocument: (el: Element | null | undefined) => Document;
|
|
25
|
+
export const getOwnerWindow: (el: (Window & typeof global) | Element | null | undefined) => Window & typeof global;
|
|
26
|
+
interface Props {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
type PropsArg = Props | null | undefined;
|
|
30
|
+
type TupleTypes<T> = {
|
|
31
|
+
[P in keyof T]: T[P];
|
|
32
|
+
} extends {
|
|
33
|
+
[key: number]: infer V;
|
|
34
|
+
} ? NullToObject<V> : never;
|
|
35
|
+
type NullToObject<T> = T extends (null | undefined) ? {} : T;
|
|
36
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
37
|
+
/**
|
|
38
|
+
* Merges multiple props objects together. Event handlers are chained,
|
|
39
|
+
* classNames are combined, and ids are deduplicated - different ids
|
|
40
|
+
* will trigger a side-effect and re-render components hooked up with `useId`.
|
|
41
|
+
* For all other props, the last prop object overrides all previous ones.
|
|
42
|
+
* @param args - Multiple sets of props to merge together.
|
|
43
|
+
*/
|
|
44
|
+
export function mergeProps<T extends PropsArg[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
|
|
45
|
+
/**
|
|
46
|
+
* Merges multiple refs into one. Works with either callback or object refs.
|
|
47
|
+
*/
|
|
48
|
+
export function mergeRefs<T>(...refs: Array<ForwardedRef<T> | MutableRefObject<T> | null | undefined>): ForwardedRef<T>;
|
|
49
|
+
interface Options {
|
|
50
|
+
/**
|
|
51
|
+
* If labelling associated aria properties should be included in the filter.
|
|
52
|
+
*/
|
|
53
|
+
labelable?: boolean;
|
|
54
|
+
/** Whether the element is a link and should include DOM props for <a> elements. */
|
|
55
|
+
isLink?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* A Set of other property names that should be included in the filter.
|
|
58
|
+
*/
|
|
59
|
+
propNames?: Set<string>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Filters out all props that aren't valid DOM props or defined via override prop obj.
|
|
63
|
+
* @param props - The component props to be filtered.
|
|
64
|
+
* @param opts - Props to override.
|
|
65
|
+
*/
|
|
66
|
+
export function filterDOMProps(props: DOMProps & AriaLabelingProps & LinkDOMProps, opts?: Options): DOMProps & AriaLabelingProps;
|
|
67
|
+
export function focusWithoutScrolling(element: FocusableElement): void;
|
|
68
|
+
export function getOffset(element: any, reverse: any, orientation?: string): any;
|
|
69
|
+
export const isMac: () => boolean;
|
|
70
|
+
export const isIPhone: () => boolean;
|
|
71
|
+
export const isIPad: () => boolean;
|
|
72
|
+
export const isIOS: () => boolean;
|
|
73
|
+
export const isAppleDevice: () => boolean;
|
|
74
|
+
export const isWebKit: () => boolean;
|
|
75
|
+
export const isChrome: () => boolean;
|
|
76
|
+
export const isAndroid: () => boolean;
|
|
77
|
+
export const isFirefox: () => boolean;
|
|
78
|
+
interface Router {
|
|
79
|
+
isNative: boolean;
|
|
80
|
+
open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => void;
|
|
81
|
+
useHref: (href: Href) => string;
|
|
82
|
+
}
|
|
83
|
+
interface RouterProviderProps {
|
|
84
|
+
navigate: (path: Href, routerOptions: RouterOptions | undefined) => void;
|
|
85
|
+
useHref?: (href: Href) => string;
|
|
86
|
+
children: ReactNode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A RouterProvider accepts a `navigate` function from a framework or client side router,
|
|
90
|
+
* and provides it to all nested React Aria links to enable client side navigation.
|
|
91
|
+
*/
|
|
92
|
+
export function RouterProvider(props: RouterProviderProps): React.JSX.Element;
|
|
93
|
+
export function useRouter(): Router;
|
|
94
|
+
interface Modifiers {
|
|
95
|
+
metaKey?: boolean;
|
|
96
|
+
ctrlKey?: boolean;
|
|
97
|
+
altKey?: boolean;
|
|
98
|
+
shiftKey?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean;
|
|
101
|
+
export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening?: boolean): void;
|
|
102
|
+
export function useSyntheticLinkProps(props: LinkDOMProps): {
|
|
103
|
+
'data-href': string;
|
|
104
|
+
'data-target': React.HTMLAttributeAnchorTarget;
|
|
105
|
+
'data-rel': string;
|
|
106
|
+
'data-download': string | boolean;
|
|
107
|
+
'data-ping': string;
|
|
108
|
+
'data-referrer-policy': React.HTMLAttributeReferrerPolicy;
|
|
109
|
+
};
|
|
110
|
+
/** @deprecated - For backward compatibility. */
|
|
111
|
+
export function getSyntheticLinkProps(props: LinkDOMProps): {
|
|
112
|
+
'data-href': string;
|
|
113
|
+
'data-target': React.HTMLAttributeAnchorTarget;
|
|
114
|
+
'data-rel': string;
|
|
115
|
+
'data-download': string | boolean;
|
|
116
|
+
'data-ping': string;
|
|
117
|
+
'data-referrer-policy': React.HTMLAttributeReferrerPolicy;
|
|
118
|
+
};
|
|
119
|
+
export function useLinkProps(props: LinkDOMProps): {
|
|
120
|
+
href: string;
|
|
121
|
+
target: React.HTMLAttributeAnchorTarget;
|
|
122
|
+
rel: string;
|
|
123
|
+
download: string | boolean;
|
|
124
|
+
ping: string;
|
|
125
|
+
referrerPolicy: React.HTMLAttributeReferrerPolicy;
|
|
126
|
+
};
|
|
127
|
+
export function runAfterTransition(fn: () => void): void;
|
|
128
|
+
interface UseDrag1DProps {
|
|
129
|
+
containerRef: MutableRefObject<HTMLElement>;
|
|
130
|
+
reverse?: boolean;
|
|
131
|
+
orientation?: Orientation;
|
|
132
|
+
onHover?: (hovered: boolean) => void;
|
|
133
|
+
onDrag?: (dragging: boolean) => void;
|
|
134
|
+
onPositionChange?: (position: number) => void;
|
|
135
|
+
onIncrement?: () => void;
|
|
136
|
+
onDecrement?: () => void;
|
|
137
|
+
onIncrementToMax?: () => void;
|
|
138
|
+
onDecrementToMin?: () => void;
|
|
139
|
+
onCollapseToggle?: () => void;
|
|
140
|
+
}
|
|
141
|
+
export function useDrag1D(props: UseDrag1DProps): HTMLAttributes<HTMLElement>;
|
|
142
|
+
interface GlobalListeners {
|
|
143
|
+
addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
144
|
+
addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
145
|
+
removeGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
146
|
+
removeGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
147
|
+
removeAllGlobalListeners(): void;
|
|
148
|
+
}
|
|
149
|
+
export function useGlobalListeners(): GlobalListeners;
|
|
150
|
+
/**
|
|
151
|
+
* Merges aria-label and aria-labelledby into aria-labelledby when both exist.
|
|
152
|
+
* @param props - Aria label props.
|
|
153
|
+
* @param defaultLabel - Default value for aria-label when not present.
|
|
154
|
+
*/
|
|
155
|
+
export function useLabels(props: DOMProps & AriaLabelingProps, defaultLabel?: string): DOMProps & AriaLabelingProps;
|
|
156
|
+
/**
|
|
157
|
+
* Offers an object ref for a given callback ref or an object ref. Especially
|
|
158
|
+
* helfpul when passing forwarded refs (created using `React.forwardRef`) to
|
|
159
|
+
* React Aria hooks.
|
|
160
|
+
*
|
|
161
|
+
* @param forwardedRef The original ref intended to be used.
|
|
162
|
+
* @returns An object ref that updates the given ref.
|
|
163
|
+
* @see https://reactjs.org/docs/forwarding-refs.html
|
|
164
|
+
*/
|
|
165
|
+
export function useObjectRef<T>(forwardedRef?: ((instance: T | null) => void) | MutableRefObject<T | null> | null): MutableRefObject<T | null>;
|
|
166
|
+
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): void;
|
|
167
|
+
type useResizeObserverOptionsType<T> = {
|
|
168
|
+
ref: RefObject<T | undefined | null> | undefined;
|
|
169
|
+
box?: ResizeObserverBoxOptions;
|
|
170
|
+
onResize: () => void;
|
|
171
|
+
};
|
|
172
|
+
export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void;
|
|
173
|
+
interface ContextValue<T> {
|
|
174
|
+
ref?: MutableRefObject<T | null>;
|
|
175
|
+
}
|
|
176
|
+
export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void;
|
|
177
|
+
export function isScrollable(node: Element, checkForOverflow?: boolean): boolean;
|
|
178
|
+
export function getScrollParent(node: Element, checkForOverflow?: boolean): Element;
|
|
179
|
+
export function getScrollParents(node: Element, checkForOverflow?: boolean): Element[];
|
|
180
|
+
interface ViewportSize {
|
|
181
|
+
width: number;
|
|
182
|
+
height: number;
|
|
183
|
+
}
|
|
184
|
+
export function useViewportSize(): ViewportSize;
|
|
185
|
+
export function useDescription(description?: string): AriaLabelingProps;
|
|
186
|
+
export function useEffectEvent<T extends Function>(fn?: T): T;
|
|
187
|
+
export function useEvent<K extends keyof GlobalEventHandlersEventMap>(ref: RefObject<EventTarget | null>, event: K | (string & {}), handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
188
|
+
type SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;
|
|
189
|
+
export function useValueEffect<S>(defaultValue: S | (() => S)): [S, Dispatch<SetValueAction<S>>];
|
|
190
|
+
interface ScrollIntoViewportOpts {
|
|
191
|
+
/** The optional containing element of the target to be centered in the viewport. */
|
|
192
|
+
containingElement?: Element;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Scrolls `scrollView` so that `element` is visible.
|
|
196
|
+
* Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge),
|
|
197
|
+
* but doesn't affect parents above `scrollView`.
|
|
198
|
+
*/
|
|
199
|
+
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void;
|
|
200
|
+
/**
|
|
201
|
+
* Scrolls the `targetElement` so it is visible in the viewport. Accepts an optional `opts.containingElement`
|
|
202
|
+
* that will be centered in the viewport prior to scrolling the targetElement into view. If scrolling is prevented on
|
|
203
|
+
* the body (e.g. targetElement is in a popover), this will only scroll the scroll parents of the targetElement up to but not including the body itself.
|
|
204
|
+
*/
|
|
205
|
+
export function scrollIntoViewport(targetElement: Element, opts?: ScrollIntoViewportOpts): void;
|
|
206
|
+
export function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
|
|
207
|
+
export function isVirtualPointerEvent(event: PointerEvent): boolean;
|
|
208
|
+
export function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T;
|
|
209
|
+
export function useFormReset<T>(ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null>, initialValue: T, onReset: (value: T) => void): void;
|
|
210
|
+
interface LoadMoreProps {
|
|
211
|
+
/** Whether data is currently being loaded. */
|
|
212
|
+
isLoading?: boolean;
|
|
213
|
+
/** Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. */
|
|
214
|
+
onLoadMore?: () => void;
|
|
215
|
+
/**
|
|
216
|
+
* The amount of offset from the bottom of your scrollable region that should trigger load more.
|
|
217
|
+
* Uses a percentage value relative to the scroll body's client height. Load more is then triggered
|
|
218
|
+
* when your current scroll position's distance from the bottom of the currently loaded list of items is less than
|
|
219
|
+
* or equal to the provided value. (e.g. 1 = 100% of the scroll region's height).
|
|
220
|
+
* @default 1
|
|
221
|
+
*/
|
|
222
|
+
scrollOffset?: number;
|
|
223
|
+
/** The data currently loaded. */
|
|
224
|
+
items?: any[];
|
|
225
|
+
}
|
|
226
|
+
export function useLoadMore(props: LoadMoreProps, ref: _RefObject1<HTMLElement | null>): void;
|
|
227
|
+
export { clamp, snapValueToStep } from '@react-stately/utils';
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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B,GAAG,EAAE,UAAU,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,IAAI,CAAC,EACjF,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,QAgB5B;AClBD;IACE,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sGAAsG;IACtG,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;CACd;AAED,4BAA4B,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,QA+CnF;AC3CD,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLayoutEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useId.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/chain.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/domHelpers.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeRefs.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/filterDOMProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/focusWithoutScrolling.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getOffset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/platform.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/openLink.tsx","packages/@react-aria/utils/src/packages/@react-aria/utils/src/runAfterTransition.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDrag1D.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useGlobalListeners.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLabels.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useObjectRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useUpdateEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useResizeObserver.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useSyncRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isScrollable.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParents.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useViewportSize.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDescription.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEffectEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useValueEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/scrollIntoView.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isVirtualEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDeepMemo.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useFormReset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLoadMore.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/index.ts","packages/@react-aria/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useId, mergeIds, useSlotId} from './useId';\nexport {chain} from './chain';\nexport {getOwnerDocument, getOwnerWindow} from './domHelpers';\nexport {mergeProps} from './mergeProps';\nexport {mergeRefs} from './mergeRefs';\nexport {filterDOMProps} from './filterDOMProps';\nexport {focusWithoutScrolling} from './focusWithoutScrolling';\nexport {getOffset} from './getOffset';\nexport {openLink, getSyntheticLinkProps, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps} from './openLink';\nexport {runAfterTransition} from './runAfterTransition';\nexport {useDrag1D} from './useDrag1D';\nexport {useGlobalListeners} from './useGlobalListeners';\nexport {useLabels} from './useLabels';\nexport {useObjectRef} from './useObjectRef';\nexport {useUpdateEffect} from './useUpdateEffect';\nexport {useLayoutEffect} from './useLayoutEffect';\nexport {useResizeObserver} from './useResizeObserver';\nexport {useSyncRef} from './useSyncRef';\nexport {getScrollParent} from './getScrollParent';\nexport {getScrollParents} from './getScrollParents';\nexport {isScrollable} from './isScrollable';\nexport {useViewportSize} from './useViewportSize';\nexport {useDescription} from './useDescription';\nexport {isMac, isIPhone, isIPad, isIOS, isAppleDevice, isWebKit, isChrome, isAndroid, isFirefox} from './platform';\nexport {useEvent} from './useEvent';\nexport {useValueEffect} from './useValueEffect';\nexport {scrollIntoView, scrollIntoViewport} from './scrollIntoView';\nexport {clamp, snapValueToStep} from '@react-stately/utils';\nexport {isVirtualClick, isVirtualPointerEvent} from './isVirtualEvent';\nexport {useEffectEvent} from './useEffectEvent';\nexport {useDeepMemo} from './useDeepMemo';\nexport {useFormReset} from './useFormReset';\nexport {useLoadMore} from './useLoadMore';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var $4FGhO$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useDeepMemo", () => $20e6e72fbf5dc81e$export$722debc0e56fea39);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
20
|
+
function $20e6e72fbf5dc81e$export$722debc0e56fea39(value, isEqual) {
|
|
21
|
+
// Using a ref during render is ok here because it's only an optimization – both values are equivalent.
|
|
22
|
+
// If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
|
|
23
|
+
let lastValue = (0, $4FGhO$react.useRef)(null);
|
|
24
|
+
if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
|
|
25
|
+
lastValue.current = value;
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useDeepMemo.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uCAAuC;AAIhC,SAAS,0CAAe,KAAQ,EAAE,OAAgC;IACvE,uGAAuG;IACvG,yGAAyG;IACzG,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAY;IACjC,IAAI,SAAS,UAAU,OAAO,IAAI,QAAQ,OAAO,UAAU,OAAO,GAChE,QAAQ,UAAU,OAAO;IAG3B,UAAU,OAAO,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/utils/src/useDeepMemo.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/* eslint-disable rulesdir/pure-render */\n\nimport {useRef} from 'react';\n\nexport function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T {\n // Using a ref during render is ok here because it's only an optimization – both values are equivalent.\n // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.\n let lastValue = useRef<T | null>(null);\n if (value && lastValue.current && isEqual(value, lastValue.current)) {\n value = lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n}\n"],"names":[],"version":3,"file":"useDeepMemo.main.js.map"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {useRef as $jtQ6z$useRef} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
14
|
+
function $5a387cc49350e6db$export$722debc0e56fea39(value, isEqual) {
|
|
15
|
+
// Using a ref during render is ok here because it's only an optimization – both values are equivalent.
|
|
16
|
+
// If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
|
|
17
|
+
let lastValue = (0, $jtQ6z$useRef)(null);
|
|
18
|
+
if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
|
|
19
|
+
lastValue.current = value;
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export {$5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo};
|
|
25
|
+
//# sourceMappingURL=useDeepMemo.module.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {useRef as $jtQ6z$useRef} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
14
|
+
function $5a387cc49350e6db$export$722debc0e56fea39(value, isEqual) {
|
|
15
|
+
// Using a ref during render is ok here because it's only an optimization – both values are equivalent.
|
|
16
|
+
// If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
|
|
17
|
+
let lastValue = (0, $jtQ6z$useRef)(null);
|
|
18
|
+
if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
|
|
19
|
+
lastValue.current = value;
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export {$5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo};
|
|
25
|
+
//# sourceMappingURL=useDeepMemo.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,uCAAuC;AAIhC,SAAS,0CAAe,KAAQ,EAAE,OAAgC;IACvE,uGAAuG;IACvG,yGAAyG;IACzG,IAAI,YAAY,CAAA,GAAA,aAAK,EAAY;IACjC,IAAI,SAAS,UAAU,OAAO,IAAI,QAAQ,OAAO,UAAU,OAAO,GAChE,QAAQ,UAAU,OAAO;IAG3B,UAAU,OAAO,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/utils/src/useDeepMemo.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/* eslint-disable rulesdir/pure-render */\n\nimport {useRef} from 'react';\n\nexport function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T {\n // Using a ref during render is ok here because it's only an optimization – both values are equivalent.\n // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.\n let lastValue = useRef<T | null>(null);\n if (value && lastValue.current && isEqual(value, lastValue.current)) {\n value = lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n}\n"],"names":[],"version":3,"file":"useDeepMemo.module.js.map"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
|
|
2
|
+
var $7PjpK$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useDescription", () => $34da4502ea8120db$export$f8aeda7b10753fa1);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
let $34da4502ea8120db$var$descriptionId = 0;
|
|
23
|
+
const $34da4502ea8120db$var$descriptionNodes = new Map();
|
|
24
|
+
function $34da4502ea8120db$export$f8aeda7b10753fa1(description) {
|
|
25
|
+
let [id, setId] = (0, $7PjpK$react.useState)();
|
|
26
|
+
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
|
|
27
|
+
if (!description) return;
|
|
28
|
+
let desc = $34da4502ea8120db$var$descriptionNodes.get(description);
|
|
29
|
+
if (!desc) {
|
|
30
|
+
let id = `react-aria-description-${$34da4502ea8120db$var$descriptionId++}`;
|
|
31
|
+
setId(id);
|
|
32
|
+
let node = document.createElement('div');
|
|
33
|
+
node.id = id;
|
|
34
|
+
node.style.display = 'none';
|
|
35
|
+
node.textContent = description;
|
|
36
|
+
document.body.appendChild(node);
|
|
37
|
+
desc = {
|
|
38
|
+
refCount: 0,
|
|
39
|
+
element: node
|
|
40
|
+
};
|
|
41
|
+
$34da4502ea8120db$var$descriptionNodes.set(description, desc);
|
|
42
|
+
} else setId(desc.element.id);
|
|
43
|
+
desc.refCount++;
|
|
44
|
+
return ()=>{
|
|
45
|
+
if (desc && --desc.refCount === 0) {
|
|
46
|
+
desc.element.remove();
|
|
47
|
+
$34da4502ea8120db$var$descriptionNodes.delete(description);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
description
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
'aria-describedby': description ? id : undefined
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=useDescription.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMD,IAAI,sCAAgB;AACpB,MAAM,yCAAmB,IAAI;AAEtB,SAAS,0CAAe,WAAoB;IACjD,IAAI,CAAC,IAAI,MAAM,GAAG,CAAA,GAAA,qBAAO;IAEzB,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,CAAC,aACH;QAGF,IAAI,OAAO,uCAAiB,GAAG,CAAC;QAChC,IAAI,CAAC,MAAM;YACT,IAAI,KAAK,CAAC,uBAAuB,EAAE,sCAAgB,CAAC;YACpD,MAAM;YAEN,IAAI,OAAO,SAAS,aAAa,CAAC;YAClC,KAAK,EAAE,GAAG;YACV,KAAK,KAAK,CAAC,OAAO,GAAG;YACrB,KAAK,WAAW,GAAG;YACnB,SAAS,IAAI,CAAC,WAAW,CAAC;YAC1B,OAAO;gBAAC,UAAU;gBAAG,SAAS;YAAI;YAClC,uCAAiB,GAAG,CAAC,aAAa;QACpC,OACE,MAAM,KAAK,OAAO,CAAC,EAAE;QAGvB,KAAK,QAAQ;QACb,OAAO;YACL,IAAI,QAAQ,EAAE,KAAK,QAAQ,KAAK,GAAG;gBACjC,KAAK,OAAO,CAAC,MAAM;gBACnB,uCAAiB,MAAM,CAAC;YAC1B;QACF;IACF,GAAG;QAAC;KAAY;IAEhB,OAAO;QACL,oBAAoB,cAAc,KAAK;IACzC;AACF","sources":["packages/@react-aria/utils/src/useDescription.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaLabelingProps} from '@react-types/shared';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useState} from 'react';\n\nlet descriptionId = 0;\nconst descriptionNodes = new Map<string, {refCount: number, element: Element}>();\n\nexport function useDescription(description?: string): AriaLabelingProps {\n let [id, setId] = useState<string | undefined>();\n\n useLayoutEffect(() => {\n if (!description) {\n return;\n }\n\n let desc = descriptionNodes.get(description);\n if (!desc) {\n let id = `react-aria-description-${descriptionId++}`;\n setId(id);\n\n let node = document.createElement('div');\n node.id = id;\n node.style.display = 'none';\n node.textContent = description;\n document.body.appendChild(node);\n desc = {refCount: 0, element: node};\n descriptionNodes.set(description, desc);\n } else {\n setId(desc.element.id);\n }\n\n desc.refCount++;\n return () => {\n if (desc && --desc.refCount === 0) {\n desc.element.remove();\n descriptionNodes.delete(description);\n }\n };\n }, [description]);\n\n return {\n 'aria-describedby': description ? id : undefined\n };\n}\n"],"names":[],"version":3,"file":"useDescription.main.js.map"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
|
|
2
|
+
import {useState as $hQ5Hp$useState} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
let $ef06256079686ba0$var$descriptionId = 0;
|
|
17
|
+
const $ef06256079686ba0$var$descriptionNodes = new Map();
|
|
18
|
+
function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
|
|
19
|
+
let [id, setId] = (0, $hQ5Hp$useState)();
|
|
20
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
21
|
+
if (!description) return;
|
|
22
|
+
let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
|
|
23
|
+
if (!desc) {
|
|
24
|
+
let id = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
|
|
25
|
+
setId(id);
|
|
26
|
+
let node = document.createElement('div');
|
|
27
|
+
node.id = id;
|
|
28
|
+
node.style.display = 'none';
|
|
29
|
+
node.textContent = description;
|
|
30
|
+
document.body.appendChild(node);
|
|
31
|
+
desc = {
|
|
32
|
+
refCount: 0,
|
|
33
|
+
element: node
|
|
34
|
+
};
|
|
35
|
+
$ef06256079686ba0$var$descriptionNodes.set(description, desc);
|
|
36
|
+
} else setId(desc.element.id);
|
|
37
|
+
desc.refCount++;
|
|
38
|
+
return ()=>{
|
|
39
|
+
if (desc && --desc.refCount === 0) {
|
|
40
|
+
desc.element.remove();
|
|
41
|
+
$ef06256079686ba0$var$descriptionNodes.delete(description);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
description
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
'aria-describedby': description ? id : undefined
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export {$ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription};
|
|
54
|
+
//# sourceMappingURL=useDescription.module.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
|
|
2
|
+
import {useState as $hQ5Hp$useState} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
let $ef06256079686ba0$var$descriptionId = 0;
|
|
17
|
+
const $ef06256079686ba0$var$descriptionNodes = new Map();
|
|
18
|
+
function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
|
|
19
|
+
let [id, setId] = (0, $hQ5Hp$useState)();
|
|
20
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
21
|
+
if (!description) return;
|
|
22
|
+
let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
|
|
23
|
+
if (!desc) {
|
|
24
|
+
let id = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
|
|
25
|
+
setId(id);
|
|
26
|
+
let node = document.createElement('div');
|
|
27
|
+
node.id = id;
|
|
28
|
+
node.style.display = 'none';
|
|
29
|
+
node.textContent = description;
|
|
30
|
+
document.body.appendChild(node);
|
|
31
|
+
desc = {
|
|
32
|
+
refCount: 0,
|
|
33
|
+
element: node
|
|
34
|
+
};
|
|
35
|
+
$ef06256079686ba0$var$descriptionNodes.set(description, desc);
|
|
36
|
+
} else setId(desc.element.id);
|
|
37
|
+
desc.refCount++;
|
|
38
|
+
return ()=>{
|
|
39
|
+
if (desc && --desc.refCount === 0) {
|
|
40
|
+
desc.element.remove();
|
|
41
|
+
$ef06256079686ba0$var$descriptionNodes.delete(description);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
description
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
'aria-describedby': description ? id : undefined
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export {$ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription};
|
|
54
|
+
//# sourceMappingURL=useDescription.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMD,IAAI,sCAAgB;AACpB,MAAM,yCAAmB,IAAI;AAEtB,SAAS,0CAAe,WAAoB;IACjD,IAAI,CAAC,IAAI,MAAM,GAAG,CAAA,GAAA,eAAO;IAEzB,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,CAAC,aACH;QAGF,IAAI,OAAO,uCAAiB,GAAG,CAAC;QAChC,IAAI,CAAC,MAAM;YACT,IAAI,KAAK,CAAC,uBAAuB,EAAE,sCAAgB,CAAC;YACpD,MAAM;YAEN,IAAI,OAAO,SAAS,aAAa,CAAC;YAClC,KAAK,EAAE,GAAG;YACV,KAAK,KAAK,CAAC,OAAO,GAAG;YACrB,KAAK,WAAW,GAAG;YACnB,SAAS,IAAI,CAAC,WAAW,CAAC;YAC1B,OAAO;gBAAC,UAAU;gBAAG,SAAS;YAAI;YAClC,uCAAiB,GAAG,CAAC,aAAa;QACpC,OACE,MAAM,KAAK,OAAO,CAAC,EAAE;QAGvB,KAAK,QAAQ;QACb,OAAO;YACL,IAAI,QAAQ,EAAE,KAAK,QAAQ,KAAK,GAAG;gBACjC,KAAK,OAAO,CAAC,MAAM;gBACnB,uCAAiB,MAAM,CAAC;YAC1B;QACF;IACF,GAAG;QAAC;KAAY;IAEhB,OAAO;QACL,oBAAoB,cAAc,KAAK;IACzC;AACF","sources":["packages/@react-aria/utils/src/useDescription.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaLabelingProps} from '@react-types/shared';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useState} from 'react';\n\nlet descriptionId = 0;\nconst descriptionNodes = new Map<string, {refCount: number, element: Element}>();\n\nexport function useDescription(description?: string): AriaLabelingProps {\n let [id, setId] = useState<string | undefined>();\n\n useLayoutEffect(() => {\n if (!description) {\n return;\n }\n\n let desc = descriptionNodes.get(description);\n if (!desc) {\n let id = `react-aria-description-${descriptionId++}`;\n setId(id);\n\n let node = document.createElement('div');\n node.id = id;\n node.style.display = 'none';\n node.textContent = description;\n document.body.appendChild(node);\n desc = {refCount: 0, element: node};\n descriptionNodes.set(description, desc);\n } else {\n setId(desc.element.id);\n }\n\n desc.refCount++;\n return () => {\n if (desc && --desc.refCount === 0) {\n desc.element.remove();\n descriptionNodes.delete(description);\n }\n };\n }, [description]);\n\n return {\n 'aria-describedby': description ? id : undefined\n };\n}\n"],"names":[],"version":3,"file":"useDescription.module.js.map"}
|