@flipdish/ui-library 0.64.0 → 0.65.0
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/__internal__/overlay/PageScrollbarGutterRelease.cjs +18 -0
- package/dist/components/__internal__/overlay/PageScrollbarGutterRelease.cjs.map +1 -0
- package/dist/components/__internal__/overlay/PageScrollbarGutterRelease.d.ts +6 -0
- package/dist/components/__internal__/overlay/PageScrollbarGutterRelease.d.ts.map +1 -0
- package/dist/components/__internal__/overlay/PageScrollbarGutterRelease.js +16 -0
- package/dist/components/__internal__/overlay/PageScrollbarGutterRelease.js.map +1 -0
- package/dist/components/__internal__/popover/ScrollClosingPopover.cjs +5 -3
- package/dist/components/__internal__/popover/ScrollClosingPopover.cjs.map +1 -1
- package/dist/components/__internal__/popover/ScrollClosingPopover.d.ts.map +1 -1
- package/dist/components/__internal__/popover/ScrollClosingPopover.js +6 -4
- package/dist/components/__internal__/popover/ScrollClosingPopover.js.map +1 -1
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.cjs +7 -2
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.cjs.map +1 -1
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.d.ts +6 -0
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.d.ts.map +1 -1
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.js +7 -2
- package/dist/components/__internal__/popover/hooks/useCloseOnTriggerScroll.js.map +1 -1
- package/dist/components/forms/FormUnsavedChangesModal/index.cjs +2 -2
- package/dist/components/forms/FormUnsavedChangesModal/index.cjs.map +1 -1
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts +4 -2
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts.map +1 -1
- package/dist/components/forms/FormUnsavedChangesModal/index.js +2 -2
- package/dist/components/forms/FormUnsavedChangesModal/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/index.cjs +11 -19
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +11 -19
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.cjs +90 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.cjs.map +1 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.d.ts +79 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.d.ts.map +1 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.js +83 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.js.map +1 -0
- package/dist/components/molecules/Modal/index.d.ts +1 -1
- package/dist/components/molecules/Modal/index.d.ts.map +1 -1
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.cjs +8 -5
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.cjs.map +1 -1
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.d.ts +12 -5
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.d.ts.map +1 -1
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.js +9 -6
- package/dist/components/molecules/Modals/ConfirmationModal/ConfirmationModal.js.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.cjs +76 -9
- package/dist/components/molecules/Modals/Modal/Modal.cjs.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.d.ts +35 -1
- package/dist/components/molecules/Modals/Modal/Modal.d.ts.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.js +77 -13
- package/dist/components/molecules/Modals/Modal/Modal.js.map +1 -1
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.cjs +15 -0
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.cjs.map +1 -0
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.d.ts +9 -0
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.d.ts.map +1 -0
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.js +13 -0
- package/dist/components/molecules/Modals/Modal/utilities/modalBody.utils.js.map +1 -0
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.cjs +4 -4
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.cjs.map +1 -1
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.d.ts +4 -2
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.d.ts.map +1 -1
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.js +5 -5
- package/dist/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.js.map +1 -1
- package/dist/components/molecules/Modals/index.cjs +3 -0
- package/dist/components/molecules/Modals/index.cjs.map +1 -1
- package/dist/components/molecules/Modals/index.d.ts +2 -2
- package/dist/components/molecules/Modals/index.d.ts.map +1 -1
- package/dist/components/molecules/Modals/index.js +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs +3 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.js +5 -3
- package/dist/components/organisms/CommandMenu/components/CommandInput.js.map +1 -1
- package/dist/components/organisms/CommandMenu/index.cjs +15 -2
- package/dist/components/organisms/CommandMenu/index.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/index.js +15 -2
- package/dist/components/organisms/CommandMenu/index.js.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.cjs +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.js +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.js.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +4 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +4 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs +11 -2
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js +12 -3
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js.map +1 -1
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.cjs +6 -4
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.d.ts +4 -2
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.js +8 -6
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.js.map +1 -1
- package/dist/components/organisms/DatePickers/providers/CalendarSheet.context.d.ts +7 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSheet.context.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.cjs +14 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.d.ts +8 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.js +12 -0
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.js.map +1 -0
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.cjs +10 -7
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.d.ts +14 -5
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.js +11 -8
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.js.map +1 -1
- package/dist/components/organisms/FilterBar/index.cjs +3 -1
- package/dist/components/organisms/FilterBar/index.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/index.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/index.js +3 -1
- package/dist/components/organisms/FilterBar/index.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/MobileHeader.cjs +2 -1
- package/dist/components/organisms/HeaderNavigation/components/MobileHeader.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/MobileHeader.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/MobileHeader.js +2 -1
- package/dist/components/organisms/HeaderNavigation/components/MobileHeader.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/MobileHeader.cjs +2 -1
- package/dist/components/organisms/SidebarNavigation/components/MobileHeader.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/MobileHeader.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/MobileHeader.js +2 -1
- package/dist/components/organisms/SidebarNavigation/components/MobileHeader.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs +33 -11
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts +4 -3
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js +35 -13
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.cjs +28 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.d.ts +20 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.js +26 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useFocusOnBecomingSheet.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/index.cjs +14 -8
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts +8 -7
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +14 -8
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.cjs +24 -0
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.cjs.map +1 -0
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.d.ts +10 -0
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.d.ts.map +1 -0
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.js +22 -0
- package/dist/hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.js.map +1 -0
- package/dist/hooks/useBreakpoints/index.cjs +6 -5
- package/dist/hooks/useBreakpoints/index.cjs.map +1 -1
- package/dist/hooks/useBreakpoints/index.d.ts +5 -5
- package/dist/hooks/useBreakpoints/index.d.ts.map +1 -1
- package/dist/hooks/useBreakpoints/index.js +6 -5
- package/dist/hooks/useBreakpoints/index.js.map +1 -1
- package/dist/styles.css +5 -0
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.cjs +58 -0
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.d.ts +8 -0
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.js +58 -1
- package/dist/utilities/__internal__/scrollUtils/scroll.utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Buttons = require('@flipdish/ui-library/components/atoms/Buttons');
|
|
5
|
+
var FeaturedIcon = require('@flipdish/ui-library/components/atoms/FeaturedIcon');
|
|
6
|
+
var useResizeObserver = require('@flipdish/ui-library/hooks/useResizeObserver');
|
|
4
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var React = require('react');
|
|
6
10
|
var reactAriaComponents = require('react-aria-components');
|
|
11
|
+
var PageScrollbarGutterRelease = require('../../../__internal__/overlay/PageScrollbarGutterRelease.cjs');
|
|
12
|
+
var modalBody_utils = require('./utilities/modalBody.utils.cjs');
|
|
7
13
|
|
|
8
14
|
/** Opens the modal when its child button is pressed; a plain alias of react-aria-components' `DialogTrigger`. */
|
|
9
15
|
const DialogTrigger = reactAriaComponents.DialogTrigger;
|
|
@@ -16,9 +22,9 @@ const DialogTrigger = reactAriaComponents.DialogTrigger;
|
|
|
16
22
|
*/
|
|
17
23
|
const ModalOverlay = ({ 'data-testid': dataTestId, ...props }) => {
|
|
18
24
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'modal', rootName: 'modal' });
|
|
19
|
-
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.ModalOverlay, { ...props, "data-testid": rootTestId, className: (state) => cx.cx('fixed inset-0 z-50 flex min-h-dvh w-full items-end justify-center bg-overlay/70
|
|
20
|
-
//
|
|
21
|
-
'pt-(--modal-pt) pb-(--modal-pb) [--modal-pb:
|
|
25
|
+
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.ModalOverlay, { ...props, "data-testid": rootTestId, className: (state) => cx.cx('fixed inset-0 z-50 flex min-h-dvh w-full items-end justify-center bg-overlay/70 outline-hidden backdrop-blur-[6px] md:items-center md:px-8',
|
|
26
|
+
// A bottom sheet below `md`: flush with the sides and bottom, lifted by an on-screen keyboard, under 56px of backdrop to press.
|
|
27
|
+
'pt-(--modal-pt) pb-[calc(var(--modal-pb)+var(--modal-keyboard))] [--modal-pb:0px] [--modal-pt:56px] md:[--modal-pb:32px] md:[--modal-pt:32px]', '[--modal-keyboard:max(0px,calc(100dvh-var(--visual-viewport-height)))] md:[--modal-keyboard:0px]',
|
|
22
28
|
// Animations
|
|
23
29
|
state.isEntering && 'duration-300 ease-out animate-in fade-in', state.isExiting && 'duration-200 ease-in animate-out fade-out', typeof props.className === 'function' ? props.className(state) : props.className) }) }));
|
|
24
30
|
};
|
|
@@ -29,20 +35,81 @@ const ModalOverlay = ({ 'data-testid': dataTestId, ...props }) => {
|
|
|
29
35
|
*
|
|
30
36
|
* @summary accessible overlay dialog for focused content or actions
|
|
31
37
|
*/
|
|
32
|
-
const Modal = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const Modal = ({ children, ...props }) => {
|
|
39
|
+
return (jsxRuntime.jsx(reactAriaComponents.Modal, { ...props, className: (state) => cx.cx('bg-primary align-middle shadow-xl outline-hidden md:rounded-2xl',
|
|
40
|
+
// Sheet below `md`: always the full width, whatever width the consumer gave the centred card.
|
|
41
|
+
'max-md:scrollbar-thin max-md:flex max-md:w-full! max-md:max-w-full! max-md:flex-col max-md:overflow-y-auto max-md:rounded-t-3xl max-md:rounded-b-none max-md:ring-1 max-md:ring-secondary_alt',
|
|
42
|
+
// Clears the home indicator with a spacer, not padding a consumer may set; an open keyboard already covers the indicator.
|
|
43
|
+
'max-md:after:shrink-0 max-md:after:h-[max(0px,calc(env(safe-area-inset-bottom)-var(--modal-keyboard)))]',
|
|
44
|
+
// Max height based on parent's vertical padding; the visual viewport already excludes the keyboard.
|
|
45
|
+
'max-h-[calc(var(--visual-viewport-height)-var(--modal-pt)-var(--modal-pb))]',
|
|
46
|
+
// Animations: the sheet slides up from the bottom edge, the centred card zooms.
|
|
47
|
+
state.isEntering && 'duration-300 ease-out animate-in max-md:slide-in-from-bottom-[100%] max-md:motion-reduce:animate-none md:zoom-in-95', state.isExiting && 'duration-200 ease-in animate-out max-md:slide-out-to-bottom-[100%] max-md:motion-reduce:animate-none md:zoom-out-95', typeof props.className === 'function' ? props.className(state) : props.className), children: (renderProps) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(PageScrollbarGutterRelease.PageScrollbarGutterRelease, {}), typeof children === 'function' ? children(renderProps) : children] })) }));
|
|
48
|
+
};
|
|
37
49
|
/** Scrollable, focus-managed content container that sits inside `Modal` and holds the dialog's content. */
|
|
38
50
|
const Dialog = ({ 'data-testid': dataTestId, ...props }) => {
|
|
39
51
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
40
52
|
const dialogTestId = dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, 'dialog') : undefined);
|
|
41
|
-
return (jsxRuntime.jsx(reactAriaComponents.Dialog, { ...props, "data-testid": dialogTestId, className: cx.cx('relative max-h-[inherit] w-full overflow-y-auto outline-hidden',
|
|
53
|
+
return (jsxRuntime.jsx(reactAriaComponents.Dialog, { ...props, "data-testid": dialogTestId, className: cx.cx('relative max-h-[inherit] w-full overflow-y-auto outline-hidden max-md:scrollbar-thin',
|
|
54
|
+
// With a `ModalBody` inside, the body scrolls and the dialog becomes the column that holds the header and footer still.
|
|
55
|
+
'has-[[data-fd-modal-body]]:flex has-[[data-fd-modal-body]]:flex-col has-[[data-fd-modal-body]]:overflow-hidden', props.className) }));
|
|
56
|
+
};
|
|
57
|
+
/** Header of a dialog built from parts: the title that names it, always in view while `ModalBody` scrolls, with the close button. */
|
|
58
|
+
const ModalHeader = ({ title, description, icon, iconColor = 'gray', showCloseButton = true, className, children, 'data-testid': dataTestId, ...props }) => {
|
|
59
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
60
|
+
// An id given to the header re-roots what it holds; otherwise the close button and icon derive from the dialog's root.
|
|
61
|
+
const partsPrefix = dataTestId ?? prefix;
|
|
62
|
+
return (jsxRuntime.jsxs("div", { ...props, "data-testid": dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, 'header') : undefined),
|
|
63
|
+
// Right padding clears the close button, so a long title wraps instead of running under it.
|
|
64
|
+
className: cx.cx('relative flex w-full shrink-0 gap-3 px-6 pt-6',
|
|
65
|
+
// An icon's circle is centred on a lone title and sits at the top of a title with a description.
|
|
66
|
+
description ? 'items-start' : 'items-center',
|
|
67
|
+
// A bare title sits closer to the content it heads than an icon's circle does.
|
|
68
|
+
icon ? 'pb-6' : 'pb-4', showCloseButton && 'pr-14', className), children: [jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: partsPrefix, children: icon && jsxRuntime.jsx(FeaturedIcon.FeaturedIcon, { icon: icon, size: "md", color: iconColor, theme: "light" }) }), jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [title && (jsxRuntime.jsx(reactAriaComponents.Heading, { slot: "title", className: "text-lg font-semibold text-primary", children: title })), description && jsxRuntime.jsx("p", { className: "text-sm text-tertiary", children: description }), children] }), showCloseButton && (jsxRuntime.jsx(Buttons.CloseButton, { slot: "close", size: "sm", className: "absolute top-3 right-3 shrink-0", "data-testid": partsPrefix ? testIdUtils.joinTestId(partsPrefix, 'close') : undefined }))] }));
|
|
69
|
+
};
|
|
70
|
+
/** Content area of a dialog built from parts, and the only one that scrolls: `ModalHeader` and `ModalFooter` stay in view around it. Plain text in it takes the body text style. */
|
|
71
|
+
const ModalBody = ({ className, 'data-testid': dataTestId, ...props }) => {
|
|
72
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
73
|
+
const bodyRef = React.useRef(null);
|
|
74
|
+
// Text that scrolls and holds no control gets a tab stop of its own, or a keyboard could not scroll it (axe: scrollable-region-focusable).
|
|
75
|
+
const [needsTabStop, setNeedsTabStop] = React.useState(false);
|
|
76
|
+
const measure = React.useCallback(() => {
|
|
77
|
+
const body = bodyRef.current;
|
|
78
|
+
if (body)
|
|
79
|
+
setNeedsTabStop(modalBody_utils.needsOwnTabStop(body));
|
|
80
|
+
}, []);
|
|
81
|
+
useResizeObserver.useResizeObserver({ ref: bodyRef, onResize: measure });
|
|
82
|
+
// A child can gain or lose its last control, or its text grow, without the body re-rendering or its own box changing.
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
const body = bodyRef.current;
|
|
85
|
+
if (!body)
|
|
86
|
+
return;
|
|
87
|
+
measure();
|
|
88
|
+
const observer = new MutationObserver(measure);
|
|
89
|
+
observer.observe(body, {
|
|
90
|
+
childList: true,
|
|
91
|
+
subtree: true,
|
|
92
|
+
characterData: true,
|
|
93
|
+
attributes: true,
|
|
94
|
+
attributeFilter: ['disabled', 'hidden', 'inert', 'tabindex', 'type'],
|
|
95
|
+
});
|
|
96
|
+
return () => observer.disconnect();
|
|
97
|
+
}, [measure]);
|
|
98
|
+
return (jsxRuntime.jsx("div", { ...props, ref: bodyRef, "data-fd-modal-body": "", "data-testid": dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, 'body') : undefined), tabIndex: needsTabStop ? 0 : undefined, className: cx.cx('min-h-0 flex-1 overflow-y-auto px-6 pb-6 text-sm text-secondary outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2 max-md:scrollbar-thin', className) }));
|
|
99
|
+
};
|
|
100
|
+
/** Actions of a dialog built from parts, in view under `ModalBody`: a row at the right from `md`, stacked at full width below it with the last one first. */
|
|
101
|
+
const ModalFooter = ({ className, 'data-testid': dataTestId, ...props }) => {
|
|
102
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
103
|
+
return (jsxRuntime.jsx("div", { ...props, "data-testid": dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, 'footer') : undefined),
|
|
104
|
+
// Stacked below `md`, the primary action last in the markup and first on screen: side by side, translated labels wrap or clip on a phone.
|
|
105
|
+
className: cx.cx('flex shrink-0 flex-col-reverse gap-3 border-t border-secondary px-6 py-4 md:flex-row md:justify-end', className) }));
|
|
42
106
|
};
|
|
43
107
|
|
|
44
108
|
exports.Dialog = Dialog;
|
|
45
109
|
exports.DialogTrigger = DialogTrigger;
|
|
46
110
|
exports.Modal = Modal;
|
|
111
|
+
exports.ModalBody = ModalBody;
|
|
112
|
+
exports.ModalFooter = ModalFooter;
|
|
113
|
+
exports.ModalHeader = ModalHeader;
|
|
47
114
|
exports.ModalOverlay = ModalOverlay;
|
|
48
115
|
//# sourceMappingURL=Modal.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.cjs","sources":["../../../../../src/components/molecules/Modals/Modal/Modal.tsx"],"sourcesContent":[null],"names":["AriaDialogTrigger","useResolvedTestId","_jsx","TestIdProvider","AriaModalOverlay","cx","AriaModal","useTestIdPrefix","joinTestId","AriaDialog"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.cjs","sources":["../../../../../src/components/molecules/Modals/Modal/Modal.tsx"],"sourcesContent":[null],"names":["AriaDialogTrigger","useResolvedTestId","_jsx","TestIdProvider","AriaModalOverlay","cx","AriaModal","_jsxs","_Fragment","PageScrollbarGutterRelease","useTestIdPrefix","joinTestId","AriaDialog","FeaturedIcon","AriaHeading","CloseButton","useRef","useState","useCallback","needsOwnTabStop","useResizeObserver","useEffect"],"mappings":";;;;;;;;;;;;;AAoBA;AACO,MAAM,aAAa,GAAGA;AAU7B;;;;;;AAMG;AACI,MAAM,YAAY,GAAG,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAqB,KAAI;AACzF,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEjG,QACEC,cAAA,CAACC,0BAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/BD,cAAA,CAACE,gCAAgB,EAAA,EAAA,GACX,KAAK,iBACI,UAAU,EACvB,SAAS,EAAE,CAAC,KAAK,KACfC,KAAE,CACA,4IAA4I;;AAE5I,YAAA,+IAA+I,EAC/I,kGAAkG;;AAElG,YAAA,KAAK,CAAC,UAAU,IAAI,0CAA0C,EAC9D,KAAK,CAAC,SAAS,IAAI,2CAA2C,EAC9D,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,SAAS,CACjF,EAAA,CAEH,EAAA,CACa;AAErB;AAEA;;;;;;AAMG;AACI,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAyB,KAAI;AACrE,IAAA,QACEH,cAAA,CAACI,yBAAS,EAAA,EAAA,GACJ,KAAK,EACT,SAAS,EAAE,CAAC,KAAK,KACfD,KAAE,CACA,iEAAiE;;QAEjE,+LAA+L;;QAE/L,yGAAyG;;QAEzG,6EAA6E;;AAE7E,QAAA,KAAK,CAAC,UAAU,IA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,MAAM,WAAW,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAoB,KAAI;AAClG,IAAA,MAAM,MAAM,GAAGK,2BAAe,EAAE;IAEhC,QACER,2BACM,KAAK,EAAA,aAAA,EACI,UAAU,KAAK,MAAM,GAAGS,sBAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC;;QAE9E,SAAS,EAAEN,KAAE,CAAC,qGAAqG,EAAE,SAAS,CAAC,EAAA,CAC/H;AAEN;;;;;;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type FeaturedIconProps } from '@flipdish/ui-library/components/atoms/FeaturedIcon';
|
|
2
|
+
import type { ComponentPropsWithoutRef, FC, ReactNode } from 'react';
|
|
1
3
|
import type { DialogProps as AriaDialogProps, ModalOverlayProps as AriaModalOverlayProps } from 'react-aria-components';
|
|
2
4
|
import { DialogTrigger as AriaDialogTrigger } from 'react-aria-components';
|
|
3
5
|
/** Opens the modal when its child button is pressed; a plain alias of react-aria-components' `DialogTrigger`. */
|
|
@@ -24,7 +26,7 @@ export declare const ModalOverlay: ({ "data-testid": dataTestId, ...props }: Mod
|
|
|
24
26
|
*
|
|
25
27
|
* @summary accessible overlay dialog for focused content or actions
|
|
26
28
|
*/
|
|
27
|
-
export declare const Modal: (props: AriaModalOverlayProps) => import("react").JSX.Element;
|
|
29
|
+
export declare const Modal: ({ children, ...props }: AriaModalOverlayProps) => import("react").JSX.Element;
|
|
28
30
|
export interface DialogProps extends AriaDialogProps {
|
|
29
31
|
/**
|
|
30
32
|
* Overrides the derived `data-testid` for the dialog (defaults to `<root>--dialog`,
|
|
@@ -34,4 +36,36 @@ export interface DialogProps extends AriaDialogProps {
|
|
|
34
36
|
}
|
|
35
37
|
/** Scrollable, focus-managed content container that sits inside `Modal` and holds the dialog's content. */
|
|
36
38
|
export declare const Dialog: ({ "data-testid": dataTestId, ...props }: DialogProps) => import("react").JSX.Element;
|
|
39
|
+
export interface ModalHeaderProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {
|
|
40
|
+
/** What the dialog is about, rendered as its heading. It also names the dialog, so `Dialog` needs no `aria-label`. */
|
|
41
|
+
title?: ReactNode;
|
|
42
|
+
/** A supporting line under the title. */
|
|
43
|
+
description?: ReactNode;
|
|
44
|
+
/** Icon shown in a circle beside the title, as the bottom sheets that replace a popover have. */
|
|
45
|
+
icon?: FC<{
|
|
46
|
+
className?: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** Colours the icon by what the dialog means, such as `error` for one that removes something. */
|
|
49
|
+
iconColor?: FeaturedIconProps['color'];
|
|
50
|
+
/** Shows the close button in the header's top-right corner. Turn it off for a dialog that must be answered with one of its actions. */
|
|
51
|
+
showCloseButton?: boolean;
|
|
52
|
+
/** Content under the title and description, or all of the header's content when there is no `title`. */
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
/** Overrides the header's `data-testid` (defaults to `<root>--header`); its close button and icon then derive theirs from it. */
|
|
55
|
+
'data-testid'?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Header of a dialog built from parts: the title that names it, always in view while `ModalBody` scrolls, with the close button. */
|
|
58
|
+
export declare const ModalHeader: ({ title, description, icon, iconColor, showCloseButton, className, children, "data-testid": dataTestId, ...props }: ModalHeaderProps) => import("react").JSX.Element;
|
|
59
|
+
export interface ModalBodyProps extends ComponentPropsWithoutRef<'div'> {
|
|
60
|
+
/** Overrides the body's `data-testid` (defaults to `<root>--body`). */
|
|
61
|
+
'data-testid'?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Content area of a dialog built from parts, and the only one that scrolls: `ModalHeader` and `ModalFooter` stay in view around it. Plain text in it takes the body text style. */
|
|
64
|
+
export declare const ModalBody: ({ className, "data-testid": dataTestId, ...props }: ModalBodyProps) => import("react").JSX.Element;
|
|
65
|
+
export interface ModalFooterProps extends ComponentPropsWithoutRef<'div'> {
|
|
66
|
+
/** Overrides the footer's `data-testid` (defaults to `<root>--footer`). */
|
|
67
|
+
'data-testid'?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Actions of a dialog built from parts, in view under `ModalBody`: a row at the right from `md`, stacked at full width below it with the last one first. */
|
|
70
|
+
export declare const ModalFooter: ({ className, "data-testid": dataTestId, ...props }: ModalFooterProps) => import("react").JSX.Element;
|
|
37
71
|
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/Modal/Modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/Modal/Modal.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAI1G,OAAO,KAAK,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACxH,OAAO,EAEL,aAAa,IAAI,iBAAiB,EAInC,MAAM,uBAAuB,CAAC;AAI/B,iHAAiH;AACjH,eAAO,MAAM,aAAa,0BAAoB,CAAC;AAE/C,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,yCAAyC,iBAAiB,gCAuBtF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,wBAAwB,qBAAqB,gCA6BlE,CAAC;AAEF,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2GAA2G;AAC3G,eAAO,MAAM,MAAM,GAAI,yCAAyC,WAAW,gCAgB1E,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACtF,sHAAsH;IACtH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yCAAyC;IACzC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,iGAAiG;IACjG,IAAI,CAAC,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,iGAAiG;IACjG,SAAS,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvC,uIAAuI;IACvI,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wGAAwG;IACxG,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,iIAAiI;IACjI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qIAAqI;AACrI,eAAO,MAAM,WAAW,GAAI,oHAUzB,gBAAgB,gCAyClB,CAAC;AAEF,MAAM,WAAW,cAAe,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACrE,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oLAAoL;AACpL,eAAO,MAAM,SAAS,GAAI,oDAAoD,cAAc,gCAuC3F,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACvE,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,6JAA6J;AAC7J,eAAO,MAAM,WAAW,GAAI,oDAAoD,gBAAgB,gCAW/F,CAAC"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { CloseButton } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
3
|
+
import { FeaturedIcon } from '@flipdish/ui-library/components/atoms/FeaturedIcon';
|
|
4
|
+
import { useResizeObserver } from '@flipdish/ui-library/hooks/useResizeObserver';
|
|
2
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
-
import { useTestIdPrefix, joinTestId,
|
|
4
|
-
import {
|
|
6
|
+
import { useTestIdPrefix, joinTestId, TestIdProvider, useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
+
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
8
|
+
import { DialogTrigger as DialogTrigger$1, Dialog as Dialog$1, Modal as Modal$1, Heading, ModalOverlay as ModalOverlay$1 } from 'react-aria-components';
|
|
9
|
+
import { PageScrollbarGutterRelease } from '../../../__internal__/overlay/PageScrollbarGutterRelease.js';
|
|
10
|
+
import { needsOwnTabStop } from './utilities/modalBody.utils.js';
|
|
5
11
|
|
|
6
12
|
/** Opens the modal when its child button is pressed; a plain alias of react-aria-components' `DialogTrigger`. */
|
|
7
13
|
const DialogTrigger = DialogTrigger$1;
|
|
@@ -14,9 +20,9 @@ const DialogTrigger = DialogTrigger$1;
|
|
|
14
20
|
*/
|
|
15
21
|
const ModalOverlay = ({ 'data-testid': dataTestId, ...props }) => {
|
|
16
22
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'modal', rootName: 'modal' });
|
|
17
|
-
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(ModalOverlay$1, { ...props, "data-testid": rootTestId, className: (state) => cx('fixed inset-0 z-50 flex min-h-dvh w-full items-end justify-center bg-overlay/70
|
|
18
|
-
//
|
|
19
|
-
'pt-(--modal-pt) pb-(--modal-pb) [--modal-pb:
|
|
23
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(ModalOverlay$1, { ...props, "data-testid": rootTestId, className: (state) => cx('fixed inset-0 z-50 flex min-h-dvh w-full items-end justify-center bg-overlay/70 outline-hidden backdrop-blur-[6px] md:items-center md:px-8',
|
|
24
|
+
// A bottom sheet below `md`: flush with the sides and bottom, lifted by an on-screen keyboard, under 56px of backdrop to press.
|
|
25
|
+
'pt-(--modal-pt) pb-[calc(var(--modal-pb)+var(--modal-keyboard))] [--modal-pb:0px] [--modal-pt:56px] md:[--modal-pb:32px] md:[--modal-pt:32px]', '[--modal-keyboard:max(0px,calc(100dvh-var(--visual-viewport-height)))] md:[--modal-keyboard:0px]',
|
|
20
26
|
// Animations
|
|
21
27
|
state.isEntering && 'duration-300 ease-out animate-in fade-in', state.isExiting && 'duration-200 ease-in animate-out fade-out', typeof props.className === 'function' ? props.className(state) : props.className) }) }));
|
|
22
28
|
};
|
|
@@ -27,17 +33,75 @@ const ModalOverlay = ({ 'data-testid': dataTestId, ...props }) => {
|
|
|
27
33
|
*
|
|
28
34
|
* @summary accessible overlay dialog for focused content or actions
|
|
29
35
|
*/
|
|
30
|
-
const Modal = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
const Modal = ({ children, ...props }) => {
|
|
37
|
+
return (jsx(Modal$1, { ...props, className: (state) => cx('bg-primary align-middle shadow-xl outline-hidden md:rounded-2xl',
|
|
38
|
+
// Sheet below `md`: always the full width, whatever width the consumer gave the centred card.
|
|
39
|
+
'max-md:scrollbar-thin max-md:flex max-md:w-full! max-md:max-w-full! max-md:flex-col max-md:overflow-y-auto max-md:rounded-t-3xl max-md:rounded-b-none max-md:ring-1 max-md:ring-secondary_alt',
|
|
40
|
+
// Clears the home indicator with a spacer, not padding a consumer may set; an open keyboard already covers the indicator.
|
|
41
|
+
'max-md:after:shrink-0 max-md:after:h-[max(0px,calc(env(safe-area-inset-bottom)-var(--modal-keyboard)))]',
|
|
42
|
+
// Max height based on parent's vertical padding; the visual viewport already excludes the keyboard.
|
|
43
|
+
'max-h-[calc(var(--visual-viewport-height)-var(--modal-pt)-var(--modal-pb))]',
|
|
44
|
+
// Animations: the sheet slides up from the bottom edge, the centred card zooms.
|
|
45
|
+
state.isEntering && 'duration-300 ease-out animate-in max-md:slide-in-from-bottom-[100%] max-md:motion-reduce:animate-none md:zoom-in-95', state.isExiting && 'duration-200 ease-in animate-out max-md:slide-out-to-bottom-[100%] max-md:motion-reduce:animate-none md:zoom-out-95', typeof props.className === 'function' ? props.className(state) : props.className), children: (renderProps) => (jsxs(Fragment, { children: [jsx(PageScrollbarGutterRelease, {}), typeof children === 'function' ? children(renderProps) : children] })) }));
|
|
46
|
+
};
|
|
35
47
|
/** Scrollable, focus-managed content container that sits inside `Modal` and holds the dialog's content. */
|
|
36
48
|
const Dialog = ({ 'data-testid': dataTestId, ...props }) => {
|
|
37
49
|
const prefix = useTestIdPrefix();
|
|
38
50
|
const dialogTestId = dataTestId ?? (prefix ? joinTestId(prefix, 'dialog') : undefined);
|
|
39
|
-
return (jsx(Dialog$1, { ...props, "data-testid": dialogTestId, className: cx('relative max-h-[inherit] w-full overflow-y-auto outline-hidden',
|
|
51
|
+
return (jsx(Dialog$1, { ...props, "data-testid": dialogTestId, className: cx('relative max-h-[inherit] w-full overflow-y-auto outline-hidden max-md:scrollbar-thin',
|
|
52
|
+
// With a `ModalBody` inside, the body scrolls and the dialog becomes the column that holds the header and footer still.
|
|
53
|
+
'has-[[data-fd-modal-body]]:flex has-[[data-fd-modal-body]]:flex-col has-[[data-fd-modal-body]]:overflow-hidden', props.className) }));
|
|
54
|
+
};
|
|
55
|
+
/** Header of a dialog built from parts: the title that names it, always in view while `ModalBody` scrolls, with the close button. */
|
|
56
|
+
const ModalHeader = ({ title, description, icon, iconColor = 'gray', showCloseButton = true, className, children, 'data-testid': dataTestId, ...props }) => {
|
|
57
|
+
const prefix = useTestIdPrefix();
|
|
58
|
+
// An id given to the header re-roots what it holds; otherwise the close button and icon derive from the dialog's root.
|
|
59
|
+
const partsPrefix = dataTestId ?? prefix;
|
|
60
|
+
return (jsxs("div", { ...props, "data-testid": dataTestId ?? (prefix ? joinTestId(prefix, 'header') : undefined),
|
|
61
|
+
// Right padding clears the close button, so a long title wraps instead of running under it.
|
|
62
|
+
className: cx('relative flex w-full shrink-0 gap-3 px-6 pt-6',
|
|
63
|
+
// An icon's circle is centred on a lone title and sits at the top of a title with a description.
|
|
64
|
+
description ? 'items-start' : 'items-center',
|
|
65
|
+
// A bare title sits closer to the content it heads than an icon's circle does.
|
|
66
|
+
icon ? 'pb-6' : 'pb-4', showCloseButton && 'pr-14', className), children: [jsx(TestIdProvider, { value: partsPrefix, children: icon && jsx(FeaturedIcon, { icon: icon, size: "md", color: iconColor, theme: "light" }) }), jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [title && (jsx(Heading, { slot: "title", className: "text-lg font-semibold text-primary", children: title })), description && jsx("p", { className: "text-sm text-tertiary", children: description }), children] }), showCloseButton && (jsx(CloseButton, { slot: "close", size: "sm", className: "absolute top-3 right-3 shrink-0", "data-testid": partsPrefix ? joinTestId(partsPrefix, 'close') : undefined }))] }));
|
|
67
|
+
};
|
|
68
|
+
/** Content area of a dialog built from parts, and the only one that scrolls: `ModalHeader` and `ModalFooter` stay in view around it. Plain text in it takes the body text style. */
|
|
69
|
+
const ModalBody = ({ className, 'data-testid': dataTestId, ...props }) => {
|
|
70
|
+
const prefix = useTestIdPrefix();
|
|
71
|
+
const bodyRef = useRef(null);
|
|
72
|
+
// Text that scrolls and holds no control gets a tab stop of its own, or a keyboard could not scroll it (axe: scrollable-region-focusable).
|
|
73
|
+
const [needsTabStop, setNeedsTabStop] = useState(false);
|
|
74
|
+
const measure = useCallback(() => {
|
|
75
|
+
const body = bodyRef.current;
|
|
76
|
+
if (body)
|
|
77
|
+
setNeedsTabStop(needsOwnTabStop(body));
|
|
78
|
+
}, []);
|
|
79
|
+
useResizeObserver({ ref: bodyRef, onResize: measure });
|
|
80
|
+
// A child can gain or lose its last control, or its text grow, without the body re-rendering or its own box changing.
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const body = bodyRef.current;
|
|
83
|
+
if (!body)
|
|
84
|
+
return;
|
|
85
|
+
measure();
|
|
86
|
+
const observer = new MutationObserver(measure);
|
|
87
|
+
observer.observe(body, {
|
|
88
|
+
childList: true,
|
|
89
|
+
subtree: true,
|
|
90
|
+
characterData: true,
|
|
91
|
+
attributes: true,
|
|
92
|
+
attributeFilter: ['disabled', 'hidden', 'inert', 'tabindex', 'type'],
|
|
93
|
+
});
|
|
94
|
+
return () => observer.disconnect();
|
|
95
|
+
}, [measure]);
|
|
96
|
+
return (jsx("div", { ...props, ref: bodyRef, "data-fd-modal-body": "", "data-testid": dataTestId ?? (prefix ? joinTestId(prefix, 'body') : undefined), tabIndex: needsTabStop ? 0 : undefined, className: cx('min-h-0 flex-1 overflow-y-auto px-6 pb-6 text-sm text-secondary outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2 max-md:scrollbar-thin', className) }));
|
|
97
|
+
};
|
|
98
|
+
/** Actions of a dialog built from parts, in view under `ModalBody`: a row at the right from `md`, stacked at full width below it with the last one first. */
|
|
99
|
+
const ModalFooter = ({ className, 'data-testid': dataTestId, ...props }) => {
|
|
100
|
+
const prefix = useTestIdPrefix();
|
|
101
|
+
return (jsx("div", { ...props, "data-testid": dataTestId ?? (prefix ? joinTestId(prefix, 'footer') : undefined),
|
|
102
|
+
// Stacked below `md`, the primary action last in the markup and first on screen: side by side, translated labels wrap or clip on a phone.
|
|
103
|
+
className: cx('flex shrink-0 flex-col-reverse gap-3 border-t border-secondary px-6 py-4 md:flex-row md:justify-end', className) }));
|
|
40
104
|
};
|
|
41
105
|
|
|
42
|
-
export { Dialog, DialogTrigger, Modal, ModalOverlay };
|
|
106
|
+
export { Dialog, DialogTrigger, Modal, ModalBody, ModalFooter, ModalHeader, ModalOverlay };
|
|
43
107
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../../../src/components/molecules/Modals/Modal/Modal.tsx"],"sourcesContent":[null],"names":["AriaDialogTrigger","_jsx","AriaModalOverlay","AriaModal","AriaDialog"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../../../src/components/molecules/Modals/Modal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AEhC,QACEA,gBACM,KAAK,EAAA,aAAA,EACI,UAAU,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC;;QAE9E,SAAS,EAAE,EAAE,CAAC,qGAAqG,EAAE,SAAS,CAAC,EAAA,CAC/H;AAEN;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var focus = require('@react-aria/focus');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tells whether a dialog body needs a tab stop of its own: it scrolls and holds nothing a keyboard can reach, so without
|
|
7
|
+
* one a keyboard could not scroll it. A hidden input, a disabled control and a control that is not shown do not count.
|
|
8
|
+
*
|
|
9
|
+
* @param body The element that scrolls the dialog's content.
|
|
10
|
+
* @returns `true` when the body overflows and has no tabbable descendant.
|
|
11
|
+
*/
|
|
12
|
+
const needsOwnTabStop = (body) => body.scrollHeight > body.clientHeight && focus.getFocusableTreeWalker(body, { tabbable: true }).nextNode() === null;
|
|
13
|
+
|
|
14
|
+
exports.needsOwnTabStop = needsOwnTabStop;
|
|
15
|
+
//# sourceMappingURL=modalBody.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modalBody.utils.cjs","sources":["../../../../../../src/components/molecules/Modals/Modal/utilities/modalBody.utils.ts"],"sourcesContent":[null],"names":["getFocusableTreeWalker"],"mappings":";;;;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,IAAiB,KAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,IAAIA,4BAAsB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells whether a dialog body needs a tab stop of its own: it scrolls and holds nothing a keyboard can reach, so without
|
|
3
|
+
* one a keyboard could not scroll it. A hidden input, a disabled control and a control that is not shown do not count.
|
|
4
|
+
*
|
|
5
|
+
* @param body The element that scrolls the dialog's content.
|
|
6
|
+
* @returns `true` when the body overflows and has no tabbable descendant.
|
|
7
|
+
*/
|
|
8
|
+
export declare const needsOwnTabStop: (body: HTMLElement) => boolean;
|
|
9
|
+
//# sourceMappingURL=modalBody.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modalBody.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/molecules/Modals/Modal/utilities/modalBody.utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,WAAW,KAAG,OAC2D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getFocusableTreeWalker } from '@react-aria/focus';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tells whether a dialog body needs a tab stop of its own: it scrolls and holds nothing a keyboard can reach, so without
|
|
5
|
+
* one a keyboard could not scroll it. A hidden input, a disabled control and a control that is not shown do not count.
|
|
6
|
+
*
|
|
7
|
+
* @param body The element that scrolls the dialog's content.
|
|
8
|
+
* @returns `true` when the body overflows and has no tabbable descendant.
|
|
9
|
+
*/
|
|
10
|
+
const needsOwnTabStop = (body) => body.scrollHeight > body.clientHeight && getFocusableTreeWalker(body, { tabbable: true }).nextNode() === null;
|
|
11
|
+
|
|
12
|
+
export { needsOwnTabStop };
|
|
13
|
+
//# sourceMappingURL=modalBody.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modalBody.utils.js","sources":["../../../../../../src/components/molecules/Modals/Modal/utilities/modalBody.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,IAAiB,KAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,sBAAsB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
4
5
|
var Buttons = require('@flipdish/ui-library/components/atoms/Buttons');
|
|
5
6
|
var useUnsavedChangesGuard = require('@flipdish/ui-library/hooks/useUnsavedChangesGuard');
|
|
6
7
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
@@ -13,17 +14,16 @@ var Modal = require('../Modal/Modal.cjs');
|
|
|
13
14
|
*
|
|
14
15
|
* @summary confirm dialog that stops navigation losing unsaved changes
|
|
15
16
|
*/
|
|
16
|
-
const UnsavedChangesModal = ({ hasUnsavedChanges, 'data-testid': dataTestId }) => {
|
|
17
|
+
const UnsavedChangesModal = ({ hasUnsavedChanges, isDismissable = true, 'data-testid': dataTestId }) => {
|
|
17
18
|
const { isPromptOpen, stay, discard } = useUnsavedChangesGuard.useUnsavedChangesGuard({ hasUnsavedChanges });
|
|
18
19
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'unsaved-changes-modal', rootName: 'unsaved-changes-modal' });
|
|
19
|
-
const titleId = React.useId();
|
|
20
20
|
const descriptionId = React.useId();
|
|
21
|
-
// Escape
|
|
21
|
+
// Escape, the close button and a press outside close the dialog, which must cancel the navigation and never let it through.
|
|
22
22
|
const stayOnClose = (isOpen) => {
|
|
23
23
|
if (!isOpen)
|
|
24
24
|
stay();
|
|
25
25
|
};
|
|
26
|
-
return (jsxRuntime.jsx(Modal.ModalOverlay, { isOpen: isPromptOpen, onOpenChange: stayOnClose, "data-testid": rootTestId, children: jsxRuntime.jsx(Modal.Modal, { className: "w-full
|
|
26
|
+
return (jsxRuntime.jsx(Modal.ModalOverlay, { isOpen: isPromptOpen, onOpenChange: stayOnClose, isDismissable: isDismissable, "data-testid": rootTestId, children: jsxRuntime.jsx(Modal.Modal, { className: "w-full md:max-w-100", children: jsxRuntime.jsxs(Modal.Dialog, { role: "alertdialog", "aria-describedby": descriptionId, children: [jsxRuntime.jsx(Modal.ModalHeader, { title: "Unsaved changes", icon: uiIcons.AlertTriangle, iconColor: "error", showCloseButton: isDismissable }), jsxRuntime.jsx(Modal.ModalBody, { id: descriptionId, children: "You have changes that have not been saved. If you leave now, they will be lost." }), jsxRuntime.jsxs(Modal.ModalFooter, { children: [jsxRuntime.jsx(Buttons.Button, { color: "secondary", onPress: stay, "data-testid": testIdUtils.joinTestId(rootTestId, 'stay'), children: "Stay" }), jsxRuntime.jsx(Buttons.Button, { color: "primary-destructive", iconLeading: uiIcons.Trash01, onPress: discard, "data-testid": testIdUtils.joinTestId(rootTestId, 'discard'), children: "Discard changes" })] })] }) }) }));
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
exports.UnsavedChangesModal = UnsavedChangesModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsavedChangesModal.cjs","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"sourcesContent":[null],"names":["useUnsavedChangesGuard","useResolvedTestId","useId","_jsx","ModalOverlay","Modal","Dialog","
|
|
1
|
+
{"version":3,"file":"UnsavedChangesModal.cjs","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"sourcesContent":[null],"names":["useUnsavedChangesGuard","useResolvedTestId","useId","_jsx","ModalOverlay","Modal","_jsxs","Dialog","ModalHeader","AlertTriangle","ModalBody","ModalFooter","Button","joinTestId","Trash01"],"mappings":";;;;;;;;;;AAkBA;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAAE,iBAAiB,EAAE,aAAa,GAAG,IAAI,EAAE,aAAa,EAAE,UAAU,EAA4B,KAAI;AACtI,IAAA,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,GA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EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,iBAAA,EAAA,CAEjH,CAAA,EAAA,CACG,CAAA,EAAA,CACP,EAAA,CACH,EAAA,CACK;AAEnB;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface UnsavedChangesModalProps {
|
|
2
2
|
/** Whether there are unsaved changes to protect, such as a form's dirty flag. */
|
|
3
3
|
hasUnsavedChanges: boolean;
|
|
4
|
-
/**
|
|
4
|
+
/** Lets the close button and a press outside cancel the navigation, the same as Stay. Turn it off when only the two buttons may answer. */
|
|
5
|
+
isDismissable?: boolean;
|
|
6
|
+
/** Overrides the root `data-testid` (defaults to `fd-unsaved-changes-modal`); the parts and the buttons derive theirs from it. */
|
|
5
7
|
'data-testid'?: string;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
@@ -10,5 +12,5 @@ export interface UnsavedChangesModalProps {
|
|
|
10
12
|
*
|
|
11
13
|
* @summary confirm dialog that stops navigation losing unsaved changes
|
|
12
14
|
*/
|
|
13
|
-
export declare const UnsavedChangesModal: ({ hasUnsavedChanges, "data-testid": dataTestId }: UnsavedChangesModalProps) => import("react").JSX.Element;
|
|
15
|
+
export declare const UnsavedChangesModal: ({ hasUnsavedChanges, isDismissable, "data-testid": dataTestId }: UnsavedChangesModalProps) => import("react").JSX.Element;
|
|
14
16
|
//# sourceMappingURL=UnsavedChangesModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsavedChangesModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UnsavedChangesModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2IAA2I;IAC3I,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kIAAkI;IAClI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,iEAAwE,wBAAwB,gCA2BnI,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { AlertTriangle, Trash01 } from '@flipdish/ui-icons';
|
|
2
3
|
import { Button } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
3
4
|
import { useUnsavedChangesGuard } from '@flipdish/ui-library/hooks/useUnsavedChangesGuard';
|
|
4
5
|
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
6
|
import { useId } from 'react';
|
|
6
|
-
import { ModalOverlay, Modal, Dialog } from '../Modal/Modal.js';
|
|
7
|
+
import { ModalOverlay, Modal, Dialog, ModalHeader, ModalBody, ModalFooter } from '../Modal/Modal.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Asks before unsaved changes are lost: a confirm dialog on navigation and the back button, and the browser's own
|
|
@@ -11,17 +12,16 @@ import { ModalOverlay, Modal, Dialog } from '../Modal/Modal.js';
|
|
|
11
12
|
*
|
|
12
13
|
* @summary confirm dialog that stops navigation losing unsaved changes
|
|
13
14
|
*/
|
|
14
|
-
const UnsavedChangesModal = ({ hasUnsavedChanges, 'data-testid': dataTestId }) => {
|
|
15
|
+
const UnsavedChangesModal = ({ hasUnsavedChanges, isDismissable = true, 'data-testid': dataTestId }) => {
|
|
15
16
|
const { isPromptOpen, stay, discard } = useUnsavedChangesGuard({ hasUnsavedChanges });
|
|
16
17
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'unsaved-changes-modal', rootName: 'unsaved-changes-modal' });
|
|
17
|
-
const titleId = useId();
|
|
18
18
|
const descriptionId = useId();
|
|
19
|
-
// Escape
|
|
19
|
+
// Escape, the close button and a press outside close the dialog, which must cancel the navigation and never let it through.
|
|
20
20
|
const stayOnClose = (isOpen) => {
|
|
21
21
|
if (!isOpen)
|
|
22
22
|
stay();
|
|
23
23
|
};
|
|
24
|
-
return (jsx(ModalOverlay, { isOpen: isPromptOpen, onOpenChange: stayOnClose, "data-testid": rootTestId, children: jsx(Modal, { className: "w-full
|
|
24
|
+
return (jsx(ModalOverlay, { isOpen: isPromptOpen, onOpenChange: stayOnClose, isDismissable: isDismissable, "data-testid": rootTestId, children: jsx(Modal, { className: "w-full md:max-w-100", children: jsxs(Dialog, { role: "alertdialog", "aria-describedby": descriptionId, children: [jsx(ModalHeader, { title: "Unsaved changes", icon: AlertTriangle, iconColor: "error", showCloseButton: isDismissable }), jsx(ModalBody, { id: descriptionId, children: "You have changes that have not been saved. If you leave now, they will be lost." }), jsxs(ModalFooter, { children: [jsx(Button, { color: "secondary", onPress: stay, "data-testid": joinTestId(rootTestId, 'stay'), children: "Stay" }), jsx(Button, { color: "primary-destructive", iconLeading: Trash01, onPress: discard, "data-testid": joinTestId(rootTestId, 'discard'), children: "Discard changes" })] })] }) }) }));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export { UnsavedChangesModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsavedChangesModal.js","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UnsavedChangesModal.js","sources":["../../../../../src/components/molecules/Modals/UnsavedChangesModal/UnsavedChangesModal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAkBA;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAAE,iBAAiB,EAAE,aAAa,GAAG,IAAI,EAAE,aAAa,EAAE,UAAU,EAA4B,KAAI;AACtI,IAAA,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,sBAA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A,EAAA,iBAAA,EAAA,CAEjH,CAAA,EAAA,CACG,CAAA,EAAA,CACP,EAAA,CACH,EAAA,CACK;AAEnB;;"}
|
|
@@ -10,6 +10,9 @@ exports.ConfirmationModal = ConfirmationModal.ConfirmationModal;
|
|
|
10
10
|
exports.Dialog = Modal.Dialog;
|
|
11
11
|
exports.DialogTrigger = Modal.DialogTrigger;
|
|
12
12
|
exports.Modal = Modal.Modal;
|
|
13
|
+
exports.ModalBody = Modal.ModalBody;
|
|
14
|
+
exports.ModalFooter = Modal.ModalFooter;
|
|
15
|
+
exports.ModalHeader = Modal.ModalHeader;
|
|
13
16
|
exports.ModalOverlay = Modal.ModalOverlay;
|
|
14
17
|
exports.UnsavedChangesModal = UnsavedChangesModal.UnsavedChangesModal;
|
|
15
18
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export type { ConfirmationModalProps } from './ConfirmationModal/ConfirmationModal';
|
|
11
11
|
export { ConfirmationModal } from './ConfirmationModal/ConfirmationModal';
|
|
12
|
-
export type { DialogProps, ModalOverlayProps } from './Modal/Modal';
|
|
13
|
-
export { Dialog, DialogTrigger, Modal, ModalOverlay } from './Modal/Modal';
|
|
12
|
+
export type { DialogProps, ModalBodyProps, ModalFooterProps, ModalHeaderProps, ModalOverlayProps } from './Modal/Modal';
|
|
13
|
+
export { Dialog, DialogTrigger, Modal, ModalBody, ModalFooter, ModalHeader, ModalOverlay } from './Modal/Modal';
|
|
14
14
|
export type { UnsavedChangesModalProps } from './UnsavedChangesModal/UnsavedChangesModal';
|
|
15
15
|
export { UnsavedChangesModal } from './UnsavedChangesModal/UnsavedChangesModal';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Modals/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Modals/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChH,YAAY,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ConfirmationModal } from './ConfirmationModal/ConfirmationModal.js';
|
|
2
|
-
export { Dialog, DialogTrigger, Modal, ModalOverlay } from './Modal/Modal.js';
|
|
2
|
+
export { Dialog, DialogTrigger, Modal, ModalBody, ModalFooter, ModalHeader, ModalOverlay } from './Modal/Modal.js';
|
|
3
3
|
export { UnsavedChangesModal } from './UnsavedChangesModal/UnsavedChangesModal.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Buttons = require('@flipdish/ui-library/components/atoms/Buttons');
|
|
5
6
|
var Tooltip = require('@flipdish/ui-library/components/atoms/Tooltip');
|
|
6
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
7
8
|
var React = require('react');
|
|
@@ -9,7 +10,8 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
9
10
|
var CommandShortcut = require('./CommandShortcut.cjs');
|
|
10
11
|
|
|
11
12
|
const CommandInput = React.forwardRef(({ placeholder, shortcutHint, tooltip, className, ...props }, ref) => {
|
|
12
|
-
|
|
13
|
+
const overlayState = React.useContext(reactAriaComponents.OverlayTriggerStateContext);
|
|
14
|
+
return (jsxRuntime.jsxs(reactAriaComponents.Group, { className: ({ isFocusWithin }) => cx.cx('flex items-center gap-x-2 rounded-xl bg-primary p-4', isFocusWithin && 'outline-2 outline-focus-ring', className), children: [jsxRuntime.jsx("div", { className: "pointer-events-none absolute", children: jsxRuntime.jsx(uiIcons.SearchLg, { className: "size-5 text-fg-quaternary" }) }), jsxRuntime.jsx(reactAriaComponents.Input, { placeholder: placeholder, className: "m-0 w-full bg-transparent pl-7 text-md text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary", ...props, ref: ref }), tooltip && (jsxRuntime.jsx(Tooltip.Tooltip, { title: tooltip, placement: "top", children: jsxRuntime.jsx(Tooltip.TooltipTrigger, { className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: jsxRuntime.jsx(uiIcons.HelpCircle, { className: "size-4 stroke-[2.25px]" }) }) })), shortcutHint && jsxRuntime.jsx(CommandShortcut.CommandShortcut, { keys: [shortcutHint], className: "max-md:hidden" }), overlayState && jsxRuntime.jsx(Buttons.CloseButton, { size: "sm", label: "Close command menu", onPress: overlayState.close, className: "-my-1.5 -mr-2 md:hidden" })] }));
|
|
13
15
|
});
|
|
14
16
|
CommandInput.displayName = 'CommandInput';
|
|
15
17
|
|