@fluentui/react-popover 9.5.4 → 9.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +82 -1
  3. package/CHANGELOG.md +22 -2
  4. package/lib/Popover.js.map +1 -1
  5. package/lib/PopoverSurface.js.map +1 -1
  6. package/lib/PopoverTrigger.js.map +1 -1
  7. package/lib/components/Popover/Popover.js +1 -0
  8. package/lib/components/Popover/Popover.js.map +1 -1
  9. package/lib/components/Popover/Popover.types.js +1 -1
  10. package/lib/components/Popover/Popover.types.js.map +1 -1
  11. package/lib/components/Popover/constants.js +1 -2
  12. package/lib/components/Popover/constants.js.map +1 -1
  13. package/lib/components/Popover/index.js.map +1 -1
  14. package/lib/components/Popover/renderPopover.js.map +1 -1
  15. package/lib/components/Popover/usePopover.js +8 -8
  16. package/lib/components/Popover/usePopover.js.map +1 -1
  17. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  18. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  19. package/lib/components/PopoverSurface/index.js.map +1 -1
  20. package/lib/components/PopoverSurface/renderPopoverSurface.js +1 -3
  21. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  22. package/lib/components/PopoverSurface/usePopoverSurface.js +3 -2
  23. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  24. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  25. package/lib/components/PopoverTrigger/PopoverTrigger.js +1 -0
  26. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  27. package/lib/components/PopoverTrigger/PopoverTrigger.types.js +1 -1
  28. package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  29. package/lib/components/PopoverTrigger/index.js.map +1 -1
  30. package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -2
  31. package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  32. package/lib/components/PopoverTrigger/usePopoverTrigger.js +1 -0
  33. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  34. package/lib/index.js.map +1 -1
  35. package/lib/popoverContext.js.map +1 -1
  36. package/lib-commonjs/Popover.js +5 -4
  37. package/lib-commonjs/Popover.js.map +1 -1
  38. package/lib-commonjs/PopoverSurface.js +5 -4
  39. package/lib-commonjs/PopoverSurface.js.map +1 -1
  40. package/lib-commonjs/PopoverTrigger.js +5 -4
  41. package/lib-commonjs/PopoverTrigger.js.map +1 -1
  42. package/lib-commonjs/components/Popover/Popover.js +14 -13
  43. package/lib-commonjs/components/Popover/Popover.js.map +1 -1
  44. package/lib-commonjs/components/Popover/Popover.types.js +5 -2
  45. package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
  46. package/lib-commonjs/components/Popover/constants.js +10 -8
  47. package/lib-commonjs/components/Popover/constants.js.map +1 -1
  48. package/lib-commonjs/components/Popover/index.js +8 -7
  49. package/lib-commonjs/components/Popover/index.js.map +1 -1
  50. package/lib-commonjs/components/Popover/renderPopover.js +31 -47
  51. package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
  52. package/lib-commonjs/components/Popover/usePopover.js +179 -173
  53. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  54. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +19 -20
  55. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  56. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js +3 -2
  57. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  58. package/lib-commonjs/components/PopoverSurface/index.js +9 -8
  59. package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
  60. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +23 -28
  61. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  62. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +70 -81
  63. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  64. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +243 -113
  65. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  66. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +15 -14
  67. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  68. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js +5 -2
  69. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  70. package/lib-commonjs/components/PopoverTrigger/index.js +8 -7
  71. package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
  72. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +12 -11
  73. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  74. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +71 -80
  75. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  76. package/lib-commonjs/index.js +30 -92
  77. package/lib-commonjs/index.js.map +1 -1
  78. package/lib-commonjs/popoverContext.js +34 -25
  79. package/lib-commonjs/popoverContext.js.map +1 -1
  80. package/package.json +14 -13
  81. package/lib-amd/Popover.js +0 -6
  82. package/lib-amd/Popover.js.map +0 -1
  83. package/lib-amd/PopoverSurface.js +0 -6
  84. package/lib-amd/PopoverSurface.js.map +0 -1
  85. package/lib-amd/PopoverTrigger.js +0 -6
  86. package/lib-amd/PopoverTrigger.js.map +0 -1
  87. package/lib-amd/components/Popover/Popover.js +0 -15
  88. package/lib-amd/components/Popover/Popover.js.map +0 -1
  89. package/lib-amd/components/Popover/Popover.types.js +0 -5
  90. package/lib-amd/components/Popover/Popover.types.js.map +0 -1
  91. package/lib-amd/components/Popover/constants.js +0 -15
  92. package/lib-amd/components/Popover/constants.js.map +0 -1
  93. package/lib-amd/components/Popover/index.js +0 -9
  94. package/lib-amd/components/Popover/index.js.map +0 -1
  95. package/lib-amd/components/Popover/renderPopover.js +0 -32
  96. package/lib-amd/components/Popover/renderPopover.js.map +0 -1
  97. package/lib-amd/components/Popover/usePopover.js +0 -147
  98. package/lib-amd/components/Popover/usePopover.js.map +0 -1
  99. package/lib-amd/components/PopoverSurface/PopoverSurface.js +0 -17
  100. package/lib-amd/components/PopoverSurface/PopoverSurface.js.map +0 -1
  101. package/lib-amd/components/PopoverSurface/PopoverSurface.types.js +0 -5
  102. package/lib-amd/components/PopoverSurface/PopoverSurface.types.js.map +0 -1
  103. package/lib-amd/components/PopoverSurface/index.js +0 -10
  104. package/lib-amd/components/PopoverSurface/index.js.map +0 -1
  105. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js +0 -20
  106. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js.map +0 -1
  107. package/lib-amd/components/PopoverSurface/usePopoverSurface.js +0 -69
  108. package/lib-amd/components/PopoverSurface/usePopoverSurface.js.map +0 -1
  109. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js +0 -44
  110. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js.map +0 -1
  111. package/lib-amd/components/PopoverTrigger/PopoverTrigger.js +0 -17
  112. package/lib-amd/components/PopoverTrigger/PopoverTrigger.js.map +0 -1
  113. package/lib-amd/components/PopoverTrigger/PopoverTrigger.types.js +0 -5
  114. package/lib-amd/components/PopoverTrigger/PopoverTrigger.types.js.map +0 -1
  115. package/lib-amd/components/PopoverTrigger/index.js +0 -9
  116. package/lib-amd/components/PopoverTrigger/index.js.map +0 -1
  117. package/lib-amd/components/PopoverTrigger/renderPopoverTrigger.js +0 -13
  118. package/lib-amd/components/PopoverTrigger/renderPopoverTrigger.js.map +0 -1
  119. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js +0 -61
  120. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js.map +0 -1
  121. package/lib-amd/index.js +0 -20
  122. package/lib-amd/index.js.map +0 -1
  123. package/lib-amd/popoverContext.js +0 -28
  124. package/lib-amd/popoverContext.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-popover",
