@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.
Files changed (59) hide show
  1. package/CHANGELOG.json +67 -1
  2. package/CHANGELOG.md +39 -2
  3. package/dist/react-popover.d.ts +35 -46
  4. package/lib/common/isConformant.js +2 -0
  5. package/lib/common/isConformant.js.map +1 -1
  6. package/lib/components/Popover/Popover.types.d.ts +13 -20
  7. package/lib/components/Popover/Popover.types.js.map +1 -1
  8. package/lib/components/Popover/usePopover.js +42 -55
  9. package/lib/components/Popover/usePopover.js.map +1 -1
  10. package/lib/components/PopoverSurface/PopoverSurface.d.ts +1 -1
  11. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  12. package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
  13. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  14. package/lib/components/PopoverSurface/renderPopoverSurface.js +4 -3
  15. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  16. package/lib/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
  17. package/lib/components/PopoverSurface/usePopoverSurface.js +24 -15
  18. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  19. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
  20. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  21. package/lib/components/PopoverTrigger/usePopoverTrigger.js +13 -16
  22. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  23. package/lib-amd/common/isConformant.js +2 -0
  24. package/lib-amd/common/isConformant.js.map +1 -1
  25. package/lib-amd/components/Popover/Popover.types.d.ts +13 -20
  26. package/lib-amd/components/Popover/Popover.types.js.map +1 -1
  27. package/lib-amd/components/Popover/usePopover.js +30 -40
  28. package/lib-amd/components/Popover/usePopover.js.map +1 -1
  29. package/lib-amd/components/PopoverSurface/PopoverSurface.d.ts +1 -1
  30. package/lib-amd/components/PopoverSurface/PopoverSurface.js.map +1 -1
  31. package/lib-amd/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
  32. package/lib-amd/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  33. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js +3 -3
  34. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  35. package/lib-amd/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
  36. package/lib-amd/components/PopoverSurface/usePopoverSurface.js +12 -10
  37. package/lib-amd/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  38. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
  39. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  40. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js +8 -11
  41. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  42. package/lib-commonjs/common/isConformant.js +2 -0
  43. package/lib-commonjs/common/isConformant.js.map +1 -1
  44. package/lib-commonjs/components/Popover/Popover.types.d.ts +13 -20
  45. package/lib-commonjs/components/Popover/usePopover.js +41 -54
  46. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  47. package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +1 -1
  48. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  49. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +7 -15
  50. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +5 -3
  51. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  52. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +4 -3
  53. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +25 -16
  54. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  55. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +1 -1
  56. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  57. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +13 -16
  58. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  59. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"usePopover.js","sourceRoot":"../src/","sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;;IAoBA;;OAEG;IACH,IAAM,UAAU,GAAG,gCAAc,CAAe,EAAE,CAAC,CAAC;IAEpD;;;;;;;;OAQG;IACI,IAAM,UAAU,GAAG,UAAC,KAAmB,EAAE,YAA2B;QACzE,IAAM,KAAK,GAAG,UAAU,CACtB;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAG,SAAgC;YACvC,OAAO,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;YACnB,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC7B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC3B,QAAQ,EAAE,IAAI;YACd,gBAAgB,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;YAC5B,aAAa,EAAE,SAAS;SACzB,EACD,YAAY,EACZ,KAAK,CACN,CAAC;QAEI,IAAA,KAAoC,KAAK,CAAC,QAAQ,EAAwB,EAAzE,aAAa,QAAA,EAAE,gBAAgB,QAA0C,CAAC;QACjF,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;QAEpC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,cAAc,CAAC,KAAK,CAAC,CAAC;QAEd,IAAA,cAAc,GAAK,iCAAS,EAAE,eAAhB,CAAiB;QACvC,mCAAiB,CAAC;YAChB,QAAQ,EAAE,8BAAe;YACzB,OAAO,EAAE,cAAc;YACvB,QAAQ,EAAE,UAAA,EAAE,IAAI,OAAA,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAA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AU,CAAC;QAC9B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE1B,OAAO,KAAK,CAAC;IACf,CAAC","sourcesContent":["import * as React from 'react';\nimport {\n makeMergeProps,\n useControllableValue,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePopper,\n createVirtualElementFromClick,\n resolvePositioningShorthand,\n mergeArrowOffset,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { PopperVirtualElement } from '@fluentui/react-positioning';\nimport type { PopoverProps, PopoverState } from './Popover.types';\n\n/**\n * Names of the shorthand properties in PopoverProps\n */\nconst mergeProps = makeMergeProps<PopoverState>({});\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 state = mergeProps(\n {\n size: 'medium',\n open: (undefined as unknown) as boolean, // mergeProps typings require this\n setOpen: () => null,\n triggerRef: { current: null },\n contentRef: { current: null },\n arrowRef: { current: null },\n children: null,\n setContextTarget: () => null,\n contextTarget: undefined,\n },\n defaultProps,\n props,\n );\n\n const [contextTarget, setContextTarget] = React.useState<PopperVirtualElement>();\n state.setContextTarget = setContextTarget;\n state.contextTarget = contextTarget;\n\n useOpenState(state);\n usePopoverRefs(state);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => state.setOpen(ev, false),\n refs: [state.triggerRef, state.contentRef],\n disabled: !state.open,\n });\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => state.setOpen(ev, false),\n refs: [state.triggerRef, state.contentRef],\n disabled: !state.open || !state.openOnContext, // only close on scroll for context\n });\n\n return state;\n};\n\n/**\n * Creates and manages the Popover open state\n * @param state Popover state\n */\nfunction useOpenState(state: PopoverState): PopoverState {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpen] = useControllableValue(state.open, state.defaultOpen);\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n state.setOpen = React.useCallback(\n (e, shouldOpen) => {\n if (shouldOpen && e.type === 'contextmenu') {\n const virtualElement = createVirtualElementFromClick((e as React.MouseEvent).nativeEvent);\n setContextTarget(virtualElement);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpen(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 [setOpen, onOpenChange, setContextTarget],\n );\n\n return state;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n * @param state Popover state\n */\nfunction usePopoverRefs(state: PopoverState): PopoverState {\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 state.contentRef = contentRef;\n state.triggerRef = triggerRef;\n state.arrowRef = arrowRef;\n\n return state;\n}\n"]}
