@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
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ The source code is open, but the system is designed for Sentry and is not intend
|
|
|
6
6
|
|
|
7
7
|
## Development in Sentry
|
|
8
8
|
|
|
9
|
-
The package source lives in [src](./src). Component
|
|
9
|
+
The package source lives in [src](./src). Component docs (`.mdx`) sit next to their components and render in the app's Scraps viewer; `.npmignore` and the build config keep them out of the published package.
|
|
10
10
|
|
|
11
|
-
Move components and their
|
|
11
|
+
Move components, their tests, and their docs into `src` as they become isolated. The [Scraps contribution guide](../../app/components/core/overview/contributing.mdx) covers component contributions and the Figma process for changing design tokens.
|
|
12
12
|
|
|
13
13
|
Run package checks from the repository root:
|
|
14
14
|
|
|
@@ -35,20 +35,86 @@ pnpm --dir static/packages/scraps pack --pack-destination .artifacts
|
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
The `prepack` hook builds JavaScript and declarations with
|
|
38
|
-
[Rslib](./rslib.config.mjs), including from a clean checkout.
|
|
39
|
-
package manifest, README, and license ship.
|
|
38
|
+
[Rslib](./rslib.config.mjs), including from a clean checkout. The package ships `dist`, the font stylesheet and WOFF2 assets, the manifest, README, and licenses.
|
|
40
39
|
|
|
41
40
|
The `exports` field in [package.json](./package.json) defines the published API.
|
|
42
41
|
Import from its explicit subpaths, including `@sentry/scraps/code/inlineCode`
|
|
43
42
|
and `@sentry/scraps/hotkey/kbd`. The package has no root export; unlisted module
|
|
44
43
|
paths remain private.
|
|
45
44
|
Add an entry only when its runtime and type dependencies belong to the package
|
|
46
|
-
or are declared dependencies.
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
or are declared dependencies. Both `Hotkey` and `Kbd` are isolated and exported
|
|
46
|
+
from `@sentry/scraps/hotkey`; `Kbd` also has its own `@sentry/scraps/hotkey/kbd`
|
|
47
|
+
entry point. App stories cover more components than this API. Published consumers
|
|
48
|
+
have no fallback to app components.
|
|
49
49
|
|
|
50
50
|
Consumers provide Emotion's `ThemeProvider` with `lightTheme` or `darkTheme`.
|
|
51
|
-
|
|
51
|
+
Load Rubik, Roboto Mono, and their metric-adjusted fallbacks in your app stylesheet.
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
@import '@sentry/scraps/fonts.css';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The stylesheet uses relative URLs to separate WOFF2 files. For direct asset imports, use paths such as `@sentry/scraps/fonts/rubik-variable.woff2`.
|
|
58
|
+
|
|
59
|
+
To self-host without a bundler, copy `fonts.css` and the `fonts/` directory from the installed package into the same public directory, then link to `fonts.css` in your page. Keep `fonts/OFL.txt` with the font files.
|
|
60
|
+
|
|
61
|
+
## Date and duration formatting
|
|
62
|
+
|
|
63
|
+
Components and plain formatters share the same presentation options:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import {DateTime, formatDateTime} from '@sentry/scraps/dateTime';
|
|
67
|
+
import {getDuration} from '@sentry/scraps/duration';
|
|
68
|
+
|
|
69
|
+
const date = '2025-01-01T12:00:00Z';
|
|
70
|
+
formatDateTime(date, {timezone: 'America/New_York', mode: 'time'});
|
|
71
|
+
<DateTime date={date} mode="time" precision="second" />;
|
|
72
|
+
getDuration(65, {precision: 1, style: 'short'}); // "1.1min"
|
|
73
|
+
getDuration(55, {minimumUnit: 'minute'}); // "1 minute"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Dates accept a `Date`, epoch milliseconds, or an ISO timestamp with an explicit
|
|
77
|
+
`Z` or UTC offset. Offset-free strings, calendar-only dates, invalid dates, and
|
|
78
|
+
unknown timezone identifiers return `Invalid date`.
|
|
79
|
+
|
|
80
|
+
Use `mode` to choose `dateTime`, `date`, or `time`. Time precision is
|
|
81
|
+
`minute`, `second`, or `millisecond`; year display is `auto`, `always`, or
|
|
82
|
+
`never`. Set `timezone: 'UTC'` for UTC output and `clock` to `'12'` or
|
|
83
|
+
`'24'`. UTC output includes its timezone label by default; `showTimezone`
|
|
84
|
+
controls the label explicitly. Formatting-engine types and patterns are private.
|
|
85
|
+
|
|
86
|
+
Parsing and timezone conversion use a private Temporal ponyfill, without changing
|
|
87
|
+
browser globals. Rendering preserves Intl's locale-specific date order, literal
|
|
88
|
+
characters, and time punctuation while honoring the configured clock. French
|
|
89
|
+
output includes `1 janv. 2025` and `1:05:06,123 PM`; Japanese output includes
|
|
90
|
+
`2025年1月1日` and `午後1:05`. These locale conventions replace Moment's fixed
|
|
91
|
+
month-first layout. Timezone labels use Intl by default. An application can supply
|
|
92
|
+
`getTimezoneAbbreviation(epochMilliseconds, timezone, locale)` in its formatting snapshot
|
|
93
|
+
to retain its existing labels. Returning `undefined` uses the Intl fallback.
|
|
94
|
+
Sentry supplies its already-loaded timezone lookup, preserving labels such as
|
|
95
|
+
`AEDT`, `AEST`, and `+0545` without adding Moment or a timezone dataset to Scraps.
|
|
96
|
+
|
|
97
|
+
Without configuration, dates use UTC and a 12-hour clock. Applications call
|
|
98
|
+
`configureFormatting` before rendering with one source. Its `getSnapshot`
|
|
99
|
+
returns the same object until preferences change, and `subscribe` notifies
|
|
100
|
+
consumers after a new snapshot is ready. Each snapshot contains `timezone`,
|
|
101
|
+
`clock`, `locale`, and matching `messages` with `t`, `tn`, and `pgettext`.
|
|
102
|
+
The source feeds a Zustand store shared by plain formatters and React consumers.
|
|
103
|
+
Plain formatters read its current snapshot; React consumers subscribe to changes.
|
|
104
|
+
The cleanup returned by `configureFormatting` disconnects the source and restores
|
|
105
|
+
the previous snapshot.
|
|
106
|
+
|
|
107
|
+
`DateTimeProvider` accepts partial timezone and clock overrides and inherits
|
|
108
|
+
unspecified values from its parent. Explicit component or function options win
|
|
109
|
+
over defaults. Use `useDateTimeFormatter()` to bind a formatter to the nearest
|
|
110
|
+
provider for callbacks and copied text. A free `formatDateTime` call reads
|
|
111
|
+
application preferences, without a React subtree's overrides.
|
|
112
|
+
|
|
113
|
+
`getDuration` accepts seconds and uses the same configured messages. Its
|
|
114
|
+
`minimumUnit` is a unit name such as `'millisecond'` or `'minute'`, and its
|
|
115
|
+
`style` is `'long'`, `'short'`, or `'narrow'`. The default style is long,
|
|
116
|
+
the minimum is one millisecond, and `precision` controls decimal places.
|
|
117
|
+
Month and year conversions remain approximate elapsed durations.
|
|
52
118
|
|
|
53
119
|
## Prepare a release
|
|
54
120
|
|
package/dist/alert/alert.js
CHANGED
|
@@ -13,7 +13,6 @@ import { Container, Flex, Grid } from "../layout/index.js";
|
|
|
13
13
|
import { PanelProvider } from "../panelProvider.js";
|
|
14
14
|
import { Text } from "../text/index.js";
|
|
15
15
|
import { useTranslation } from "../translation/useTranslation.js";
|
|
16
|
-
import { unreachable } from "../unreachable.js";
|
|
17
16
|
const AlertPanel = styled('div')`
|
|
18
17
|
position: relative;
|
|
19
18
|
display: grid;
|
|
@@ -83,7 +82,6 @@ function getAlertTokens(variant, theme) {
|
|
|
83
82
|
border: theme.tokens.border.primary
|
|
84
83
|
};
|
|
85
84
|
default:
|
|
86
|
-
unreachable(variant);
|
|
87
85
|
}
|
|
88
86
|
throw new TypeError(`Invalid alert variant, got ${variant}`);
|
|
89
87
|
}
|
|
@@ -240,7 +238,6 @@ function AlertIcon({ variant }) {
|
|
|
240
238
|
case 'muted':
|
|
241
239
|
return /*#__PURE__*/ jsx(IconInfo, {});
|
|
242
240
|
default:
|
|
243
|
-
unreachable(variant);
|
|
244
241
|
}
|
|
245
242
|
return null;
|
|
246
243
|
}
|
package/dist/badge/badge.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled from "@emotion/styled";
|
|
2
|
-
import { unreachable } from "../unreachable.js";
|
|
3
2
|
const Badge = styled('span')`
|
|
4
3
|
${(p)=>({
|
|
5
4
|
...makeBadgeTheme(p, p.theme)
|
|
@@ -73,7 +72,7 @@ function makeBadgeTheme(p, theme) {
|
|
|
73
72
|
background: theme.tokens.background.transparent.success.muted
|
|
74
73
|
};
|
|
75
74
|
default:
|
|
76
|
-
|
|
75
|
+
p.variant;
|
|
77
76
|
throw new TypeError(`Unsupported badge variant: ${p.variant}`);
|
|
78
77
|
}
|
|
79
78
|
}
|
package/dist/badge/tag.js
CHANGED
|
@@ -4,7 +4,6 @@ import { IconClose } from "@sentry/icons/close";
|
|
|
4
4
|
import { IconDefaultsProvider } from "@sentry/icons/useIconDefaults";
|
|
5
5
|
import { Button } from "../button/index.js";
|
|
6
6
|
import { useTranslation } from "../translation/useTranslation.js";
|
|
7
|
-
import { unreachable } from "../unreachable.js";
|
|
8
7
|
function Tag({ ref, variant, icon, onDismiss, children, ...props }) {
|
|
9
8
|
const { t } = useTranslation();
|
|
10
9
|
return /*#__PURE__*/ jsxs(TagPill, {
|
|
@@ -47,8 +46,9 @@ const TagPill = styled('div')`
|
|
|
47
46
|
display: inline-flex;
|
|
48
47
|
gap: ${(p)=>p.theme.space.xs};
|
|
49
48
|
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
50
|
border-radius: ${(p)=>p.theme.radius.xs};
|
|
51
|
-
padding: 0 ${(p)=>p.theme.space.
|
|
51
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
52
52
|
max-width: 100%;
|
|
53
53
|
|
|
54
54
|
/* @TODO(jonasbadalic): We need to override button colors because they wrongly default to a blue color... */
|
|
@@ -91,7 +91,6 @@ function makeTagPillTheme(type, theme) {
|
|
|
91
91
|
background: theme.tokens.background.transparent.success.muted
|
|
92
92
|
};
|
|
93
93
|
default:
|
|
94
|
-
unreachable(type);
|
|
95
94
|
throw new TypeError(`Unsupported badge type: ${type}`);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
@@ -100,6 +99,8 @@ const TagText = styled('div')`
|
|
|
100
99
|
white-space: nowrap;
|
|
101
100
|
text-overflow: ellipsis;
|
|
102
101
|
min-width: 0;
|
|
102
|
+
text-box-edge: text text;
|
|
103
|
+
text-box-trim: trim-both;
|
|
103
104
|
|
|
104
105
|
&:has(> *) {
|
|
105
106
|
display: flex;
|
|
@@ -113,7 +114,6 @@ const IconWrapper = styled('span')`
|
|
|
113
114
|
gap: inherit;
|
|
114
115
|
`;
|
|
115
116
|
const DismissButton = styled(Button)`
|
|
116
|
-
margin-right: -${(p)=>p.theme.space.xs};
|
|
117
117
|
border: none;
|
|
118
118
|
`;
|
|
119
119
|
export { Tag };
|
package/dist/button/button.js
CHANGED
package/dist/button/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { Button, type ButtonProps } from './button.js';
|
|
2
2
|
export { ButtonBar, type ButtonBarProps } from './buttonBar.js';
|
|
3
3
|
export { LinkButton, type LinkButtonProps } from './linkButton.js';
|
|
4
|
-
export { DO_NOT_USE_getButtonStyles } from './styles.js';
|
|
5
4
|
export type { ButtonSize } from './types.js';
|
package/dist/button/index.js
CHANGED
|
@@ -32,6 +32,7 @@ function LinkButton({ disabled, tooltipProps, size: explicitSize, ...props }) {
|
|
|
32
32
|
to: disabled ? void 0 : 'to' in props ? props.to : void 0,
|
|
33
33
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
34
34
|
as: "span",
|
|
35
|
+
"data-button-label": true,
|
|
35
36
|
align: "center",
|
|
36
37
|
justify: "center",
|
|
37
38
|
minWidth: "0",
|
package/dist/button/styles.js
CHANGED
|
@@ -4,61 +4,102 @@ const DO_NOT_USE_BUTTON_ICON_SIZES = {
|
|
|
4
4
|
sm: 'sm',
|
|
5
5
|
md: 'sm'
|
|
6
6
|
};
|
|
7
|
-
const elevation = {
|
|
8
|
-
md: '2px',
|
|
9
|
-
sm: '2px',
|
|
10
|
-
xs: '1px',
|
|
11
|
-
zero: '0px'
|
|
12
|
-
};
|
|
13
|
-
const hoverElevation = '1px';
|
|
14
7
|
function DO_NOT_USE_getButtonStyles(p) {
|
|
15
|
-
const variant = p.variant ?? 'secondary';
|
|
16
8
|
const ariaDisabled = p['aria-disabled'];
|
|
17
|
-
const disabled = p.disabled || true === ariaDisabled || 'true' === ariaDisabled;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
lineHeight: '1rem'
|
|
25
|
-
}
|
|
9
|
+
const disabled = Boolean(p.disabled || true === ariaDisabled || 'true' === ariaDisabled);
|
|
10
|
+
const props = {
|
|
11
|
+
busy: Boolean(p.busy),
|
|
12
|
+
disabled,
|
|
13
|
+
shapeVariant: p.shapeVariant,
|
|
14
|
+
size: getSizeTokens(p.size, p.theme),
|
|
15
|
+
theme: p.theme
|
|
26
16
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
17
|
+
const variant = p.variant ?? 'secondary';
|
|
18
|
+
switch(variant){
|
|
19
|
+
case 'transparent':
|
|
20
|
+
return getTransparentStyles(props);
|
|
21
|
+
case 'link':
|
|
22
|
+
return getLinkStyles(props);
|
|
23
|
+
default:
|
|
24
|
+
return getChonkyStyles(props, chonkyTokens[variant](p.theme.tokens.interactive.chonky.embossed, p.theme));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getBaseStyles(p) {
|
|
29
28
|
return {
|
|
30
|
-
'--button-lift': buttonElevation,
|
|
31
29
|
position: 'relative',
|
|
32
30
|
display: 'inline-flex',
|
|
33
31
|
alignItems: 'center',
|
|
34
32
|
justifyContent: 'center',
|
|
35
33
|
whiteSpace: 'nowrap',
|
|
36
34
|
fontWeight: p.theme.font.weight.sans.medium,
|
|
37
|
-
|
|
35
|
+
fontSize: p.size.fontSize,
|
|
36
|
+
lineHeight: p.size.lineHeight,
|
|
37
|
+
opacity: p.disabled ? 0.6 : void 0,
|
|
38
|
+
borderRadius: p.size.borderRadius,
|
|
39
|
+
border: 'none',
|
|
40
|
+
background: 'none',
|
|
38
41
|
cursor: 'pointer',
|
|
39
42
|
'&[disabled], &[aria-disabled="true"]': {
|
|
40
43
|
cursor: 'not-allowed'
|
|
41
44
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
'&[aria-busy="true"]': {
|
|
46
|
+
cursor: 'progress'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const chonkyTokens = {
|
|
51
|
+
primary: (embossed, theme)=>({
|
|
52
|
+
surface: embossed.accent.background,
|
|
53
|
+
chonk: embossed.accent.chonk,
|
|
54
|
+
content: embossed.accent.content,
|
|
55
|
+
focus: {
|
|
56
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
secondary: (embossed, theme)=>({
|
|
60
|
+
surface: embossed.neutral.background,
|
|
61
|
+
chonk: embossed.neutral.chonk,
|
|
62
|
+
content: embossed.neutral.content.primary,
|
|
63
|
+
focus: {
|
|
64
|
+
boxShadow: `0 var(--button-lift) 0 0 ${embossed.neutral.chonk}, 0 var(--button-lift) 0 2px ${theme.tokens.focus.default}, 0 0 0 2px ${theme.tokens.focus.default}`
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
warning: (embossed, theme)=>({
|
|
68
|
+
surface: embossed.warning.background,
|
|
69
|
+
chonk: embossed.warning.chonk,
|
|
70
|
+
content: embossed.warning.content,
|
|
71
|
+
focus: {
|
|
72
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.dark}`
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
danger: (embossed, theme)=>({
|
|
76
|
+
surface: embossed.danger.background,
|
|
77
|
+
chonk: embossed.danger.chonk,
|
|
78
|
+
content: embossed.danger.content,
|
|
79
|
+
focus: {
|
|
80
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
function getChonkyStyles(p, tokens) {
|
|
85
|
+
return {
|
|
86
|
+
...getBaseStyles(p),
|
|
87
|
+
'--button-lift': p.size.lift,
|
|
88
|
+
padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
|
|
89
|
+
height: p.size.height,
|
|
90
|
+
minHeight: p.size.minHeight,
|
|
91
|
+
minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
|
|
92
|
+
color: tokens.content,
|
|
52
93
|
'&::before': {
|
|
53
94
|
content: '""',
|
|
54
95
|
display: 'block',
|
|
55
96
|
position: 'absolute',
|
|
56
97
|
inset: '0',
|
|
57
|
-
height: `calc(100% - ${
|
|
58
|
-
top:
|
|
59
|
-
transform: `translateY(-${
|
|
60
|
-
boxShadow: `0 ${
|
|
61
|
-
background:
|
|
98
|
+
height: `calc(100% - ${p.size.lift})`,
|
|
99
|
+
top: p.size.lift,
|
|
100
|
+
transform: `translateY(-${p.size.lift})`,
|
|
101
|
+
boxShadow: `0 ${p.size.lift} 0 0px ${tokens.chonk}`,
|
|
102
|
+
background: tokens.chonk,
|
|
62
103
|
borderRadius: 'inherit'
|
|
63
104
|
},
|
|
64
105
|
'&::after': {
|
|
@@ -66,23 +107,16 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
66
107
|
display: 'block',
|
|
67
108
|
position: 'absolute',
|
|
68
109
|
inset: '0',
|
|
69
|
-
background:
|
|
110
|
+
background: tokens.surface,
|
|
70
111
|
borderRadius: 'inherit',
|
|
71
|
-
border: `1px solid ${
|
|
112
|
+
border: `1px solid ${tokens.chonk}`,
|
|
72
113
|
transform: 'translateY(calc(-1 * var(--button-lift)))',
|
|
73
114
|
transition: `transform ${p.theme.motion.snap.fast}`
|
|
74
115
|
},
|
|
75
116
|
'&:focus-visible': {
|
|
76
117
|
outline: 'none',
|
|
77
|
-
color: disabled || p.busy ? void 0 :
|
|
78
|
-
'&::after':
|
|
79
|
-
border: `2px dotted ${buttonTheme.focus}`
|
|
80
|
-
} : {
|
|
81
|
-
boxShadow: `0 var(--button-lift) 0 0 ${buttonTheme.background}, 0 var(--button-lift) 0 2px ${p.theme.tokens.focus.default}, 0 0 0 2px ${p.theme.tokens.focus.default}`
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
'&[aria-busy="true"] > span:last-child': {
|
|
85
|
-
overflow: 'visible'
|
|
118
|
+
color: p.disabled || p.busy ? void 0 : tokens.content,
|
|
119
|
+
'&::after': tokens.focus
|
|
86
120
|
},
|
|
87
121
|
'> span:last-child': {
|
|
88
122
|
zIndex: 1,
|
|
@@ -97,9 +131,12 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
97
131
|
transform: 'translateY(calc(-1 * var(--button-lift)))',
|
|
98
132
|
transition: `transform ${p.theme.motion.snap.fast}`
|
|
99
133
|
},
|
|
134
|
+
'&[aria-busy="true"] > span:last-child': {
|
|
135
|
+
overflow: 'visible'
|
|
136
|
+
},
|
|
100
137
|
'&:hover': {
|
|
101
|
-
'--button-lift': `calc(${
|
|
102
|
-
color: disabled || p.busy ? void 0 :
|
|
138
|
+
'--button-lift': `calc(${p.size.lift} + 1px)`,
|
|
139
|
+
color: p.disabled || p.busy ? void 0 : tokens.content
|
|
103
140
|
},
|
|
104
141
|
'&:active, &[aria-expanded="true"], &[aria-checked="true"]': {
|
|
105
142
|
'--button-lift': '0px'
|
|
@@ -114,134 +151,102 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
114
151
|
},
|
|
115
152
|
'&:disabled, &[aria-disabled="true"], &[aria-busy="true"]': {
|
|
116
153
|
'--button-lift': '0px'
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function getTransparentStyles(p) {
|
|
158
|
+
return {
|
|
159
|
+
...getBaseStyles(p),
|
|
160
|
+
padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
|
|
161
|
+
height: p.size.height,
|
|
162
|
+
minHeight: p.size.minHeight,
|
|
163
|
+
minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
|
|
164
|
+
color: p.theme.tokens.interactive.transparent.neutral.content.primary,
|
|
165
|
+
transform: 'translateY(0px)',
|
|
166
|
+
'&::before': {
|
|
167
|
+
display: 'none'
|
|
117
168
|
},
|
|
118
|
-
'
|
|
119
|
-
|
|
169
|
+
'&::after': {
|
|
170
|
+
display: 'none'
|
|
120
171
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
'
|
|
124
|
-
display: 'none'
|
|
125
|
-
},
|
|
126
|
-
'&::after': {
|
|
127
|
-
display: 'none'
|
|
128
|
-
}
|
|
172
|
+
'&:focus-visible': p.theme.focusRing(),
|
|
173
|
+
'> span:last-child': {
|
|
174
|
+
transform: 'translateY(0px)'
|
|
129
175
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
transform: 'translateY(0px)',
|
|
133
|
-
'&::before': {
|
|
134
|
-
display: 'none'
|
|
135
|
-
},
|
|
136
|
-
'&::after': {
|
|
137
|
-
display: 'none'
|
|
138
|
-
},
|
|
139
|
-
'&:focus-visible': {
|
|
140
|
-
...p.theme.focusRing()
|
|
141
|
-
},
|
|
142
|
-
'> span:last-child': {
|
|
143
|
-
transform: 'translateY(0px)'
|
|
144
|
-
},
|
|
145
|
-
'&:hover': {
|
|
146
|
-
'> span:last-child': {
|
|
147
|
-
transform: 'translateY(0px)'
|
|
148
|
-
},
|
|
149
|
-
backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray100
|
|
150
|
-
},
|
|
151
|
-
'&:active': {
|
|
152
|
-
'> span:last-child': {
|
|
153
|
-
transform: 'translateY(0px)'
|
|
154
|
-
},
|
|
155
|
-
backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray200
|
|
156
|
-
}
|
|
176
|
+
'&:hover': {
|
|
177
|
+
backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray100
|
|
157
178
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
height: 'auto',
|
|
161
|
-
minHeight: 'auto',
|
|
162
|
-
minWidth: 'auto',
|
|
163
|
-
border: 'none',
|
|
164
|
-
transform: 'translateY(0px)',
|
|
165
|
-
'> span:last-child': {
|
|
166
|
-
color: 'inherit'
|
|
167
|
-
},
|
|
168
|
-
'&:hover': {
|
|
169
|
-
'> span:last-child': {
|
|
170
|
-
transform: 'translateY(0px)'
|
|
171
|
-
}
|
|
172
|
-
}
|
|
179
|
+
'&:active': {
|
|
180
|
+
backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray200
|
|
173
181
|
}
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
surface: theme.tokens.interactive.chonky.embossed.danger.background,
|
|
201
|
-
background: theme.tokens.interactive.chonky.embossed.danger.chonk,
|
|
202
|
-
color: theme.tokens.interactive.chonky.embossed.danger.content,
|
|
203
|
-
focus: theme.tokens.focus.onVibrant.light
|
|
204
|
-
};
|
|
205
|
-
case 'transparent':
|
|
206
|
-
return {
|
|
207
|
-
surface: theme.tokens.interactive.transparent.neutral.background.rest,
|
|
208
|
-
background: theme.tokens.interactive.transparent.neutral.background.rest,
|
|
209
|
-
color: theme.tokens.interactive.transparent.neutral.content.primary
|
|
210
|
-
};
|
|
211
|
-
case 'link':
|
|
212
|
-
return {
|
|
213
|
-
surface: 'transparent',
|
|
214
|
-
background: 'transparent',
|
|
215
|
-
color: theme.tokens.interactive.link.accent.rest
|
|
216
|
-
};
|
|
217
|
-
default:
|
|
218
|
-
return {};
|
|
219
|
-
}
|
|
184
|
+
function getLinkStyles(p) {
|
|
185
|
+
return {
|
|
186
|
+
...getBaseStyles(p),
|
|
187
|
+
padding: '0',
|
|
188
|
+
height: 'auto',
|
|
189
|
+
minHeight: 'auto',
|
|
190
|
+
minWidth: 'auto',
|
|
191
|
+
color: p.theme.tokens.interactive.link.accent.rest,
|
|
192
|
+
transform: 'translateY(0px)',
|
|
193
|
+
'&::before': {
|
|
194
|
+
display: 'none'
|
|
195
|
+
},
|
|
196
|
+
'&::after': {
|
|
197
|
+
display: 'none'
|
|
198
|
+
},
|
|
199
|
+
'&:focus-visible': p.theme.focusRing(),
|
|
200
|
+
'> span:last-child': {
|
|
201
|
+
color: 'inherit'
|
|
202
|
+
},
|
|
203
|
+
'&:active': {
|
|
204
|
+
backgroundColor: 'inherit'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
220
207
|
}
|
|
221
|
-
function
|
|
208
|
+
function getSizeTokens(size, theme) {
|
|
222
209
|
switch(size){
|
|
223
210
|
case 'md':
|
|
224
211
|
return {
|
|
212
|
+
height: '36px',
|
|
213
|
+
minHeight: '36px',
|
|
214
|
+
fontSize: '0.875rem',
|
|
215
|
+
lineHeight: '1rem',
|
|
216
|
+
padding: `${theme.space.md} ${theme.space.xl}`,
|
|
225
217
|
borderRadius: theme.radius.lg,
|
|
226
|
-
|
|
218
|
+
lift: '2px'
|
|
227
219
|
};
|
|
228
220
|
case 'sm':
|
|
229
221
|
return {
|
|
222
|
+
height: '32px',
|
|
223
|
+
minHeight: '32px',
|
|
224
|
+
fontSize: '0.875rem',
|
|
225
|
+
lineHeight: '1rem',
|
|
226
|
+
padding: `${theme.space.md} ${theme.space.lg}`,
|
|
230
227
|
borderRadius: theme.radius.md,
|
|
231
|
-
|
|
228
|
+
lift: '2px'
|
|
232
229
|
};
|
|
233
230
|
case 'xs':
|
|
234
231
|
return {
|
|
232
|
+
height: '28px',
|
|
233
|
+
minHeight: '28px',
|
|
234
|
+
fontSize: '0.75rem',
|
|
235
|
+
lineHeight: '1rem',
|
|
236
|
+
padding: `${theme.space.sm} ${theme.space.md}`,
|
|
235
237
|
borderRadius: theme.radius.sm,
|
|
236
|
-
|
|
238
|
+
lift: '1px'
|
|
237
239
|
};
|
|
238
240
|
case 'zero':
|
|
239
241
|
return {
|
|
242
|
+
height: '24px',
|
|
243
|
+
minHeight: '24px',
|
|
244
|
+
fontSize: '0.75rem',
|
|
245
|
+
lineHeight: '1rem',
|
|
246
|
+
padding: `${theme.space.xs} ${theme.space.sm}`,
|
|
240
247
|
borderRadius: theme.radius.xs,
|
|
241
|
-
|
|
248
|
+
lift: '0px'
|
|
242
249
|
};
|
|
243
|
-
default:
|
|
244
|
-
return {};
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
export { DO_NOT_USE_BUTTON_ICON_SIZES, DO_NOT_USE_getButtonStyles };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type ButtonProps } from '../button/index.js';
|
|
3
|
+
export interface CopyToClipboardButtonProps extends Omit<Extract<ButtonProps, {
|
|
4
|
+
'aria-label': string;
|
|
5
|
+
}>, 'children' | 'onCopy' | 'onError'> {
|
|
6
|
+
text: string;
|
|
7
|
+
children?: never;
|
|
8
|
+
/** Custom failure feedback. Pass false to suppress the toast. */
|
|
9
|
+
errorMessage?: React.ReactNode;
|
|
10
|
+
onCopy?: (copiedText: string) => void;
|
|
11
|
+
onError?: (error: unknown) => void;
|
|
12
|
+
/** Custom success feedback. Pass false to suppress the toast. */
|
|
13
|
+
successMessage?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function CopyToClipboardButton({ onCopy, onError, onClick, text, icon, errorMessage, successMessage, ...props }: CopyToClipboardButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { IconCopy } from "@sentry/icons/copy";
|
|
3
|
+
import { Button } from "../button/index.js";
|
|
4
|
+
import { toast } from "../toast/index.js";
|
|
5
|
+
import { useTranslation } from "../translation/index.js";
|
|
6
|
+
function CopyToClipboardButton({ onCopy, onError, onClick, text, icon, errorMessage, successMessage, ...props }) {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
async function copy() {
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(text);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
const message = errorMessage ?? t('Error copying to clipboard');
|
|
13
|
+
if (message) toast.error(message);
|
|
14
|
+
onError?.(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const message = successMessage ?? t('Copied to clipboard');
|
|
18
|
+
if (message) toast.success(message);
|
|
19
|
+
onCopy?.(text);
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
22
|
+
...props,
|
|
23
|
+
onClick: (event)=>{
|
|
24
|
+
copy();
|
|
25
|
+
onClick?.(event);
|
|
26
|
+
},
|
|
27
|
+
icon: icon ?? /*#__PURE__*/ jsx(IconCopy, {
|
|
28
|
+
variant: "muted"
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export { CopyToClipboardButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyToClipboardButton, type CopyToClipboardButtonProps, } from './copyToClipboardButton.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyToClipboardButton } from "./copyToClipboardButton.js";
|