@fluentui/react-popover 9.0.0-alpha.40 → 9.0.0-alpha.44
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +67 -1
- package/CHANGELOG.md +39 -2
- package/dist/react-popover.d.ts +35 -46
- package/lib/common/isConformant.js +2 -0
- package/lib/common/isConformant.js.map +1 -1
- package/lib/components/Popover/Popover.types.d.ts +13 -20
- package/lib/components/Popover/Popover.types.js.map +1 -1
- package/lib/components/Popover/usePopover.js +42 -55
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.d.ts +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
- package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib/components/PopoverSurface/renderPopoverSurface.js +4 -3
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
- package/lib/components/PopoverSurface/usePopoverSurface.js +24 -15
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +13 -16
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-amd/common/isConformant.js +2 -0
- package/lib-amd/common/isConformant.js.map +1 -1
- package/lib-amd/components/Popover/Popover.types.d.ts +13 -20
- package/lib-amd/components/Popover/Popover.types.js.map +1 -1
- package/lib-amd/components/Popover/usePopover.js +30 -40
- package/lib-amd/components/Popover/usePopover.js.map +1 -1
- package/lib-amd/components/PopoverSurface/PopoverSurface.d.ts +1 -1
- package/lib-amd/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib-amd/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
- package/lib-amd/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib-amd/components/PopoverSurface/renderPopoverSurface.js +3 -3
- package/lib-amd/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-amd/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
- package/lib-amd/components/PopoverSurface/usePopoverSurface.js +12 -10
- package/lib-amd/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
- package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js +8 -11
- package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/common/isConformant.js +2 -0
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.types.d.ts +13 -20
- package/lib-commonjs/components/Popover/usePopover.js +41 -54
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +5 -3
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +25 -16
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +13 -16
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/package.json +10 -10
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Popover/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ACE,KADF,EACuH;AAErH,MAAM,aAAa,GAAA,OAAA,CAAA,QAAA,CAAA;AACjB,IAAA,QAAQ,EAAE,OADO;AAEjB,IAAA,KAAK,EAAE,QAFU;AAGjB,IAAA,MAAM,EAAE,KAAK,CAAC,aAAN,GAAsB,KAAK,CAAC,aAA5B,GAA4C;AAHnC,GAAA,EAId,mBAAA,CAAA,2BAAA,CAA4B,KAAK,CAAC,WAAlC,CAJc,CAAnB,CAFqH,CASrH;;;AACA,MAAI,aAAa,CAAC,WAAlB,EAA+B;AAC7B,IAAA,KAAK,CAAC,OAAN,GAAgB,IAAhB;AACD;;AAED,MAAI,CAAC,KAAK,CAAC,OAAX,EAAoB;AAClB,IAAA,aAAa,CAAC,MAAd,GAAuB,mBAAA,CAAA,gBAAA,CAAiB,aAAa,CAAC,MAA/B,EAAuC,OAAA,CAAA,YAAA,CAAa,KAAK,CAAC,IAAnB,CAAvC,CAAvB;AACD;;AAEK,MAAA,EAAA,GAAgE,mBAAA,CAAA,SAAA,CAAU,aAAV,CAAhE;AAAA,MAAa,UAAU,GAAA,EAAA,CAAA,SAAvB;AAAA,MAAuC,UAAU,GAAA,EAAA,CAAA,YAAjD;AAAA,MAAmD,QAAQ,GAAA,EAAA,CAAA,QAA3D;;AAEN,SAAO;AACL,IAAA,UAAU,EAAA,UADL;AAEL,IAAA,UAAU,EAAA,UAFL;AAGL,IAAA,QAAQ,EAAA;AAHH,GAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePopper,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePopperMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover.\n *\n * @param props - props from this instance of Popover\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopover = (props: PopoverProps, defaultProps?: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePopperMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const [open, setOpen] = useOpenState(initialState);\n const popperRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open,\n });\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open || !initialState.openOnContext, // only close on scroll for context\n });\n\n return {\n ...initialState,\n ...popperRefs,\n open,\n setOpen,\n setContextTarget,\n contextTarget,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(prevOpen => {\n // More than one event (mouse, focus, keyboard) can request the Popover to close\n // We assume the first event is the correct one\n if (prevOpen !== shouldOpen) {\n onOpenChange?.(e, { open: shouldOpen });\n }\n\n return shouldOpen;\n });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> & Pick<PopoverProps, 'positioning' | 'openOnContext' | 'noArrow'>,\n) {\n const popperOptions = {\n position: 'above' as const,\n align: 'center' as const,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (popperOptions.coverTarget) {\n state.noArrow = true;\n }\n\n if (!state.noArrow) {\n popperOptions.offset = mergeArrowOffset(popperOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePopper(popperOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
@@ -3,4 +3,4 @@ import type { PopoverSurfaceProps } from './PopoverSurface.types';
|
|
3
3
|
/**
|
4
4
|
* PopoverSurface component renders react children in a positioned box
|
5
5
|
*/
|
6
|
-
export declare const PopoverSurface: React.ForwardRefExoticComponent<PopoverSurfaceProps & React.RefAttributes<
|
6
|
+
export declare const PopoverSurface: React.ForwardRefExoticComponent<PopoverSurfaceProps & React.RefAttributes<HTMLDivElement>>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACU,OAAA,CAAA,cAAA,gBAAiB,KAAK,CAAC,UAAN,
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACU,OAAA,CAAA,cAAA,gBAAiB,KAAK,CAAC,UAAN,CAAsD,UAAC,KAAD,EAAQ,GAAR,EAAW;AAC7F,MAAM,KAAK,GAAG,mBAAA,CAAA,iBAAA,CAAkB,KAAlB,EAAyB,GAAzB,CAAd;AAEA,EAAA,yBAAA,CAAA,uBAAA,CAAwB,KAAxB;AACA,SAAO,sBAAA,CAAA,oBAAA,CAAqB,KAArB,CAAP;AACD,CAL6B,CAAjB;AAOb,OAAA,CAAA,cAAA,CAAe,WAAf,GAA6B,gBAA7B","sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface } from './usePopoverSurface';\nimport { renderPopoverSurface } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles } from './usePopoverSurfaceStyles';\nimport type { PopoverSurfaceProps } from './PopoverSurface.types';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface = React.forwardRef<HTMLDivElement, PopoverSurfaceProps>((props, ref) => {\n const state = usePopoverSurface(props, ref);\n\n usePopoverSurfaceStyles(state);\n return renderPopoverSurface(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"],"sourceRoot":"../src/"}
|
@@ -1,28 +1,20 @@
|
|
1
|
-
import
|
2
|
-
import type { ComponentPropsCompat, ComponentStateCompat } from '@fluentui/react-utilities';
|
1
|
+
import type { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
3
2
|
import type { PopoverContextValue } from '../../popoverContext';
|
4
3
|
/**
|
5
4
|
* PopoverSurface Props
|
6
5
|
*/
|
7
|
-
export interface PopoverSurfaceProps extends
|
6
|
+
export interface PopoverSurfaceProps extends ComponentProps<PopoverSurfaceSlots> {
|
8
7
|
}
|
9
8
|
/**
|
10
|
-
* Names of the
|
9
|
+
* Names of the slots in PopoverSurfaceProps
|
11
10
|
*/
|
12
|
-
export declare type
|
13
|
-
|
14
|
-
|
15
|
-
*/
|
16
|
-
export declare type PopoverSurfaceDefaultedProps = never;
|
11
|
+
export declare type PopoverSurfaceSlots = {
|
12
|
+
root: IntrinsicShorthandProps<'div'>;
|
13
|
+
};
|
17
14
|
/**
|
18
15
|
* PopoverSurface State
|
19
16
|
*/
|
20
|
-
export interface PopoverSurfaceState extends
|
21
|
-
ref: React.Ref<HTMLElement>;
|
22
|
-
/**
|
23
|
-
* Ref to the arrow element
|
24
|
-
*/
|
25
|
-
arrowRef?: React.Ref<HTMLDivElement>;
|
17
|
+
export interface PopoverSurfaceState extends ComponentState<PopoverSurfaceSlots>, Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted' | 'arrowRef'> {
|
26
18
|
/**
|
27
19
|
* CSS class for the arrow element
|
28
20
|
*/
|
@@ -9,16 +9,18 @@ var tslib_1 = /*#__PURE__*/require("tslib");
|
|
9
9
|
|
10
10
|
var React = /*#__PURE__*/require("react");
|
11
11
|
|
12
|
+
var react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
13
|
+
|
12
14
|
var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
13
15
|
|
14
|
-
var
|
16
|
+
var usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
|
15
17
|
/**
|
16
18
|
* Render the final JSX of PopoverSurface
|
17
19
|
*/
|
18
20
|
|
19
21
|
|
20
22
|
var renderPopoverSurface = function (state) {
|
21
|
-
var _a = react_utilities_1.
|
23
|
+
var _a = react_utilities_1.getSlots(state, usePopoverSurface_1.popoverSurfaceSlots),
|
22
24
|
slots = _a.slots,
|
23
25
|
slotProps = _a.slotProps; // TODO should hidden Popovers be supported ?
|
24
26
|
|
@@ -32,7 +34,7 @@ var renderPopoverSurface = function (state) {
|
|
32
34
|
}, React.createElement(slots.root, tslib_1.__assign({}, slotProps.root), !state.noArrow && React.createElement("div", {
|
33
35
|
ref: state.arrowRef,
|
34
36
|
className: state.arrowClassName
|
35
|
-
}),
|
37
|
+
}), slotProps.root.children));
|
36
38
|
};
|
37
39
|
|
38
40
|
exports.renderPopoverSurface = renderPopoverSurface;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;AAEA;;AAEG;;;AACI,IAAM,oBAAoB,GAAG,UAAC,KAAD,EAA2B;AACvD,MAAA,EAAA,GAAuB,iBAAA,CAAA,QAAA,CAA8B,KAA9B,EAAqC,mBAAA,CAAA,mBAArC,CAAvB;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAlB,CADuD,CAG7D;;;AACA,MAAI,CAAC,KAAK,CAAC,IAAX,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,SACE,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,OAAA,CAAA,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,EACG,CAAC,KAAK,CAAC,OAAP,IAAkB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADrB,EAEG,SAAS,CAAC,IAAV,CAAe,QAFlB,CADF,CADF;AAQD,CAhBM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\nimport { popoverSurfaceSlots } from './usePopoverSurface';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots<PopoverSurfaceSlots>(state, popoverSurfaceSlots);\n\n // TODO should hidden Popovers be supported ?\n if (!state.open) {\n return null;\n }\n\n return (\n <Portal mountNode={state.mountNode}>\n <slots.root {...slotProps.root}>\n {!state.noArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {slotProps.root.children}\n </slots.root>\n </Portal>\n );\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';
|
2
|
+
import type { PopoverSurfaceProps, PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';
|
3
|
+
export declare const popoverSurfaceSlots: Array<keyof PopoverSurfaceSlots>;
|
3
4
|
/**
|
4
5
|
* Create the state required to render PopoverSurface.
|
5
6
|
*
|
@@ -7,7 +8,7 @@ import type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.
|
|
7
8
|
* before being passed to renderPopoverSurface.
|
8
9
|
*
|
9
10
|
* @param props - props from this instance of PopoverSurface
|
10
|
-
* @param ref - reference to root
|
11
|
+
* @param ref - reference to root HTMLDivElement of PopoverSurface
|
11
12
|
* @param defaultProps - (optional) default prop values provided by the implementing type
|
12
13
|
*/
|
13
|
-
export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React.Ref<
|
14
|
+
export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React.Ref<HTMLDivElement>) => PopoverSurfaceState;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.usePopoverSurface = void 0;
|
6
|
+
exports.usePopoverSurface = exports.popoverSurfaceSlots = void 0;
|
7
7
|
|
8
8
|
var tslib_1 = /*#__PURE__*/require("tslib");
|
9
9
|
|
@@ -15,7 +15,7 @@ var react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
15
15
|
|
16
16
|
var popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
17
17
|
|
18
|
-
|
18
|
+
exports.popoverSurfaceSlots = ['root'];
|
19
19
|
/**
|
20
20
|
* Create the state required to render PopoverSurface.
|
21
21
|
*
|
@@ -23,11 +23,11 @@ var mergeProps = /*#__PURE__*/react_utilities_1.makeMergeProps({});
|
|
23
23
|
* before being passed to renderPopoverSurface.
|
24
24
|
*
|
25
25
|
* @param props - props from this instance of PopoverSurface
|
26
|
-
* @param ref - reference to root
|
26
|
+
* @param ref - reference to root HTMLDivElement of PopoverSurface
|
27
27
|
* @param defaultProps - (optional) default prop values provided by the implementing type
|
28
28
|
*/
|
29
29
|
|
30
|
-
var usePopoverSurface = function (props, ref
|
30
|
+
var usePopoverSurface = function (props, ref) {
|
31
31
|
var contentRef = popoverContext_1.usePopoverContext(function (context) {
|
32
32
|
return context.contentRef;
|
33
33
|
});
|
@@ -64,22 +64,31 @@ var usePopoverSurface = function (props, ref, defaultProps) {
|
|
64
64
|
var modalAttributes = react_tabster_1.useModalAttributes({
|
65
65
|
trapFocus: trapFocus
|
66
66
|
}).modalAttributes;
|
67
|
-
|
67
|
+
|
68
|
+
var state = tslib_1.__assign(tslib_1.__assign({
|
68
69
|
brand: brand,
|
69
70
|
inverted: inverted,
|
70
71
|
noArrow: noArrow,
|
71
72
|
size: size,
|
72
73
|
arrowRef: arrowRef,
|
73
74
|
open: open,
|
74
|
-
mountNode: mountNode
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
mountNode: mountNode
|
76
|
+
}, props), {
|
77
|
+
components: {
|
78
|
+
root: 'div'
|
79
|
+
},
|
80
|
+
root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({
|
81
|
+
ref: react_utilities_1.useMergedRefs(ref, contentRef),
|
82
|
+
role: 'dialog'
|
83
|
+
}, modalAttributes), props))
|
84
|
+
});
|
85
|
+
|
86
|
+
var _a = state.root,
|
87
|
+
onMouseEnterOriginal = _a.onMouseEnter,
|
88
|
+
onMouseLeaveOriginal = _a.onMouseLeave,
|
89
|
+
onKeyDownOriginal = _a.onKeyDown;
|
90
|
+
|
91
|
+
state.root.onMouseEnter = function (e) {
|
83
92
|
if (openOnHover) {
|
84
93
|
setOpen(e, true);
|
85
94
|
}
|
@@ -87,7 +96,7 @@ var usePopoverSurface = function (props, ref, defaultProps) {
|
|
87
96
|
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
|
88
97
|
};
|
89
98
|
|
90
|
-
state.onMouseLeave = function (e) {
|
99
|
+
state.root.onMouseLeave = function (e) {
|
91
100
|
if (openOnHover) {
|
92
101
|
setOpen(e, false);
|
93
102
|
}
|
@@ -95,7 +104,7 @@ var usePopoverSurface = function (props, ref, defaultProps) {
|
|
95
104
|
onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
|
96
105
|
};
|
97
106
|
|
98
|
-
state.onKeyDown = function (e) {
|
107
|
+
state.root.onKeyDown = function (e) {
|
99
108
|
var _a; // only close if the event happened inside the current popover
|
100
109
|
// If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
|
101
110
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,IAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,IAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AAGa,OAAA,CAAA,mBAAA,GAAwD,CAAC,MAAD,CAAxD;AAEb;;;;;;;;;AASG;;AACI,IAAM,iBAAiB,GAAG,UAAC,KAAD,EAA6B,GAA7B,EAA2D;AAC1F,MAAM,UAAU,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,UAAA;AAAkB,GAA/C,CAAnB;AACA,MAAM,IAAI,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAzC,CAAb;AACA,MAAM,WAAW,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,WAAA;AAAmB,GAAhD,CAApB;AACA,MAAM,OAAO,GAAG,gBAAA,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AuB,UAAC,CAAD,EAAuC;WAAA,CAC5D;AACA;;;AACA,QAAI,CAAC,CAAC,GAAF,KAAU,QAAV,KAAkB,CAAA,EAAA,GAAI,UAAU,CAAC,OAAf,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAE,QAAF,CAAW,CAAC,CAAC,MAAb,CAAxC,CAAJ,EAAoF;AAClF,MAAA,OAAO,CAAC,CAAD,EAAI,KAAJ,CAAP;AACD;;AAED,IAAA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,CAAH,CAAjB;AACD,GARD;;AAUQ,MAAA,kBAAkB,GAAK,eAAA,CAAA,eAAA,GAAL,kBAAlB;AAER,EAAA,KAAK,CAAC,SAAN,CAAgB,YAAA;AACd,QAAI,KAAK,CAAC,IAAN,IAAc,UAAU,CAAC,OAA7B,EAAsC;AACpC,UAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAZ,CAAzC;AACA,MAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,KAAhB,EAAA;AACD;AACF,GALD,EAKG,CAAC,UAAD,EAAa,kBAAb,EAAiC,KAAK,CAAC,IAAvC,CALH;AAMA,SAAO,KAAP;AACD,CA1EM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\n\nexport const popoverSurfaceSlots: Array<keyof PopoverSurfaceSlots> = ['root'];\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles,\n * before being passed to renderPopoverSurface.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopoverSurface = (props: PopoverSurfaceProps, ref: React.Ref<HTMLDivElement>): PopoverSurfaceState => {\n const contentRef = usePopoverContext(context => context.contentRef);\n const open = usePopoverContext(context => context.open);\n const openOnHover = usePopoverContext(context => context.openOnHover);\n const setOpen = usePopoverContext(context => context.setOpen);\n const mountNode = usePopoverContext(context => context.mountNode);\n const arrowRef = usePopoverContext(context => context.arrowRef);\n const size = usePopoverContext(context => context.size);\n const noArrow = usePopoverContext(context => context.noArrow);\n const brand = usePopoverContext(context => context.brand);\n const inverted = usePopoverContext(context => context.inverted);\n const trapFocus = usePopoverContext(context => context.trapFocus);\n const { modalAttributes } = useModalAttributes({ trapFocus });\n\n const state: PopoverSurfaceState = {\n brand,\n inverted,\n noArrow,\n size,\n arrowRef,\n open,\n mountNode,\n ...props,\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, contentRef),\n role: 'dialog',\n ...modalAttributes,\n ...props,\n }),\n };\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state.root;\n state.root.onMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.root.onMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.root.onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // only close if the event happened inside the current popover\n // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack\n if (e.key === 'Escape' && contentRef.current?.contains(e.target as HTMLDivElement)) {\n setOpen(e, false);\n }\n\n onKeyDownOriginal?.(e);\n };\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (state.open && contentRef.current) {\n const firstFocusable = findFirstFocusable(contentRef.current);\n firstFocusable?.focus();\n }\n }, [contentRef, findFirstFocusable, state.open]);\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -89,7 +89,7 @@ var useStyles = /*#__PURE__*/react_make_styles_1.__styles({
|
|
89
89
|
|
90
90
|
var usePopoverSurfaceStyles = function (state) {
|
91
91
|
var styles = useStyles();
|
92
|
-
state.className = react_make_styles_1.mergeClasses(styles.root, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.inverted && styles.inverted, state.brand && styles.brand, state.className);
|
92
|
+
state.root.className = react_make_styles_1.mergeClasses(styles.root, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.inverted && styles.inverted, state.brand && styles.brand, state.root.className);
|
93
93
|
state.arrowClassName = react_make_styles_1.mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
|
94
94
|
return state;
|
95
95
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAIa,OAAA,CAAA,YAAA,GAA4C;AACvD,EAAA,KAAK,EAAE,CADgD;AAEvD,EAAA,MAAM,EAAE,CAF+C;AAGvD,EAAA,KAAK,EAAE;AAHgD,CAA5C;AAMb;;AAEG;;AACH,IAAM,SAAS,gBAAG,mBAAA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAA,YAAA,CACrB,MAAM,CAAC,IADc,EAErB,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAFZ,EAGrB,KAAK,CAAC,IAAN,KAAe,QAAf,IAA2B,MAAM,CAAC,aAHb,EAIrB,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAJZ,EAKrB,KAAK,CAAC,QAAN,IAAkB,MAAM,CAAC,QALJ,EAMrB,KAAK,CAAC,KAAN,IAAe,MAAM,CAAC,KAND,EAOrB,KAAK,CAAC,IAAN,CAAW,SAPU,CAAvB;AAUA,EAAA,KAAK,CAAC,cAAN,GAAuB,mBAAA,CAAA,YAAA,CACrB,MAAM,CAAC,KADc,EAErB,KAAK,CAAC,IAAN,KAAe,OAAf,GAAyB,MAAM,CAAC,UAAhC,GAA6C,MAAM,CAAC,gBAF/B,CAAvB;AAKA,SAAO,KAAP;AACD,CAlBM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","sourcesContent":["import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';\nimport type { PopoverSize } from '../Popover/Popover.types';\nimport type { PopoverSurfaceState } from './PopoverSurface.types';\n\nexport const arrowHeights: Record<PopoverSize, number> = {\n small: 6,\n medium: 8,\n large: 8,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: theme => ({\n backgroundColor: theme.alias.color.neutral.neutralBackground1,\n boxShadow: theme.alias.shadow.shadow16,\n borderRadius: '4px',\n }),\n\n inverted: theme => ({\n // TODO: neutral background inverted missing from superset and theme\n backgroundColor: theme.global.palette.grey[16],\n color: theme.alias.color.neutral.neutralForegroundInverted,\n }),\n\n brand: theme => ({\n backgroundColor: theme.alias.color.neutral.brandBackground,\n // TODO: clarify with designers what foreground color should be with brand background,\n color: theme.alias.color.neutral.neutralForegroundInverted,\n }),\n\n smallPadding: () => ({\n padding: '12px',\n }),\n\n mediumPadding: () => ({\n padding: '16px',\n }),\n\n largePadding: () => ({\n padding: '20px',\n }),\n\n smallArrow: () => ({\n width: `${Math.SQRT2 * arrowHeights.small}px`,\n height: `${Math.SQRT2 * arrowHeights.small}px`,\n }),\n\n mediumLargeArrow: () => ({\n width: `${Math.SQRT2 * arrowHeights.medium}px`,\n height: `${Math.SQRT2 * arrowHeights.medium}px`,\n }),\n\n // TODO dedupe these styles with tooltip\n arrow: theme => ({\n position: 'absolute',\n background: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ':before': {\n content: '\"\"',\n borderRadius: '4px',\n position: 'absolute',\n width: 'inherit',\n height: 'inherit',\n background: 'inherit',\n visibility: 'visible',\n borderBottomRightRadius: theme.global.borderRadius.small,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': { bottom: 0, '--angle': '0' },\n ':global([data-popper-placement^=\"right\"])': { left: 0, '--angle': '90deg' },\n ':global([data-popper-placement^=\"bottom\"])': { top: 0, '--angle': '180deg' },\n ':global([data-popper-placement^=\"left\"])': { right: 0, '--angle': '270deg' },\n }),\n});\n\n/**\n * Apply styling to the PopoverSurface slots based on the state\n */\nexport const usePopoverSurfaceStyles = (state: PopoverSurfaceState): PopoverSurfaceState => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n styles.root,\n state.size === 'small' && styles.smallPadding,\n state.size === 'medium' && styles.mediumPadding,\n state.size === 'large' && styles.largePadding,\n state.inverted && styles.inverted,\n state.brand && styles.brand,\n state.root.className,\n );\n\n state.arrowClassName = mergeClasses(\n styles.arrow,\n state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -14,8 +14,6 @@ var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
14
14
|
var react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
15
15
|
|
16
16
|
var popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
17
|
-
|
18
|
-
var mergeProps = /*#__PURE__*/react_utilities_1.makeMergeProps({});
|
19
17
|
/**
|
20
18
|
* Create the state required to render PopoverTrigger.
|
21
19
|
*
|
@@ -26,6 +24,7 @@ var mergeProps = /*#__PURE__*/react_utilities_1.makeMergeProps({});
|
|
26
24
|
* @param defaultProps - (optional) default prop values provided by the implementing type
|
27
25
|
*/
|
28
26
|
|
27
|
+
|
29
28
|
var usePopoverTrigger = function (props, defaultProps) {
|
30
29
|
var setOpen = popoverContext_1.usePopoverContext(function (context) {
|
31
30
|
return context.setOpen;
|
@@ -43,9 +42,6 @@ var usePopoverTrigger = function (props, defaultProps) {
|
|
43
42
|
return context.openOnContext;
|
44
43
|
});
|
45
44
|
var triggerAttributes = react_tabster_1.useModalAttributes().triggerAttributes;
|
46
|
-
var state = mergeProps({
|
47
|
-
children: null
|
48
|
-
}, defaultProps, props);
|
49
45
|
var onContextMenu = react_utilities_1.useEventCallback(function (e) {
|
50
46
|
var _a, _b;
|
51
47
|
|
@@ -97,17 +93,18 @@ var usePopoverTrigger = function (props, defaultProps) {
|
|
97
93
|
|
98
94
|
(_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
99
95
|
});
|
100
|
-
var child = React.Children.only(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
96
|
+
var child = React.Children.only(props.children);
|
97
|
+
return {
|
98
|
+
children: React.cloneElement(child, tslib_1.__assign({
|
99
|
+
'aria-haspopup': 'true',
|
100
|
+
onClick: onClick,
|
101
|
+
onMouseEnter: onMouseEnter,
|
102
|
+
onKeyDown: onKeyDown,
|
103
|
+
onMouseLeave: onMouseLeave,
|
104
|
+
onContextMenu: onContextMenu,
|
105
|
+
ref: react_utilities_1.useMergedRefs(child.ref, triggerRef)
|
106
|
+
}, triggerAttributes))
|
107
|
+
};
|
111
108
|
};
|
112
109
|
|
113
110
|
exports.usePopoverTrigger = usePopoverTrigger;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,IAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,IAAM,iBAAiB,GAAG,UAC/B,KAD+B,EAE/B,YAF+B,EAEG;AAElC,MAAM,OAAO,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,OAAA;AAAe,GAA5C,CAAhB;AACA,MAAM,IAAI,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAzC,CAAb;AACA,MAAM,UAAU,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,UAAA;AAAkB,GAA/C,CAAnB;AACA,MAAM,WAAW,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,WAAA;AAAmB,GAAhD,CAApB;AACA,MAAM,aAAa,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,aAAA;AAAqB,GAAlD,CAAtB;AACQ,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AA,CAAE,YAAb,MAAyB,IAAzB,IAAyB,EAAA,KAAA,KAAA,CAAzB,GAAyB,KAAA,CAAzB,GAAyB,EAAA,CAAA,IAAA,CAAA,EAAA,EAAG,CAAH,CAAzB;AACD,GALoB,CAArB;AAOA,MAAM,KAAK,GAAG,KAAK,CAAC,QAAN,CAAe,IAAf,CAAoB,KAAK,CAAC,QAA1B,CAAd;AACA,SAAO;AACL,IAAA,QAAQ,EAAE,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAAwB,OAAA,CAAA,QAAA,CAAA;AAChC,uBAAiB,MADe;AAEhC,MAAA,OAAO,EAAA,OAFyB;AAGhC,MAAA,YAAY,EAAA,YAHoB;AAIhC,MAAA,SAAS,EAAA,SAJuB;AAKhC,MAAA,YAAY,EAAA,YALoB;AAMhC,MAAA,aAAa,EAAA,aANmB;AAOhC,MAAA,GAAG,EAAE,iBAAA,CAAA,aAAA,CAAgB,KAAuE,CAAC,GAAxF,EAA6F,UAA7F;AAP2B,KAAA,EAQ7B,iBAR6B,CAAxB;AADL,GAAP;AAYD,CAnEM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourcesContent":["import * as React from 'react';\nimport { useMergedRefs, useEventCallback, shouldPreventDefaultOnKeyDown } from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext } from '../../popoverContext';\nimport type { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\n\n/**\n * Create the state required to render PopoverTrigger.\n *\n * The returned state can be modified with hooks such as usePopoverTriggerStyles,\n * before being passed to renderPopoverTrigger.\n *\n * @param props - props from this instance of PopoverTrigger\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopoverTrigger = (\n props: PopoverTriggerProps,\n defaultProps?: PopoverTriggerProps,\n): PopoverTriggerState => {\n const setOpen = usePopoverContext(context => context.setOpen);\n const open = usePopoverContext(context => context.open);\n const triggerRef = usePopoverContext(context => context.triggerRef);\n const openOnHover = usePopoverContext(context => context.openOnHover);\n const openOnContext = usePopoverContext(context => context.openOnContext);\n const { triggerAttributes } = useModalAttributes();\n\n const onContextMenu = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, true);\n }\n\n child.props?.onContextMenu?.(e);\n });\n\n const onClick = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (!openOnContext) {\n setOpen(e, !open);\n }\n child.props?.onClick?.(e);\n });\n\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLElement>) => {\n if (shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {\n e.preventDefault();\n (e.target as HTMLElement)?.click();\n }\n\n if (e.key === 'Escape') {\n setOpen(e, false);\n }\n\n child.props?.onKeyDown?.(e);\n });\n\n const onMouseEnter = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n child.props?.onMouseEnter?.(e);\n });\n\n const onMouseLeave = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n child.props?.onMouseLeave?.(e);\n });\n\n const child = React.Children.only(props.children);\n return {\n children: React.cloneElement(child, {\n 'aria-haspopup': 'true',\n onClick,\n onMouseEnter,\n onKeyDown,\n onMouseLeave,\n onContextMenu,\n ref: useMergedRefs(((child as unknown) as React.ReactElement & React.RefAttributes<unknown>).ref, triggerRef),\n ...triggerAttributes,\n }),\n };\n};\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-popover",
|
3
|
-
"version": "9.0.0-alpha.
|
3
|
+
"version": "9.0.0-alpha.44",
|
4
4
|
"description": "Popover component for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -26,11 +26,11 @@
|
|
26
26
|
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-popover/src && yarn docs"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
29
|
-
"@fluentui/babel-make-styles": "9.0.0-alpha.
|
29
|
+
"@fluentui/babel-make-styles": "9.0.0-alpha.49",
|
30
30
|
"@fluentui/eslint-plugin": "^1.4.1",
|
31
|
-
"@fluentui/jest-serializer-make-styles": "9.0.0-alpha.
|
31
|
+
"@fluentui/jest-serializer-make-styles": "9.0.0-alpha.42",
|
32
32
|
"@fluentui/react-conformance": "^0.5.0",
|
33
|
-
"@fluentui/react-conformance-make-styles": "9.0.0-alpha.
|
33
|
+
"@fluentui/react-conformance-make-styles": "9.0.0-alpha.11",
|
34
34
|
"@fluentui/scripts": "^1.0.0",
|
35
35
|
"@types/enzyme": "3.10.3",
|
36
36
|
"@types/enzyme-adapter-react-16": "1.0.3",
|
@@ -44,13 +44,13 @@
|
|
44
44
|
"react-test-renderer": "^16.3.0"
|
45
45
|
},
|
46
46
|
"dependencies": {
|
47
|
-
"@fluentui/react-context-selector": "9.0.0-alpha.
|
48
|
-
"@fluentui/react-make-styles": "9.0.0-alpha.
|
49
|
-
"@fluentui/react-portal": "9.0.0-alpha.
|
50
|
-
"@fluentui/react-positioning": "9.0.0-alpha.
|
47
|
+
"@fluentui/react-context-selector": "9.0.0-alpha.32",
|
48
|
+
"@fluentui/react-make-styles": "9.0.0-alpha.67",
|
49
|
+
"@fluentui/react-portal": "9.0.0-alpha.49",
|
50
|
+
"@fluentui/react-positioning": "9.0.0-alpha.55",
|
51
51
|
"@fluentui/react-shared-contexts": "9.0.0-alpha.24",
|
52
|
-
"@fluentui/react-tabster": "9.0.0-alpha.
|
53
|
-
"@fluentui/react-utilities": "9.0.0-alpha.
|
52
|
+
"@fluentui/react-tabster": "9.0.0-alpha.61",
|
53
|
+
"@fluentui/react-utilities": "9.0.0-alpha.49",
|
54
54
|
"tslib": "^2.1.0"
|
55
55
|
},
|
56
56
|
"peerDependencies": {
|