1
+ {"version":3,"file":"usePopover.js","sourceRoot":"../src/","sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;;IAkBA;;;;;;;;OAQG;IACI,IAAM,UAAU,GAAG,UAAC,KAAmB,EAAE,YAA2B;QACnE,IAAA,KAAoC,wCAAoB,EAAE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C,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAC1D,+CAA2B,CAAC,KAAK,CAAC,WAAW,CAAC,CAClD,CAAC;QAEF,qDAAqD;QACrD,IAAI,aAAa,CAAC,WAAW,EAAE;YAC7B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;SACtB;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAClB,aAAa,CAAC,MAAM,GAAG,oCAAgB,CAAC,aAAa,CAAC,MAAM,EAAE,oBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;SACzF;QAEK,IAAA,KAAgE,6BAAS,CAAC,aAAa,CAAC,EAA3E,UAAU,eAAA,EAAgB,UAAU,kBAAA,EAAE,QAAQ,cAA6B,CAAC;QAE/F,OAAO;YACL,UAAU,YAAA;YACV,UAAU,YAAA;YACV,QAAQ,UAAA;SACA,CAAC;IACb,CAAC","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"]}
@@ -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<HTMLElement>>;
6
+ export declare const PopoverSurface: React.ForwardRefExoticComponent<PopoverSurfaceProps & React.RefAttributes<HTMLDivElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;IAMA;;OAEG;IACU,QAAA,cAAc,GAAG,KAAK,CAAC,UAAU,CAAmC,UAAC,KAAK,EAAE,GAAG;QAC1F,IAAM,KAAK,GAAG,qCAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE5C,iDAAuB,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,2CAAoB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","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<HTMLElement, PopoverSurfaceProps>((props, ref) => {\n const state = usePopoverSurface(props, ref);\n\n usePopoverSurfaceStyles(state);\n return renderPopoverSurface(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"]}
1
+ {"version":3,"file":"PopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;IAMA;;OAEG;IACU,QAAA,cAAc,GAAG,KAAK,CAAC,UAAU,CAAsC,UAAC,KAAK,EAAE,GAAG;QAC7F,IAAM,KAAK,GAAG,qCAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE5C,iDAAuB,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,2CAAoB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","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"]}
@@ -1,28 +1,20 @@
1
- import * as React from 'react';
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 ComponentPropsCompat, React.HTMLAttributes<HTMLElement> {
6
+ export interface PopoverSurfaceProps extends ComponentProps<PopoverSurfaceSlots> {
8
7
  }
9
8
  /**
10
- * Names of the shorthand properties in PopoverSurfaceProps
9
+ * Names of the slots in PopoverSurfaceProps
11
10
  */
12
- export declare type PopoverSurfaceShorthandProps = never;
13
- /**
14
- * Names of PopoverSurfaceProps that have a default value in usePopoverSurface
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 ComponentStateCompat<PopoverSurfaceProps, PopoverSurfaceShorthandProps, PopoverSurfaceDefaultedProps>, Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted'> {
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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentPropsCompat, ComponentStateCompat } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport interface PopoverSurfaceProps extends ComponentPropsCompat, React.HTMLAttributes<HTMLElement> {}\n\n/**\n * Names of the shorthand properties in PopoverSurfaceProps\n */\nexport type PopoverSurfaceShorthandProps = never;\n\n/**\n * Names of PopoverSurfaceProps that have a default value in usePopoverSurface\n */\nexport type PopoverSurfaceDefaultedProps = never;\n\n/**\n * PopoverSurface State\n */\nexport interface PopoverSurfaceState\n extends ComponentStateCompat<PopoverSurfaceProps, PopoverSurfaceShorthandProps, PopoverSurfaceDefaultedProps>,\n Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted'> {\n ref: React.Ref<HTMLElement>;\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n}\n"]}
1
+ {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport interface PopoverSurfaceProps extends ComponentProps<PopoverSurfaceSlots> {}\n\n/**\n * Names of the slots in PopoverSurfaceProps\n */\nexport type PopoverSurfaceSlots = {\n root: IntrinsicShorthandProps<'div'>;\n};\n\n/**\n * PopoverSurface State\n */\nexport interface PopoverSurfaceState\n extends ComponentState<PopoverSurfaceSlots>,\n Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted' | 'arrowRef'> {\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-portal"], function (require, exports, tslib_1, React, react_utilities_1, react_portal_1) {
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-portal", "@fluentui/react-utilities", "./usePopoverSurface"], function (require, exports, tslib_1, React, react_portal_1, react_utilities_1, usePopoverSurface_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.renderPopoverSurface = void 0;
@@ -6,7 +6,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
6
6
  * Render the final JSX of PopoverSurface
7
7
  */
8
8
  var renderPopoverSurface = function (state) {
9
- var _a = react_utilities_1.getSlotsCompat(state), slots = _a.slots, slotProps = _a.slotProps;
9
+ var _a = react_utilities_1.getSlots(state, usePopoverSurface_1.popoverSurfaceSlots), slots = _a.slots, slotProps = _a.slotProps;
10
10
  // TODO should hidden Popovers be supported ?
11
11
  if (!state.open) {
12
12
  return null;
@@ -14,7 +14,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
14
14
  return (React.createElement(react_portal_1.Portal, { mountNode: state.mountNode },
15
15
  React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
16
16
  !state.noArrow && React.createElement("div", { ref: state.arrowRef, className: state.arrowClassName }),
17
- state.children)));
17
+ slotProps.root.children)));
18
18
  };
19
19
  exports.renderPopoverSurface = renderPopoverSurface;
20
20
  });
