@react-spectrum/dialog 3.8.9 → 3.8.11

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.
Files changed (51) hide show
  1. package/dist/AlertDialog.main.js +98 -0
  2. package/dist/AlertDialog.main.js.map +1 -0
  3. package/dist/AlertDialog.mjs +93 -0
  4. package/dist/AlertDialog.module.js +93 -0
  5. package/dist/AlertDialog.module.js.map +1 -0
  6. package/dist/Dialog.main.js +135 -0
  7. package/dist/Dialog.main.js.map +1 -0
  8. package/dist/Dialog.mjs +130 -0
  9. package/dist/Dialog.module.js +130 -0
  10. package/dist/Dialog.module.js.map +1 -0
  11. package/dist/DialogContainer.main.js +63 -0
  12. package/dist/DialogContainer.main.js.map +1 -0
  13. package/dist/DialogContainer.mjs +54 -0
  14. package/dist/DialogContainer.module.js +54 -0
  15. package/dist/DialogContainer.module.js.map +1 -0
  16. package/dist/DialogTrigger.main.js +162 -0
  17. package/dist/DialogTrigger.main.js.map +1 -0
  18. package/dist/DialogTrigger.mjs +153 -0
  19. package/dist/DialogTrigger.module.js +153 -0
  20. package/dist/DialogTrigger.module.js.map +1 -0
  21. package/dist/context.main.js +27 -0
  22. package/dist/context.main.js.map +1 -0
  23. package/dist/context.mjs +18 -0
  24. package/dist/context.module.js +18 -0
  25. package/dist/context.module.js.map +1 -0
  26. package/dist/dialog_vars_css.main.js +161 -0
  27. package/dist/dialog_vars_css.main.js.map +1 -0
  28. package/dist/dialog_vars_css.mjs +163 -0
  29. package/dist/dialog_vars_css.module.js +163 -0
  30. package/dist/dialog_vars_css.module.js.map +1 -0
  31. package/dist/import.mjs +5 -692
  32. package/dist/intlStrings.main.js +108 -0
  33. package/dist/intlStrings.main.js.map +1 -0
  34. package/dist/intlStrings.mjs +110 -0
  35. package/dist/intlStrings.module.js +110 -0
  36. package/dist/intlStrings.module.js.map +1 -0
  37. package/dist/main.js +10 -693
  38. package/dist/main.js.map +1 -1
  39. package/dist/module.js +5 -692
  40. package/dist/module.js.map +1 -1
  41. package/dist/types.d.ts +3 -2
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/useDialogContainer.main.js +34 -0
  44. package/dist/useDialogContainer.main.js.map +1 -0
  45. package/dist/useDialogContainer.mjs +29 -0
  46. package/dist/useDialogContainer.module.js +29 -0
  47. package/dist/useDialogContainer.module.js.map +1 -0
  48. package/dist/{main.css → vars.6a3d7df3.css} +22 -63
  49. package/dist/vars.6a3d7df3.css.map +1 -0
  50. package/package.json +21 -21
  51. package/dist/main.css.map +0 -1