3
- "version": "9.5.4",
3
+ "version": "9.5.5",
4
4
  "description": "Popover component for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -24,28 +24,28 @@
24
24
  "storybook": "start-storybook",
25
25
  "test": "jest --passWithNoTests",
26
26
  "type-check": "tsc -b tsconfig.json",
27
- "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
27
+ "generate-api": "just-scripts generate-api"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@fluentui/eslint-plugin": "*",
31
31
  "@fluentui/react-conformance": "*",
32
- "@fluentui/react-conformance-griffel": "9.0.0-beta.19",
32
+ "@fluentui/react-conformance-griffel": "9.0.0-beta.20",
33
33
  "@fluentui/scripts-api-extractor": "*",
34
34
  "@fluentui/scripts-cypress": "*",
35
35
  "@fluentui/scripts-tasks": "*"
36
36
  },
37
37
  "dependencies": {
38
- "@fluentui/keyboard-keys": "^9.0.1",
39
- "@fluentui/react-aria": "^9.3.14",
40
- "@fluentui/react-context-selector": "^9.1.14",
41
- "@fluentui/react-portal": "^9.2.1",
42
- "@fluentui/react-positioning": "^9.5.5",
43
- "@fluentui/react-shared-contexts": "^9.3.1",
44
- "@fluentui/react-tabster": "^9.6.0",
45
- "@fluentui/react-theme": "^9.1.6",
46
- "@fluentui/react-utilities": "^9.7.1",
38
+ "@fluentui/keyboard-keys": "^9.0.2",
39
+ "@fluentui/react-aria": "^9.3.15",
40
+ "@fluentui/react-context-selector": "^9.1.15",
41
+ "@fluentui/react-portal": "^9.2.2",
42
+ "@fluentui/react-positioning": "^9.5.6",
43
+ "@fluentui/react-shared-contexts": "^9.3.2",
44
+ "@fluentui/react-tabster": "^9.6.1",
45
+ "@fluentui/react-theme": "^9.1.7",
46
+ "@fluentui/react-utilities": "^9.7.2",
47
47
  "@griffel/react": "^1.5.2",
48
- "tslib": "^2.1.0"
48
+ "@swc/helpers": "^0.4.14"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@types/react": ">=16.8.0 <19.0.0",
@@ -63,6 +63,7 @@
63
63
  "exports": {
64
64
  ".": {
65
65
  "types": "./dist/index.d.ts",
66
+ "node": "./lib-commonjs/index.js",
66
67
  "import": "./lib/index.js",
67
68
  "require": "./lib-commonjs/index.js"
68
69
  },
@@ -1,6 +0,0 @@
1
- define(["require", "exports", "tslib", "./components/Popover/index"], function (require, exports, tslib_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(index_1, exports);
5
- });
6
- //# sourceMappingURL=Popover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-popover/src/Popover.ts"],"names":[],"mappings":";;;IAAA,uCAA2C","sourcesContent":["export * from './components/Popover/index';\n"]}
@@ -1,6 +0,0 @@
1
- define(["require", "exports", "tslib", "./components/PopoverSurface/index"], function (require, exports, tslib_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(index_1, exports);
5
- });
6
- //# sourceMappingURL=PopoverSurface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverSurface.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-popover/src/PopoverSurface.ts"],"names":[],"mappings":";;;IAAA,uCAAkD","sourcesContent":["export * from './components/PopoverSurface/index';\n"]}
@@ -1,6 +0,0 @@
1
- define(["require", "exports", "tslib", "./components/PopoverTrigger/index"], function (require, exports, tslib_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(index_1, exports);
5
- });
6
- //# sourceMappingURL=PopoverTrigger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverTrigger.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-popover/src/PopoverTrigger.ts"],"names":[],"mappings":";;;IAAA,uCAAkD","sourcesContent":["export * from './components/PopoverTrigger/index';\n"]}
@@ -1,15 +0,0 @@
1
- define(["require", "exports", "./usePopover", "./renderPopover"], function (require, exports, usePopover_1, renderPopover_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Popover = void 0;
5
- /**
6
- * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
7
- */
8
- var Popover = function (props) {
9
- var state = usePopover_1.usePopover_unstable(props);
10
- return renderPopover_1.renderPopover_unstable(state);
11
- };
12
- exports.Popover = Popover;
13
- exports.Popover.displayName = 'Popover';
14
- });
15
- //# sourceMappingURL=Popover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/Popover.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,OAAO,GAA2B,UAAA,KAAK;QAClD,IAAM,KAAK,GAAG,gCAAmB,CAAC,KAAK,CAAC,CAAC;QAEzC,OAAO,sCAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC;IAJW,QAAA,OAAO,WAIlB;IAEF,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC","sourcesContent":["import * as React from 'react';\nimport { usePopover_unstable } from './usePopover';\nimport { renderPopover_unstable } from './renderPopover';\nimport type { PopoverProps } from './Popover.types';\n\n/**\n * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.\n */\nexport const Popover: React.FC<PopoverProps> = props => {\n const state = usePopover_unstable(props);\n\n return renderPopover_unstable(state);\n};\n\nPopover.displayName = 'Popover';\n"]}
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=Popover.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Popover.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/Popover.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type {\n PositioningVirtualElement,\n PositioningShorthand,\n SetVirtualMouseTarget,\n} from '@fluentui/react-positioning';\nimport type { PortalProps } from '@fluentui/react-portal';\n\n/**\n * Determines popover padding and arrow size\n */\nexport type PopoverSize = 'small' | 'medium' | 'large';\n\n/**\n * Popover Props\n */\nexport type PopoverProps = Pick<PortalProps, 'mountNode'> & {\n /**\n * A popover can appear styled with brand or inverted.\n * When not specified, the default style is used.\n */\n appearance?: 'brand' | 'inverted';\n\n /**\n * Can contain two children including {@link PopoverTrigger} and {@link PopoverSurface}.\n * Alternatively can only contain {@link PopoverSurface} if using a custom `target`.\n */\n children: [JSX.Element, JSX.Element] | JSX.Element;\n\n /**\n * Close when scroll outside of it\n *\n * @default false\n */\n closeOnScroll?: boolean;\n\n /**\n * Used to set the initial open state of the Popover in uncontrolled mode\n *\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * Popovers are rendered out of DOM order on `document.body` by default, use this to render the popover in DOM order\n *\n * @default false\n */\n inline?: boolean;\n\n /**\n * Sets the delay for closing popover on mouse leave\n */\n mouseLeaveDelay?: number;\n\n /**\n * Display an arrow pointing to the target.\n *\n * @default false\n */\n withArrow?: boolean;\n\n /**\n * Call back when the component requests to change value\n * The `open` value is used as a hint when directly controlling the component\n */\n onOpenChange?: (e: OpenPopoverEvents, data: OnOpenChangeData) => void;\n\n /**\n * Controls the opening of the Popover\n *\n * @default false\n */\n open?: boolean;\n\n /**\n * Flag to open the Popover as a context menu. Disables all other interactions\n *\n * @default false\n */\n openOnContext?: boolean;\n\n /**\n * Flag to open the Popover by hovering the trigger\n *\n * @default false\n */\n openOnHover?: boolean;\n\n /**\n * Configures the position of the Popover\n */\n positioning?: PositioningShorthand;\n\n /**\n * Determines popover padding and arrow size\n *\n * @default medium\n */\n size?: PopoverSize;\n\n /**\n * Should trap focus\n *\n * @default false\n */\n trapFocus?: boolean;\n\n /**\n * Must be used with the `trapFocus` prop\n * Enables older Fluent UI focus trap behavior where the user\n * cannot tab into the window outside of the document. This is now\n * non-standard behavior according to the [HTML dialog spec](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)\n * where the focus trap involves setting outside elements inert.\n *\n * @deprecated this behavior is default provided now, to opt-out of it in favor of standard behavior use the `inertTrapFocus` property\n */\n legacyTrapFocus?: boolean;\n /**\n * Enables standard behavior according to the [HTML dialog spec](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)\n * where the focus trap involves setting outside elements inert,\n * making navigation leak from the trapped area back to the browser toolbar and vice-versa.\n *\n * @default false\n */\n inertTrapFocus?: boolean;\n\n /**\n * By default Popover focuses the first focusable element in PopoverSurface on open.\n * Specify `disableAutoFocus` to prevent this behavior.\n *\n * @default false\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableAutoFocus?: boolean;\n};\n\n/**\n * Popover State\n */\nexport type PopoverState = Pick<\n PopoverProps,\n | 'appearance'\n | 'mountNode'\n | 'onOpenChange'\n | 'openOnContext'\n | 'openOnHover'\n | 'trapFocus'\n | 'withArrow'\n | 'inertTrapFocus'\n> &\n Required<Pick<PopoverProps, 'inline' | 'open'>> &\n Pick<PopoverProps, 'children'> & {\n /**\n * Ref of the pointing arrow\n */\n arrowRef: React.MutableRefObject<HTMLDivElement | null>;\n\n /**\n * Ref of the PopoverSurface\n */\n contentRef: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * Anchors the popper to the mouse click for context events\n */\n contextTarget: PositioningVirtualElement | undefined;\n\n popoverSurface: React.ReactElement | undefined;\n\n popoverTrigger: React.ReactElement | undefined;\n\n /**\n * A callback to set the target of the popper to the mouse click for context events\n */\n setContextTarget: SetVirtualMouseTarget;\n\n /**\n * Callback to open/close the Popover\n */\n setOpen: (e: OpenPopoverEvents, open: boolean) => void;\n\n size: NonNullable<PopoverProps['size']>;\n\n /**\n * Callback to toggle the open state of the Popover\n */\n toggleOpen: (e: OpenPopoverEvents) => void;\n\n /**\n * Ref of the PopoverTrigger\n */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n };\n\n/**\n * Data attached to open/close events\n */\nexport type OnOpenChangeData = { open: boolean };\n\n/**\n * The supported events that will trigger open/close of the menu\n */\nexport type OpenPopoverEvents =\n | MouseEvent\n | TouchEvent\n | React.FocusEvent<HTMLElement>\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>;\n"]}
@@ -1,15 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.popoverSurfaceBorderRadius = void 0;
5
- /**
6
- * @internal
7
- * The default value of the tooltip's border radius (borderRadiusMedium).
8
- *
9
- * Unfortunately, Popper requires it to be specified as a variable instead of using CSS.
10
- * While we could use getComputedStyle, that adds a performance penalty for something that
11
- * will likely never change.
12
- */
13
- exports.popoverSurfaceBorderRadius = 4;
14
- });
15
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/constants.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;OAOG;IACU,QAAA,0BAA0B,GAAG,CAAC,CAAC","sourcesContent":["/**\n * @internal\n * The default value of the tooltip's border radius (borderRadiusMedium).\n *\n * Unfortunately, Popper requires it to be specified as a variable instead of using CSS.\n * While we could use getComputedStyle, that adds a performance penalty for something that\n * will likely never change.\n */\nexport const popoverSurfaceBorderRadius = 4;\n"]}
@@ -1,9 +0,0 @@
1
- define(["require", "exports", "tslib", "./Popover", "./Popover.types", "./renderPopover", "./usePopover"], function (require, exports, tslib_1, Popover_1, Popover_types_1, renderPopover_1, usePopover_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(Popover_1, exports);
5
- tslib_1.__exportStar(Popover_types_1, exports);
6
- tslib_1.__exportStar(renderPopover_1, exports);
7
- tslib_1.__exportStar(usePopover_1, exports);
8
- });
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/index.ts"],"names":[],"mappings":";;;IAAA,yCAA0B;IAC1B,+CAAgC;IAChC,+CAAgC;IAChC,4CAA6B","sourcesContent":["export * from './Popover';\nexport * from './Popover.types';\nexport * from './renderPopover';\nexport * from './usePopover';\n"]}
@@ -1,32 +0,0 @@
1
- define(["require", "exports", "react", "../../popoverContext"], function (require, exports, React, popoverContext_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.renderPopover_unstable = void 0;
5
- /**
6
- * Render the final JSX of Popover
7
- */
8
- var renderPopover_unstable = function (state) {
9
- var appearance = state.appearance, arrowRef = state.arrowRef, contentRef = state.contentRef, inline = state.inline, mountNode = state.mountNode, open = state.open, openOnContext = state.openOnContext, openOnHover = state.openOnHover, setOpen = state.setOpen, size = state.size, toggleOpen = state.toggleOpen, trapFocus = state.trapFocus, triggerRef = state.triggerRef, withArrow = state.withArrow, inertTrapFocus = state.inertTrapFocus;
10
- return (React.createElement(popoverContext_1.PopoverContext.Provider, { value: {
11
- appearance: appearance,
12
- arrowRef: arrowRef,
13
- contentRef: contentRef,
14
- inline: inline,
15
- mountNode: mountNode,
16
- open: open,
17
- openOnContext: openOnContext,
18
- openOnHover: openOnHover,
19
- setOpen: setOpen,
20
- toggleOpen: toggleOpen,
21
- triggerRef: triggerRef,
22
- size: size,
23
- trapFocus: trapFocus,
24
- inertTrapFocus: inertTrapFocus,
25
- withArrow: withArrow,
26
- } },
27
- state.popoverTrigger,
28
- state.open && state.popoverSurface));
29
- };
30
- exports.renderPopover_unstable = renderPopover_unstable;
31
- });
32
- //# sourceMappingURL=renderPopover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderPopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/renderPopover.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,sBAAsB,GAAG,UAAC,KAAmB;QAEtD,IAAA,UAAU,GAeR,KAAK,WAfG,EACV,QAAQ,GAcN,KAAK,SAdC,EACR,UAAU,GAaR,KAAK,WAbG,EACV,MAAM,GAYJ,KAAK,OAZD,EACN,SAAS,GAWP,KAAK,UAXE,EACT,IAAI,GAUF,KAAK,KAVH,EACJ,aAAa,GASX,KAAK,cATM,EACb,WAAW,GAQT,KAAK,YARI,EACX,OAAO,GAOL,KAAK,QAPA,EACP,IAAI,GAMF,KAAK,KANH,EACJ,UAAU,GAKR,KAAK,WALG,EACV,SAAS,GAIP,KAAK,UAJE,EACT,UAAU,GAGR,KAAK,WAHG,EACV,SAAS,GAEP,KAAK,UAFE,EACT,cAAc,GACZ,KAAK,eADO,CACN;QAEV,OAAO,CACL,oBAAC,+BAAc,CAAC,QAAQ,IACtB,KAAK,EAAE;gBACL,UAAU,YAAA;gBACV,QAAQ,UAAA;gBACR,UAAU,YAAA;gBACV,MAAM,QAAA;gBACN,SAAS,WAAA;gBACT,IAAI,MAAA;gBACJ,aAAa,eAAA;gBACb,WAAW,aAAA;gBACX,OAAO,SAAA;gBACP,UAAU,YAAA;gBACV,UAAU,YAAA;gBACV,IAAI,MAAA;gBACJ,SAAS,WAAA;gBACT,cAAc,gBAAA;gBACd,SAAS,WAAA;aACV;YAEA,KAAK,CAAC,cAAc;YACpB,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,cAAc,CACX,CAC3B,CAAC;IACJ,CAAC,CAAC;IA3CW,QAAA,sBAAsB,0BA2CjC","sourcesContent":["import * as React from 'react';\nimport { PopoverContext } from '../../popoverContext';\nimport type { PopoverState } from './Popover.types';\n\n/**\n * Render the final JSX of Popover\n */\nexport const renderPopover_unstable = (state: PopoverState) => {\n const {\n appearance,\n arrowRef,\n contentRef,\n inline,\n mountNode,\n open,\n openOnContext,\n openOnHover,\n setOpen,\n size,\n toggleOpen,\n trapFocus,\n triggerRef,\n withArrow,\n inertTrapFocus,\n } = state;\n\n return (\n <PopoverContext.Provider\n value={{\n appearance,\n arrowRef,\n contentRef,\n inline,\n mountNode,\n open,\n openOnContext,\n openOnHover,\n setOpen,\n toggleOpen,\n triggerRef,\n size,\n trapFocus,\n inertTrapFocus,\n withArrow,\n }}\n >\n {state.popoverTrigger}\n {state.open && state.popoverSurface}\n </PopoverContext.Provider>\n );\n};\n"]}
@@ -1,147 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-shared-contexts", "@fluentui/react-positioning", "@fluentui/react-portal", "@fluentui/react-tabster", "../PopoverSurface/index", "./constants"], function (require, exports, tslib_1, React, react_utilities_1, react_shared_contexts_1, react_positioning_1, react_portal_1, react_tabster_1, index_1, constants_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePopover_unstable = void 0;
5
- /**
6
- * Create the state required to render Popover.
7
- *
8
- * The returned state can be modified with hooks such as usePopoverStyles,
9
- * before being passed to renderPopover_unstable.
10
- *
11
- * @param props - props from this instance of Popover
12
- */
13
- var usePopover_unstable = function (props) {
14
- var _a;
15
- var _b = react_positioning_1.usePositioningMouseTarget(), contextTarget = _b[0], setContextTarget = _b[1];
16
- var initialState = tslib_1.__assign({ size: 'medium', contextTarget: contextTarget, setContextTarget: setContextTarget }, props);
17
- var children = React.Children.toArray(props.children);
18
- if (process.env.NODE_ENV !== 'production') {
19
- if (children.length === 0) {
20
- // eslint-disable-next-line no-console
21
- console.warn('Popover must contain at least one child');
22
- }
23
- if (children.length > 2) {
24
- // eslint-disable-next-line no-console
25
- console.warn('Popover must contain at most two children');
26
- }
27
- }
28
- var popoverTrigger = undefined;
29
- var popoverSurface = undefined;
30
- if (children.length === 2) {
31
- popoverTrigger = children[0];
32
- popoverSurface = children[1];
33
- }
34
- else if (children.length === 1) {
35
- popoverSurface = children[0];
36
- }
37
- var _c = useOpenState(initialState), open = _c[0], setOpenState = _c[1];
38
- var setOpenTimeoutRef = React.useRef(0);
39
- var setOpen = react_utilities_1.useEventCallback(function (e, shouldOpen) {
40
- var _a;
41
- clearTimeout(setOpenTimeoutRef.current);
42
- if (!(e instanceof Event) && e.persist) {
43
- // < React 17 still uses pooled synthetic events
44
- e.persist();
45
- }
46
- if (e.type === 'mouseleave') {
47
- // FIXME leaking Node timeout type
48
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
- // @ts-ignore
50
- setOpenTimeoutRef.current = setTimeout(function () {
51
- setOpenState(e, shouldOpen);
52
- }, (_a = props.mouseLeaveDelay) !== null && _a !== void 0 ? _a : 500);
53
- }
54
- else {
55
- setOpenState(e, shouldOpen);
56
- }
57
- });
58
- // Clear timeout on unmount
59
- // Setting state after a component unmounts can cause memory leaks
60
- React.useEffect(function () {
61
- return function () {
62
- clearTimeout(setOpenTimeoutRef.current);
63
- };
64
- }, []);
65
- var toggleOpen = React.useCallback(function (e) {
66
- setOpen(e, !open);
67
- }, [setOpen, open]);
68
- var positioningRefs = usePopoverRefs(initialState);
69
- var targetDocument = react_shared_contexts_1.useFluent_unstable().targetDocument;
70
- react_utilities_1.useOnClickOutside({
71
- contains: react_portal_1.elementContains,
72
- element: targetDocument,
73
- callback: function (ev) { return setOpen(ev, false); },
74
- refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
75
- disabled: !open,
76
- });
77
- // only close on scroll for context, or when closeOnScroll is specified
78
- var closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;
79
- react_utilities_1.useOnScrollOutside({
80
- contains: react_portal_1.elementContains,
81
- element: targetDocument,
82
- callback: function (ev) { return setOpen(ev, false); },
83
- refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
84
- disabled: !open || !closeOnScroll,
85
- });
86
- var findFirstFocusable = react_tabster_1.useFocusFinders().findFirstFocusable;
87
- React.useEffect(function () {
88
- var _a;
89
- if (props.unstable_disableAutoFocus) {
90
- return;
91
- }
92
- if (open && positioningRefs.contentRef.current) {
93
- var containerTabIndex = (_a = positioningRefs.contentRef.current.getAttribute('tabIndex')) !== null && _a !== void 0 ? _a : undefined;
94
- var firstFocusable = isNaN(containerTabIndex)
95
- ? findFirstFocusable(positioningRefs.contentRef.current)
96
- : positioningRefs.contentRef.current;
97
- firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
98
- }
99
- }, [findFirstFocusable, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);
100
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, initialState), positioningRefs), { popoverTrigger: popoverTrigger, popoverSurface: popoverSurface, open: open, setOpen: setOpen, toggleOpen: toggleOpen, setContextTarget: setContextTarget, contextTarget: contextTarget, inline: (_a = props.inline) !== null && _a !== void 0 ? _a : false });
101
- };
102
- exports.usePopover_unstable = usePopover_unstable;
103
- /**
104
- * Creates and manages the Popover open state
105
- */
106
- function useOpenState(state) {
107
- var onOpenChange = react_utilities_1.useEventCallback(function (e, data) { var _a; return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data); });
108
- var _a = react_utilities_1.useControllableState({
109
- state: state.open,
110
- defaultState: state.defaultOpen,
111
- initialState: false,
112
- }), open = _a[0], setOpenState = _a[1];
113
- state.open = open !== undefined ? open : state.open;
114
- var setContextTarget = state.setContextTarget;
115
- var setOpen = React.useCallback(function (e, shouldOpen) {
116
- if (shouldOpen && e.type === 'contextmenu') {
117
- setContextTarget(e);
118
- }
119
- if (!shouldOpen) {
120
- setContextTarget(undefined);
121
- }
122
- setOpenState(shouldOpen);
123
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(e, { open: shouldOpen });
124
- }, [setOpenState, onOpenChange, setContextTarget]);
125
- return [open, setOpen];
126
- }
127
- /**
128
- * Creates and sets the necessary trigger, target and content refs used by Popover
129
- */
130
- function usePopoverRefs(state) {
131
- var positioningOptions = tslib_1.__assign({ position: 'above', align: 'center', arrowPadding: 2 * constants_1.popoverSurfaceBorderRadius, target: state.openOnContext ? state.contextTarget : undefined }, react_positioning_1.resolvePositioningShorthand(state.positioning));
132
- // no reason to render arrow when covering the target
133
- if (positioningOptions.coverTarget) {
134
- state.withArrow = false;
135
- }
136
- if (state.withArrow) {
137
- positioningOptions.offset = react_positioning_1.mergeArrowOffset(positioningOptions.offset, index_1.arrowHeights[state.size]);
138
- }
139
- var _a = react_positioning_1.usePositioning(positioningOptions), triggerRef = _a.targetRef, contentRef = _a.containerRef, arrowRef = _a.arrowRef;
140
- return {
141
- triggerRef: triggerRef,
142
- contentRef: contentRef,
143
- arrowRef: arrowRef,
144
- };
145
- }
146
- });
147
- //# sourceMappingURL=usePopover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/usePopover.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;;OAOG;IACI,IAAM,mBAAmB,GAAG,UAAC,KAAmB;;QAC/C,IAAA,KAAoC,6CAAyB,EAAE,EAA9D,aAAa,QAAA,EAAE,gBAAgB,QAA+B,CAAC;QACtE,IAAM,YAAY,GAAG,mBACnB,IAAI,EAAE,QAAQ,EACd,aAAa,eAAA,EACb,gBAAgB,kBAAA,IACb,KAAK,CACA,CAAC;QAEX,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAyB,CAAC;QAEhF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YACzC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;aACzD;YAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvB,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;aAC3D;SACF;QAED,IAAI,cAAc,GAAmC,SAAS,CAAC;QA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EzG,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_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\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_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (props.unstable_disableAutoFocus) {\n return;\n }\n\n if (open && positioningRefs.contentRef.current) {\n const containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : positioningRefs.contentRef.current;\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\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(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\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'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\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 (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"]}
@@ -1,17 +0,0 @@
1
- define(["require", "exports", "react", "./usePopoverSurface", "./renderPopoverSurface", "./usePopoverSurfaceStyles", "@fluentui/react-shared-contexts"], function (require, exports, React, usePopoverSurface_1, renderPopoverSurface_1, usePopoverSurfaceStyles_1, react_shared_contexts_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PopoverSurface = void 0;
5
- /**
6
- * PopoverSurface component renders react children in a positioned box
7
- */
8
- exports.PopoverSurface = React.forwardRef(function (props, ref) {
9
- var state = usePopoverSurface_1.usePopoverSurface_unstable(props, ref);
10
- usePopoverSurfaceStyles_1.usePopoverSurfaceStyles_unstable(state);
11
- var useCustomStyles = react_shared_contexts_1.useCustomStyleHooks_unstable().usePopoverSurfaceStyles_unstable;
12
- useCustomStyles(state);
13
- return renderPopoverSurface_1.renderPopoverSurface_unstable(state);
14
- });
15
- exports.PopoverSurface.displayName = 'PopoverSurface';
16
- });
17
- //# sourceMappingURL=PopoverSurface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverSurface.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;IAQA;;OAEG;IACU,QAAA,cAAc,GAA6C,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAClG,IAAM,KAAK,GAAG,8CAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAErD,0DAAgC,CAAC,KAAK,CAAC,CAAC;QAEhC,IAAkC,eAAe,GAAK,oDAA4B,EAAE,iCAAnC,CAAoC;QAC7F,eAAe,CAAC,KAAK,CAAC,CAAC;QAEvB,OAAO,oDAA6B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface_unstable } from './usePopoverSurface';\nimport { renderPopoverSurface_unstable } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles';\nimport type { PopoverSurfaceProps } from './PopoverSurface.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps> = React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n\n usePopoverSurfaceStyles_unstable(state);\n\n const { usePopoverSurfaceStyles_unstable: useCustomStyles } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n\n return renderPopoverSurface_unstable(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"]}
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=PopoverSurface.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;\n\n/**\n * Names of the slots in PopoverSurfaceProps\n */\nexport type PopoverSurfaceSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PopoverSurface State\n */\nexport type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &\n Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'size' | 'withArrow'> & {\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n"]}
@@ -1,10 +0,0 @@
1
- define(["require", "exports", "tslib", "./PopoverSurface", "./PopoverSurface.types", "./renderPopoverSurface", "./usePopoverSurface", "./usePopoverSurfaceStyles"], function (require, exports, tslib_1, PopoverSurface_1, PopoverSurface_types_1, renderPopoverSurface_1, usePopoverSurface_1, usePopoverSurfaceStyles_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(PopoverSurface_1, exports);
5
- tslib_1.__exportStar(PopoverSurface_types_1, exports);
6
- tslib_1.__exportStar(renderPopoverSurface_1, exports);
7
- tslib_1.__exportStar(usePopoverSurface_1, exports);
8
- tslib_1.__exportStar(usePopoverSurfaceStyles_1, exports);
9
- });
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/index.ts"],"names":[],"mappings":";;;IAAA,gDAAiC;IACjC,sDAAuC;IACvC,sDAAuC;IACvC,mDAAoC;IACpC,yDAA0C","sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"]}
@@ -1,20 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-portal", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_portal_1, react_utilities_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.renderPopoverSurface_unstable = void 0;
5
- /**
6
- * Render the final JSX of PopoverSurface
7
- */
8
- var renderPopoverSurface_unstable = function (state) {
9
- var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
- var surface = (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
11
- state.withArrow && React.createElement("div", { ref: state.arrowRef, className: state.arrowClassName }),
12
- slotProps.root.children));
13
- if (state.inline) {
14
- return surface;
15
- }
16
- return React.createElement(react_portal_1.Portal, { mountNode: state.mountNode }, surface);
17
- };
18
- exports.renderPopoverSurface_unstable = renderPopoverSurface_unstable;
19
- });
20
- //# sourceMappingURL=renderPopoverSurface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderPopoverSurface.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,6BAA6B,GAAG,UAAC,KAA0B;QAChE,IAAA,KAAuB,0BAAQ,CAAsB,KAAK,CAAC,EAAzD,KAAK,WAAA,EAAE,SAAS,eAAyC,CAAC;QAElE,IAAM,OAAO,GAAG,CACd,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC3B,KAAK,CAAC,SAAS,IAAI,6BAAK,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,GAAI;YAChF,SAAS,CAAC,IAAI,CAAC,QAAQ,CACb,CACd,CAAC;QAEF,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,oBAAC,qBAAM,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,OAAO,CAAU,CAAC;IAChE,CAAC,CAAC;IAfW,QAAA,6BAA6B,iCAexC","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';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots<PopoverSurfaceSlots>(state);\n\n const surface = (\n <slots.root {...slotProps.root}>\n {state.withArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {slotProps.root.children}\n </slots.root>\n );\n\n if (state.inline) {\n return surface;\n }\n\n return <Portal mountNode={state.mountNode}>{surface}</Portal>;\n};\n"]}
@@ -1,69 +0,0 @@
1
- define(["require", "exports", "tslib", "@fluentui/react-utilities", "@fluentui/react-tabster", "../../popoverContext"], function (require, exports, tslib_1, react_utilities_1, react_tabster_1, popoverContext_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePopoverSurface_unstable = void 0;
5
- /**
6
- * Create the state required to render PopoverSurface.
7
- *
8
- * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
9
- * before being passed to renderPopoverSurface_unstable.
10
- *
11
- * @param props - props from this instance of PopoverSurface
12
- * @param ref - reference to root HTMLDivElement of PopoverSurface
13
- */
14
- var usePopoverSurface_unstable = function (props, ref) {
15
- var contentRef = popoverContext_1.usePopoverContext_unstable(function (context) { return context.contentRef; });
16
- var openOnHover = popoverContext_1.usePopoverContext_unstable(function (context) { return context.openOnHover; });
17
- var setOpen = popoverContext_1.usePopoverContext_unstable(function (context) { return context.setOpen; });
18
- var mountNode = popoverContext_1.usePopoverContext_unstable(function (context) { return context.mountNode; });
19
- var arrowRef = popoverContext_1.usePopoverContext_unstable(function (context) { return context.arrowRef; });
20
- var size = popoverContext_1.usePopoverContext_unstable(function (context) { return context.size; });
21
- var withArrow = popoverContext_1.usePopoverContext_unstable(function (context) { return context.withArrow; });
22
- var appearance = popoverContext_1.usePopoverContext_unstable(function (context) { return context.appearance; });
23
- var trapFocus = popoverContext_1.usePopoverContext_unstable(function (context) { return context.trapFocus; });
24
- var inertTrapFocus = popoverContext_1.usePopoverContext_unstable(function (context) { return context.inertTrapFocus; });
25
- var inline = popoverContext_1.usePopoverContext_unstable(function (context) { return context.inline; });
26
- var modalAttributes = react_tabster_1.useModalAttributes({
27
- trapFocus: trapFocus,
28
- legacyTrapFocus: !inertTrapFocus,
29
- alwaysFocusable: !trapFocus,
30
- }).modalAttributes;
31
- var state = {
32
- inline: inline,
33
- appearance: appearance,
34
- withArrow: withArrow,
35
- size: size,
36
- arrowRef: arrowRef,
37
- mountNode: mountNode,
38
- components: {
39
- root: 'div',
40
- },
41
- root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({ ref: react_utilities_1.useMergedRefs(ref, contentRef), role: trapFocus ? 'dialog' : 'group', 'aria-modal': trapFocus ? true : undefined }, modalAttributes), props)),
42
- };
43
- var _a = state.root, onMouseEnterOriginal = _a.onMouseEnter, onMouseLeaveOriginal = _a.onMouseLeave, onKeyDownOriginal = _a.onKeyDown;
44
- state.root.onMouseEnter = function (e) {
45
- if (openOnHover) {
46
- setOpen(e, true);
47
- }
48
- onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
49
- };
50
- state.root.onMouseLeave = function (e) {
51
- if (openOnHover) {
52
- setOpen(e, false);
53
- }
54
- onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
55
- };
56
- state.root.onKeyDown = function (e) {
57
- var _a;
58
- // only close if the event happened inside the current popover
59
- // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
60
- if (e.key === 'Escape' && ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
61
- setOpen(e, false);
62
- }
63
- onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
64
- };
65
- return state;
66
- };
67
- exports.usePopoverSurface_unstable = usePopoverSurface_unstable;
68
- });
69
- //# sourceMappingURL=usePopoverSurface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePopoverSurface.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;IAMA;;;;;;;;OAQG;IACI,IAAM,0BAA0B,GAAG,UACxC,KAA0B,EAC1B,GAA8B;QAE9B,IAAM,UAAU,GAAG,2CAA0B,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU,EAAlB,CAAkB,CAAC,CAAC;QAC7E,IAAM,WAAW,GAAG,2CAA0B,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,EAAnB,CAAmB,CAAC,CAAC;QAC/E,IAAM,OAAO,GAAG,2CAA0B,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;QACvE,IAAM,SAAS,GAAG,2CAA0B,CAAC,UAAA,O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,EACnC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EACpC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,IACvC,eAAe,GACf,KAAK,EACR;SACH,CAAC;QAEI,IAAA,KAIF,KAAK,CAAC,IAAI,EAHE,oBAAoB,kBAAA,EACpB,oBAAoB,kBAAA,EACvB,iBAAiB,eAChB,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,UAAC,CAAmC;YAC5D,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClB;YAED,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,UAAC,CAAmC;YAC5D,IAAI,WAAW,EAAE;gBACf,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,UAAC,CAAsC;;YAC5D,8DAA8D;YAC9D,mHAAmH;YACnH,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,KAAI,MAAA,UAAU,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC,MAAwB,CAAC,CAAA,EAAE;gBAClF,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACnB;YAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAxEW,QAAA,0BAA0B,8BAwErC","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,\n * before being passed to renderPopoverSurface_unstable.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n */\nexport const usePopoverSurface_unstable = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLDivElement>,\n): PopoverSurfaceState => {\n const contentRef = usePopoverContext_unstable(context => context.contentRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const mountNode = usePopoverContext_unstable(context => context.mountNode);\n const arrowRef = usePopoverContext_unstable(context => context.arrowRef);\n const size = usePopoverContext_unstable(context => context.size);\n const withArrow = usePopoverContext_unstable(context => context.withArrow);\n const appearance = usePopoverContext_unstable(context => context.appearance);\n const trapFocus = usePopoverContext_unstable(context => context.trapFocus);\n const inertTrapFocus = usePopoverContext_unstable(context => context.inertTrapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const { modalAttributes } = useModalAttributes({\n trapFocus,\n legacyTrapFocus: !inertTrapFocus,\n alwaysFocusable: !trapFocus,\n });\n\n const state: PopoverSurfaceState = {\n inline,\n appearance,\n withArrow,\n size,\n arrowRef,\n mountNode,\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, contentRef),\n role: trapFocus ? 'dialog' : 'group',\n 'aria-modal': trapFocus ? true : undefined,\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 return state;\n};\n"]}
@@ -1,44 +0,0 @@
1
- define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-positioning", "@fluentui/react-theme"], function (require, exports, tslib_1, react_1, react_positioning_1, react_theme_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePopoverSurfaceStyles_unstable = exports.arrowHeights = exports.popoverSurfaceClassNames = void 0;
5
- exports.popoverSurfaceClassNames = {
6
- root: 'fui-PopoverSurface',
7
- };
8
- exports.arrowHeights = {
9
- small: 6,
10
- medium: 8,
11
- large: 8,
12
- };
13
- /**
14
- * Styles for the root slot
15
- */
16
- var useStyles = react_1.makeStyles({
17
- root: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ color: react_theme_1.tokens.colorNeutralForeground1, backgroundColor: react_theme_1.tokens.colorNeutralBackground1, boxShadow: react_theme_1.tokens.shadow16 }, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)), react_1.shorthands.border('1px', 'solid', react_theme_1.tokens.colorTransparentStroke)), react_theme_1.typographyStyles.body1),
18
- inverted: {
19
- backgroundColor: react_theme_1.tokens.colorNeutralBackgroundStatic,
20
- color: react_theme_1.tokens.colorNeutralForegroundStaticInverted,
21
- },
22
- brand: {
23
- backgroundColor: react_theme_1.tokens.colorBrandBackground,
24
- color: react_theme_1.tokens.colorNeutralForegroundOnBrand,
25
- },
26
- smallPadding: tslib_1.__assign({}, react_1.shorthands.padding('12px')),
27
- mediumPadding: tslib_1.__assign({}, react_1.shorthands.padding('16px')),
28
- largePadding: tslib_1.__assign({}, react_1.shorthands.padding('20px')),
29
- smallArrow: react_positioning_1.createArrowHeightStyles(exports.arrowHeights.small),
30
- mediumLargeArrow: react_positioning_1.createArrowHeightStyles(exports.arrowHeights.medium),
31
- arrow: react_positioning_1.createArrowStyles({ arrowHeight: undefined }),
32
- });
33
- /**
34
- * Apply styling to the PopoverSurface slots based on the state
35
- */
36
- var usePopoverSurfaceStyles_unstable = function (state) {
37
- var styles = useStyles();
38
- state.root.className = react_1.mergeClasses(exports.popoverSurfaceClassNames.root, styles.root, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.appearance === 'inverted' && styles.inverted, state.appearance === 'brand' && styles.brand, state.root.className);
39
- state.arrowClassName = react_1.mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
40
- return state;
41
- };
42
- exports.usePopoverSurfaceStyles_unstable = usePopoverSurfaceStyles_unstable;
43
- });
44
- //# sourceMappingURL=usePopoverSurfaceStyles.js.map