@@ -1 +1 @@
1
- {"version":3,"file":"renderPopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,oBAAoB,GAAG,UAAC,KAA0B;QACvD,IAAA,KAAuB,gCAAc,CAAC,KAAK,CAAC,EAA1C,KAAK,WAAA,EAAE,SAAS,eAA0B,CAAC;QAEnD,6CAA6C;QAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACf,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CACL,oBAAC,qBAAM,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS;YAChC,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;gBAC3B,CAAC,KAAK,CAAC,OAAO,IAAI,6BAAK,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,GAAI;gBAC/E,KAAK,CAAC,QAAQ,CACJ,CACN,CACV,CAAC;IACJ,CAAC,CAAC;IAhBW,QAAA,oBAAoB,wBAgB/B","sourcesContent":["import * as React from 'react';\nimport { getSlotsCompat } from '@fluentui/react-utilities';\nimport { Portal } from '@fluentui/react-portal';\nimport type { PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlotsCompat(state);\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 {state.children}\n </slots.root>\n </Portal>\n );\n};\n"]}
1
+ {"version":3,"file":"renderPopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;IAMA;;OAEG;IACI,IAAM,oBAAoB,GAAG,UAAC,KAA0B;QACvD,IAAA,KAAuB,0BAAQ,CAAsB,KAAK,EAAE,uCAAmB,CAAC,EAA9E,KAAK,WAAA,EAAE,SAAS,eAA8D,CAAC;QAEvF,6CAA6C;QAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACf,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CACL,oBAAC,qBAAM,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS;YAChC,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;gBAC3B,CAAC,KAAK,CAAC,OAAO,IAAI,6BAAK,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,GAAI;gBAC/E,SAAS,CAAC,IAAI,CAAC,QAAQ,CACb,CACN,CACV,CAAC;IACJ,CAAC,CAAC;IAhBW,QAAA,oBAAoB,wBAgB/B","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"]}
@@ -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 HTMLElement of PopoverSurface
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<HTMLElement>, defaultProps?: PopoverSurfaceProps | undefined) => PopoverSurfaceState;
14
+ export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React.Ref<HTMLDivElement>) => PopoverSurfaceState;
@@ -1,8 +1,8 @@
1
1
  define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-tabster", "../../popoverContext"], function (require, exports, tslib_1, React, react_utilities_1, react_tabster_1, popoverContext_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePopoverSurface = void 0;
5
- var mergeProps = react_utilities_1.makeMergeProps({});
4
+ exports.usePopoverSurface = exports.popoverSurfaceSlots = void 0;
5
+ exports.popoverSurfaceSlots = ['root'];
6
6
  /**
7
7
  * Create the state required to render PopoverSurface.
8
8
  *
@@ -10,10 +10,10 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
10
10
  * before being passed to renderPopoverSurface.
11
11
  *
12
12
  * @param props - props from this instance of PopoverSurface
13
- * @param ref - reference to root HTMLElement of PopoverSurface
13
+ * @param ref - reference to root HTMLDivElement of PopoverSurface
14
14
  * @param defaultProps - (optional) default prop values provided by the implementing type
15
15
  */