@@ -0,0 +1,130 @@
1
+ import {DialogContext as $97b119e05830ea0d$export$8b93a07348a7730c} from "./context.module.js";
2
+ import $3e38X$intlStringsmodulejs from "./intlStrings.module.js";
3
+ import "./vars.6a3d7df3.css";
4
+ import $3e38X$dialog_vars_cssmodulejs from "./dialog_vars_css.module.js";
5
+ import {ActionButton as $3e38X$ActionButton} from "@react-spectrum/button";
6
+ import {useSlotProps as $3e38X$useSlotProps, useStyleProps as $3e38X$useStyleProps, useDOMRef as $3e38X$useDOMRef, useHasChild as $3e38X$useHasChild, unwrapDOMRef as $3e38X$unwrapDOMRef, classNames as $3e38X$classNames, SlotProvider as $3e38X$SlotProvider} from "@react-spectrum/utils";
7
+ import $3e38X$spectrumiconsuiCrossLarge from "@spectrum-icons/ui/CrossLarge";
8
+ import {Grid as $3e38X$Grid} from "@react-spectrum/layout";
9
+ import {mergeProps as $3e38X$mergeProps} from "@react-aria/utils";
10
+ import $3e38X$react, {useContext as $3e38X$useContext, useRef as $3e38X$useRef, useMemo as $3e38X$useMemo} from "react";
11
+ import {useDialog as $3e38X$useDialog} from "@react-aria/dialog";
12
+ import {useLocalizedStringFormatter as $3e38X$useLocalizedStringFormatter} from "@react-aria/i18n";
13
+
14
+
15
+ function $parcel$interopDefault(a) {
16
+ return a && a.__esModule ? a.default : a;
17
+ }
18
+ /*
19
+ * Copyright 2020 Adobe. All rights reserved.
20
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License. You may obtain a copy
22
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software distributed under
25
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
26
+ * OF ANY KIND, either express or implied. See the License for the specific language
27
+ * governing permissions and limitations under the License.
28
+ */
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ let $99cd51dc4eb569f7$var$sizeMap = {
40
+ S: 'small',
41
+ M: 'medium',
42
+ L: 'large',
43
+ fullscreen: 'fullscreen',
44
+ fullscreenTakeover: 'fullscreenTakeover'
45
+ };
46
+ function $99cd51dc4eb569f7$var$Dialog(props, ref) {
47
+ props = (0, $3e38X$useSlotProps)(props, 'dialog');
48
+ let { type: type = 'modal', ...contextProps } = (0, $3e38X$useContext)((0, $97b119e05830ea0d$export$8b93a07348a7730c)) || {};
49
+ let { children: children, isDismissable: isDismissable = contextProps.isDismissable, onDismiss: onDismiss = contextProps.onClose, size: size, ...otherProps } = props;
50
+ let stringFormatter = (0, $3e38X$useLocalizedStringFormatter)((0, ($parcel$interopDefault($3e38X$intlStringsmodulejs))), '@react-spectrum/dialog');
51
+ let { styleProps: styleProps } = (0, $3e38X$useStyleProps)(otherProps);
52
+ size = type === 'popover' ? size || 'S' : size || 'L';
53
+ let domRef = (0, $3e38X$useDOMRef)(ref);
54
+ let gridRef = (0, $3e38X$useRef)(null);
55
+ let sizeVariant = $99cd51dc4eb569f7$var$sizeMap[type] || $99cd51dc4eb569f7$var$sizeMap[size];
56
+ let { dialogProps: dialogProps, titleProps: titleProps } = (0, $3e38X$useDialog)((0, $3e38X$mergeProps)(contextProps, props), domRef);
57
+ let hasHeader = (0, $3e38X$useHasChild)(`.${(0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-header']}`, (0, $3e38X$unwrapDOMRef)(gridRef));
58
+ let hasHeading = (0, $3e38X$useHasChild)(`.${(0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-heading']}`, (0, $3e38X$unwrapDOMRef)(gridRef));
59
+ let hasFooter = (0, $3e38X$useHasChild)(`.${(0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-footer']}`, (0, $3e38X$unwrapDOMRef)(gridRef));
60
+ let hasTypeIcon = (0, $3e38X$useHasChild)(`.${(0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-typeIcon']}`, (0, $3e38X$unwrapDOMRef)(gridRef));
61
+ let slots = (0, $3e38X$useMemo)(()=>({
62
+ hero: {
63
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-hero']
64
+ },
65
+ heading: {
66
+ UNSAFE_className: (0, $3e38X$classNames)((0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs))), 'spectrum-Dialog-heading', {
67
+ 'spectrum-Dialog-heading--noHeader': !hasHeader,
68
+ 'spectrum-Dialog-heading--noTypeIcon': !hasTypeIcon
69
+ }),
70
+ level: 2,
71
+ ...titleProps
72
+ },
73
+ header: {
74
+ UNSAFE_className: (0, $3e38X$classNames)((0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs))), 'spectrum-Dialog-header', {
75
+ 'spectrum-Dialog-header--noHeading': !hasHeading,
76
+ 'spectrum-Dialog-header--noTypeIcon': !hasTypeIcon
77
+ })
78
+ },
79
+ typeIcon: {
80
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-typeIcon']
81
+ },
82
+ divider: {
83
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-divider'],
84
+ size: 'M'
85
+ },
86
+ content: {
87
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-content']
88
+ },
89
+ footer: {
90
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-footer']
91
+ },
92
+ buttonGroup: {
93
+ UNSAFE_className: (0, $3e38X$classNames)((0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs))), 'spectrum-Dialog-buttonGroup', {
94
+ 'spectrum-Dialog-buttonGroup--noFooter': !hasFooter
95
+ }),
96
+ align: 'end'
97
+ }
98
+ }), [
99
+ hasFooter,
100
+ hasHeader,
101
+ titleProps
102
+ ]);
103
+ return /*#__PURE__*/ (0, $3e38X$react).createElement("section", {
104
+ ...styleProps,
105
+ ...dialogProps,
106
+ className: (0, $3e38X$classNames)((0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs))), 'spectrum-Dialog', {
107
+ [`spectrum-Dialog--${sizeVariant}`]: sizeVariant,
108
+ 'spectrum-Dialog--dismissable': isDismissable
109
+ }, styleProps.className),
110
+ ref: domRef
111
+ }, /*#__PURE__*/ (0, $3e38X$react).createElement((0, $3e38X$Grid), {
112
+ ref: gridRef,
113
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-grid']
114
+ }, /*#__PURE__*/ (0, $3e38X$react).createElement((0, $3e38X$SlotProvider), {
115
+ slots: slots
116
+ }, children), isDismissable && /*#__PURE__*/ (0, $3e38X$react).createElement((0, $3e38X$ActionButton), {
117
+ UNSAFE_className: (0, ($parcel$interopDefault($3e38X$dialog_vars_cssmodulejs)))['spectrum-Dialog-closeButton'],
118
+ isQuiet: true,
119
+ "aria-label": stringFormatter.format('dismiss'),
120
+ onPress: onDismiss
121
+ }, /*#__PURE__*/ (0, $3e38X$react).createElement((0, $3e38X$spectrumiconsuiCrossLarge), null))));
122
+ }
123
+ /**
124
+ * Dialogs are windows containing contextual information, tasks, or workflows that appear over the user interface.
125
+ * Depending on the kind of Dialog, further interactions may be blocked until the Dialog is acknowledged.
126
+ */ let $99cd51dc4eb569f7$export$3ddf2d174ce01153 = /*#__PURE__*/ (0, $3e38X$react).forwardRef($99cd51dc4eb569f7$var$Dialog);
127
+
128
+
129
+ export {$99cd51dc4eb569f7$export$3ddf2d174ce01153 as Dialog};
130
+ //# sourceMappingURL=Dialog.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"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","sources":["packages/@react-spectrum/dialog/src/Dialog.tsx"],"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 {ActionButton} from '@react-spectrum/button';\nimport {\n classNames,\n SlotProvider,\n unwrapDOMRef,\n useDOMRef,\n useHasChild,\n useSlotProps,\n useStyleProps\n} from '@react-spectrum/utils';\nimport CrossLarge from '@spectrum-icons/ui/CrossLarge';\nimport {DialogContext, DialogContextValue} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {Grid} from '@react-spectrum/layout';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {useContext, useMemo, useRef} from 'react';\nimport {SpectrumDialogProps} from '@react-types/dialog';\nimport styles from '@adobe/spectrum-css-temp/components/dialog/vars.css';\nimport {useDialog} from '@react-aria/dialog';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nlet sizeMap = {\n S: 'small',\n M: 'medium',\n L: 'large',\n fullscreen: 'fullscreen',\n fullscreenTakeover: 'fullscreenTakeover'\n};\n\nfunction Dialog(props: SpectrumDialogProps, ref: DOMRef) {\n props = useSlotProps(props, 'dialog');\n let {\n type = 'modal',\n ...contextProps\n } = useContext(DialogContext) || {} as DialogContextValue;\n let {\n children,\n isDismissable = contextProps.isDismissable,\n onDismiss = contextProps.onClose,\n size,\n ...otherProps\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/dialog');\n let {styleProps} = useStyleProps(otherProps);\n\n size = type === 'popover' ? (size || 'S') : (size || 'L');\n\n let domRef = useDOMRef(ref);\n let gridRef = useRef(null);\n let sizeVariant = sizeMap[type] || sizeMap[size];\n let {dialogProps, titleProps} = useDialog(mergeProps(contextProps, props), domRef);\n\n let hasHeader = useHasChild(`.${styles['spectrum-Dialog-header']}`, unwrapDOMRef(gridRef));\n let hasHeading = useHasChild(`.${styles['spectrum-Dialog-heading']}`, unwrapDOMRef(gridRef));\n let hasFooter = useHasChild(`.${styles['spectrum-Dialog-footer']}`, unwrapDOMRef(gridRef));\n let hasTypeIcon = useHasChild(`.${styles['spectrum-Dialog-typeIcon']}`, unwrapDOMRef(gridRef));\n\n let slots = useMemo(() => ({\n hero: {UNSAFE_className: styles['spectrum-Dialog-hero']},\n heading: {UNSAFE_className: classNames(styles, 'spectrum-Dialog-heading', {'spectrum-Dialog-heading--noHeader': !hasHeader, 'spectrum-Dialog-heading--noTypeIcon': !hasTypeIcon}), level: 2, ...titleProps},\n header: {UNSAFE_className: classNames(styles, 'spectrum-Dialog-header', {'spectrum-Dialog-header--noHeading': !hasHeading, 'spectrum-Dialog-header--noTypeIcon': !hasTypeIcon})},\n typeIcon: {UNSAFE_className: styles['spectrum-Dialog-typeIcon']},\n divider: {UNSAFE_className: styles['spectrum-Dialog-divider'], size: 'M'},\n content: {UNSAFE_className: styles['spectrum-Dialog-content']},\n footer: {UNSAFE_className: styles['spectrum-Dialog-footer']},\n buttonGroup: {UNSAFE_className: classNames(styles, 'spectrum-Dialog-buttonGroup', {'spectrum-Dialog-buttonGroup--noFooter': !hasFooter}), align: 'end'}\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [hasFooter, hasHeader, titleProps]);\n\n return (\n <section\n {...styleProps}\n {...dialogProps}\n className={classNames(\n styles,\n 'spectrum-Dialog',\n {\n [`spectrum-Dialog--${sizeVariant}`]: sizeVariant,\n 'spectrum-Dialog--dismissable': isDismissable\n },\n styleProps.className\n )}\n ref={domRef}>\n <Grid ref={gridRef} UNSAFE_className={styles['spectrum-Dialog-grid']}>\n <SlotProvider slots={slots}>\n {children}\n </SlotProvider>\n {isDismissable &&\n <ActionButton\n UNSAFE_className={styles['spectrum-Dialog-closeButton']}\n isQuiet\n aria-label={stringFormatter.format('dismiss')}\n onPress={onDismiss}>\n <CrossLarge />\n </ActionButton>\n }\n </Grid>\n </section>\n );\n}\n\n/**\n * Dialogs are windows containing contextual information, tasks, or workflows that appear over the user interface.\n * Depending on the kind of Dialog, further interactions may be blocked until the Dialog is acknowledged.\n */\nlet _Dialog = React.forwardRef(Dialog);\nexport {_Dialog as Dialog};\n"],"names":[],"version":3,"file":"Dialog.module.js.map"}
@@ -0,0 +1,63 @@
1
+ var $0eb909ad2388d989$exports = require("./context.main.js");
2
+ var $k1djg$reactspectrumoverlays = require("@react-spectrum/overlays");
3
+ var $k1djg$react = require("react");
4
+ var $k1djg$reactstatelyoverlays = require("@react-stately/overlays");
5
+
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+
11
+ function $parcel$export(e, n, v, s) {
12
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
+ }
14
+
15
+ $parcel$export(module.exports, "DialogContainer", () => $1b7050825e0eb5b6$export$547754aada6e339f);
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+ function $1b7050825e0eb5b6$export$547754aada6e339f(props) {
31
+ let { children: children, type: type = 'modal', onDismiss: onDismiss, isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled } = props;
32
+ let childArray = (0, ($parcel$interopDefault($k1djg$react))).Children.toArray(children);
33
+ if (childArray.length > 1) throw new Error('Only a single child can be passed to DialogContainer.');
34
+ let [lastChild, setLastChild] = (0, $k1djg$react.useState)(null);
35
+ // React.Children.toArray mutates the children, and we need them to be stable
36
+ // between renders so that the lastChild comparison works.
37
+ let child = undefined;
38
+ if (Array.isArray(children)) child = children.find((0, ($parcel$interopDefault($k1djg$react))).isValidElement);
39
+ else if (/*#__PURE__*/ (0, ($parcel$interopDefault($k1djg$react))).isValidElement(children)) child = children;
40
+ if (child && child !== lastChild) setLastChild(child);
41
+ let context = {
42
+ type: type,
43
+ onClose: onDismiss,
44
+ isDismissable: isDismissable
45
+ };
46
+ let state = (0, $k1djg$reactstatelyoverlays.useOverlayTriggerState)({
47
+ isOpen: !!child,
48
+ onOpenChange: (isOpen)=>{
49
+ if (!isOpen) onDismiss();
50
+ }
51
+ });
52
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($k1djg$react))).createElement((0, $k1djg$reactspectrumoverlays.Modal), {
53
+ state: state,
54
+ type: type,
55
+ isDismissable: isDismissable,
56
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled
57
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($k1djg$react))).createElement((0, $0eb909ad2388d989$exports.DialogContext).Provider, {
58
+ value: context
59
+ }, lastChild));
60
+ }
61
+
62
+
63
+ //# sourceMappingURL=DialogContainer.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAaM,SAAS,0CAAgB,KAAmC;IACjE,IAAI,YACF,QAAQ,QACR,OAAO,oBACP,SAAS,iBACT,aAAa,6BACb,yBAAyB,EAC1B,GAAG;IAEJ,IAAI,aAAa,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;IACxC,IAAI,WAAW,MAAM,GAAG,GACtB,MAAM,IAAI,MAAM;IAGlB,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAuB;IAE9D,6EAA6E;IAC7E,0DAA0D;IAC1D,IAAI,QAAkC;IACtC,IAAI,MAAM,OAAO,CAAC,WAChB,QAAQ,SAAS,IAAI,CAAC,CAAA,GAAA,sCAAI,EAAE,cAAc;SACrC,kBAAI,CAAA,GAAA,sCAAI,EAAE,cAAc,CAAC,WAC9B,QAAQ;IAGV,IAAI,SAAS,UAAU,WACrB,aAAa;IAGf,IAAI,UAAU;cACZ;QACA,SAAS;uBACT;IACF;IAEA,IAAI,QAAQ,CAAA,GAAA,kDAAqB,EAAE;QACjC,QAAQ,CAAC,CAAC;QACV,cAAc,CAAA;YACZ,IAAI,CAAC,QACH;QAEJ;IACF;IAEA,qBACE,0DAAC,CAAA,GAAA,kCAAI;QACH,OAAO;QACP,MAAM;QACN,eAAe;QACf,2BAA2B;qBAC3B,0DAAC,CAAA,GAAA,uCAAY,EAAE,QAAQ;QAAC,OAAO;OAC5B;AAIT","sources":["packages/@react-spectrum/dialog/src/DialogContainer.tsx"],"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 {DialogContext} from './context';\nimport {Modal} from '@react-spectrum/overlays';\nimport React, {ReactElement, useState} from 'react';\nimport {SpectrumDialogContainerProps} from '@react-types/dialog';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\n/**\n * A DialogContainer accepts a single Dialog as a child, and manages showing and hiding\n * it in a modal. Useful in cases where there is no trigger element\n * or when the trigger unmounts while the dialog is open.\n */\nexport function DialogContainer(props: SpectrumDialogContainerProps) {\n let {\n children,\n type = 'modal',\n onDismiss,\n isDismissable,\n isKeyboardDismissDisabled\n } = props;\n\n let childArray = React.Children.toArray(children);\n if (childArray.length > 1) {\n throw new Error('Only a single child can be passed to DialogContainer.');\n }\n\n let [lastChild, setLastChild] = useState<ReactElement | null>(null);\n\n // React.Children.toArray mutates the children, and we need them to be stable\n // between renders so that the lastChild comparison works.\n let child: ReactElement | undefined = undefined;\n if (Array.isArray(children)) {\n child = children.find(React.isValidElement);\n } else if (React.isValidElement(children)) {\n child = children;\n }\n\n if (child && child !== lastChild) {\n setLastChild(child);\n }\n\n let context = {\n type,\n onClose: onDismiss,\n isDismissable\n };\n\n let state = useOverlayTriggerState({\n isOpen: !!child,\n onOpenChange: isOpen => {\n if (!isOpen) {\n onDismiss();\n }\n }\n });\n\n return (\n <Modal\n state={state}\n type={type}\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}>\n <DialogContext.Provider value={context}>\n {lastChild}\n </DialogContext.Provider>\n </Modal>\n );\n}\n"],"names":[],"version":3,"file":"DialogContainer.main.js.map"}
@@ -0,0 +1,54 @@
1
+ import {DialogContext as $97b119e05830ea0d$export$8b93a07348a7730c} from "./context.mjs";
2
+ import {Modal as $2W2Rs$Modal} from "@react-spectrum/overlays";
3
+ import $2W2Rs$react, {useState as $2W2Rs$useState} from "react";
4
+ import {useOverlayTriggerState as $2W2Rs$useOverlayTriggerState} from "@react-stately/overlays";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ function $2a9f0ad39ddaa8d9$export$547754aada6e339f(props) {
21
+ let { children: children, type: type = 'modal', onDismiss: onDismiss, isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled } = props;
22
+ let childArray = (0, $2W2Rs$react).Children.toArray(children);
23
+ if (childArray.length > 1) throw new Error('Only a single child can be passed to DialogContainer.');
24
+ let [lastChild, setLastChild] = (0, $2W2Rs$useState)(null);
25
+ // React.Children.toArray mutates the children, and we need them to be stable
26
+ // between renders so that the lastChild comparison works.
27
+ let child = undefined;
28
+ if (Array.isArray(children)) child = children.find((0, $2W2Rs$react).isValidElement);
29
+ else if (/*#__PURE__*/ (0, $2W2Rs$react).isValidElement(children)) child = children;
30
+ if (child && child !== lastChild) setLastChild(child);
31
+ let context = {
32
+ type: type,
33
+ onClose: onDismiss,
34
+ isDismissable: isDismissable
35
+ };
36
+ let state = (0, $2W2Rs$useOverlayTriggerState)({
37
+ isOpen: !!child,
38
+ onOpenChange: (isOpen)=>{
39
+ if (!isOpen) onDismiss();
40
+ }
41
+ });
42
+ return /*#__PURE__*/ (0, $2W2Rs$react).createElement((0, $2W2Rs$Modal), {
43
+ state: state,
44
+ type: type,
45
+ isDismissable: isDismissable,
46
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled
47
+ }, /*#__PURE__*/ (0, $2W2Rs$react).createElement((0, $97b119e05830ea0d$export$8b93a07348a7730c).Provider, {
48
+ value: context
49
+ }, lastChild));
50
+ }
51
+
52
+
53
+ export {$2a9f0ad39ddaa8d9$export$547754aada6e339f as DialogContainer};
54
+ //# sourceMappingURL=DialogContainer.module.js.map
@@ -0,0 +1,54 @@
1
+ import {DialogContext as $97b119e05830ea0d$export$8b93a07348a7730c} from "./context.module.js";
2
+ import {Modal as $2W2Rs$Modal} from "@react-spectrum/overlays";
3
+ import $2W2Rs$react, {useState as $2W2Rs$useState} from "react";
4
+ import {useOverlayTriggerState as $2W2Rs$useOverlayTriggerState} from "@react-stately/overlays";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ function $2a9f0ad39ddaa8d9$export$547754aada6e339f(props) {
21
+ let { children: children, type: type = 'modal', onDismiss: onDismiss, isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled } = props;
22
+ let childArray = (0, $2W2Rs$react).Children.toArray(children);
23
+ if (childArray.length > 1) throw new Error('Only a single child can be passed to DialogContainer.');
24
+ let [lastChild, setLastChild] = (0, $2W2Rs$useState)(null);
25
+ // React.Children.toArray mutates the children, and we need them to be stable
26
+ // between renders so that the lastChild comparison works.
27
+ let child = undefined;
28
+ if (Array.isArray(children)) child = children.find((0, $2W2Rs$react).isValidElement);
29
+ else if (/*#__PURE__*/ (0, $2W2Rs$react).isValidElement(children)) child = children;
30
+ if (child && child !== lastChild) setLastChild(child);
31
+ let context = {
32
+ type: type,
33
+ onClose: onDismiss,
34
+ isDismissable: isDismissable
35
+ };
36
+ let state = (0, $2W2Rs$useOverlayTriggerState)({
37
+ isOpen: !!child,
38
+ onOpenChange: (isOpen)=>{
39
+ if (!isOpen) onDismiss();
40
+ }
41
+ });
42
+ return /*#__PURE__*/ (0, $2W2Rs$react).createElement((0, $2W2Rs$Modal), {
43
+ state: state,
44
+ type: type,
45
+ isDismissable: isDismissable,
46
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled
47
+ }, /*#__PURE__*/ (0, $2W2Rs$react).createElement((0, $97b119e05830ea0d$export$8b93a07348a7730c).Provider, {
48
+ value: context
49
+ }, lastChild));
50
+ }
51
+
52
+
53
+ export {$2a9f0ad39ddaa8d9$export$547754aada6e339f as DialogContainer};
54
+ //# sourceMappingURL=DialogContainer.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAaM,SAAS,0CAAgB,KAAmC;IACjE,IAAI,YACF,QAAQ,QACR,OAAO,oBACP,SAAS,iBACT,aAAa,6BACb,yBAAyB,EAC1B,GAAG;IAEJ,IAAI,aAAa,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;IACxC,IAAI,WAAW,MAAM,GAAG,GACtB,MAAM,IAAI,MAAM;IAGlB,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAuB;IAE9D,6EAA6E;IAC7E,0DAA0D;IAC1D,IAAI,QAAkC;IACtC,IAAI,MAAM,OAAO,CAAC,WAChB,QAAQ,SAAS,IAAI,CAAC,CAAA,GAAA,YAAI,EAAE,cAAc;SACrC,kBAAI,CAAA,GAAA,YAAI,EAAE,cAAc,CAAC,WAC9B,QAAQ;IAGV,IAAI,SAAS,UAAU,WACrB,aAAa;IAGf,IAAI,UAAU;cACZ;QACA,SAAS;uBACT;IACF;IAEA,IAAI,QAAQ,CAAA,GAAA,6BAAqB,EAAE;QACjC,QAAQ,CAAC,CAAC;QACV,cAAc,CAAA;YACZ,IAAI,CAAC,QACH;QAEJ;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,YAAI;QACH,OAAO;QACP,MAAM;QACN,eAAe;QACf,2BAA2B;qBAC3B,gCAAC,CAAA,GAAA,yCAAY,EAAE,QAAQ;QAAC,OAAO;OAC5B;AAIT","sources":["packages/@react-spectrum/dialog/src/DialogContainer.tsx"],"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 {DialogContext} from './context';\nimport {Modal} from '@react-spectrum/overlays';\nimport React, {ReactElement, useState} from 'react';\nimport {SpectrumDialogContainerProps} from '@react-types/dialog';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\n/**\n * A DialogContainer accepts a single Dialog as a child, and manages showing and hiding\n * it in a modal. Useful in cases where there is no trigger element\n * or when the trigger unmounts while the dialog is open.\n */\nexport function DialogContainer(props: SpectrumDialogContainerProps) {\n let {\n children,\n type = 'modal',\n onDismiss,\n isDismissable,\n isKeyboardDismissDisabled\n } = props;\n\n let childArray = React.Children.toArray(children);\n if (childArray.length > 1) {\n throw new Error('Only a single child can be passed to DialogContainer.');\n }\n\n let [lastChild, setLastChild] = useState<ReactElement | null>(null);\n\n // React.Children.toArray mutates the children, and we need them to be stable\n // between renders so that the lastChild comparison works.\n let child: ReactElement | undefined = undefined;\n if (Array.isArray(children)) {\n child = children.find(React.isValidElement);\n } else if (React.isValidElement(children)) {\n child = children;\n }\n\n if (child && child !== lastChild) {\n setLastChild(child);\n }\n\n let context = {\n type,\n onClose: onDismiss,\n isDismissable\n };\n\n let state = useOverlayTriggerState({\n isOpen: !!child,\n onOpenChange: isOpen => {\n if (!isOpen) {\n onDismiss();\n }\n }\n });\n\n return (\n <Modal\n state={state}\n type={type}\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}>\n <DialogContext.Provider value={context}>\n {lastChild}\n </DialogContext.Provider>\n </Modal>\n );\n}\n"],"names":[],"version":3,"file":"DialogContainer.module.js.map"}
@@ -0,0 +1,162 @@
1
+ var $0eb909ad2388d989$exports = require("./context.main.js");
2
+ var $7xftW$reactspectrumoverlays = require("@react-spectrum/overlays");
3
+ var $7xftW$reactstatelyoverlays = require("@react-stately/overlays");
4
+ var $7xftW$reactariainteractions = require("@react-aria/interactions");
5
+ var $7xftW$react = require("react");
6
+ var $7xftW$reactspectrumutils = require("@react-spectrum/utils");
7
+ var $7xftW$reactariaoverlays = require("@react-aria/overlays");
8
+
9
+
10
+ function $parcel$interopDefault(a) {
11
+ return a && a.__esModule ? a.default : a;
12
+ }
13
+
14
+ function $parcel$export(e, n, v, s) {
15
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
+ }
17
+
18
+ $parcel$export(module.exports, "DialogTrigger", () => $46e54a192dc519c9$export$2e1e1122cf0cba88);
19
+ /*
20
+ * Copyright 2020 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */
30
+
31
+
32
+
33
+
34
+
35
+
36
+ function $46e54a192dc519c9$var$DialogTrigger(props) {
37
+ let { children: children, type: type = 'modal', mobileType: mobileType = type === 'popover' ? 'modal' : type, hideArrow: hideArrow, targetRef: targetRef, isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled, ...positionProps } = props;
38
+ if (!Array.isArray(children) || children.length > 2) throw new Error('DialogTrigger must have exactly 2 children');
39
+ // if a function is passed as the second child, it won't appear in toArray
40
+ let [trigger, content] = children;
41
+ // On small devices, show a modal or tray instead of a popover.
42
+ let isMobile = (0, $7xftW$reactspectrumutils.useIsMobileDevice)();
43
+ if (isMobile) {
44
+ // handle cases where desktop popovers need a close button for the mobile modal view
45
+ if (type !== 'modal' && mobileType === 'modal') isDismissable = true;
46
+ type = mobileType;
47
+ }
48
+ let state = (0, $7xftW$reactstatelyoverlays.useOverlayTriggerState)(props);
49
+ let wasOpen = (0, $7xftW$react.useRef)(false);
50
+ (0, $7xftW$react.useEffect)(()=>{
51
+ wasOpen.current = state.isOpen;
52
+ }, [
53
+ state.isOpen
54
+ ]);
55
+ let isExiting = (0, $7xftW$react.useRef)(false);
56
+ let onExiting = ()=>isExiting.current = true;
57
+ let onExited = ()=>isExiting.current = false;
58
+ // eslint-disable-next-line arrow-body-style
59
+ (0, $7xftW$react.useEffect)(()=>{
60
+ return ()=>{
61
+ if ((wasOpen.current || isExiting.current) && type !== 'popover' && type !== 'tray') console.warn('A DialogTrigger unmounted while open. This is likely due to being placed within a trigger that unmounts or inside a conditional. Consider using a DialogContainer instead.');
62
+ };
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, []);
65
+ if (type === 'popover') return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement($46e54a192dc519c9$var$PopoverTrigger, {
66
+ ...positionProps,
67
+ state: state,
68
+ targetRef: targetRef,
69
+ trigger: trigger,
70
+ content: content,
71
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled,
72
+ hideArrow: hideArrow
73
+ });
74
+ let renderOverlay = ()=>{
75
+ switch(type){
76
+ case 'fullscreen':
77
+ case 'fullscreenTakeover':
78
+ case 'modal':
79
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $7xftW$reactspectrumoverlays.Modal), {
80
+ state: state,
81
+ isDismissable: type === 'modal' ? isDismissable : false,
82
+ type: type,
83
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled,
84
+ onExiting: onExiting,
85
+ onExited: onExited
86
+ }, typeof content === 'function' ? content(state.close) : content);
87
+ case 'tray':
88
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $7xftW$reactspectrumoverlays.Tray), {
89
+ state: state,
90
+ isKeyboardDismissDisabled: isKeyboardDismissDisabled
91
+ }, typeof content === 'function' ? content(state.close) : content);
92
+ }
93
+ };
94
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement($46e54a192dc519c9$var$DialogTriggerBase, {
95
+ type: type,
96
+ state: state,
97
+ isDismissable: isDismissable,
98
+ trigger: trigger,
99
+ overlay: renderOverlay()
100
+ });
101
+ }
102
+ // Support DialogTrigger inside components using CollectionBuilder.
103
+ $46e54a192dc519c9$var$DialogTrigger.getCollectionNode = function*(props) {
104
+ // @ts-ignore - seems like types are wrong. Function children work fine.
105
+ let [trigger] = (0, ($parcel$interopDefault($7xftW$react))).Children.toArray(props.children);
106
+ let [, content] = props.children;
107
+ yield {
108
+ element: trigger,
109
+ wrapper: (element)=>/*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement($46e54a192dc519c9$var$DialogTrigger, {
110
+ key: element.key,
111
+ ...props
112
+ }, element, content)
113
+ };
114
+ };
115
+ /**
116
+ * DialogTrigger serves as a wrapper around a Dialog and its associated trigger, linking the Dialog's
117
+ * open state with the trigger's press state. Additionally, it allows you to customize the type and
118
+ * positioning of the Dialog.
119
+ */ // We don't want getCollectionNode to show up in the type definition
120
+ let $46e54a192dc519c9$export$2e1e1122cf0cba88 = $46e54a192dc519c9$var$DialogTrigger;
121
+ function $46e54a192dc519c9$var$PopoverTrigger({ state: state, targetRef: targetRef, trigger: trigger, content: content, hideArrow: hideArrow, ...props }) {
122
+ let triggerRef = (0, $7xftW$react.useRef)(null);
123
+ let { triggerProps: triggerProps, overlayProps: overlayProps } = (0, $7xftW$reactariaoverlays.useOverlayTrigger)({
124
+ type: 'dialog'
125
+ }, state, triggerRef);
126
+ let triggerPropsWithRef = {
127
+ ...triggerProps,
128
+ ref: targetRef ? undefined : triggerRef
129
+ };
130
+ let overlay = /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $7xftW$reactspectrumoverlays.Popover), {
131
+ ...props,
132
+ hideArrow: hideArrow,
133
+ triggerRef: targetRef || triggerRef,
134
+ state: state
135
+ }, typeof content === 'function' ? content(state.close) : content);
136
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement($46e54a192dc519c9$var$DialogTriggerBase, {
137
+ type: "popover",
138
+ state: state,
139
+ triggerProps: triggerPropsWithRef,
140
+ dialogProps: overlayProps,
141
+ trigger: trigger,
142
+ overlay: overlay
143
+ });
144
+ }
145
+ function $46e54a192dc519c9$var$DialogTriggerBase({ type: type, state: state, isDismissable: isDismissable, dialogProps: dialogProps = {}, triggerProps: triggerProps = {}, overlay: overlay, trigger: trigger }) {
146
+ let context = {
147
+ type: type,
148
+ onClose: state.close,
149
+ isDismissable: isDismissable,
150
+ ...dialogProps
151
+ };
152
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $7xftW$react.Fragment), null, /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $7xftW$reactariainteractions.PressResponder), {
153
+ ...triggerProps,
154
+ onPress: state.toggle,
155
+ isPressed: state.isOpen && type !== 'modal' && type !== 'fullscreen' && type !== 'fullscreenTakeover'
156
+ }, trigger), /*#__PURE__*/ (0, ($parcel$interopDefault($7xftW$react))).createElement((0, $0eb909ad2388d989$exports.DialogContext).Provider, {
157
+ value: context
158
+ }, overlay));
159
+ }
160
+
161
+
162
+ //# sourceMappingURL=DialogTrigger.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"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","sources":["packages/@react-spectrum/dialog/src/DialogTrigger.tsx"],"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 {DialogContext} from './context';\nimport {Modal, Popover, Tray} from '@react-spectrum/overlays';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {PressResponder} from '@react-aria/interactions';\nimport React, {Fragment, JSX, ReactElement, useEffect, useRef} from 'react';\nimport {SpectrumDialogClose, SpectrumDialogProps, SpectrumDialogTriggerProps} from '@react-types/dialog';\nimport {useIsMobileDevice} from '@react-spectrum/utils';\nimport {useOverlayTrigger} from '@react-aria/overlays';\n\nfunction DialogTrigger(props: SpectrumDialogTriggerProps) {\n let {\n children,\n type = 'modal',\n mobileType = type === 'popover' ? 'modal' : type,\n hideArrow,\n targetRef,\n isDismissable,\n isKeyboardDismissDisabled,\n ...positionProps\n } = props;\n if (!Array.isArray(children) || children.length > 2) {\n throw new Error('DialogTrigger must have exactly 2 children');\n }\n // if a function is passed as the second child, it won't appear in toArray\n let [trigger, content] = children as [ReactElement, SpectrumDialogClose];\n\n // On small devices, show a modal or tray instead of a popover.\n let isMobile = useIsMobileDevice();\n if (isMobile) {\n // handle cases where desktop popovers need a close button for the mobile modal view\n if (type !== 'modal' && mobileType === 'modal') {\n isDismissable = true;\n }\n\n type = mobileType;\n }\n\n let state = useOverlayTriggerState(props);\n let wasOpen = useRef(false);\n useEffect(() => {\n wasOpen.current = state.isOpen;\n }, [state.isOpen]);\n\n let isExiting = useRef(false);\n let onExiting = () => isExiting.current = true;\n let onExited = () => isExiting.current = false;\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if ((wasOpen.current || isExiting.current) && type !== 'popover' && type !== 'tray') {\n console.warn('A DialogTrigger unmounted while open. This is likely due to being placed within a trigger that unmounts or inside a conditional. Consider using a DialogContainer instead.');\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n if (type === 'popover') {\n return (\n <PopoverTrigger\n {...positionProps}\n state={state}\n targetRef={targetRef}\n trigger={trigger}\n content={content}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n hideArrow={hideArrow} />\n );\n }\n\n let renderOverlay = () => {\n switch (type) {\n case 'fullscreen':\n case 'fullscreenTakeover':\n case 'modal':\n return (\n <Modal\n state={state}\n isDismissable={type === 'modal' ? isDismissable : false}\n type={type}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n onExiting={onExiting}\n onExited={onExited}>\n {typeof content === 'function' ? content(state.close) : content}\n </Modal>\n );\n case 'tray':\n return (\n <Tray\n state={state}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}>\n {typeof content === 'function' ? content(state.close) : content}\n </Tray>\n );\n }\n };\n\n return (\n <DialogTriggerBase\n type={type}\n state={state}\n isDismissable={isDismissable}\n trigger={trigger}\n overlay={renderOverlay()} />\n );\n}\n\n// Support DialogTrigger inside components using CollectionBuilder.\nDialogTrigger.getCollectionNode = function* (props: SpectrumDialogTriggerProps) {\n // @ts-ignore - seems like types are wrong. Function children work fine.\n let [trigger] = React.Children.toArray(props.children);\n let [, content] = props.children as [ReactElement, SpectrumDialogClose];\n yield {\n element: trigger,\n wrapper: (element) => (\n <DialogTrigger key={element.key} {...props}>\n {element}\n {content}\n </DialogTrigger>\n )\n };\n};\n\n/**\n * DialogTrigger serves as a wrapper around a Dialog and its associated trigger, linking the Dialog's\n * open state with the trigger's press state. Additionally, it allows you to customize the type and\n * positioning of the Dialog.\n */\n\n// We don't want getCollectionNode to show up in the type definition\nlet _DialogTrigger = DialogTrigger as (props: SpectrumDialogTriggerProps) => JSX.Element;\nexport {_DialogTrigger as DialogTrigger};\n\nfunction PopoverTrigger({state, targetRef, trigger, content, hideArrow, ...props}) {\n let triggerRef = useRef<HTMLElement>(null);\n let {triggerProps, overlayProps} = useOverlayTrigger({type: 'dialog'}, state, triggerRef);\n\n let triggerPropsWithRef = {\n ...triggerProps,\n ref: targetRef ? undefined : triggerRef\n };\n\n let overlay = (\n <Popover\n {...props}\n hideArrow={hideArrow}\n triggerRef={targetRef || triggerRef}\n state={state}>\n {typeof content === 'function' ? content(state.close) : content}\n </Popover>\n );\n\n return (\n <DialogTriggerBase\n type=\"popover\"\n state={state}\n triggerProps={triggerPropsWithRef}\n dialogProps={overlayProps}\n trigger={trigger}\n overlay={overlay} />\n );\n}\n\ninterface SpectrumDialogTriggerBase {\n type: 'modal' | 'popover' | 'tray' | 'fullscreen' | 'fullscreenTakeover',\n state: OverlayTriggerState,\n isDismissable?: boolean,\n dialogProps?: SpectrumDialogProps | {},\n triggerProps?: any,\n overlay?: ReactElement,\n trigger: ReactElement\n}\n\nfunction DialogTriggerBase({type, state, isDismissable, dialogProps = {}, triggerProps = {}, overlay, trigger}: SpectrumDialogTriggerBase) {\n let context = {\n type,\n onClose: state.close,\n isDismissable,\n ...dialogProps\n };\n\n return (\n <Fragment>\n <PressResponder\n {...triggerProps}\n onPress={state.toggle}\n isPressed={state.isOpen && type !== 'modal' && type !== 'fullscreen' && type !== 'fullscreenTakeover'}>\n {trigger}\n </PressResponder>\n <DialogContext.Provider value={context}>\n {overlay}\n </DialogContext.Provider>\n </Fragment>\n );\n}\n"],"names":[],"version":3,"file":"DialogTrigger.main.js.map"}