@react-stately/overlays 3.0.0-nightly-641446f65-240905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-stately/overlays
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,17 @@
1
+ import {useOverlayTriggerState as $fc909762b330b746$export$61c6a8c84e605fb6} from "./useOverlayTriggerState.mjs";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$fc909762b330b746$export$61c6a8c84e605fb6 as useOverlayTriggerState};
17
+ //# sourceMappingURL=module.js.map
package/dist/main.js ADDED
@@ -0,0 +1,22 @@
1
+ var $5076d97fb6884665$exports = require("./useOverlayTriggerState.main.js");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useOverlayTriggerState", () => $5076d97fb6884665$exports.useOverlayTriggerState);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/overlays/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useOverlayTriggerState} from './useOverlayTriggerState';\n\nexport type {OverlayTriggerProps} from '@react-types/overlays';\nexport type {OverlayTriggerState} from './useOverlayTriggerState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js ADDED
@@ -0,0 +1,17 @@
1
+ import {useOverlayTriggerState as $fc909762b330b746$export$61c6a8c84e605fb6} from "./useOverlayTriggerState.module.js";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$fc909762b330b746$export$61c6a8c84e605fb6 as useOverlayTriggerState};
17
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/overlays/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useOverlayTriggerState} from './useOverlayTriggerState';\n\nexport type {OverlayTriggerProps} from '@react-types/overlays';\nexport type {OverlayTriggerState} from './useOverlayTriggerState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,21 @@
1
+ import { OverlayTriggerProps } from "@react-types/overlays";
2
+ export interface OverlayTriggerState {
3
+ /** Whether the overlay is currently open. */
4
+ readonly isOpen: boolean;
5
+ /** Sets whether the overlay is open. */
6
+ setOpen(isOpen: boolean): void;
7
+ /** Opens the overlay. */
8
+ open(): void;
9
+ /** Closes the overlay. */
10
+ close(): void;
11
+ /** Toggles the overlay's visibility. */
12
+ toggle(): void;
13
+ }
14
+ /**
15
+ * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides
16
+ * methods to toggle this state.
17
+ */
18
+ export function useOverlayTriggerState(props: OverlayTriggerProps): OverlayTriggerState;
19
+ export type { OverlayTriggerProps } from '@react-types/overlays';
20
+
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";AAgBA;IACE,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,wCAAwC;IACxC,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,yBAAyB;IACzB,IAAI,IAAI,IAAI,CAAC;IACb,0BAA0B;IAC1B,KAAK,IAAI,IAAI,CAAC;IACd,wCAAwC;IACxC,MAAM,IAAI,IAAI,CAAA;CACf;AAED;;;GAGG;AACH,uCAAuC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAsBtF;ACzCD,YAAY,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-stately/overlays/src/packages/@react-stately/overlays/src/useOverlayTriggerState.ts","packages/@react-stately/overlays/src/packages/@react-stately/overlays/src/index.ts","packages/@react-stately/overlays/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useOverlayTriggerState} from './useOverlayTriggerState';\n\nexport type {OverlayTriggerProps} from '@react-types/overlays';\nexport type {OverlayTriggerState} from './useOverlayTriggerState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,50 @@
1
+ var $62yjz$react = require("react");
2
+ var $62yjz$reactstatelyutils = require("@react-stately/utils");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useOverlayTriggerState", () => $5076d97fb6884665$export$61c6a8c84e605fb6);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+
22
+ function $5076d97fb6884665$export$61c6a8c84e605fb6(props) {
23
+ let [isOpen, setOpen] = (0, $62yjz$reactstatelyutils.useControlledState)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
24
+ const open = (0, $62yjz$react.useCallback)(()=>{
25
+ setOpen(true);
26
+ }, [
27
+ setOpen
28
+ ]);
29
+ const close = (0, $62yjz$react.useCallback)(()=>{
30
+ setOpen(false);
31
+ }, [
32
+ setOpen
33
+ ]);
34
+ const toggle = (0, $62yjz$react.useCallback)(()=>{
35
+ setOpen(!isOpen);
36
+ }, [
37
+ setOpen,
38
+ isOpen
39
+ ]);
40
+ return {
41
+ isOpen: isOpen,
42
+ setOpen: setOpen,
43
+ open: open,
44
+ close: close,
45
+ toggle: toggle
46
+ };
47
+ }
48
+
49
+
50
+ //# sourceMappingURL=useOverlayTriggerState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAuBM,SAAS,0CAAuB,KAA0B;IAC/D,IAAI,CAAC,QAAQ,QAAQ,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,MAAM,EAAE,MAAM,WAAW,IAAI,OAAO,MAAM,YAAY;IAEvG,MAAM,OAAO,CAAA,GAAA,wBAAU,EAAE;QACvB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,QAAQ,CAAA,GAAA,wBAAU,EAAE;QACxB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,SAAS,CAAA,GAAA,wBAAU,EAAE;QACzB,QAAQ,CAAC;IACX,GAAG;QAAC;QAAS;KAAO;IAEpB,OAAO;gBACL;iBACA;cACA;eACA;gBACA;IACF;AACF","sources":["packages/@react-stately/overlays/src/useOverlayTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {OverlayTriggerProps} from '@react-types/overlays';\nimport {useCallback} from 'react';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface OverlayTriggerState {\n /** Whether the overlay is currently open. */\n readonly isOpen: boolean,\n /** Sets whether the overlay is open. */\n setOpen(isOpen: boolean): void,\n /** Opens the overlay. */\n open(): void,\n /** Closes the overlay. */\n close(): void,\n /** Toggles the overlay's visibility. */\n toggle(): void\n}\n\n/**\n * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides\n * methods to toggle this state.\n */\nexport function useOverlayTriggerState(props: OverlayTriggerProps): OverlayTriggerState {\n let [isOpen, setOpen] = useControlledState(props.isOpen, props.defaultOpen || false, props.onOpenChange);\n\n const open = useCallback(() => {\n setOpen(true);\n }, [setOpen]);\n\n const close = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const toggle = useCallback(() => {\n setOpen(!isOpen);\n }, [setOpen, isOpen]);\n\n return {\n isOpen,\n setOpen,\n open,\n close,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTriggerState.main.js.map"}
@@ -0,0 +1,45 @@
1
+ import {useCallback as $hnMvi$useCallback} from "react";
2
+ import {useControlledState as $hnMvi$useControlledState} from "@react-stately/utils";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
17
+ let [isOpen, setOpen] = (0, $hnMvi$useControlledState)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
18
+ const open = (0, $hnMvi$useCallback)(()=>{
19
+ setOpen(true);
20
+ }, [
21
+ setOpen
22
+ ]);
23
+ const close = (0, $hnMvi$useCallback)(()=>{
24
+ setOpen(false);
25
+ }, [
26
+ setOpen
27
+ ]);
28
+ const toggle = (0, $hnMvi$useCallback)(()=>{
29
+ setOpen(!isOpen);
30
+ }, [
31
+ setOpen,
32
+ isOpen
33
+ ]);
34
+ return {
35
+ isOpen: isOpen,
36
+ setOpen: setOpen,
37
+ open: open,
38
+ close: close,
39
+ toggle: toggle
40
+ };
41
+ }
42
+
43
+
44
+ export {$fc909762b330b746$export$61c6a8c84e605fb6 as useOverlayTriggerState};
45
+ //# sourceMappingURL=useOverlayTriggerState.module.js.map
@@ -0,0 +1,45 @@
1
+ import {useCallback as $hnMvi$useCallback} from "react";
2
+ import {useControlledState as $hnMvi$useControlledState} from "@react-stately/utils";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
17
+ let [isOpen, setOpen] = (0, $hnMvi$useControlledState)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
18
+ const open = (0, $hnMvi$useCallback)(()=>{
19
+ setOpen(true);
20
+ }, [
21
+ setOpen
22
+ ]);
23
+ const close = (0, $hnMvi$useCallback)(()=>{
24
+ setOpen(false);
25
+ }, [
26
+ setOpen
27
+ ]);
28
+ const toggle = (0, $hnMvi$useCallback)(()=>{
29
+ setOpen(!isOpen);
30
+ }, [
31
+ setOpen,
32
+ isOpen
33
+ ]);
34
+ return {
35
+ isOpen: isOpen,
36
+ setOpen: setOpen,
37
+ open: open,
38
+ close: close,
39
+ toggle: toggle
40
+ };
41
+ }
42
+
43
+
44
+ export {$fc909762b330b746$export$61c6a8c84e605fb6 as useOverlayTriggerState};
45
+ //# sourceMappingURL=useOverlayTriggerState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAuBM,SAAS,0CAAuB,KAA0B;IAC/D,IAAI,CAAC,QAAQ,QAAQ,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,MAAM,EAAE,MAAM,WAAW,IAAI,OAAO,MAAM,YAAY;IAEvG,MAAM,OAAO,CAAA,GAAA,kBAAU,EAAE;QACvB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,QAAQ,CAAA,GAAA,kBAAU,EAAE;QACxB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,QAAQ,CAAC;IACX,GAAG;QAAC;QAAS;KAAO;IAEpB,OAAO;gBACL;iBACA;cACA;eACA;gBACA;IACF;AACF","sources":["packages/@react-stately/overlays/src/useOverlayTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {OverlayTriggerProps} from '@react-types/overlays';\nimport {useCallback} from 'react';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface OverlayTriggerState {\n /** Whether the overlay is currently open. */\n readonly isOpen: boolean,\n /** Sets whether the overlay is open. */\n setOpen(isOpen: boolean): void,\n /** Opens the overlay. */\n open(): void,\n /** Closes the overlay. */\n close(): void,\n /** Toggles the overlay's visibility. */\n toggle(): void\n}\n\n/**\n * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides\n * methods to toggle this state.\n */\nexport function useOverlayTriggerState(props: OverlayTriggerProps): OverlayTriggerState {\n let [isOpen, setOpen] = useControlledState(props.isOpen, props.defaultOpen || false, props.onOpenChange);\n\n const open = useCallback(() => {\n setOpen(true);\n }, [setOpen]);\n\n const close = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const toggle = useCallback(() => {\n setOpen(!isOpen);\n }, [setOpen, isOpen]);\n\n return {\n isOpen,\n setOpen,\n open,\n close,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTriggerState.module.js.map"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@react-stately/overlays",
3
+ "version": "3.0.0-nightly-641446f65-240905",
4
+ "description": "Spectrum UI components in React",
5
+ "license": "Apache-2.0",
6
+ "main": "dist/main.js",
7
+ "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
13
+ "types": "dist/types.d.ts",
14
+ "source": "src/index.ts",
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "sideEffects": false,
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/adobe/react-spectrum"
23
+ },
24
+ "dependencies": {
25
+ "@react-stately/utils": "^3.0.0-nightly-641446f65-240905",
26
+ "@react-types/overlays": "^3.0.0-nightly-641446f65-240905",
27
+ "@swc/helpers": "^0.5.0"
28
+ },
29
+ "peerDependencies": {
30
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "stableVersion": "3.6.10"
36
+ }
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ export {useOverlayTriggerState} from './useOverlayTriggerState';
14
+
15
+ export type {OverlayTriggerProps} from '@react-types/overlays';
16
+ export type {OverlayTriggerState} from './useOverlayTriggerState';
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {OverlayTriggerProps} from '@react-types/overlays';
14
+ import {useCallback} from 'react';
15
+ import {useControlledState} from '@react-stately/utils';
16
+
17
+ export interface OverlayTriggerState {
18
+ /** Whether the overlay is currently open. */
19
+ readonly isOpen: boolean,
20
+ /** Sets whether the overlay is open. */
21
+ setOpen(isOpen: boolean): void,
22
+ /** Opens the overlay. */
23
+ open(): void,
24
+ /** Closes the overlay. */
25
+ close(): void,
26
+ /** Toggles the overlay's visibility. */
27
+ toggle(): void
28
+ }
29
+
30
+ /**
31
+ * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides
32
+ * methods to toggle this state.
33
+ */
34
+ export function useOverlayTriggerState(props: OverlayTriggerProps): OverlayTriggerState {
35
+ let [isOpen, setOpen] = useControlledState(props.isOpen, props.defaultOpen || false, props.onOpenChange);
36
+
37
+ const open = useCallback(() => {
38
+ setOpen(true);
39
+ }, [setOpen]);
40
+
41
+ const close = useCallback(() => {
42
+ setOpen(false);
43
+ }, [setOpen]);
44
+
45
+ const toggle = useCallback(() => {
46
+ setOpen(!isOpen);
47
+ }, [setOpen, isOpen]);
48
+
49
+ return {
50
+ isOpen,
51
+ setOpen,
52
+ open,
53
+ close,
54
+ toggle
55
+ };
56
+ }