@planningcenter/tapestry 4.4.0 → 4.4.1-rc.1
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/dist/components/DataTable/ViewSettingsToggle.d.ts.map +1 -1
- package/dist/components/DataTable/ViewSettingsToggle.js +4 -5
- package/dist/components/DataTable/ViewSettingsToggle.js.map +1 -1
- package/dist/components/popover/Popover.d.ts +93 -0
- package/dist/components/popover/Popover.d.ts.map +1 -0
- package/dist/components/popover/Popover.js +70 -0
- package/dist/components/popover/Popover.js.map +1 -0
- package/dist/components/popover/index.d.ts +4 -0
- package/dist/components/popover/index.d.ts.map +1 -0
- package/dist/reactRender.css +748 -745
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +748 -745
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +42 -39
- package/dist/unstable.css.map +1 -1
- package/dist/unstable.d.ts +1 -0
- package/dist/unstable.d.ts.map +1 -1
- package/dist/unstable.js +1 -0
- package/dist/unstable.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSettingsToggle.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/ViewSettingsToggle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ViewSettingsToggle.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/ViewSettingsToggle.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,MAAM,WAAW,uBAAuB;IACtC,iEAAiE;IACjE,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,wBAAwB,EAAE,CAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAChE,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,wBAAwB,EACxB,kBAAkB,GACnB,EAAE,uBAAuB,qBAyCzB;yBA7Ce,kBAAkB"}
|
|
@@ -6,9 +6,9 @@ import { IconButton } from '../button/IconButton.js';
|
|
|
6
6
|
import '../button/LoadingButton.js';
|
|
7
7
|
import '../button/PageHeaderActionsDropdownButton.js';
|
|
8
8
|
import { FilterableListBox, FilterableListBoxItem } from '../internal/filterable-list-box/FilterableListBox.js';
|
|
9
|
+
import { Popover, PopoverTrigger, PopoverContent } from '../popover/Popover.js';
|
|
9
10
|
import Icon from '../../utilities/Icon.js';
|
|
10
11
|
import React__default from 'react';
|
|
11
|
-
import { DialogTrigger, Pressable, Popover, Dialog } from 'react-aria-components/Popover';
|
|
12
12
|
import { Tooltip } from '../internal/tooltip/Tooltip.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -19,12 +19,11 @@ import { Tooltip } from '../internal/tooltip/Tooltip.js';
|
|
|
19
19
|
*/
|
|
20
20
|
function ViewSettingsToggle({ columns, onColumnVisibilityChange, visibleColumnNames, }) {
|
|
21
21
|
return (React__default.createElement("div", { className: "tds-data-table-view-settings-toggle" },
|
|
22
|
-
React__default.createElement(
|
|
22
|
+
React__default.createElement(Popover, null,
|
|
23
23
|
React__default.createElement(Tooltip, { content: "View settings", placement: "bottom end" },
|
|
24
|
-
React__default.createElement(
|
|
24
|
+
React__default.createElement(PopoverTrigger, null,
|
|
25
25
|
React__default.createElement(IconButton, { "aria-label": "View settings", className: "tds-data-table-popover-trigger", icon: React__default.createElement(Icon, { "aria-hidden": true, symbol: "general#faders" }) }))),
|
|
26
|
-
React__default.createElement(
|
|
27
|
-
React__default.createElement(Dialog, null, columns.length > 0 && (React__default.createElement(FilterableListBox, { hideLabel: true, items: columns, label: "Column visibility", onSelectionChange: (keys) => onColumnVisibilityChange(keys), placeholder: "Search columns", selectedKeys: visibleColumnNames, selectionMode: "multiple" }, (column) => (React__default.createElement(FilterableListBoxItem, { id: column.name }, column.headerLabel)))))))));
|
|
26
|
+
React__default.createElement(PopoverContent, { className: "tds-data-table-popover", modal: false, placement: "bottom end" }, columns.length > 0 && (React__default.createElement(FilterableListBox, { hideLabel: true, items: columns, label: "Column visibility", onSelectionChange: (keys) => onColumnVisibilityChange(keys), placeholder: "Search columns", selectedKeys: visibleColumnNames, selectionMode: "multiple" }, (column) => (React__default.createElement(FilterableListBoxItem, { id: column.name }, column.headerLabel))))))));
|
|
28
27
|
}
|
|
29
28
|
ViewSettingsToggle.displayName = "ViewSettingsToggle";
|
|
30
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSettingsToggle.js","sources":["../../../src/components/DataTable/ViewSettingsToggle.tsx"],"sourcesContent":["import { IconButton } from \"@components/button\"\nimport {\n FilterableListBox,\n FilterableListBoxItem,\n} from \"@components/internal/filterable-list-box\"\nimport
|
|
1
|
+
{"version":3,"file":"ViewSettingsToggle.js","sources":["../../../src/components/DataTable/ViewSettingsToggle.tsx"],"sourcesContent":["import { IconButton } from \"@components/button\"\nimport {\n FilterableListBox,\n FilterableListBoxItem,\n} from \"@components/internal/filterable-list-box\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"@components/popover\"\nimport Icon from \"@utilities/Icon\"\nimport React from \"react\"\n\nimport { Tooltip } from \"../internal/tooltip/Tooltip\"\nimport type { DataTableColumn } from \"./DataTableColumn\"\n\nexport interface ViewSettingsToggleProps {\n /** The columns opted into visibility toggling via `hideable`. */\n columns: DataTableColumn[]\n onColumnVisibilityChange: (visibleColumnNames: string[]) => void\n visibleColumnNames: string[]\n}\n\n/**\n * A trigger + popover for table view settings. Today it only holds column\n * visibility (via `FilterableListBox`), but the panel is meant to grow to\n * include other view-related settings (e.g. a Table/Card display toggle, a\n * Compact View switch) as siblings inside the same dialog.\n */\nexport function ViewSettingsToggle({\n columns,\n onColumnVisibilityChange,\n visibleColumnNames,\n}: ViewSettingsToggleProps) {\n return (\n <div className=\"tds-data-table-view-settings-toggle\">\n <Popover>\n <Tooltip content=\"View settings\" placement=\"bottom end\">\n <PopoverTrigger>\n <IconButton\n aria-label=\"View settings\"\n className=\"tds-data-table-popover-trigger\"\n icon={<Icon aria-hidden symbol=\"general#faders\" />}\n />\n </PopoverTrigger>\n </Tooltip>\n <PopoverContent\n className=\"tds-data-table-popover\"\n modal={false}\n placement=\"bottom end\"\n >\n {columns.length > 0 && (\n <FilterableListBox\n hideLabel\n items={columns}\n label=\"Column visibility\"\n onSelectionChange={(keys) =>\n onColumnVisibilityChange(keys as string[])\n }\n placeholder=\"Search columns\"\n selectedKeys={visibleColumnNames}\n selectionMode=\"multiple\"\n >\n {(column) => (\n <FilterableListBoxItem id={column.name}>\n {column.headerLabel}\n </FilterableListBoxItem>\n )}\n </FilterableListBox>\n )}\n </PopoverContent>\n </Popover>\n </div>\n )\n}\n\nViewSettingsToggle.displayName = \"ViewSettingsToggle\"\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AAmBA;;;;;AAKG;AACG,SAAU,kBAAkB,CAAC,EACjC,OAAO,EACP,wBAAwB,EACxB,kBAAkB,GACM,EAAA;AACxB,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qCAAqC,EAAA;AAClD,QAAAA,cAAA,CAAA,aAAA,CAAC,OAAO,EAAA,IAAA;YACNA,cAAA,CAAA,aAAA,CAAC,OAAO,IAAC,OAAO,EAAC,eAAe,EAAC,SAAS,EAAC,YAAY,EAAA;AACrD,gBAAAA,cAAA,CAAA,aAAA,CAAC,cAAc,EAAA,IAAA;AACb,oBAAAA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAA,YAAA,EACE,eAAe,EAC1B,SAAS,EAAC,gCAAgC,EAC1C,IAAI,EAAEA,cAAA,CAAA,aAAA,CAAC,IAAI,yBAAa,MAAM,EAAC,gBAAgB,EAAA,CAAG,EAAA,CAClD,CACa,CACT;AACV,YAAAA,cAAA,CAAA,aAAA,CAAC,cAAc,EAAA,EACb,SAAS,EAAC,wBAAwB,EAClC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,YAAY,EAAA,EAErB,OAAO,CAAC,MAAM,GAAG,CAAC,KACjBA,cAAA,CAAA,aAAA,CAAC,iBAAiB,EAAA,EAChB,SAAS,QACT,KAAK,EAAE,OAAO,EACd,KAAK,EAAC,mBAAmB,EACzB,iBAAiB,EAAE,CAAC,IAAI,KACtB,wBAAwB,CAAC,IAAgB,CAAC,EAE5C,WAAW,EAAC,gBAAgB,EAC5B,YAAY,EAAE,kBAAkB,EAChC,aAAa,EAAC,UAAU,EAAA,EAEvB,CAAC,MAAM,MACNA,cAAA,CAAA,aAAA,CAAC,qBAAqB,IAAC,EAAE,EAAE,MAAM,CAAC,IAAI,IACnC,MAAM,CAAC,WAAW,CACG,CACzB,CACiB,CACrB,CACc,CACT,CACN;AAEV;AAEA,kBAAkB,CAAC,WAAW,GAAG,oBAAoB;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import React, { type ReactElement, type ReactNode } from "react";
|
|
3
|
+
import type { PopoverProps as AriaPopoverProps } from "react-aria-components/Popover";
|
|
4
|
+
export interface PopoverProps {
|
|
5
|
+
/** A `<PopoverTrigger>` followed by a `<PopoverContent>`. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Initial open state for the uncontrolled case. Useful for stories and tests. */
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Fires whenever the surface opens or closes — trigger press, Escape,
|
|
11
|
+
* outside press, or `close()`. Required when `open` is set.
|
|
12
|
+
*/
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
/** Controlled open state. Renamed from React Aria's `isOpen`. Omit for uncontrolled. */
|
|
15
|
+
open?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type PopoverElementProps = PopoverProps;
|
|
18
|
+
/**
|
|
19
|
+
* A generic popover surface anchored to a trigger button. Unlike `Dropdown`
|
|
20
|
+
* (a semantic `role="menu"` action list), `Popover` renders arbitrary content
|
|
21
|
+
* — a search field, a form, a list, plain text.
|
|
22
|
+
*
|
|
23
|
+
* **Rule of thumb:** a flat list of actions or links → `Dropdown`. Anything
|
|
24
|
+
* else anchored to a button → `Popover`. Owns the screen until resolved →
|
|
25
|
+
* `Modal`.
|
|
26
|
+
*
|
|
27
|
+
* @component
|
|
28
|
+
* @see {@link https://app.notion.com/p/planningcenter/RFC-Tapestry-Popover-3baabbce69a2802e8fe8e65a7f72821c | RFC}
|
|
29
|
+
*/
|
|
30
|
+
export declare function Popover({ children, defaultOpen, onOpenChange, open, }: PopoverElementProps): React.JSX.Element;
|
|
31
|
+
export interface PopoverTriggerProps {
|
|
32
|
+
/**
|
|
33
|
+
* Exactly one Tapestry button element — `Button`, `IconButton`,
|
|
34
|
+
* `DropdownButton`, `DropdownIconButton`, `ActionsDropdownIconButton`, or
|
|
35
|
+
* `PageHeaderActionsDropdownButton`. Receives `aria-expanded`,
|
|
36
|
+
* `aria-controls`, `id`, and press wiring via `Pressable` — the same RAC
|
|
37
|
+
* mechanism `Dropdown`'s trigger already uses. Must render a real `<button>`.
|
|
38
|
+
*/
|
|
39
|
+
children: ReactElement;
|
|
40
|
+
}
|
|
41
|
+
export type PopoverTriggerElementProps = PopoverTriggerProps;
|
|
42
|
+
/**
|
|
43
|
+
* Wraps a single Tapestry button and bridges it to React Aria's
|
|
44
|
+
* `DialogTrigger` via `<Pressable>`.
|
|
45
|
+
*
|
|
46
|
+
* @component
|
|
47
|
+
*/
|
|
48
|
+
export declare function PopoverTrigger({ children }: PopoverTriggerElementProps): React.JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the enclosing `<PopoverContent>`'s `close` function. Call it from
|
|
51
|
+
* any descendant to close the surface — e.g. a plain `<Button onClick={close}>`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function usePopoverClose(): () => void;
|
|
54
|
+
export interface PopoverContentProps {
|
|
55
|
+
/**
|
|
56
|
+
* Accessible name for the surface. Defaults to the trigger's accessible
|
|
57
|
+
* name (React Aria points `aria-labelledby` at the trigger's id). Set this
|
|
58
|
+
* when the surface needs a different name than the trigger.
|
|
59
|
+
*/
|
|
60
|
+
"aria-label"?: string;
|
|
61
|
+
/** Arbitrary content. */
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
/** Appended to `tds-popover` on the positioned surface. */
|
|
64
|
+
className?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Defaults to `true`. When `true`, the surface contains focus, hides
|
|
67
|
+
* outside content from assistive tech, and blocks page scroll while open —
|
|
68
|
+
* the right default for most popovers. Set to `false` for lighter-weight
|
|
69
|
+
* dismissal behavior (maps to React Aria's `isNonModal`, whose own doc
|
|
70
|
+
* comment scopes it to "components such as combobox" — this is why it
|
|
71
|
+
* isn't the default). `<Dialog>` always renders regardless of this prop;
|
|
72
|
+
* `modal` only toggles containment, not whether a dialog role exists.
|
|
73
|
+
*
|
|
74
|
+
* `modal={false}` still blocks page scroll while open — React Aria's own
|
|
75
|
+
* scroll-close behavior for non-modal popovers can't be disabled, so
|
|
76
|
+
* scrolling is locked instead, the same way `Dropdown`'s menu does.
|
|
77
|
+
*/
|
|
78
|
+
modal?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Position relative to the trigger, in React Aria's space-separated form.
|
|
81
|
+
* Defaults to `'bottom start'`. Flips automatically when there isn't room.
|
|
82
|
+
*/
|
|
83
|
+
placement?: AriaPopoverProps["placement"];
|
|
84
|
+
}
|
|
85
|
+
export type PopoverContentElementProps = PopoverContentProps;
|
|
86
|
+
/**
|
|
87
|
+
* The popover surface for a `<Popover>`. Wraps React Aria's `<Popover>` and
|
|
88
|
+
* `<Dialog>` and contains arbitrary content.
|
|
89
|
+
*
|
|
90
|
+
* @component
|
|
91
|
+
*/
|
|
92
|
+
export declare function PopoverContent({ "aria-label": ariaLabel, children, className, modal, placement, }: PopoverContentElementProps): React.JSX.Element;
|
|
93
|
+
//# sourceMappingUR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AA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;CAC1C;AAED,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,CAAA;AAE5D;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,SAAS,EACT,KAAY,EACZ,SAA0B,GAC3B,EAAE,0BAA0B,qBAsC5B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React__default, { createContext, useRef, useContext, useCallback } from 'react';
|
|
3
|
+
import { useInteractOutside, usePreventScroll, FocusScope } from 'react-aria';
|
|
4
|
+
import { OverlayTriggerStateContext } from 'react-aria-components/Dialog';
|
|
5
|
+
import { DialogTrigger, PopoverContext, Popover as Popover$1, Dialog, Pressable } from 'react-aria-components/Popover';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A generic popover surface anchored to a trigger button. Unlike `Dropdown`
|
|
9
|
+
* (a semantic `role="menu"` action list), `Popover` renders arbitrary content
|
|
10
|
+
* — a search field, a form, a list, plain text.
|
|
11
|
+
*
|
|
12
|
+
* **Rule of thumb:** a flat list of actions or links → `Dropdown`. Anything
|
|
13
|
+
* else anchored to a button → `Popover`. Owns the screen until resolved →
|
|
14
|
+
* `Modal`.
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @see {@link https://app.notion.com/p/planningcenter/RFC-Tapestry-Popover-3baabbce69a2802e8fe8e65a7f72821c | RFC}
|
|
18
|
+
*/
|
|
19
|
+
function Popover({ children, defaultOpen, onOpenChange, open, }) {
|
|
20
|
+
return (React__default.createElement(DialogTrigger, { defaultOpen: defaultOpen, isOpen: open, onOpenChange: onOpenChange }, children));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a single Tapestry button and bridges it to React Aria's
|
|
24
|
+
* `DialogTrigger` via `<Pressable>`.
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
*/
|
|
28
|
+
function PopoverTrigger({ children }) {
|
|
29
|
+
return React__default.createElement(Pressable, null, children);
|
|
30
|
+
}
|
|
31
|
+
const PopoverCloseContext = createContext(() => { });
|
|
32
|
+
/**
|
|
33
|
+
* Returns the enclosing `<PopoverContent>`'s `close` function. Call it from
|
|
34
|
+
* any descendant to close the surface — e.g. a plain `<Button onClick={close}>`.
|
|
35
|
+
*/
|
|
36
|
+
function usePopoverClose() {
|
|
37
|
+
return useContext(PopoverCloseContext);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The popover surface for a `<Popover>`. Wraps React Aria's `<Popover>` and
|
|
41
|
+
* `<Dialog>` and contains arbitrary content.
|
|
42
|
+
*
|
|
43
|
+
* @component
|
|
44
|
+
*/
|
|
45
|
+
function PopoverContent({ "aria-label": ariaLabel, children, className, modal = true, placement = "bottom start", }) {
|
|
46
|
+
const popoverRef = useRef(null);
|
|
47
|
+
const state = useContext(OverlayTriggerStateContext);
|
|
48
|
+
const close = useCallback(() => state?.close(), [state]);
|
|
49
|
+
const popoverContext = useContext(PopoverContext);
|
|
50
|
+
const triggerRef = popoverContext && "triggerRef" in popoverContext
|
|
51
|
+
? popoverContext.triggerRef
|
|
52
|
+
: undefined;
|
|
53
|
+
useInteractOutside({
|
|
54
|
+
isDisabled: modal || !state?.isOpen,
|
|
55
|
+
onInteractOutside: (event) => {
|
|
56
|
+
if (triggerRef?.current?.contains(event.target))
|
|
57
|
+
return;
|
|
58
|
+
close();
|
|
59
|
+
},
|
|
60
|
+
ref: popoverRef,
|
|
61
|
+
});
|
|
62
|
+
usePreventScroll({ isDisabled: modal || !state?.isOpen });
|
|
63
|
+
return (React__default.createElement(Popover$1, { className: classNames("tds-popover", className), isNonModal: !modal, placement: placement, ref: popoverRef, shouldCloseOnInteractOutside: modal ? undefined : () => false },
|
|
64
|
+
React__default.createElement(FocusScope, { contain: !modal },
|
|
65
|
+
React__default.createElement(Dialog, { "aria-label": ariaLabel, className: "tds-popover-content" },
|
|
66
|
+
React__default.createElement(PopoverCloseContext.Provider, { value: close }, children)))));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { Popover, PopoverContent, PopoverTrigger, usePopoverClose };
|
|
70
|
+
//# sourceMappingURL=Popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../src/components/popover/Popover.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport classNames from \"classnames\"\nimport React, {\n type ComponentProps,\n createContext,\n type ReactElement,\n type ReactNode,\n useCallback,\n useContext,\n useRef,\n} from \"react\"\nimport { FocusScope, useInteractOutside, usePreventScroll } from \"react-aria\"\nimport { OverlayTriggerStateContext } from \"react-aria-components/Dialog\"\nimport type { PopoverProps as AriaPopoverProps } from \"react-aria-components/Popover\"\nimport {\n Dialog,\n DialogTrigger,\n Popover as AriaPopover,\n PopoverContext as AriaPopoverContext,\n Pressable,\n} from \"react-aria-components/Popover\"\n\nexport interface PopoverProps {\n /** A `<PopoverTrigger>` followed by a `<PopoverContent>`. */\n children: ReactNode\n /** Initial open state for the uncontrolled case. Useful for stories and tests. */\n defaultOpen?: boolean\n /**\n * Fires whenever the surface opens or closes — trigger press, Escape,\n * outside press, or `close()`. Required when `open` is set.\n */\n onOpenChange?: (open: boolean) => void\n /** Controlled open state. Renamed from React Aria's `isOpen`. Omit for uncontrolled. */\n open?: boolean\n}\n\nexport type PopoverElementProps = PopoverProps\n\n/**\n * A generic popover surface anchored to a trigger button. Unlike `Dropdown`\n * (a semantic `role=\"menu\"` action list), `Popover` renders arbitrary content\n * — a search field, a form, a list, plain text.\n *\n * **Rule of thumb:** a flat list of actions or links → `Dropdown`. Anything\n * else anchored to a button → `Popover`. Owns the screen until resolved →\n * `Modal`.\n *\n * @component\n * @see {@link https://app.notion.com/p/planningcenter/RFC-Tapestry-Popover-3baabbce69a2802e8fe8e65a7f72821c | RFC}\n */\nexport function Popover({\n children,\n defaultOpen,\n onOpenChange,\n open,\n}: PopoverElementProps) {\n return (\n <DialogTrigger\n defaultOpen={defaultOpen}\n isOpen={open}\n onOpenChange={onOpenChange}\n >\n {children}\n </DialogTrigger>\n )\n}\n\nexport interface PopoverTriggerProps {\n /**\n * Exactly one Tapestry button element — `Button`, `IconButton`,\n * `DropdownButton`, `DropdownIconButton`, `ActionsDropdownIconButton`, or\n * `PageHeaderActionsDropdownButton`. Receives `aria-expanded`,\n * `aria-controls`, `id`, and press wiring via `Pressable` — the same RAC\n * mechanism `Dropdown`'s trigger already uses. Must render a real `<button>`.\n */\n children: ReactElement\n}\n\nexport type PopoverTriggerElementProps = PopoverTriggerProps\n\ntype PressableChild = ComponentProps<typeof Pressable>[\"children\"]\n\n/**\n * Wraps a single Tapestry button and bridges it to React Aria's\n * `DialogTrigger` via `<Pressable>`.\n *\n * @component\n */\nexport function PopoverTrigger({ children }: PopoverTriggerElementProps) {\n return <Pressable>{children as PressableChild}</Pressable>\n}\n\nconst PopoverCloseContext = createContext<() => void>(() => {})\n\n/**\n * Returns the enclosing `<PopoverContent>`'s `close` function. Call it from\n * any descendant to close the surface — e.g. a plain `<Button onClick={close}>`.\n */\nexport function usePopoverClose(): () => void {\n return useContext(PopoverCloseContext)\n}\n\nexport interface PopoverContentProps {\n /**\n * Accessible name for the surface. Defaults to the trigger's accessible\n * name (React Aria points `aria-labelledby` at the trigger's id). Set this\n * when the surface needs a different name than the trigger.\n */\n \"aria-label\"?: string\n /** Arbitrary content. */\n children: ReactNode\n /** Appended to `tds-popover` on the positioned surface. */\n className?: string\n /**\n * Defaults to `true`. When `true`, the surface contains focus, hides\n * outside content from assistive tech, and blocks page scroll while open —\n * the right default for most popovers. Set to `false` for lighter-weight\n * dismissal behavior (maps to React Aria's `isNonModal`, whose own doc\n * comment scopes it to \"components such as combobox\" — this is why it\n * isn't the default). `<Dialog>` always renders regardless of this prop;\n * `modal` only toggles containment, not whether a dialog role exists.\n *\n * `modal={false}` still blocks page scroll while open — React Aria's own\n * scroll-close behavior for non-modal popovers can't be disabled, so\n * scrolling is locked instead, the same way `Dropdown`'s menu does.\n */\n modal?: boolean\n /**\n * Position relative to the trigger, in React Aria's space-separated form.\n * Defaults to `'bottom start'`. Flips automatically when there isn't room.\n */\n placement?: AriaPopoverProps[\"placement\"]\n}\n\nexport type PopoverContentElementProps = PopoverContentProps\n\n/**\n * The popover surface for a `<Popover>`. Wraps React Aria's `<Popover>` and\n * `<Dialog>` and contains arbitrary content.\n *\n * @component\n */\nexport function PopoverContent({\n \"aria-label\": ariaLabel,\n children,\n className,\n modal = true,\n placement = \"bottom start\",\n}: PopoverContentElementProps) {\n const popoverRef = useRef<HTMLElement>(null)\n const state = useContext(OverlayTriggerStateContext)\n const close = useCallback(() => state?.close(), [state])\n\n const popoverContext = useContext(AriaPopoverContext)\n const triggerRef =\n popoverContext && \"triggerRef\" in popoverContext\n ? popoverContext.triggerRef\n : undefined\n\n useInteractOutside({\n isDisabled: modal || !state?.isOpen,\n onInteractOutside: (event) => {\n if (triggerRef?.current?.contains(event.target as Node)) return\n close()\n },\n ref: popoverRef,\n })\n usePreventScroll({ isDisabled: modal || !state?.isOpen })\n\n return (\n <AriaPopover\n className={classNames(\"tds-popover\", className)}\n isNonModal={!modal}\n placement={placement}\n ref={popoverRef}\n shouldCloseOnInteractOutside={modal ? undefined : () => false}\n >\n <FocusScope contain={!modal}>\n <Dialog aria-label={ariaLabel} className=\"tds-popover-content\">\n <PopoverCloseContext.Provider value={close}>\n {children}\n </PopoverCloseContext.Provider>\n </Dialog>\n </FocusScope>\n </AriaPopover>\n )\n}\n"],"names":["React","AriaPopoverContext","AriaPopover"],"mappings":";;;;;;AAuCA;;;;;;;;;;;AAWG;AACG,SAAU,OAAO,CAAC,EACtB,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,IAAI,GACgB,EAAA;AACpB,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,aAAa,IACZ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,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E,CAAC;AAEzD,IAAA,QACED,cAAA,CAAA,aAAA,CAACE,SAAW,EAAA,EACV,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,EAC/C,UAAU,EAAE,CAAC,KAAK,EAClB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,UAAU,EACf,4BAA4B,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,KAAK,EAAA;AAE7D,QAAAF,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAE,CAAC,KAAK,EAAA;AACzB,YAAAA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAA,YAAA,EAAa,SAAS,EAAE,SAAS,EAAC,qBAAqB,EAAA;AAC5D,gBAAAA,cAAA,CAAA,aAAA,CAAC,mBAAmB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EACvC,QAAQ,CACoB,CACxB,CACE,CACD;AAElB;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
export type { PopoverContentElementProps, PopoverContentProps, PopoverElementProps, PopoverProps, PopoverTriggerElementProps, PopoverTriggerProps, } from "./Popover";
|
|
3
|
+
export { Popover, PopoverContent, PopoverTrigger, usePopoverClose, } from "./Popover";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,WAAW,CAAA"}
|