@sentry/scraps 0.4.0 → 0.6.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/README.md +74 -8
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +4 -4
- package/dist/button/button.js +1 -0
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +243 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +355 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +264 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/dateTime/config.d.ts +23 -0
- package/dist/dateTime/config.js +50 -0
- package/dist/dateTime/context.d.ts +18 -0
- package/dist/dateTime/context.js +46 -0
- package/dist/dateTime/dateTime.d.ts +6 -0
- package/dist/dateTime/dateTime.js +30 -0
- package/dist/dateTime/format.d.ts +24 -0
- package/dist/dateTime/format.js +45 -0
- package/dist/dateTime/index.d.ts +6 -0
- package/dist/dateTime/index.js +6 -0
- package/dist/dateTime/intlFormatter.d.ts +9 -0
- package/dist/dateTime/intlFormatter.js +16 -0
- package/dist/dateTime/parseDate.d.ts +3 -0
- package/dist/dateTime/parseDate.js +12 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +39 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +109 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +140 -0
- package/dist/dropdownMenu/item.js +142 -0
- package/dist/dropdownMenu/list.d.ts +85 -0
- package/dist/dropdownMenu/list.js +429 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +55 -0
- package/dist/duration/formatElapsedDuration.d.ts +4 -0
- package/dist/duration/formatElapsedDuration.js +10 -0
- package/dist/duration/getDuration.d.ts +68 -0
- package/dist/duration/getDuration.js +80 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.js +2 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/fzf.d.ts +9 -0
- package/dist/fzf.js +155 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/container.d.ts +8 -2
- package/dist/layout/container.js +2 -2
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +2 -1
- package/dist/layout/styles.js +11 -5
- package/dist/legacyDatetime.d.ts +21 -0
- package/dist/legacyDatetime.js +13 -0
- package/dist/link/index.d.ts +1 -1
- package/dist/link/index.js +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +11 -0
- package/dist/link/linkBehaviorContext.js +48 -11
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -8
- package/dist/menu/menu.js +163 -60
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/relativeTime/getRelativeDate.d.ts +14 -0
- package/dist/relativeTime/getRelativeDate.js +107 -0
- package/dist/relativeTime/index.d.ts +3 -0
- package/dist/relativeTime/index.js +3 -0
- package/dist/relativeTime/relativeTime.d.ts +55 -0
- package/dist/relativeTime/relativeTime.js +102 -0
- package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
- package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +1 -0
- package/dist/tabs/item.d.ts +24 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +208 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +258 -0
- package/dist/tabs/tabPanels.d.ts +13 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +53 -0
- package/dist/tabs/tabs.js +59 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/prose.d.ts +2 -2
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +20 -2
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/translation/index.d.ts +1 -0
- package/dist/translation/index.js +1 -0
- package/dist/translation/translate.d.ts +9 -0
- package/dist/translation/translate.js +5 -0
- package/dist/translation/translationContext.d.ts +2 -1
- package/dist/translation/translationContext.js +2 -1
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/fonts/OFL.txt +94 -0
- package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
- package/fonts/roboto-mono-variable-greek.woff2 +0 -0
- package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
- package/fonts/roboto-mono-variable.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic.woff2 +0 -0
- package/fonts/rubik-variable-latin-ext.woff2 +0 -0
- package/fonts/rubik-variable.woff2 +0 -0
- package/fonts.css +211 -0
- package/package.json +140 -23
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, cloneElement, isValidElement, useRef, useState } from "react";
|
|
3
|
+
import { Alert } from "../alert/index.js";
|
|
4
|
+
import { Button } from "../button/index.js";
|
|
5
|
+
import { Grid } from "../layout/index.js";
|
|
6
|
+
import { openModal } from "../modal/index.js";
|
|
7
|
+
import { useTranslation } from "../translation/useTranslation.js";
|
|
8
|
+
const openConfirmModal = ({ bypass, onConfirming, priority = 'primary', cancelText, confirmText, disableConfirmButton = false, onClose, ...rest })=>{
|
|
9
|
+
if (bypass) return void rest.onConfirm?.();
|
|
10
|
+
const modalProps = {
|
|
11
|
+
...rest,
|
|
12
|
+
priority,
|
|
13
|
+
confirmText,
|
|
14
|
+
cancelText,
|
|
15
|
+
disableConfirmButton
|
|
16
|
+
};
|
|
17
|
+
onConfirming?.();
|
|
18
|
+
openModal((renderProps)=>/*#__PURE__*/ jsx(ConfirmModal, {
|
|
19
|
+
...renderProps,
|
|
20
|
+
...modalProps
|
|
21
|
+
}), {
|
|
22
|
+
onClose
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
function Confirm({ disabled, children, stopPropagation = false, ...openConfirmOptions }) {
|
|
26
|
+
const triggerModal = (e)=>{
|
|
27
|
+
if (stopPropagation) e?.stopPropagation();
|
|
28
|
+
if (disabled) return;
|
|
29
|
+
openConfirmModal(openConfirmOptions);
|
|
30
|
+
};
|
|
31
|
+
if ('function' == typeof children) return children({
|
|
32
|
+
open: triggerModal
|
|
33
|
+
});
|
|
34
|
+
if (!/*#__PURE__*/ isValidElement(children)) return null;
|
|
35
|
+
return /*#__PURE__*/ cloneElement(children, {
|
|
36
|
+
disabled,
|
|
37
|
+
onClick: triggerModal
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function ConfirmModal({ Header, Body, Footer, priority, confirmText, cancelText, header, isDangerous, renderConfirmButton, renderCancelButton, disableConfirmButton, onCancel, onConfirm, renderMessage, message, errorMessage, closeModal }) {
|
|
41
|
+
const { t } = useTranslation();
|
|
42
|
+
const confirmCallbackRef = useRef(()=>{});
|
|
43
|
+
const [shouldDisableConfirmButton, setShouldDisableConfirmButton] = useState(disableConfirmButton);
|
|
44
|
+
const [isConfirming, setIsConfirming] = useState(false);
|
|
45
|
+
const [isError, setIsError] = useState(false);
|
|
46
|
+
const handleClose = ()=>{
|
|
47
|
+
onCancel?.();
|
|
48
|
+
setShouldDisableConfirmButton(disableConfirmButton ?? false);
|
|
49
|
+
setIsConfirming(false);
|
|
50
|
+
closeModal();
|
|
51
|
+
};
|
|
52
|
+
const handleConfirm = async ()=>{
|
|
53
|
+
if (isConfirming) return;
|
|
54
|
+
setIsConfirming(true);
|
|
55
|
+
if (onConfirm) try {
|
|
56
|
+
await onConfirm();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
setIsError(true);
|
|
59
|
+
return;
|
|
60
|
+
} finally{
|
|
61
|
+
setIsConfirming(false);
|
|
62
|
+
}
|
|
63
|
+
confirmCallbackRef.current();
|
|
64
|
+
closeModal();
|
|
65
|
+
};
|
|
66
|
+
const makeConfirmMessage = ()=>{
|
|
67
|
+
if ('function' == typeof renderMessage) return renderMessage({
|
|
68
|
+
confirm: handleConfirm,
|
|
69
|
+
close: handleClose,
|
|
70
|
+
disableConfirmButton: (state)=>setShouldDisableConfirmButton(state),
|
|
71
|
+
setConfirmCallback: (confirmCallback)=>confirmCallbackRef.current = confirmCallback
|
|
72
|
+
});
|
|
73
|
+
if (/*#__PURE__*/ isValidElement(message)) return message;
|
|
74
|
+
return /*#__PURE__*/ jsx("p", {
|
|
75
|
+
style: {
|
|
76
|
+
wordWrap: 'break-word'
|
|
77
|
+
},
|
|
78
|
+
children: message
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
82
|
+
children: [
|
|
83
|
+
header && /*#__PURE__*/ jsx(Header, {
|
|
84
|
+
children: header
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsxs(Body, {
|
|
87
|
+
children: [
|
|
88
|
+
isError && /*#__PURE__*/ jsx(Alert.Container, {
|
|
89
|
+
children: /*#__PURE__*/ jsx(Alert, {
|
|
90
|
+
variant: "danger",
|
|
91
|
+
showIcon: false,
|
|
92
|
+
children: errorMessage ?? t('Something went wrong. Please try again.')
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
makeConfirmMessage()
|
|
96
|
+
]
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx(Footer, {
|
|
99
|
+
children: /*#__PURE__*/ jsxs(Grid, {
|
|
100
|
+
flow: "column",
|
|
101
|
+
align: "center",
|
|
102
|
+
gap: "xl",
|
|
103
|
+
children: [
|
|
104
|
+
renderCancelButton ? renderCancelButton({
|
|
105
|
+
closeModal,
|
|
106
|
+
defaultOnClick: handleClose
|
|
107
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
108
|
+
onClick: handleClose,
|
|
109
|
+
autoFocus: !!isDangerous,
|
|
110
|
+
"aria-label": 'string' == typeof cancelText ? cancelText : t('Cancel'),
|
|
111
|
+
children: cancelText ?? t('Cancel')
|
|
112
|
+
}),
|
|
113
|
+
renderConfirmButton ? renderConfirmButton({
|
|
114
|
+
closeModal,
|
|
115
|
+
defaultOnClick: handleConfirm
|
|
116
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
117
|
+
"data-test-id": "confirm-button",
|
|
118
|
+
disabled: shouldDisableConfirmButton,
|
|
119
|
+
busy: isConfirming,
|
|
120
|
+
variant: priority,
|
|
121
|
+
onClick: handleConfirm,
|
|
122
|
+
autoFocus: !isDangerous,
|
|
123
|
+
"aria-label": 'string' == typeof confirmText ? confirmText : t('Confirm'),
|
|
124
|
+
children: confirmText ?? t('Confirm')
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export { Confirm, openConfirmModal };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Translation } from '../translation/translate.js';
|
|
2
|
+
export interface DateTimePreferences {
|
|
3
|
+
clock: '12' | '24';
|
|
4
|
+
timezone: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FormattingSnapshot extends DateTimePreferences {
|
|
7
|
+
locale: string;
|
|
8
|
+
messages: Translation;
|
|
9
|
+
/** Optional application label source. Returning undefined falls back to Intl. */
|
|
10
|
+
getTimezoneAbbreviation?: (epochMilliseconds: number, timezone: string, locale: string) => string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface FormattingSource {
|
|
13
|
+
getSnapshot: () => Readonly<FormattingSnapshot>;
|
|
14
|
+
subscribe: (onChange: () => void) => () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const formattingStore: {
|
|
17
|
+
getState: () => Readonly<FormattingSnapshot>;
|
|
18
|
+
getInitialState: () => Readonly<FormattingSnapshot>;
|
|
19
|
+
subscribe: (listener: (state: Readonly<FormattingSnapshot>, prevState: Readonly<FormattingSnapshot>) => void) => () => void;
|
|
20
|
+
};
|
|
21
|
+
/** Connect application preferences and locale to the reactive formatting store. */
|
|
22
|
+
export declare function configureFormatting(source: FormattingSource): () => void;
|
|
23
|
+
export declare const getSnapshot: () => Readonly<FormattingSnapshot>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createStore } from "zustand/vanilla";
|
|
2
|
+
const defaults = {
|
|
3
|
+
timezone: 'UTC',
|
|
4
|
+
clock: '12',
|
|
5
|
+
locale: 'en',
|
|
6
|
+
messages: {
|
|
7
|
+
t: (message, ...args)=>message.replace(/%s/g, ()=>{
|
|
8
|
+
const value = args.shift();
|
|
9
|
+
return 'string' == typeof value || 'number' == typeof value ? `${value}` : '%s';
|
|
10
|
+
}),
|
|
11
|
+
tn: (singular, plural, count)=>1 === Math.abs(count) ? singular : plural,
|
|
12
|
+
pgettext: (_context, message)=>message
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const store = createStore(()=>defaults);
|
|
16
|
+
const formattingStore = {
|
|
17
|
+
getState: store.getState,
|
|
18
|
+
getInitialState: store.getState,
|
|
19
|
+
subscribe: store.subscribe
|
|
20
|
+
};
|
|
21
|
+
function toIntlLocale(locale) {
|
|
22
|
+
try {
|
|
23
|
+
return Intl.getCanonicalLocales(locale.replaceAll('_', '-'))[0] ?? defaults.locale;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof RangeError) return defaults.locale;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function configureFormatting(source) {
|
|
30
|
+
const previous = store.getState();
|
|
31
|
+
let lastSnapshot;
|
|
32
|
+
const update = ()=>{
|
|
33
|
+
const snapshot = source.getSnapshot();
|
|
34
|
+
if (snapshot === lastSnapshot) return;
|
|
35
|
+
lastSnapshot = snapshot;
|
|
36
|
+
const locale = toIntlLocale(snapshot.locale);
|
|
37
|
+
store.setState(locale === snapshot.locale ? snapshot : {
|
|
38
|
+
...snapshot,
|
|
39
|
+
locale
|
|
40
|
+
}, true);
|
|
41
|
+
};
|
|
42
|
+
const unsubscribe = source.subscribe(update);
|
|
43
|
+
update();
|
|
44
|
+
return ()=>{
|
|
45
|
+
unsubscribe();
|
|
46
|
+
store.setState(previous, true);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const getSnapshot = store.getState;
|
|
50
|
+
export { configureFormatting, formattingStore, getSnapshot };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type DateTimePreferences } from './config.js';
|
|
3
|
+
import { type DateTimeInput, type DateTimeOptions } from './format.js';
|
|
4
|
+
/** Override only the specified preferences, inheriting the rest from the parent. */
|
|
5
|
+
export declare function DateTimeProvider({ value, children, }: {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
value: Partial<DateTimePreferences>;
|
|
8
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function useFormattingSnapshot(): {
|
|
10
|
+
timezone: string;
|
|
11
|
+
clock: "12" | "24";
|
|
12
|
+
locale: string;
|
|
13
|
+
messages: import("../translation/index.js").Translation;
|
|
14
|
+
getTimezoneAbbreviation?: (epochMilliseconds: number, timezone: string, locale: string) => string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare function useTimezone(): string;
|
|
17
|
+
export declare function useClock(): DateTimePreferences['clock'];
|
|
18
|
+
export declare function useDateTimeFormatter(): (date: DateTimeInput, options?: DateTimeOptions) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo } from "react";
|
|
3
|
+
import { useStore } from "zustand";
|
|
4
|
+
import { formattingStore } from "./config.js";
|
|
5
|
+
import { formatDateTimeWithSnapshot } from "./format.js";
|
|
6
|
+
const DateTimeContext = /*#__PURE__*/ createContext({});
|
|
7
|
+
function DateTimeProvider({ value, children }) {
|
|
8
|
+
const parent = useContext(DateTimeContext);
|
|
9
|
+
const preferences = useMemo(()=>({
|
|
10
|
+
timezone: value.timezone ?? parent.timezone,
|
|
11
|
+
clock: value.clock ?? parent.clock
|
|
12
|
+
}), [
|
|
13
|
+
parent,
|
|
14
|
+
value.timezone,
|
|
15
|
+
value.clock
|
|
16
|
+
]);
|
|
17
|
+
return /*#__PURE__*/ jsx(DateTimeContext, {
|
|
18
|
+
value: preferences,
|
|
19
|
+
children: children
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function useFormattingSnapshot() {
|
|
23
|
+
const overrides = useContext(DateTimeContext);
|
|
24
|
+
const snapshot = useStore(formattingStore);
|
|
25
|
+
return useMemo(()=>({
|
|
26
|
+
...snapshot,
|
|
27
|
+
timezone: overrides.timezone ?? snapshot.timezone,
|
|
28
|
+
clock: overrides.clock ?? snapshot.clock
|
|
29
|
+
}), [
|
|
30
|
+
snapshot,
|
|
31
|
+
overrides
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
function useTimezone() {
|
|
35
|
+
return useFormattingSnapshot().timezone;
|
|
36
|
+
}
|
|
37
|
+
function useClock() {
|
|
38
|
+
return useFormattingSnapshot().clock;
|
|
39
|
+
}
|
|
40
|
+
function useDateTimeFormatter() {
|
|
41
|
+
const snapshot = useFormattingSnapshot();
|
|
42
|
+
return useCallback((date, options = {})=>formatDateTimeWithSnapshot(date, options, snapshot), [
|
|
43
|
+
snapshot
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
export { DateTimeProvider, useClock, useDateTimeFormatter, useFormattingSnapshot, useTimezone };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { DateTimeInput, DateTimeOptions } from './format.js';
|
|
3
|
+
export type DateTimeProps = Omit<React.HTMLAttributes<HTMLTimeElement>, 'children'> & DateTimeOptions & {
|
|
4
|
+
date: DateTimeInput;
|
|
5
|
+
};
|
|
6
|
+
export declare function DateTime({ date, mode, year, precision, timezone, clock, showTimezone, ...props }: DateTimeProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useDateTimeFormatter } from "./context.js";
|
|
3
|
+
function DateTime({ date, mode, year, precision, timezone, clock, showTimezone, ...props }) {
|
|
4
|
+
const format = useDateTimeFormatter();
|
|
5
|
+
const options = 'date' === mode ? {
|
|
6
|
+
mode,
|
|
7
|
+
year,
|
|
8
|
+
timezone,
|
|
9
|
+
clock,
|
|
10
|
+
showTimezone
|
|
11
|
+
} : 'time' === mode ? {
|
|
12
|
+
mode,
|
|
13
|
+
precision,
|
|
14
|
+
timezone,
|
|
15
|
+
clock,
|
|
16
|
+
showTimezone
|
|
17
|
+
} : {
|
|
18
|
+
mode,
|
|
19
|
+
year,
|
|
20
|
+
precision,
|
|
21
|
+
timezone,
|
|
22
|
+
clock,
|
|
23
|
+
showTimezone
|
|
24
|
+
};
|
|
25
|
+
return /*#__PURE__*/ jsx("time", {
|
|
26
|
+
...props,
|
|
27
|
+
children: format(date, options)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { DateTime };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DateTimePreferences, type FormattingSnapshot } from './config.js';
|
|
2
|
+
/** Numbers are epoch milliseconds; strings must be ISO timestamps with an offset. */
|
|
3
|
+
export type DateTimeInput = Date | number | string;
|
|
4
|
+
export type TimePrecision = 'minute' | 'second' | 'millisecond';
|
|
5
|
+
export type YearDisplay = 'auto' | 'always' | 'never';
|
|
6
|
+
export type DateTimeOptions = Partial<DateTimePreferences> & {
|
|
7
|
+
/** Defaults to true only when the caller explicitly selects timezone "UTC". */
|
|
8
|
+
showTimezone?: boolean;
|
|
9
|
+
} & ({
|
|
10
|
+
mode?: 'dateTime';
|
|
11
|
+
precision?: TimePrecision;
|
|
12
|
+
year?: YearDisplay;
|
|
13
|
+
} | {
|
|
14
|
+
mode: 'date';
|
|
15
|
+
precision?: never;
|
|
16
|
+
year?: YearDisplay;
|
|
17
|
+
} | {
|
|
18
|
+
mode: 'time';
|
|
19
|
+
precision?: TimePrecision;
|
|
20
|
+
year?: never;
|
|
21
|
+
});
|
|
22
|
+
export declare function formatDateTime(date: DateTimeInput, options?: DateTimeOptions): string;
|
|
23
|
+
export declare function formatTimezone(epochMilliseconds: number, timezone: string, snapshot?: Readonly<FormattingSnapshot>): string;
|
|
24
|
+
export declare function formatDateTimeWithSnapshot(date: DateTimeInput, options: DateTimeOptions, snapshot: Readonly<FormattingSnapshot>): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { getSnapshot } from "./config.js";
|
|
3
|
+
import { getIntlFormatter } from "./intlFormatter.js";
|
|
4
|
+
import { parseDate } from "./parseDate.js";
|
|
5
|
+
function formatDateTime(date, options = {}) {
|
|
6
|
+
return formatDateTimeWithSnapshot(date, options, getSnapshot());
|
|
7
|
+
}
|
|
8
|
+
function formatTimezone(epochMilliseconds, timezone, snapshot = getSnapshot()) {
|
|
9
|
+
if ('UTC' === timezone) return 'UTC';
|
|
10
|
+
return snapshot.getTimezoneAbbreviation?.(epochMilliseconds, timezone, snapshot.locale) ?? getIntlFormatter(Intl.DateTimeFormat, snapshot.locale, {
|
|
11
|
+
timeZone: timezone,
|
|
12
|
+
timeZoneName: 'short'
|
|
13
|
+
}).formatToParts(epochMilliseconds).find((part)=>'timeZoneName' === part.type)?.value ?? '';
|
|
14
|
+
}
|
|
15
|
+
function formatDateTimeWithSnapshot(date, options, snapshot) {
|
|
16
|
+
const { mode = 'dateTime', clock = snapshot.clock, year = 'auto', precision = 'minute' } = options;
|
|
17
|
+
const timezone = options.timezone ?? snapshot.timezone;
|
|
18
|
+
const showTimezone = options.showTimezone ?? 'UTC' === options.timezone;
|
|
19
|
+
const value = parseDate(date, timezone);
|
|
20
|
+
if (!value) return 'Invalid date';
|
|
21
|
+
const currentYear = Temporal.Instant.fromEpochMilliseconds(Date.now()).toZonedDateTimeISO(timezone).year;
|
|
22
|
+
const showYear = 'always' === year || 'auto' === year && value.year !== currentYear;
|
|
23
|
+
const dateParts = getIntlFormatter(Intl.DateTimeFormat, snapshot.locale, {
|
|
24
|
+
calendar: 'gregory',
|
|
25
|
+
timeZone: timezone,
|
|
26
|
+
year: showYear ? 'numeric' : void 0,
|
|
27
|
+
month: 'short',
|
|
28
|
+
day: 'numeric'
|
|
29
|
+
}).formatToParts(value.epochMilliseconds);
|
|
30
|
+
const dateText = dateParts.map((part)=>'year' === part.type && value.year < 1000 ? getIntlFormatter(Intl.NumberFormat, snapshot.locale, {
|
|
31
|
+
minimumIntegerDigits: 4,
|
|
32
|
+
useGrouping: false
|
|
33
|
+
}).format(value.year) : part.value).join('');
|
|
34
|
+
const timeText = getIntlFormatter(Intl.DateTimeFormat, snapshot.locale, {
|
|
35
|
+
timeZone: timezone,
|
|
36
|
+
hour: '24' === clock ? '2-digit' : 'numeric',
|
|
37
|
+
minute: '2-digit',
|
|
38
|
+
second: 'minute' === precision ? void 0 : '2-digit',
|
|
39
|
+
fractionalSecondDigits: 'millisecond' === precision ? 3 : void 0,
|
|
40
|
+
hourCycle: '24' === clock ? 'h23' : 'h12'
|
|
41
|
+
}).format(value.epochMilliseconds).replaceAll('\u202F', ' ');
|
|
42
|
+
const text = 'date' === mode ? dateText : 'time' === mode ? timeText : `${dateText}${showYear ? ' ' : ', '}${timeText}`;
|
|
43
|
+
return showTimezone ? `${text} ${formatTimezone(value.epochMilliseconds, timezone, snapshot)}` : text;
|
|
44
|
+
}
|
|
45
|
+
export { formatDateTime, formatDateTimeWithSnapshot, formatTimezone };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DateTime, type DateTimeProps } from './dateTime.js';
|
|
2
|
+
export { DateTimeProvider, useTimezone, useClock, useDateTimeFormatter } from './context.js';
|
|
3
|
+
export { configureFormatting, type DateTimePreferences, type FormattingSource, type FormattingSnapshot, } from './config.js';
|
|
4
|
+
export { formatDateTime, formatTimezone, type DateTimeInput, type DateTimeOptions, type TimePrecision, type YearDisplay, } from './format.js';
|
|
5
|
+
export { getIntlFormatter } from './intlFormatter.js';
|
|
6
|
+
export { parseDate } from './parseDate.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DateTime } from "./dateTime.js";
|
|
2
|
+
export { DateTimeProvider, useClock, useDateTimeFormatter, useTimezone } from "./context.js";
|
|
3
|
+
export { configureFormatting } from "./config.js";
|
|
4
|
+
export { formatDateTime, formatTimezone } from "./format.js";
|
|
5
|
+
export { getIntlFormatter } from "./intlFormatter.js";
|
|
6
|
+
export { parseDate } from "./parseDate.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type IntlFormatterConstructor<Formatter, Options> = new (locale: string, options?: Options) => Formatter;
|
|
2
|
+
/**
|
|
3
|
+
* Constructing an Intl formatter costs far more than formatting with one, and
|
|
4
|
+
* dates render in large tables and on every relative-time tick. Formatters are
|
|
5
|
+
* reused per locale and options. The set stays small: a session uses few
|
|
6
|
+
* locales, timezones, and option shapes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getIntlFormatter<Formatter, Options>(Constructor: IntlFormatterConstructor<Formatter, Options>, locale: string, options: NoInfer<Options>): Formatter;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const formattersByConstructor = new Map();
|
|
2
|
+
function getIntlFormatter(Constructor, locale, options) {
|
|
3
|
+
let formatters = formattersByConstructor.get(Constructor);
|
|
4
|
+
if (!formatters) {
|
|
5
|
+
formatters = new Map();
|
|
6
|
+
formattersByConstructor.set(Constructor, formatters);
|
|
7
|
+
}
|
|
8
|
+
const key = `${locale}|${JSON.stringify(options)}`;
|
|
9
|
+
let formatter = formatters.get(key);
|
|
10
|
+
if (!formatter) {
|
|
11
|
+
formatter = new Constructor(locale, options);
|
|
12
|
+
formatters.set(key, formatter);
|
|
13
|
+
}
|
|
14
|
+
return formatter;
|
|
15
|
+
}
|
|
16
|
+
export { getIntlFormatter };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
function parseDate(date, timezone) {
|
|
3
|
+
if ('string' != typeof date && 'number' != typeof date && !(date instanceof Date)) return null;
|
|
4
|
+
try {
|
|
5
|
+
const instant = 'string' == typeof date ? Temporal.Instant.from(date) : Temporal.Instant.fromEpochMilliseconds(Math.trunc(date instanceof Date ? date.getTime() : date));
|
|
6
|
+
return instant.toZonedDateTimeISO(timezone);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
if (error instanceof RangeError || error instanceof TypeError) return null;
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export { parseDate };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import is_prop_valid from "@emotion/is-prop-valid";
|
|
2
2
|
import { css } from "@emotion/react";
|
|
3
3
|
import styled from "@emotion/styled";
|
|
4
|
-
import { getSpacing
|
|
4
|
+
import { getSpacing } from "../layout/index.js";
|
|
5
|
+
import { rc } from "../layout/styles.js";
|
|
5
6
|
const List = styled('dl', {
|
|
6
7
|
shouldForwardProp: (prop)=>'gap' !== prop && 'nowrap' !== prop && 'columns' !== prop && 'align' !== prop && 'terms' !== prop && 'striped' !== prop && is_prop_valid(prop)
|
|
7
8
|
})`
|
|
@@ -70,7 +71,7 @@ const Details = styled('dd')`
|
|
|
70
71
|
overflow-wrap: anywhere;
|
|
71
72
|
`;
|
|
72
73
|
const DescriptionList = Object.assign(List, {
|
|
73
|
-
Term
|
|
74
|
-
Details
|
|
74
|
+
Term,
|
|
75
|
+
Details
|
|
75
76
|
});
|
|
76
77
|
export { DescriptionList };
|
|
@@ -149,7 +149,7 @@ const AlignedContainer = styled(Container)`
|
|
|
149
149
|
padding-left: ${(p)=>'xs' === p.size ? '22px' : 'sm' === p.size ? '26px' : '26px'};
|
|
150
150
|
`;
|
|
151
151
|
const Disclosure = Object.assign(DisclosureComponent, {
|
|
152
|
-
Title
|
|
153
|
-
Content
|
|
152
|
+
Title,
|
|
153
|
+
Content
|
|
154
154
|
});
|
|
155
155
|
export { Disclosure };
|
|
@@ -25,10 +25,12 @@ export type DragHandleProps = DragHandleNameProps & {
|
|
|
25
25
|
onMove: (delta: number) => void;
|
|
26
26
|
orientation: Orientation;
|
|
27
27
|
value: number;
|
|
28
|
+
/** Makes the handle inert: it cannot be dragged, focused, or hovered. */
|
|
29
|
+
disabled?: boolean;
|
|
28
30
|
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
29
31
|
onMoveEnd?: () => void;
|
|
30
32
|
onMoveStart?: () => void;
|
|
31
33
|
variant?: DragHandleVariant;
|
|
32
34
|
};
|
|
33
|
-
export declare function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant, isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart, }: DragHandleProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, disabled, variant, isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart, }: DragHandleProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
34
36
|
export {};
|
|
@@ -7,7 +7,7 @@ const DRAG_HANDLE_SIZE = 1;
|
|
|
7
7
|
const DRAG_SEPARATOR_TARGET_SIZE = 24;
|
|
8
8
|
const targetLength = 'var(--drag-separator-target-length, none)';
|
|
9
9
|
const targetOffset = `calc(50% - ${DRAG_SEPARATOR_TARGET_SIZE / 2}px)`;
|
|
10
|
-
function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant = 'solid', isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart }) {
|
|
10
|
+
function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, disabled, variant = 'solid', isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart }) {
|
|
11
11
|
const { cursor, separatorProps } = useDragSeparator({
|
|
12
12
|
isSizedFirst,
|
|
13
13
|
max,
|
|
@@ -29,7 +29,8 @@ function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby
|
|
|
29
29
|
$cursor: cursor,
|
|
30
30
|
"aria-label": ariaLabel,
|
|
31
31
|
"aria-labelledby": ariaLabelledby,
|
|
32
|
-
"data-variant": variant
|
|
32
|
+
"data-variant": variant,
|
|
33
|
+
inert: disabled
|
|
33
34
|
})
|
|
34
35
|
});
|
|
35
36
|
}
|
|
@@ -38,11 +39,13 @@ const DragHandleLine = styled('div')`
|
|
|
38
39
|
touch-action: none;
|
|
39
40
|
pointer-events: none;
|
|
40
41
|
|
|
41
|
-
/* Invisible wider hit area for dragging, and the only part that takes pointer events
|
|
42
|
+
/* Invisible wider hit area for dragging, and the only part that takes pointer events.
|
|
43
|
+
One below the drawer z-index: above pane content, but below global drawers, which render
|
|
44
|
+
before the app in the DOM and so lose a z-index tie. */
|
|
42
45
|
&::before {
|
|
43
46
|
content: '';
|
|
44
47
|
position: absolute;
|
|
45
|
-
z-index: ${(p)=>p.theme.zIndex.drawer};
|
|
48
|
+
z-index: ${(p)=>p.theme.zIndex.drawer - 1};
|
|
46
49
|
pointer-events: auto;
|
|
47
50
|
cursor: ${(p)=>p.$cursor};
|
|
48
51
|
}
|
|
@@ -51,7 +54,7 @@ const DragHandleLine = styled('div')`
|
|
|
51
54
|
&::after {
|
|
52
55
|
content: '';
|
|
53
56
|
position: absolute;
|
|
54
|
-
z-index: ${(p)=>p.theme.zIndex.drawer};
|
|
57
|
+
z-index: ${(p)=>p.theme.zIndex.drawer - 1};
|
|
55
58
|
opacity: 0.8;
|
|
56
59
|
background: transparent;
|
|
57
60
|
transition: background ${(p)=>p.theme.motion.smooth.slow};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { DrawerOptions } from './globalDrawer.js';
|
|
3
|
+
type DrawerContentContextType = Pick<DrawerOptions, 'ariaLabel' | 'onClose'>;
|
|
4
|
+
export declare function useDrawerContentContext(): DrawerContentContextType;
|
|
5
|
+
/**
|
|
6
|
+
* Rendering props for the inner DrawerPanel component. Inherits the shared
|
|
7
|
+
* panel-configuration props directly from DrawerOptions so the two interfaces
|
|
8
|
+
* can't drift. GlobalDrawer-only options (shouldClose*, onClose
|
|
9
|
+
* callback) are consumed before reaching this component.
|
|
10
|
+
*/
|
|
11
|
+
export interface DrawerPanelProps extends Pick<DrawerOptions, 'ariaLabel' | 'drawerKey' | 'drawerWidth' | 'drawerMaxWidth' | 'resizable' | 'onClose'> {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/** Required — GlobalDrawer applies the default before passing it down. */
|
|
14
|
+
mode: NonNullable<DrawerOptions['mode']>;
|
|
15
|
+
/** Minimum panel width in pixels, e.g. to cover a pane docked on the right. */
|
|
16
|
+
minPanelWidth?: number;
|
|
17
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
18
|
+
/** Distance in pixels from the viewport top, e.g. to clear page banners. */
|
|
19
|
+
topOffset?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function DrawerPanel({ ref, mode, ariaLabel, children, onClose, drawerWidth, drawerMaxWidth, drawerKey, minPanelWidth, topOffset, resizable, }: DrawerPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
22
|
+
export interface DrawerHeaderProps {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* If true, hides the spacer bar separating close button from custom header content
|
|
27
|
+
*/
|
|
28
|
+
hideBar?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If true, hides the close button
|
|
31
|
+
*/
|
|
32
|
+
hideCloseButton?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* If true, hides the label of the close button
|
|
35
|
+
*/
|
|
36
|
+
hideCloseButtonText?: boolean;
|
|
37
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
38
|
+
}
|
|
39
|
+
export declare function DrawerHeader({ ref, className, children, hideBar, hideCloseButton, hideCloseButtonText, }: DrawerHeaderProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare function DrawerBody({ ref, ...props }: React.ComponentProps<'aside'>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare const DrawerComponents: {
|
|
42
|
+
DrawerBody: typeof DrawerBody;
|
|
43
|
+
DrawerHeader: typeof DrawerHeader;
|
|
44
|
+
DrawerPanel: typeof DrawerPanel;
|
|
45
|
+
};
|
|
46
|
+
export {};
|