16
- var usePopoverSurface = function (props, ref, defaultProps) {
16
+ var usePopoverSurface = function (props, ref) {
17
17
  var contentRef = popoverContext_1.usePopoverContext(function (context) { return context.contentRef; });
18
18
  var open = popoverContext_1.usePopoverContext(function (context) { return context.open; });
19
19
  var openOnHover = popoverContext_1.usePopoverContext(function (context) { return context.openOnHover; });
@@ -26,27 +26,29 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
26
26
  var inverted = popoverContext_1.usePopoverContext(function (context) { return context.inverted; });
27
27
  var trapFocus = popoverContext_1.usePopoverContext(function (context) { return context.trapFocus; });
28
28
  var modalAttributes = react_tabster_1.useModalAttributes({ trapFocus: trapFocus }).modalAttributes;
29
- var state = mergeProps(tslib_1.__assign({ brand: brand,
29
+ var state = tslib_1.__assign(tslib_1.__assign({ brand: brand,
30
30
  inverted: inverted,
31
31
  noArrow: noArrow,
32
32
  size: size,
33
33
  arrowRef: arrowRef,
34
34
  open: open,
35
- mountNode: mountNode, role: 'dialog', ref: react_utilities_1.useMergedRefs(ref, contentRef) }, modalAttributes), defaultProps, props);
36
- var onMouseEnterOriginal = state.onMouseEnter, onMouseLeaveOriginal = state.onMouseLeave, onKeyDownOriginal = state.onKeyDown;
37
- state.onMouseEnter = function (e) {
35
+ mountNode: mountNode }, props), { components: {
36
+ root: 'div',
37
+ }, root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({ ref: react_utilities_1.useMergedRefs(ref, contentRef), role: 'dialog' }, modalAttributes), props)) });
38
+ var _a = state.root, onMouseEnterOriginal = _a.onMouseEnter, onMouseLeaveOriginal = _a.onMouseLeave, onKeyDownOriginal = _a.onKeyDown;
39
+ state.root.onMouseEnter = function (e) {
38
40
  if (openOnHover) {
39
41
  setOpen(e, true);
40
42
  }
41
43
  onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
42
44
  };
43
- state.onMouseLeave = function (e) {
45
+ state.root.onMouseLeave = function (e) {
44
46
  if (openOnHover) {
45
47
  setOpen(e, false);
46
48
  }
47
49
  onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
48
50
  };
49
- state.onKeyDown = function (e) {
51
+ state.root.onKeyDown = function (e) {
50
52
  var _a;
51
53
  // only close if the event happened inside the current popover
52
54
  // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;IAMA,IAAM,UAAU,GAAG,gCAAc,CAAsB,EAAE,CAAC,CAAC;IAE3D;;;;;;;;;OASG;IACI,IAAM,iBAAiB,GAAG,UAC/B,KAA0B,EAC1B,GAA2B,EAC3B,YAAkC;QAElC,IAAM,UAAU,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;QACpE,IAAM,IAAI,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;QACxD,IAAM,WAAW,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,EAAnB,CAAmB,CAAC,CAAC;QACtE,IAAM,OAAO,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;QAC9D,IAAM,SAAS,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,SAAS,EAAjB,CAAiB,CAAC,CAAC;QAClE,IAAM,QAAQ,GAAG,kCAAiB,CAAC,UAAA,OAAO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,oBAAoB,CAAG,CAAC,EAAE;QAC5B,CAAC,CAAC;QAEF,KAAK,CAAC,YAAY,GAAG,UAAC,CAAgC;YACpD,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,CAAC,EAAE;QAC5B,CAAC,CAAC;QAEF,KAAK,CAAC,SAAS,GAAG,UAAC,CAAmC;;YACpD,8DAA8D;YAC9D,mHAAmH;YACnH,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,WAAI,UAAU,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC,MAAqB,EAAC,EAAE;gBAC/E,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,EAAE;QACzB,CAAC,CAAC;QAEM,IAAA,kBAAkB,GAAK,+BAAe,EAAE,mBAAtB,CAAuB;QAEjD,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;gBACpC,IAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC9D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,GAAG;aACzB;QACH,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA3EW,QAAA,iBAAiB,qBA2E5B","sourcesContent":["import * as React from 'react';\nimport { makeMergeProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\n\nconst mergeProps = makeMergeProps<PopoverSurfaceState>({});\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 HTMLElement of PopoverSurface\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopoverSurface = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLElement>,\n defaultProps?: PopoverSurfaceProps,\n): 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 = mergeProps(\n {\n brand,\n inverted,\n noArrow,\n size,\n arrowRef,\n open,\n mountNode,\n role: 'dialog',\n ref: useMergedRefs(ref, contentRef),\n ...modalAttributes,\n },\n defaultProps,\n props,\n );\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state;\n state.onMouseEnter = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\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 HTMLElement)) {\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"]}
1
+ {"version":3,"file":"usePopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;IAMa,QAAA,mBAAmB,GAAqC,CAAC,MAAM,CAAC,CAAC;IAE9E;;;;;;;;;OASG;IACI,IAAM,iBAAiB,GAAG,UAAC,KAA0B,EAAE,GAA8B;QAC1F,IAAM,UAAU,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;QACpE,IAAM,IAAI,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;QACxD,IAAM,WAAW,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,EAAnB,CAAmB,CAAC,CAAC;QACtE,IAAM,OAAO,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;QAC9D,IAAM,SAAS,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,SAAS,EAAjB,CAAiB,CAAC,CAAC;QAClE,IAAM,QAAQ,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,QAAQ,EAAhB,CAAgB,CAAC,CAAC;QAChE,IAAM,IAAI,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;QACxD,IAAM,OAAO,GAAG,kCAAiB,CAAC,UAAA,OAAO,I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,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,CAAC,EAAE;QAC5B,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,UAAC,CAAsC;;YAC5D,8DAA8D;YAC9D,mHAAmH;YACnH,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,WAAI,UAAU,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC,MAAwB,EAAC,EAAE;gBAClF,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,EAAE;QACzB,CAAC,CAAC;QAEM,IAAA,kBAAkB,GAAK,+BAAe,EAAE,mBAAtB,CAAuB;QAEjD,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;gBACpC,IAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC9D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,GAAG;aACzB;QACH,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA1EW,QAAA,iBAAiB,qBA0E5B","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"]}
@@ -72,7 +72,7 @@ define(["require", "exports", "@fluentui/react-make-styles"], function (require,
72
72
  */
73
73
  var usePopoverSurfaceStyles = function (state) {
74
74
  var styles = useStyles();
75
- 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);
75
+ 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);
76
76
  state.arrowClassName = react_make_styles_1.mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
77
77
  return state;
78
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverSurfaceStyles.js","sourceRoot":"../src/","sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":";;;;IAIa,QAAA,YAAY,GAAgC;QACvD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;KACT,CAAC;IAEF;;OAEG;IACH,IAAM,SAAS,GAAG,8BAAU,CAAC;QAC3B,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;YACd,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB;YAC7D,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ;YACtC,YAAY,EAAE,KAAK;SACpB,CAAC,EAJa,CAIb;QAEF,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;YAClB,oEAAoE;YACpE,e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C,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CACrE,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAlBW,QAAA,uBAAuB,2BAkBlC","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.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.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"]}
1
+ {"version":3,"file":"usePopoverSurfaceStyles.js","sourceRoot":"../src/","sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":";;;;IAIa,QAAA,YAAY,GAAgC;QACvD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;KACT,CAAC;IAEF;;OAEG;IACH,IAAM,SAAS,GAAG,8BAAU,CAAC;QAC3B,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;YACd,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB;YAC7D,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ;YACtC,YAAY,EAAE,KAAK;SACpB,CAAC,EAJa,CAIb;QAEF,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;YAClB,oEAAoE;YACpE,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,KAAK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C,gBAAgB,CACrE,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAlBW,QAAA,uBAAuB,2BAkBlC","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"]}
@@ -2,7 +2,6 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.usePopoverTrigger = void 0;
5
- var mergeProps = react_utilities_1.makeMergeProps({});
6
5
  /**
7
6
  * Create the state required to render PopoverTrigger.
8
7
  *
@@ -19,9 +18,6 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
19
18
  var openOnHover = popoverContext_1.usePopoverContext(function (context) { return context.openOnHover; });
20
19
  var openOnContext = popoverContext_1.usePopoverContext(function (context) { return context.openOnContext; });
21
20
  var triggerAttributes = react_tabster_1.useModalAttributes().triggerAttributes;
22
- var state = mergeProps({
23
- children: null,
24
- }, defaultProps, props);
25
21
  var onContextMenu = react_utilities_1.useEventCallback(function (e) {
26
22
  var _a, _b;
27
23
  if (openOnContext) {
@@ -62,13 +58,14 @@ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@f
62
58
  }
63
59
  (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
64
60
  });
65
- var child = React.Children.only(state.children);
66
- state.children = React.cloneElement(child, tslib_1.__assign({ 'aria-haspopup': 'true', onClick: onClick,
67
- onMouseEnter: onMouseEnter,
68
- onKeyDown: onKeyDown,
69
- onMouseLeave: onMouseLeave,
70
- onContextMenu: onContextMenu, ref: react_utilities_1.useMergedRefs(child.ref, triggerRef) }, triggerAttributes));
71
- return state;
61
+ var child = React.Children.only(props.children);
62
+ return {
63
+ children: React.cloneElement(child, tslib_1.__assign({ 'aria-haspopup': 'true', onClick: onClick,
64
+ onMouseEnter: onMouseEnter,
65
+ onKeyDown: onKeyDown,
66
+ onMouseLeave: onMouseLeave,
67
+ onContextMenu: onContextMenu, ref: react_utilities_1.useMergedRefs(child.ref, triggerRef) }, triggerAttributes)),
68
+ };
72
69
  };
73
70
  exports.usePopoverTrigger = usePopoverTrigger;
74
71
  });
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;IAWA,IAAM,UAAU,GAAG,gCAAc,CAAsB,EAAE,CAAC,CAAC;IAE3D;;;;;;;;OAQG;IACI,IAAM,iBAAiB,GAAG,UAC/B,KAA0B,EAC1B,YAAkC;QAElC,IAAM,OAAO,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;QAC9D,IAAM,IAAI,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;QACxD,IAAM,UAAU,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;QACpE,IAAM,WAAW,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,EAAnB,CAAmB,CAAC,CAAC;QACtE,IAAM,aAAa,GAAG,kCAAi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,CAAgC;;YACrE,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClB;YACD,YAAA,KAAK,CAAC,KAAK,0CAAE,YAAY,mDAAG,CAAC,EAAE;QACjC,CAAC,CAAC,CAAC;QAEH,IAAM,YAAY,GAAG,kCAAgB,CAAC,UAAC,CAAgC;;YACrE,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YACD,YAAA,KAAK,CAAC,KAAK,0CAAE,YAAY,mDAAG,CAAC,EAAE;QACjC,CAAC,CAAC,CAAC;QAEH,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClD,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,qBACvC,eAAe,EAAE,MAAM,EACvB,OAAO,SAAA;YACP,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,YAAY,cAAA;YACZ,aAAa,eAAA,EACb,GAAG,EAAE,+BAAa,CAAG,KAAuE,CAAC,GAAG,EAAE,UAAU,CAAC,IAC1G,iBAAiB,EACpB,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA3EW,QAAA,iBAAiB,qBA2E5B","sourcesContent":["import * as React from 'react';\nimport {\n makeMergeProps,\n useMergedRefs,\n useEventCallback,\n shouldPreventDefaultOnKeyDown,\n} from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext } from '../../popoverContext';\nimport type { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\n\nconst mergeProps = makeMergeProps<PopoverTriggerState>({});\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 state = mergeProps(\n {\n children: (null as unknown) as React.ReactElement,\n },\n defaultProps,\n props,\n );\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(state.children);\n state.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 return state;\n};\n"]}
1
+ {"version":3,"file":"usePopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverT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,CAAC,CAAC;IAnEW,QAAA,iBAAiB,qBAmE5B","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"]}
@@ -13,6 +13,8 @@ function isConformant(testInfo) {
13
13
  var defaultOptions = {
14
14
  asPropHandlesRef: true,
15
15
  componentPath: module.parent.filename.replace('.test', ''),
16
+ // TODO // https://github.com/microsoft/fluentui/issues/19522
17
+ skipAsPropTests: true,
16
18
  extraTests: react_conformance_make_styles_1.default
17
19
  };
18
20
  react_conformance_1.isConformant(defaultOptions, testInfo);
@@ -1 +1 @@
1
- {"version":3,"sources":["common/isConformant.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAEA,IAAA,+BAAA,gBAAA,OAAA,CAAA,yCAAA,CAAA;;AAEA,SAAgB,YAAhB,CACE,QADF,EAC2F;AAEzF,MAAM,cAAc,GAAyC;AAC3D,IAAA,gBAAgB,EAAE,IADyC;AAE3D,IAAA,aAAa,EAAE,MAAO,CAAC,MAAR,CAAgB,QAAhB,CAAyB,OAAzB,CAAiC,OAAjC,EAA0C,EAA1C,CAF4C;AAG3D,IAAA,UAAU,EAAE,+BAAA,CAAA;AAH+C,GAA7D;AAMA,EAAA,mBAAA,CAAA,YAAA,CAAiB,cAAjB,EAAiC,QAAjC;AACD;;AAVD,OAAA,CAAA,YAAA,GAAA,YAAA","sourcesContent":["import { isConformant as baseIsConformant } from '@fluentui/react-conformance';\nimport type { IsConformantOptions, TestObject } from '@fluentui/react-conformance';\nimport makeStylesTests from '@fluentui/react-conformance-make-styles';\n\nexport function isConformant<TProps = {}>(\n testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & { componentPath?: string },\n) {\n const defaultOptions: Partial<IsConformantOptions<TProps>> = {\n asPropHandlesRef: true,\n componentPath: module!.parent!.filename.replace('.test', ''),\n extraTests: makeStylesTests as TestObject<TProps>,\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["common/isConformant.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAEA,IAAA,+BAAA,gBAAA,OAAA,CAAA,yCAAA,CAAA;;AAEA,SAAgB,YAAhB,CACE,QADF,EAC2F;AAEzF,MAAM,cAAc,GAAyC;AAC3D,IAAA,gBAAgB,EAAE,IADyC;AAE3D,IAAA,aAAa,EAAE,MAAO,CAAC,MAAR,CAAgB,QAAhB,CAAyB,OAAzB,CAAiC,OAAjC,EAA0C,EAA1C,CAF4C;AAG3D;AACA,IAAA,eAAe,EAAE,IAJ0C;AAK3D,IAAA,UAAU,EAAE,+BAAA,CAAA;AAL+C,GAA7D;AAQA,EAAA,mBAAA,CAAA,YAAA,CAAiB,cAAjB,EAAiC,QAAjC;AACD;;AAZD,OAAA,CAAA,YAAA,GAAA,YAAA","sourcesContent":["import { isConformant as baseIsConformant } from '@fluentui/react-conformance';\nimport type { IsConformantOptions, TestObject } from '@fluentui/react-conformance';\nimport makeStylesTests from '@fluentui/react-conformance-make-styles';\n\nexport function isConformant<TProps = {}>(\n testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & { componentPath?: string },\n) {\n const defaultOptions: Partial<IsConformantOptions<TProps>> = {\n asPropHandlesRef: true,\n componentPath: module!.parent!.filename.replace('.test', ''),\n // TODO // https://github.com/microsoft/fluentui/issues/19522\n skipAsPropTests: true,\n extraTests: makeStylesTests as TestObject<TProps>,\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"],"sourceRoot":"../src/"}
@@ -1,20 +1,15 @@
1
1
  import * as React from 'react';
2
- import type { PopperVirtualElement, PositioningShorthand } from '@fluentui/react-positioning';
2
+ import type { PopperVirtualElement, PositioningShorthand, usePopperMouseTarget } from '@fluentui/react-positioning';
3
3
  import type { PortalProps } from '@fluentui/react-portal';
4
- import type { ComponentStateCompat } from '@fluentui/react-utilities';
5
4
  /**
6
5
  * Determines popover padding and arrow size
7
6
  */
8
7
  export declare type PopoverSize = 'small' | 'medium' | 'large';
9
- /**
10
- * Popover Props
11
- */
12
- export interface PopoverProps extends Pick<PortalProps, 'mountNode'> {
13
- children: React.ReactNode;
8
+ export interface PopoverCommons extends Pick<PortalProps, 'mountNode'> {
14
9
  /**
15
10
  * Controls the opening of the Popover
16
11
  */
17
- open?: boolean;
12
+ open: boolean;
18
13
  /**
19
14
  * Used to set the initial open state of the Popover in uncontrolled mode
20
15
  */
@@ -61,21 +56,19 @@ export interface PopoverProps extends Pick<PortalProps, 'mountNode'> {
61
56
  positioning?: PositioningShorthand;
62
57
  }
63
58
  /**
64
- * Names of the shorthand properties in PopoverProps
65
- */
66
- export declare type PopoverShorthandProps = never;
67
- /**
68
- * Names of PopoverProps that have a default value in usePopover
59
+ * Popover Props
69
60
  */
70
- export declare type PopoverDefaultedProps = never;
61
+ export interface PopoverProps extends Partial<PopoverCommons> {
62
+ /**
63
+ * Can contain two children including {@link PopoverTrigger} and {@link PopoverPopover}.
64
+ * Alternatively can only contain {@link PopoverPopover} if using a custom `target`.
65
+ */
66
+ children: [JSX.Element, JSX.Element] | JSX.Element;
67
+ }
71
68
  /**
72
69
  * Popover State
73
70
  */
74
- export interface PopoverState extends ComponentStateCompat<PopoverProps, PopoverShorthandProps, PopoverDefaultedProps> {
75
- /**
76
- * Open state of the Popover
77
- */
78
- open: boolean;
71
+ export interface PopoverState extends PopoverCommons, Pick<PopoverProps, 'children'> {
79
72
  /**
80
73
  * Callback to open/close the Popover
81
74
  */
@@ -99,7 +92,7 @@ export interface PopoverState extends ComponentStateCompat<PopoverProps, Popover
99
92
  /**
100
93
  * A callback to set the target of the popper to the mouse click for context events
101
94
  */
102
- setContextTarget: React.Dispatch<PopperVirtualElement | undefined>;
95
+ setContextTarget: ReturnType<typeof usePopperMouseTarget>[1];
103
96
  size: NonNullable<PopoverProps['size']>;
104
97
  }
105
98
  /**
@@ -18,12 +18,6 @@ var react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
18
18
  var react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
19
19
 
20
20
  var index_1 = /*#__PURE__*/require("../PopoverSurface/index");
21
- /**
22
- * Names of the shorthand properties in PopoverProps
23
- */
24
-
25
-
26
- var mergeProps = /*#__PURE__*/react_utilities_1.makeMergeProps({});
27
21
  /**
28
22
  * Create the state required to render Popover.
29
23
  *
@@ -34,63 +28,53 @@ var mergeProps = /*#__PURE__*/react_utilities_1.makeMergeProps({});
34
28
  * @param defaultProps - (optional) default prop values provided by the implementing type
35
29
  */
36
30
 
37
- var usePopover = function (props, defaultProps) {
38
- var state = mergeProps({
39
- size: 'medium',
40
- open: undefined,
41
- setOpen: function () {
42
- return null;
43
- },
44
- triggerRef: {
45
- current: null
46
- },
47
- contentRef: {
48
- current: null
49
- },
50
- arrowRef: {
51
- current: null
52
- },
53
- children: null,
54
- setContextTarget: function () {
55
- return null;
56
- },
57
- contextTarget: undefined
58
- }, defaultProps, props);
59
31
 
60
- var _a = React.useState(),
32
+ var usePopover = function (props, defaultProps) {
33
+ var _a = react_positioning_1.usePopperMouseTarget(),
61
34
  contextTarget = _a[0],
62
35
  setContextTarget = _a[1];
63
36
 
64
- state.setContextTarget = setContextTarget;
65
- state.contextTarget = contextTarget;
66
- useOpenState(state);
67
- usePopoverRefs(state);
37
+ var initialState = tslib_1.__assign({
38
+ size: 'medium',
39
+ contextTarget: contextTarget,
40
+ setContextTarget: setContextTarget
41
+ }, props);
42
+
43
+ var _b = useOpenState(initialState),
44
+ open = _b[0],
45
+ setOpen = _b[1];
46
+
47
+ var popperRefs = usePopoverRefs(initialState);
68
48
  var targetDocument = react_shared_contexts_1.useFluent().targetDocument;
69
49
  react_utilities_1.useOnClickOutside({
70
50
  contains: react_portal_1.elementContains,
71
51
  element: targetDocument,
72
52
  callback: function (ev) {
73
- return state.setOpen(ev, false);
53
+ return setOpen(ev, false);
74
54
  },
75
- refs: [state.triggerRef, state.contentRef],
76
- disabled: !state.open
55
+ refs: [popperRefs.triggerRef, popperRefs.contentRef],
56
+ disabled: !open
77
57
  });
78
58
  react_utilities_1.useOnScrollOutside({
79
59
  contains: react_portal_1.elementContains,
80
60
  element: targetDocument,
81
61
  callback: function (ev) {
82
- return state.setOpen(ev, false);
62
+ return setOpen(ev, false);
83
63
  },
84
- refs: [state.triggerRef, state.contentRef],
85
- disabled: !state.open || !state.openOnContext
64
+ refs: [popperRefs.triggerRef, popperRefs.contentRef],
65
+ disabled: !open || !initialState.openOnContext
66
+ });
67
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, initialState), popperRefs), {
68
+ open: open,
69
+ setOpen: setOpen,
70
+ setContextTarget: setContextTarget,
71
+ contextTarget: contextTarget
86
72
  });
87
- return state;
88
73
  };
89
74
 
90
75
  exports.usePopover = usePopover;
91
76
  /**
92
77
  * Creates and manages the Popover open state
93
- * @param state Popover state
94
78
  */
95
79
 
96
80
  function useOpenState(state) {
@@ -100,23 +84,26 @@ function useOpenState(state) {
100
84
  return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
101
85
  });
102
86
 
103
- var _a = react_utilities_1.useControllableValue(state.open, state.defaultOpen),
87
+ var _a = react_utilities_1.useControllableState({
88
+ state: state.open,
89
+ defaultState: state.defaultOpen,
90
+ initialState: false
91
+ }),
104
92
  open = _a[0],
105
- setOpen = _a[1];
93
+ setOpenState = _a[1];
106
94
 
107
95
  state.open = open !== undefined ? open : state.open;
108
96
  var setContextTarget = state.setContextTarget;
109
- state.setOpen = React.useCallback(function (e, shouldOpen) {
97
+ var setOpen = React.useCallback(function (e, shouldOpen) {
110
98
  if (shouldOpen && e.type === 'contextmenu') {
111
- var virtualElement = react_positioning_1.createVirtualElementFromClick(e.nativeEvent);
112
- setContextTarget(virtualElement);
99
+ setContextTarget(e);
113
100
  }
114
101
 
115
102
  if (!shouldOpen) {
116
103
  setContextTarget(undefined);
117
104
  }
118
105
 
119
- setOpen(function (prevOpen) {
106
+ setOpenState(function (prevOpen) {
120
107
  // More than one event (mouse, focus, keyboard) can request the Popover to close
121
108
  // We assume the first event is the correct one
122
109
  if (prevOpen !== shouldOpen) {
@@ -127,12 +114,11 @@ function useOpenState(state) {
127
114
 
128
115
  return shouldOpen;
129
116
  });
130
- }, [setOpen, onOpenChange, setContextTarget]);
131
- return state;
117
+ }, [setOpenState, onOpenChange, setContextTarget]);
118
+ return [open, setOpen];
132
119
  }
133
120
  /**
134
121
  * Creates and sets the necessary trigger, target and content refs used by Popover
135
- * @param state Popover state
136
122
  */
137
123
 
138
124
 
@@ -157,9 +143,10 @@ function usePopoverRefs(state) {
157
143
  contentRef = _a.containerRef,
158
144
  arrowRef = _a.arrowRef;
159
145
 
160
- state.contentRef = contentRef;
161
- state.triggerRef = triggerRef;
162
- state.arrowRef = arrowRef;
163
- return state;
146
+ return {
147
+ triggerRef: triggerRef,
148
+ contentRef: contentRef,
149
+ arrowRef: arrowRef
150
+ };
164
151
  }
165
152
  //# sourceMappingURL=usePopover.js.map