@flipdish/ui-library 0.64.1 → 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/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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactAriaComponents = require('react-aria-components');
|
|
5
|
+
var useReleasePageScrollbarGutter = require('../../../hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Rendered inside a react-aria modal overlay, where it reads that overlay's open state: while the overlay is open the
|
|
9
|
+
* page gives up the scrollbar gutter react-aria reserves, so the backdrop covers the full width of the window.
|
|
10
|
+
*/
|
|
11
|
+
const PageScrollbarGutterRelease = () => {
|
|
12
|
+
const overlayState = React.useContext(reactAriaComponents.OverlayTriggerStateContext);
|
|
13
|
+
useReleasePageScrollbarGutter.useReleasePageScrollbarGutter(overlayState?.isOpen ?? true);
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.PageScrollbarGutterRelease = PageScrollbarGutterRelease;
|
|
18
|
+
//# sourceMappingURL=PageScrollbarGutterRelease.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageScrollbarGutterRelease.cjs","sources":["../../../../src/components/__internal__/overlay/PageScrollbarGutterRelease.tsx"],"sourcesContent":[null],"names":["useContext","OverlayTriggerStateContext","useReleasePageScrollbarGutter"],"mappings":";;;;;;AAMA;;;AAGG;AACI,MAAM,0BAA0B,GAAG,MAAK;AAC7C,IAAA,MAAM,YAAY,GAAGA,gBAAU,CAACC,8CAA0B,CAAC;AAC3D,IAAAC,2DAA6B,CAAC,YAAY,EAAE,MAAM,IAAI,IAAI,CAAC;AAE3D,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendered inside a react-aria modal overlay, where it reads that overlay's open state: while the overlay is open the
|
|
3
|
+
* page gives up the scrollbar gutter react-aria reserves, so the backdrop covers the full width of the window.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PageScrollbarGutterRelease: () => null;
|
|
6
|
+
//# sourceMappingURL=PageScrollbarGutterRelease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageScrollbarGutterRelease.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/overlay/PageScrollbarGutterRelease.tsx"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,0BAA0B,YAKtC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { OverlayTriggerStateContext } from 'react-aria-components';
|
|
3
|
+
import { useReleasePageScrollbarGutter } from '../../../hooks/__internal__/useReleasePageScrollbarGutter/useReleasePageScrollbarGutter.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Rendered inside a react-aria modal overlay, where it reads that overlay's open state: while the overlay is open the
|
|
7
|
+
* page gives up the scrollbar gutter react-aria reserves, so the backdrop covers the full width of the window.
|
|
8
|
+
*/
|
|
9
|
+
const PageScrollbarGutterRelease = () => {
|
|
10
|
+
const overlayState = useContext(OverlayTriggerStateContext);
|
|
11
|
+
useReleasePageScrollbarGutter(overlayState?.isOpen ?? true);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { PageScrollbarGutterRelease };
|
|
16
|
+
//# sourceMappingURL=PageScrollbarGutterRelease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageScrollbarGutterRelease.js","sources":["../../../../src/components/__internal__/overlay/PageScrollbarGutterRelease.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;;;AAGG;AACI,MAAM,0BAA0B,GAAG,MAAK;AAC7C,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,0BAA0B,CAAC;AAC3D,IAAA,6BAA6B,CAAC,YAAY,EAAE,MAAM,IAAI,IAAI,CAAC;AAE3D,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -16,10 +16,12 @@ const ScrollClosingPopover = (props) => {
|
|
|
16
16
|
const [isOpen, setOpen] = utils.useControlledState(props.isOpen, props.defaultOpen ?? false, props.onOpenChange);
|
|
17
17
|
const close = React.useCallback(() => setOpen(false), [setOpen]);
|
|
18
18
|
const ownState = React.useMemo(() => ({ isOpen, close }), [isOpen, close]);
|
|
19
|
-
|
|
19
|
+
// Only a popover that is on screen closes on scroll: react-aria also renders this component in a hidden pass with no element of its own.
|
|
20
|
+
const popoverRef = React.useRef(null);
|
|
21
|
+
useCloseOnTriggerScroll.useCloseOnTriggerScroll({ triggerRef: props.triggerRef, state: ownsState ? ownState : undefined, slot: props.slot, popoverRef });
|
|
20
22
|
if (!ownsState)
|
|
21
|
-
return jsxRuntime.jsx(reactAriaComponents.Popover, { ...props });
|
|
22
|
-
return jsxRuntime.jsx(reactAriaComponents.Popover, { ...props, isOpen: isOpen, onOpenChange: setOpen });
|
|
23
|
+
return jsxRuntime.jsx(reactAriaComponents.Popover, { ...props, ref: popoverRef });
|
|
24
|
+
return jsxRuntime.jsx(reactAriaComponents.Popover, { ...props, ref: popoverRef, isOpen: isOpen, onOpenChange: setOpen });
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
exports.ScrollClosingPopover = ScrollClosingPopover;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollClosingPopover.cjs","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"sourcesContent":[null],"names":["useControlledState","useCallback","useMemo","useCloseOnTriggerScroll","_jsx","AriaPopover"],"mappings":";;;;;;;;AAQA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAuB,KAAI;;AAE9D,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI;IACnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAGA,wBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;AAC1G,IAAA,MAAM,KAAK,GAAGC,iBAAW,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAGC,aAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ScrollClosingPopover.cjs","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"sourcesContent":[null],"names":["useControlledState","useCallback","useMemo","useRef","useCloseOnTriggerScroll","_jsx","AriaPopover"],"mappings":";;;;;;;;AAQA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAuB,KAAI;;AAE9D,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI;IACnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAGA,wBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;AAC1G,IAAA,MAAM,KAAK,GAAGC,iBAAW,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAGC,aAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;;AAGpE,IAAA,MAAM,UAAU,GAAGC,YAAM,CAAc,IAAI,CAAC;AAE5C,IAAAC,+CAAuB,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;AAEhI,IAAA,IAAI,CAAC,SAAS;QAAE,OAAOC,cAAA,CAACC,2BAAW,EAAA,EAAA,GAAK,KAAK,EAAE,GAAG,EAAE,UAAU,EAAA,CAAI;AAClE,IAAA,OAAOD,eAACC,2BAAW,EAAA,EAAA,GAAK,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAI;AAC3F;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollClosingPopover.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ScrollClosingPopover.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,gBAAgB,gCAc3D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useControlledState } from '@react-stately/utils';
|
|
3
|
-
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { Popover } from 'react-aria-components';
|
|
5
5
|
import { useCloseOnTriggerScroll } from './hooks/useCloseOnTriggerScroll.js';
|
|
6
6
|
|
|
@@ -14,10 +14,12 @@ const ScrollClosingPopover = (props) => {
|
|
|
14
14
|
const [isOpen, setOpen] = useControlledState(props.isOpen, props.defaultOpen ?? false, props.onOpenChange);
|
|
15
15
|
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
16
16
|
const ownState = useMemo(() => ({ isOpen, close }), [isOpen, close]);
|
|
17
|
-
|
|
17
|
+
// Only a popover that is on screen closes on scroll: react-aria also renders this component in a hidden pass with no element of its own.
|
|
18
|
+
const popoverRef = useRef(null);
|
|
19
|
+
useCloseOnTriggerScroll({ triggerRef: props.triggerRef, state: ownsState ? ownState : undefined, slot: props.slot, popoverRef });
|
|
18
20
|
if (!ownsState)
|
|
19
|
-
return jsx(Popover, { ...props });
|
|
20
|
-
return jsx(Popover, { ...props, isOpen: isOpen, onOpenChange: setOpen });
|
|
21
|
+
return jsx(Popover, { ...props, ref: popoverRef });
|
|
22
|
+
return jsx(Popover, { ...props, ref: popoverRef, isOpen: isOpen, onOpenChange: setOpen });
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export { ScrollClosingPopover };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollClosingPopover.js","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"sourcesContent":[null],"names":["_jsx","AriaPopover"],"mappings":";;;;;;AAQA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAuB,KAAI;;AAE9D,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI;IACnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;AAC1G,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ScrollClosingPopover.js","sources":["../../../../src/components/__internal__/popover/ScrollClosingPopover.tsx"],"sourcesContent":[null],"names":["_jsx","AriaPopover"],"mappings":";;;;;;AAQA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAuB,KAAI;;AAE9D,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI;IACnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;AAC1G,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;;AAGpE,IAAA,MAAM,UAAU,GAAG,MAAM,CAAc,IAAI,CAAC;AAE5C,IAAA,uBAAuB,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;AAEhI,IAAA,IAAI,CAAC,SAAS;QAAE,OAAOA,GAAA,CAACC,OAAW,EAAA,EAAA,GAAK,KAAK,EAAE,GAAG,EAAE,UAAU,EAAA,CAAI;AAClE,IAAA,OAAOD,IAACC,OAAW,EAAA,EAAA,GAAK,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAI;AAC3F;;"}
|
|
@@ -21,12 +21,17 @@ const useCloseOnTriggerScroll = (options = {}) => {
|
|
|
21
21
|
const resolvedTriggerRef = options.triggerRef ?? popoverContext?.triggerRef;
|
|
22
22
|
const isOpen = state?.isOpen ?? false;
|
|
23
23
|
const close = state?.close;
|
|
24
|
+
const { popoverRef } = options;
|
|
24
25
|
React.useEffect(() => {
|
|
25
26
|
const trigger = resolvedTriggerRef?.current;
|
|
26
27
|
if (!isOpen || !close || !trigger)
|
|
27
28
|
return;
|
|
28
|
-
return scroll_utils.subscribeToAncestorScroll(trigger,
|
|
29
|
-
|
|
29
|
+
return scroll_utils.subscribeToAncestorScroll(trigger, () => {
|
|
30
|
+
if (popoverRef && !popoverRef.current)
|
|
31
|
+
return;
|
|
32
|
+
close();
|
|
33
|
+
});
|
|
34
|
+
}, [isOpen, close, resolvedTriggerRef, popoverRef]);
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
exports.useCloseOnTriggerScroll = useCloseOnTriggerScroll;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloseOnTriggerScroll.cjs","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"sourcesContent":[null],"names":["useContext","OverlayTriggerStateContext","useSlottedContext","PopoverContext","useEffect","subscribeToAncestorScroll"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useCloseOnTriggerScroll.cjs","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"sourcesContent":[null],"names":["useContext","OverlayTriggerStateContext","useSlottedContext","PopoverContext","useEffect","subscribeToAncestorScroll"],"mappings":";;;;;;AAqBA;;;;;;;;;AASG;MACU,uBAAuB,GAAG,CAAC,OAAA,GAA0C,EAAE,KAAI;AACtF,IAAA,MAAM,YAAY,GAAGA,gBAAU,CAACC,8CAA0B,CAAC;IAC3D,MAAM,cAAc,GAAGC,qCAAiB,CAACC,kCAAc,EAAE,OAAO,CAAC,IAAI,CAAC;AACtE,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY;IAC3C,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,IAAI,cAAc,EAAE,UAAU;AAC3E,IAAA,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,KAAK;AACrC,IAAA,MAAM,KAAK,GAAG,KAAK,EAAE,KAAK;AAC1B,IAAA,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO;IAE9BC,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,kBAAkB,EAAE,OAAO;AAC3C,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO;YAAE;AACnC,QAAA,OAAOC,sCAAyB,CAAC,OAAO,EAAE,MAAK;AAC7C,YAAA,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO;gBAAE;AACvC,YAAA,KAAK,EAAE;AACT,QAAA,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;AACrD;;"}
|
|
@@ -7,6 +7,12 @@ export interface UseCloseOnTriggerScrollOptions {
|
|
|
7
7
|
state?: Pick<OverlayTriggerState, 'isOpen' | 'close'>;
|
|
8
8
|
/** The popover's `slot`, so a `PopoverContext` that only defines named slots resolves instead of throwing. */
|
|
9
9
|
slot?: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The popover's own element. Given, a scroll closes the popover only while that element is rendered: the hidden copy
|
|
12
|
+
* react-aria renders of a `Select`'s children, to build its collection, has none, and reads the state of whatever
|
|
13
|
+
* overlay the `Select` sits in, which it would close.
|
|
14
|
+
*/
|
|
15
|
+
popoverRef?: RefObject<Element | null>;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* Closes the enclosing React Aria popover when a scroll container holding its trigger scrolls,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloseOnTriggerScroll.d.ts","sourceRoot":"","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,KAAK,mBAAmB,EAAiE,MAAM,uBAAuB,CAAC;AAGhI,MAAM,WAAW,8BAA8B;IAC7C,8FAA8F;IAC9F,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvC,mIAAmI;IACnI,KAAK,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;IACtD,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"useCloseOnTriggerScroll.d.ts","sourceRoot":"","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,KAAK,mBAAmB,EAAiE,MAAM,uBAAuB,CAAC;AAGhI,MAAM,WAAW,8BAA8B;IAC7C,8FAA8F;IAC9F,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvC,mIAAmI;IACnI,KAAK,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;IACtD,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAS,8BAAmC,SAiBnF,CAAC"}
|
|
@@ -19,12 +19,17 @@ const useCloseOnTriggerScroll = (options = {}) => {
|
|
|
19
19
|
const resolvedTriggerRef = options.triggerRef ?? popoverContext?.triggerRef;
|
|
20
20
|
const isOpen = state?.isOpen ?? false;
|
|
21
21
|
const close = state?.close;
|
|
22
|
+
const { popoverRef } = options;
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
const trigger = resolvedTriggerRef?.current;
|
|
24
25
|
if (!isOpen || !close || !trigger)
|
|
25
26
|
return;
|
|
26
|
-
return subscribeToAncestorScroll(trigger,
|
|
27
|
-
|
|
27
|
+
return subscribeToAncestorScroll(trigger, () => {
|
|
28
|
+
if (popoverRef && !popoverRef.current)
|
|
29
|
+
return;
|
|
30
|
+
close();
|
|
31
|
+
});
|
|
32
|
+
}, [isOpen, close, resolvedTriggerRef, popoverRef]);
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
export { useCloseOnTriggerScroll };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloseOnTriggerScroll.js","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useCloseOnTriggerScroll.js","sources":["../../../../../src/components/__internal__/popover/hooks/useCloseOnTriggerScroll.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAqBA;;;;;;;;;AASG;MACU,uBAAuB,GAAG,CAAC,OAAA,GAA0C,EAAE,KAAI;AACtF,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,0BAA0B,CAAC;IAC3D,MAAM,cAAc,GAAG,iBAAiB,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC;AACtE,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY;IAC3C,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,IAAI,cAAc,EAAE,UAAU;AAC3E,IAAA,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,KAAK;AACrC,IAAA,MAAM,KAAK,GAAG,KAAK,EAAE,KAAK;AAC1B,IAAA,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO;IAE9B,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,kBAAkB,EAAE,OAAO;AAC3C,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO;YAAE;AACnC,QAAA,OAAO,yBAAyB,CAAC,OAAO,EAAE,MAAK;AAC7C,YAAA,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO;gBAAE;AACvC,YAAA,KAAK,EAAE;AACT,QAAA,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;AACrD;;"}
|
|
@@ -10,14 +10,14 @@ var reactHookForm = require('react-hook-form');
|
|
|
10
10
|
*
|
|
11
11
|
* @summary unsaved-changes modal driven by its form's own state
|
|
12
12
|
*/
|
|
13
|
-
const FormUnsavedChangesModal = ({ isDisabled = false, 'data-testid': dataTestId }) => {
|
|
13
|
+
const FormUnsavedChangesModal = ({ isDisabled = false, isDismissable = true, 'data-testid': dataTestId }) => {
|
|
14
14
|
const form = reactHookForm.useFormContext();
|
|
15
15
|
if (!form)
|
|
16
16
|
throw new Error("FormUnsavedChangesModal needs Form above it: it guards that form's unsaved edits.");
|
|
17
17
|
const { isDirty, isSubmitting } = reactHookForm.useFormState({ control: form.control });
|
|
18
18
|
// Edits a save is sending can no longer be discarded by leaving, so only a draft at rest is guarded.
|
|
19
19
|
const hasUnsavedChanges = isDirty && !isSubmitting && !isDisabled;
|
|
20
|
-
return jsxRuntime.jsx(Modals.UnsavedChangesModal, { hasUnsavedChanges: hasUnsavedChanges, "data-testid": dataTestId });
|
|
20
|
+
return jsxRuntime.jsx(Modals.UnsavedChangesModal, { hasUnsavedChanges: hasUnsavedChanges, isDismissable: isDismissable, "data-testid": dataTestId });
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.FormUnsavedChangesModal = FormUnsavedChangesModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"sourcesContent":[null],"names":["useFormContext","useFormState","_jsx","UnsavedChangesModal"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"sourcesContent":[null],"names":["useFormContext","useFormState","_jsx","UnsavedChangesModal"],"mappings":";;;;;;AAcA;;;;;AAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,EAAE,aAAa,GAAG,IAAI,EAAE,aAAa,EAAE,UAAU,EAAgC,KAAI;AAC/I,IAAA,MAAM,IAAI,GAAGA,4BAAc,EAAE;AAC7B,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC;AAC/G,IAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAGC,0BAAY,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;IAEzE,MAAM,iBAAiB,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU;AAEjE,IAAA,OAAOC,cAAA,CAACC,0BAAmB,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAA,aAAA,EAAe,UAAU,GAAI;AAC7H;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface FormUnsavedChangesModalProps {
|
|
2
2
|
/** Switches the guard off while the edits are going anyway, such as while the record the form edits is being removed. */
|
|
3
3
|
isDisabled?: 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 FormUnsavedChangesModalProps {
|
|
|
10
12
|
*
|
|
11
13
|
* @summary unsaved-changes modal driven by its form's own state
|
|
12
14
|
*/
|
|
13
|
-
export declare const FormUnsavedChangesModal: ({ isDisabled, "data-testid": dataTestId }: FormUnsavedChangesModalProps) => import("react").JSX.Element;
|
|
15
|
+
export declare const FormUnsavedChangesModal: ({ isDisabled, isDismissable, "data-testid": dataTestId }: FormUnsavedChangesModalProps) => import("react").JSX.Element;
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,4BAA4B;IAC3C,yHAAyH;IACzH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,4BAA4B;IAC3C,yHAAyH;IACzH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2IAA2I;IAC3I,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kIAAkI;IAClI,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,0DAAyE,4BAA4B,gCAQ5I,CAAC"}
|
|
@@ -8,14 +8,14 @@ import { useFormContext, useFormState } from 'react-hook-form';
|
|
|
8
8
|
*
|
|
9
9
|
* @summary unsaved-changes modal driven by its form's own state
|
|
10
10
|
*/
|
|
11
|
-
const FormUnsavedChangesModal = ({ isDisabled = false, 'data-testid': dataTestId }) => {
|
|
11
|
+
const FormUnsavedChangesModal = ({ isDisabled = false, isDismissable = true, 'data-testid': dataTestId }) => {
|
|
12
12
|
const form = useFormContext();
|
|
13
13
|
if (!form)
|
|
14
14
|
throw new Error("FormUnsavedChangesModal needs Form above it: it guards that form's unsaved edits.");
|
|
15
15
|
const { isDirty, isSubmitting } = useFormState({ control: form.control });
|
|
16
16
|
// Edits a save is sending can no longer be discarded by leaving, so only a draft at rest is guarded.
|
|
17
17
|
const hasUnsavedChanges = isDirty && !isSubmitting && !isDisabled;
|
|
18
|
-
return jsx(UnsavedChangesModal, { hasUnsavedChanges: hasUnsavedChanges, "data-testid": dataTestId });
|
|
18
|
+
return jsx(UnsavedChangesModal, { hasUnsavedChanges: hasUnsavedChanges, isDismissable: isDismissable, "data-testid": dataTestId });
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export { FormUnsavedChangesModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/forms/FormUnsavedChangesModal/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAcA;;;;;AAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,EAAE,aAAa,GAAG,IAAI,EAAE,aAAa,EAAE,UAAU,EAAgC,KAAI;AAC/I,IAAA,MAAM,IAAI,GAAG,cAAc,EAAE;AAC7B,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC;AAC/G,IAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;IAEzE,MAAM,iBAAiB,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU;AAEjE,IAAA,OAAOA,GAAA,CAAC,mBAAmB,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAA,aAAA,EAAe,UAAU,GAAI;AAC7H;;"}
|
|
@@ -4,7 +4,7 @@ export declare const DialogTrigger: typeof import("react-aria-components").Dialo
|
|
|
4
4
|
/** @deprecated Import from `@flipdish/ui-library/components/molecules/Modals`. Removed in the next major. */
|
|
5
5
|
export declare const ModalOverlay: ({ "data-testid": dataTestId, ...props }: ModalOverlayPropsNext) => import("react").JSX.Element;
|
|
6
6
|
/** @deprecated Import from `@flipdish/ui-library/components/molecules/Modals`. Removed in the next major. */
|
|
7
|
-
export declare const Modal: (props: import("react-aria-components").ModalOverlayProps) => import("react").JSX.Element;
|
|
7
|
+
export declare const Modal: ({ children, ...props }: import("react-aria-components").ModalOverlayProps) => import("react").JSX.Element;
|
|
8
8
|
/** @deprecated Import from `@flipdish/ui-library/components/molecules/Modals`. Removed in the next major. */
|
|
9
9
|
export declare const Dialog: ({ "data-testid": dataTestId, ...props }: DialogPropsNext) => import("react").JSX.Element;
|
|
10
10
|
/** @deprecated Import from `@flipdish/ui-library/components/molecules/Modals`. Removed in the next major. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Modal/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EAInC,KAAK,iBAAiB,IAAI,qBAAqB,EAChD,MAAM,kDAAkD,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,aAAa,sDAAoB,CAAC;AAC/C,6GAA6G;AAC7G,eAAO,MAAM,YAAY,iGAAmB,CAAC;AAC7C,6GAA6G;AAC7G,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Modal/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,IAAI,eAAe,EAInC,KAAK,iBAAiB,IAAI,qBAAqB,EAChD,MAAM,kDAAkD,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,aAAa,sDAAoB,CAAC;AAC/C,6GAA6G;AAC7G,eAAO,MAAM,YAAY,iGAAmB,CAAC;AAC7C,6GAA6G;AAC7G,eAAO,MAAM,KAAK,4GAAY,CAAC;AAC/B,6GAA6G;AAC7G,eAAO,MAAM,MAAM,2FAAa,CAAC;AACjC,6GAA6G;AAC7G,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AACtD,6GAA6G;AAC7G,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -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 testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
7
|
var React = require('react');
|
|
@@ -12,10 +13,11 @@ var Modal = require('../Modal/Modal.cjs');
|
|
|
12
13
|
*
|
|
13
14
|
* @summary confirm dialog asked before a destructive or final action
|
|
14
15
|
*/
|
|
15
|
-
const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLabel, onConfirm, isDestructive = false, isConfirming = false, 'data-testid': dataTestId, }) => {
|
|
16
|
+
const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLabel, confirmIcon, onConfirm, isDestructive = false, isConfirming = false, isDismissable = true, 'data-testid': dataTestId, }) => {
|
|
16
17
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'confirmation-modal', rootName: 'confirmation-modal' });
|
|
17
|
-
const titleId = React.useId();
|
|
18
18
|
const descriptionId = React.useId();
|
|
19
|
+
// Closing mid-action would hide whether it landed, so every way out waits until it settles.
|
|
20
|
+
const canDismiss = isDismissable && !isConfirming;
|
|
19
21
|
const cancel = () => onOpenChange(false);
|
|
20
22
|
// The buttons stay on screen while the dialog animates out, so a second press must not run the action again.
|
|
21
23
|
const confirm = () => {
|
|
@@ -23,9 +25,10 @@ const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLa
|
|
|
23
25
|
onConfirm();
|
|
24
26
|
};
|
|
25
27
|
return (jsxRuntime.jsx(Modal.ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange,
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// Dismissing only ever backs out, so a stray press outside cannot run the action.
|
|
29
|
+
isDismissable: canDismiss, isKeyboardDismissDisabled: isConfirming, "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: title, icon: isDestructive ? uiIcons.AlertTriangle : uiIcons.HelpCircle, iconColor: isDestructive ? 'error' : 'gray', showCloseButton: canDismiss,
|
|
30
|
+
// Keeps the room for the close button while confirming hides it, so the title does not rewrap.
|
|
31
|
+
className: isDismissable ? 'pr-14' : undefined }), jsxRuntime.jsx(Modal.ModalBody, { id: descriptionId, children: description }), jsxRuntime.jsxs(Modal.ModalFooter, { children: [jsxRuntime.jsx(Buttons.Button, { color: "secondary", size: "md", isDisabled: isConfirming, onPress: cancel, "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), children: "Cancel" }), jsxRuntime.jsx(Buttons.Button, { color: isDestructive ? 'primary-destructive' : 'primary', size: "md", iconLeading: confirmIcon, isLoading: isConfirming, showTextWhileLoading: true, onPress: confirm, "data-testid": testIdUtils.joinTestId(rootTestId, 'confirm'), children: confirmLabel })] })] }) }) }));
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
exports.ConfirmationModal = ConfirmationModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationModal.cjs","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","useId","_jsx","ModalOverlay","Modal","Dialog","
|
|
1
|
+
{"version":3,"file":"ConfirmationModal.cjs","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","useId","_jsx","ModalOverlay","Modal","_jsxs","Dialog","ModalHeader","AlertTriangle","HelpCircle","ModalBody","ModalFooter","Button","joinTestId"],"mappings":";;;;;;;;;AAkCA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAChC,MAAM,EACN,YAAY,EACZ,KAAK,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,aAAa,GAAG,KAAK,EACrB,YAAY,GAAG,KAAK,EACpB,aAAa,GAAG,IAAI,EACpB,aAAa,EAAE,UAAU,GACF,KAAI;AAC3B,IAAA,MAAM,UAAU,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC;AAC3H,IAAA,MAAM,aAAa,GAAGC,WAAK,EAAE;;AAE7B,IAAA,MAAM,UAAU,GAAG,aAAa,IAAI,CAAC,YAAY;IACjD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC;;IAExC,MAAM,OAAO,GAAG,MAAK;AACnB,QAAA,IAAI,MAAM;AAAE,YAAA,SAAS,EAAE;AACzB,IAAA,CAAC;IAED,QACEC,cAAA,CAACC,kBAAY,EAAA,EACX,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY;;QAE1B,aAAa,EAAE,UAAU,EACzB,yBAAyB,EAAE,YAAY,EAAA,aAAA,EAC1B,UAAU,EAAA,QAAA,EAEvBD,cAAA,CAACE,WAAK,EAAA,EAAC,SAAS,EAAC,qBAAqB,EAAA,QAAA,EACpCC,eAAA,CAACC,YAAM,EAAA,EAAC,IAAI,EAAC,aAAa,EAAA,kBAAA,EAAmB,aAAa,EAAA,QAAA,EAAA,CACxDJ,cAAA,CAACK,iBAAW,EAAA,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,GAAGC,qBAAa,GAAGC,kBAAU,EAChD,SAAS,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,EAC3C,eAAe,EAAE,UAAU;;wBAE3B,SAAS,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,GAC9C,EACFP,cAAA,CAACQ,eAAS,EAAA,EAAC,EAAE,EAAE,aAAa,EAAA,QAAA,EAAG,WAAW,EAAA,CAAa,EACvDL,eAAA,CAACM,iBAAW,EAAA,EAAA,QAAA,EAAA,CACVT,cAAA,CAACU,cAAM,EAAA,EAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAA,aAAA,EAAeC,sBAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAEnH,EACTX,eAACU,cAAM,EAAA,EACL,KAAK,EAAE,aAAa,GAAG,qBAAqB,GAAG,SAAS,EACxD,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,YAAY,EACvB,oBAAoB,EAAA,IAAA,EACpB,OAAO,EAAE,OAAO,EAAA,aAAA,EACHC,sBAAU,CAAC,UAAU,EAAE,SAAS,CAAC,YAE7C,YAAY,EAAA,CACN,IACG,CAAA,EAAA,CACP,EAAA,CACH,EAAA,CACK;AAEnB;;"}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
1
2
|
export interface ConfirmationModalProps {
|
|
2
3
|
/** Shows the dialog. */
|
|
3
4
|
isOpen: boolean;
|
|
4
|
-
/** Called with `false` when Cancel
|
|
5
|
+
/** Called with `false` when Cancel, the close button, Escape or a press outside asks the dialog to close; set `isOpen` from it. */
|
|
5
6
|
onOpenChange: (isOpen: boolean) => void;
|
|
6
7
|
/** The question being asked, such as "Remove this property?"; it names the dialog. */
|
|
7
8
|
title: string;
|
|
8
|
-
/** What confirming will do,
|
|
9
|
+
/** What confirming will do, in the dialog's body; it describes the dialog. */
|
|
9
10
|
description: string;
|
|
10
11
|
/** Text of the confirming button, naming the action, such as "Remove property". */
|
|
11
12
|
confirmLabel: string;
|
|
13
|
+
/** Icon shown before the confirming button's text, picturing the action, such as a bin for a removal. */
|
|
14
|
+
confirmIcon?: FC<{
|
|
15
|
+
className?: string;
|
|
16
|
+
}>;
|
|
12
17
|
/** Runs the action. The dialog stays open until `isOpen` turns `false`, so close it here or once the action lands. */
|
|
13
18
|
onConfirm: () => void;
|
|
14
|
-
/**
|
|
19
|
+
/** Marks the action as one that removes something or cannot be undone: a destructive confirming button and a warning icon. */
|
|
15
20
|
isDestructive?: boolean;
|
|
16
21
|
/** Shows the confirming button's loading state and stops the dialog being dismissed while the action is in flight. */
|
|
17
22
|
isConfirming?: boolean;
|
|
18
|
-
/**
|
|
23
|
+
/** Lets the close button and a press outside back out, the same as Cancel. Turn it off when only the two buttons may answer. */
|
|
24
|
+
isDismissable?: boolean;
|
|
25
|
+
/** Overrides the root `data-testid` (defaults to `fd-confirmation-modal`); the dialog, its parts and its buttons derive theirs from it. */
|
|
19
26
|
'data-testid'?: string;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
@@ -24,5 +31,5 @@ export interface ConfirmationModalProps {
|
|
|
24
31
|
*
|
|
25
32
|
* @summary confirm dialog asked before a destructive or final action
|
|
26
33
|
*/
|
|
27
|
-
export declare const ConfirmationModal: ({ isOpen, onOpenChange, title, description, confirmLabel, onConfirm, isDestructive, isConfirming, "data-testid": dataTestId, }: ConfirmationModalProps) => import("react").JSX.Element;
|
|
34
|
+
export declare const ConfirmationModal: ({ isOpen, onOpenChange, title, description, confirmLabel, confirmIcon, onConfirm, isDestructive, isConfirming, isDismissable, "data-testid": dataTestId, }: ConfirmationModalProps) => import("react").JSX.Element;
|
|
28
35
|
//# sourceMappingURL=ConfirmationModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfirmationModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,MAAM,WAAW,sBAAsB;IACrC,wBAAwB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,mIAAmI;IACnI,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,yGAAyG;IACzG,WAAW,CAAC,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzC,sHAAsH;IACtH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,8HAA8H;IAC9H,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sHAAsH;IACtH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gIAAgI;IAChI,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2IAA2I;IAC3I,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,4JAY/B,sBAAsB,gCAmDxB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { AlertTriangle, HelpCircle } from '@flipdish/ui-icons';
|
|
2
3
|
import { Button } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
3
4
|
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
5
|
import { useId } from 'react';
|
|
5
|
-
import { ModalOverlay, Modal, Dialog } from '../Modal/Modal.js';
|
|
6
|
+
import { ModalOverlay, Modal, Dialog, ModalHeader, ModalBody, ModalFooter } from '../Modal/Modal.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Asks the user to confirm one action before it runs, with a button that backs out and a button that goes ahead.
|
|
@@ -10,10 +11,11 @@ import { ModalOverlay, Modal, Dialog } from '../Modal/Modal.js';
|
|
|
10
11
|
*
|
|
11
12
|
* @summary confirm dialog asked before a destructive or final action
|
|
12
13
|
*/
|
|
13
|
-
const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLabel, onConfirm, isDestructive = false, isConfirming = false, 'data-testid': dataTestId, }) => {
|
|
14
|
+
const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLabel, confirmIcon, onConfirm, isDestructive = false, isConfirming = false, isDismissable = true, 'data-testid': dataTestId, }) => {
|
|
14
15
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'confirmation-modal', rootName: 'confirmation-modal' });
|
|
15
|
-
const titleId = useId();
|
|
16
16
|
const descriptionId = useId();
|
|
17
|
+
// Closing mid-action would hide whether it landed, so every way out waits until it settles.
|
|
18
|
+
const canDismiss = isDismissable && !isConfirming;
|
|
17
19
|
const cancel = () => onOpenChange(false);
|
|
18
20
|
// The buttons stay on screen while the dialog animates out, so a second press must not run the action again.
|
|
19
21
|
const confirm = () => {
|
|
@@ -21,9 +23,10 @@ const ConfirmationModal = ({ isOpen, onOpenChange, title, description, confirmLa
|
|
|
21
23
|
onConfirm();
|
|
22
24
|
};
|
|
23
25
|
return (jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange,
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
// Dismissing only ever backs out, so a stray press outside cannot run the action.
|
|
27
|
+
isDismissable: canDismiss, isKeyboardDismissDisabled: isConfirming, "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: title, icon: isDestructive ? AlertTriangle : HelpCircle, iconColor: isDestructive ? 'error' : 'gray', showCloseButton: canDismiss,
|
|
28
|
+
// Keeps the room for the close button while confirming hides it, so the title does not rewrap.
|
|
29
|
+
className: isDismissable ? 'pr-14' : undefined }), jsx(ModalBody, { id: descriptionId, children: description }), jsxs(ModalFooter, { children: [jsx(Button, { color: "secondary", size: "md", isDisabled: isConfirming, onPress: cancel, "data-testid": joinTestId(rootTestId, 'cancel'), children: "Cancel" }), jsx(Button, { color: isDestructive ? 'primary-destructive' : 'primary', size: "md", iconLeading: confirmIcon, isLoading: isConfirming, showTextWhileLoading: true, onPress: confirm, "data-testid": joinTestId(rootTestId, 'confirm'), children: confirmLabel })] })] }) }) }));
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
export { ConfirmationModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationModal.js","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfirmationModal.js","sources":["../../../../../src/components/molecules/Modals/ConfirmationModal/ConfirmationModal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":";;;;;;;AAkCA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAChC,MAAM,EACN,YAAY,EACZ,KAAK,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,aAAa,GAAG,KAAK,EACrB,YAAY,GAAG,KAAK,EACpB,aAAa,GAAG,IAAI,EACpB,aAAa,EAAE,UAAU,GACF,KAAI;AAC3B,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC;AAC3H,IAAA,MAAM,aAAa,GAAG,KAAK,EAAE;;AAE7B,IAAA,MAAM,UAAU,GAAG,aAAa,IAAI,CAAC,YAAY;IACjD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC;;IAExC,MAAM,OAAO,GAAG,MAAK;AACnB,QAAA,IAAI,MAAM;AAAE,YAAA,SAAS,EAAE;AACzB,IAAA,CAAC;IAED,QACEA,GAAA,CAAC,YAAY,EAAA,EACX,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY;;QAE1B,aAAa,EAAE,UAAU,EACzB,yBAAyB,EAAE,YAAY,EAAA,aAAA,EAC1B,UAAU,EAAA,QAAA,EAEvBA,GAAA,CAAC,KAAK,EAAA,EAAC,SAAS,EAAC,qBAAqB,EAAA,QAAA,EACpCC,IAAA,CAAC,MAAM,EAAA,EAAC,IAAI,EAAC,aAAa,EAAA,kBAAA,EAAmB,aAAa,EAAA,QAAA,EAAA,CACxDD,GAAA,CAAC,WAAW,EAAA,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,UAAU,EAChD,SAAS,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,EAC3C,eAAe,EAAE,UAAU;;wBAE3B,SAAS,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,GAC9C,EACFA,GAAA,CAAC,SAAS,EAAA,EAAC,EAAE,EAAE,aAAa,EAAA,QAAA,EAAG,WAAW,EAAA,CAAa,EACvDC,IAAA,CAAC,WAAW,EAAA,EAAA,QAAA,EAAA,CACVD,GAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAA,aAAA,EAAe,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAEnH,EACTA,IAAC,MAAM,EAAA,EACL,KAAK,EAAE,aAAa,GAAG,qBAAqB,GAAG,SAAS,EACxD,IAAI,EAAC,IAAI,EACT,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,YAAY,EACvB,oBAAoB,EAAA,IAAA,EACpB,OAAO,EAAE,OAAO,EAAA,aAAA,EACH,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,YAE7C,YAAY,EAAA,CACN,IACG,CAAA,EAAA,CACP,EAAA,CACH,EAAA,CACK;AAEnB;;"}
|
|
@@ -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
|