@transferwise/components 46.167.0 → 46.168.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 +1 -1
- package/build/Link/Link.js.map +1 -1
- package/build/Link/Link.mjs.map +1 -1
- package/build/Loader/Loader.js.map +1 -1
- package/build/Loader/Loader.mjs.map +1 -1
- package/build/Prompt/PrimitivePrompt/PrimitivePrompt.js +2 -1
- package/build/Prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/Prompt/PrimitivePrompt/PrimitivePrompt.mjs +2 -1
- package/build/Prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/Prompt/Snackbar/Snackbar.js +205 -0
- package/build/Prompt/Snackbar/Snackbar.js.map +1 -0
- package/build/Prompt/Snackbar/Snackbar.messages.js +14 -0
- package/build/Prompt/Snackbar/Snackbar.messages.js.map +1 -0
- package/build/Prompt/Snackbar/Snackbar.messages.mjs +10 -0
- package/build/Prompt/Snackbar/Snackbar.messages.mjs.map +1 -0
- package/build/Prompt/Snackbar/Snackbar.mjs +203 -0
- package/build/Prompt/Snackbar/Snackbar.mjs.map +1 -0
- package/build/Prompt/Snackbar/SnackbarContext.js.map +1 -0
- package/build/Prompt/Snackbar/SnackbarContext.mjs.map +1 -0
- package/build/Prompt/Snackbar/SnackbarPortal.js +12 -0
- package/build/Prompt/Snackbar/SnackbarPortal.js.map +1 -0
- package/build/Prompt/Snackbar/SnackbarPortal.mjs +8 -0
- package/build/Prompt/Snackbar/SnackbarPortal.mjs.map +1 -0
- package/build/Prompt/Snackbar/SnackbarProvider.js +42 -0
- package/build/Prompt/Snackbar/SnackbarProvider.js.map +1 -0
- package/build/Prompt/Snackbar/SnackbarProvider.mjs +38 -0
- package/build/Prompt/Snackbar/SnackbarProvider.mjs.map +1 -0
- package/build/Prompt/Snackbar/constants.js +17 -0
- package/build/Prompt/Snackbar/constants.js.map +1 -0
- package/build/Prompt/Snackbar/constants.mjs +11 -0
- package/build/Prompt/Snackbar/constants.mjs.map +1 -0
- package/build/Prompt/Snackbar/useSnackbar.js.map +1 -0
- package/build/Prompt/Snackbar/useSnackbar.mjs.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarAutoDismiss.js +66 -0
- package/build/Prompt/Snackbar/useSnackbarAutoDismiss.js.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarAutoDismiss.mjs +62 -0
- package/build/Prompt/Snackbar/useSnackbarAutoDismiss.mjs.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarManager.js +153 -0
- package/build/Prompt/Snackbar/useSnackbarManager.js.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarManager.mjs +149 -0
- package/build/Prompt/Snackbar/useSnackbarManager.mjs.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.js +135 -0
- package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.js.map +1 -0
- package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.mjs +131 -0
- package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.mjs.map +1 -0
- package/build/Section/Section.js.map +1 -1
- package/build/Section/Section.mjs.map +1 -1
- package/build/_deprecated/Select/Select.js +1 -1
- package/build/_deprecated/Select/Select.js.map +1 -1
- package/build/_deprecated/Select/Select.mjs +1 -1
- package/build/_deprecated/Select/Select.mjs.map +1 -1
- package/build/common/BottomSheet/BottomSheet.js +1 -3
- package/build/common/BottomSheet/BottomSheet.js.map +1 -1
- package/build/common/BottomSheet/BottomSheet.mjs +1 -3
- package/build/common/BottomSheet/BottomSheet.mjs.map +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +3 -3
- package/build/index.mjs +3 -3
- package/build/main.css +137 -75
- package/build/styles/IconButton/IconButton.css +3 -4
- package/build/styles/Prompt/Snackbar/Snackbar.css +134 -0
- package/build/styles/main.css +137 -75
- package/build/types/Link/Link.d.ts +1 -1
- package/build/types/Loader/Loader.d.ts +1 -1
- package/build/types/Prompt/PrimitivePrompt/PrimitivePrompt.d.ts +11 -0
- package/build/types/Prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/Prompt/Snackbar/Snackbar.d.ts +62 -0
- package/build/types/Prompt/Snackbar/Snackbar.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/Snackbar.messages.d.ts +9 -0
- package/build/types/Prompt/Snackbar/Snackbar.messages.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/Snackbar.types.d.ts +12 -0
- package/build/types/Prompt/Snackbar/Snackbar.types.d.ts.map +1 -0
- package/build/types/{Snackbar → Prompt/Snackbar}/SnackbarContext.d.ts +2 -2
- package/build/types/Prompt/Snackbar/SnackbarContext.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts +4 -0
- package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/SnackbarProvider.d.ts +13 -0
- package/build/types/Prompt/Snackbar/SnackbarProvider.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/constants.d.ts +9 -0
- package/build/types/Prompt/Snackbar/constants.d.ts.map +1 -0
- package/build/types/{Snackbar → Prompt/Snackbar}/index.d.ts +1 -1
- package/build/types/Prompt/Snackbar/index.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/useSnackbar.d.ts +3 -0
- package/build/types/Prompt/Snackbar/useSnackbar.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/useSnackbarAutoDismiss.d.ts +13 -0
- package/build/types/Prompt/Snackbar/useSnackbarAutoDismiss.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/useSnackbarManager.d.ts +20 -0
- package/build/types/Prompt/Snackbar/useSnackbarManager.d.ts.map +1 -0
- package/build/types/Prompt/Snackbar/useSnackbarSwipeDismiss.d.ts +22 -0
- package/build/types/Prompt/Snackbar/useSnackbarSwipeDismiss.d.ts.map +1 -0
- package/build/types/Section/Section.d.ts +1 -1
- package/build/types/_deprecated/Select/Select.d.ts +1 -1
- package/build/types/common/BottomSheet/BottomSheet.d.ts +1 -3
- package/build/types/common/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/index.d.ts +5 -5
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/IconButton/IconButton.css +3 -4
- package/src/IconButton/IconButton.less +14 -1
- package/src/Link/Link.tsx +1 -1
- package/src/ListItem/AdditionalInfo/_stories/ListItemAdditionalInfo.story.tsx +1 -1
- package/src/ListItem/AvatarView/_stories/ListItemAvatarView.story.tsx +3 -3
- package/src/ListItem/_stories/ListItem.disabled.story.tsx +1 -1
- package/src/ListItem/_stories/ListItem.scenarios.story.tsx +2 -2
- package/src/Loader/Loader.tsx +1 -1
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.test.tsx +24 -1
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.tsx +8 -2
- package/src/Prompt/Snackbar/Snackbar.css +134 -0
- package/src/Prompt/Snackbar/Snackbar.less +159 -0
- package/src/Prompt/Snackbar/Snackbar.messages.ts +9 -0
- package/src/Prompt/Snackbar/Snackbar.test.tsx +1079 -0
- package/src/Prompt/Snackbar/Snackbar.tsx +245 -0
- package/src/Prompt/Snackbar/Snackbar.types.ts +17 -0
- package/src/{Snackbar → Prompt/Snackbar}/SnackbarContext.ts +2 -2
- package/src/Prompt/Snackbar/SnackbarPortal.tsx +8 -0
- package/src/Prompt/Snackbar/SnackbarProvider.test.tsx +783 -0
- package/src/Prompt/Snackbar/SnackbarProvider.tsx +41 -0
- package/src/Prompt/Snackbar/_stories/Snackbar.accessibility.docs.mdx +58 -0
- package/src/{Snackbar → Prompt/Snackbar}/_stories/Snackbar.rtl.test.story.tsx +17 -9
- package/src/Prompt/Snackbar/_stories/Snackbar.story.tsx +416 -0
- package/src/Prompt/Snackbar/_stories/Snackbar.test.story.tsx +263 -0
- package/src/Prompt/Snackbar/constants.ts +10 -0
- package/src/{Snackbar → Prompt/Snackbar}/index.ts +1 -1
- package/src/Prompt/Snackbar/useSnackbarAutoDismiss.ts +74 -0
- package/src/Prompt/Snackbar/useSnackbarManager.ts +169 -0
- package/src/Prompt/Snackbar/useSnackbarSwipeDismiss.ts +169 -0
- package/src/Section/Section.tsx +1 -1
- package/src/_deprecated/Select/Select.tsx +1 -1
- package/src/_deprecated/Select/_stories/Select.story.tsx +1 -1
- package/src/common/BottomSheet/BottomSheet.tsx +1 -3
- package/src/i18n/en.json +1 -0
- package/src/index.ts +5 -5
- package/src/main.css +137 -75
- package/src/main.less +1 -1
- package/build/Snackbar/Snackbar.js +0 -128
- package/build/Snackbar/Snackbar.js.map +0 -1
- package/build/Snackbar/Snackbar.mjs +0 -123
- package/build/Snackbar/Snackbar.mjs.map +0 -1
- package/build/Snackbar/SnackbarContext.js.map +0 -1
- package/build/Snackbar/SnackbarContext.mjs.map +0 -1
- package/build/Snackbar/SnackbarProvider.js +0 -46
- package/build/Snackbar/SnackbarProvider.js.map +0 -1
- package/build/Snackbar/SnackbarProvider.mjs +0 -42
- package/build/Snackbar/SnackbarProvider.mjs.map +0 -1
- package/build/Snackbar/useSnackbar.js.map +0 -1
- package/build/Snackbar/useSnackbar.mjs.map +0 -1
- package/build/styles/Snackbar/Snackbar.css +0 -71
- package/build/types/Snackbar/Snackbar.d.ts +0 -16
- package/build/types/Snackbar/Snackbar.d.ts.map +0 -1
- package/build/types/Snackbar/SnackbarContext.d.ts.map +0 -1
- package/build/types/Snackbar/SnackbarProvider.d.ts +0 -6
- package/build/types/Snackbar/SnackbarProvider.d.ts.map +0 -1
- package/build/types/Snackbar/index.d.ts.map +0 -1
- package/build/types/Snackbar/useSnackbar.d.ts +0 -3
- package/build/types/Snackbar/useSnackbar.d.ts.map +0 -1
- package/src/Snackbar/Snackbar.css +0 -71
- package/src/Snackbar/Snackbar.less +0 -80
- package/src/Snackbar/Snackbar.test.tsx +0 -206
- package/src/Snackbar/Snackbar.tsx +0 -129
- package/src/Snackbar/SnackbarProvider.tsx +0 -33
- package/src/Snackbar/_stories/Snackbar.story.tsx +0 -89
- package/src/Snackbar/_stories/Snackbar.test.story.tsx +0 -139
- /package/build/{Snackbar → Prompt/Snackbar}/SnackbarContext.js +0 -0
- /package/build/{Snackbar → Prompt/Snackbar}/SnackbarContext.mjs +0 -0
- /package/build/{Snackbar → Prompt/Snackbar}/useSnackbar.js +0 -0
- /package/build/{Snackbar → Prompt/Snackbar}/useSnackbar.mjs +0 -0
- /package/src/{Snackbar → Prompt/Snackbar}/useSnackbar.ts +0 -0
|
@@ -141,7 +141,7 @@ export interface SelectProps {
|
|
|
141
141
|
const defaultClassNames = {};
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* @deprecated Use `SelectInput` instead (https://
|
|
144
|
+
* @deprecated Use `SelectInput` instead (https://storybook.wise.design/?path=/docs/forms-selectinput--docs)
|
|
145
145
|
*/
|
|
146
146
|
export default function Select({
|
|
147
147
|
placeholder,
|
|
@@ -4,7 +4,7 @@ import { useState } from 'react';
|
|
|
4
4
|
import Select, { SelectItem, SelectOptionItem } from '..';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @deprecated Use **`SelectInput`** instead <br/> [https://
|
|
7
|
+
* @deprecated Use **`SelectInput`** instead <br/> [https://storybook.wise.design/?path=/docs/forms-selectinput--docs](https://storybook.wise.design/?path=/docs/forms-selectinput--docs)
|
|
8
8
|
*/
|
|
9
9
|
const meta: Meta<typeof Select> = {
|
|
10
10
|
component: Select,
|
|
@@ -36,9 +36,7 @@ export type BottomSheetProps = PropsWithChildren<
|
|
|
36
36
|
>;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
|
|
39
|
+
* Design guidance: https://docs.wise.design/components/bottom-sheet/
|
|
42
40
|
*
|
|
43
41
|
*/
|
|
44
42
|
const BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {
|
package/src/i18n/en.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Search...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "No results found",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Press Escape to dismiss.",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "Error:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "Information:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "Pending:",
|
package/src/index.ts
CHANGED
|
@@ -146,8 +146,8 @@ export type {
|
|
|
146
146
|
SelectProps,
|
|
147
147
|
} from './_deprecated/Select';
|
|
148
148
|
export type { SlidingPanelProps } from './SlidingPanel';
|
|
149
|
-
export type {
|
|
150
|
-
export type { SnackbarContextType } from './Snackbar/SnackbarContext';
|
|
149
|
+
export type { SnackbarCreationProps, SnackbarProviderProps } from './Prompt/Snackbar';
|
|
150
|
+
export type { SnackbarContextType } from './Prompt/Snackbar/SnackbarContext';
|
|
151
151
|
export type { StatusIconProps, StatusIconSentiment } from './StatusIcon';
|
|
152
152
|
export type { StickyProps } from './Sticky';
|
|
153
153
|
export type { SummaryProps } from './_deprecated/Summary';
|
|
@@ -295,8 +295,8 @@ export { default as SegmentedControl } from './SegmentedControl';
|
|
|
295
295
|
export { default as Select } from './_deprecated/Select';
|
|
296
296
|
export { default as SentimentSurface } from './SentimentSurface';
|
|
297
297
|
export { default as SlidingPanel } from './SlidingPanel';
|
|
298
|
-
export { SnackbarConsumer, SnackbarContext } from './Snackbar/SnackbarContext';
|
|
299
|
-
export { default as SnackbarProvider } from './Snackbar/SnackbarProvider';
|
|
298
|
+
export { SnackbarConsumer, SnackbarContext } from './Prompt/Snackbar/SnackbarContext';
|
|
299
|
+
export { default as SnackbarProvider } from './Prompt/Snackbar/SnackbarProvider';
|
|
300
300
|
export { default as StatusIcon } from './StatusIcon/StatusIcon';
|
|
301
301
|
export { default as Stepper } from './Stepper/Stepper';
|
|
302
302
|
export { default as Sticky } from './Sticky';
|
|
@@ -321,7 +321,7 @@ export { default as List } from './List';
|
|
|
321
321
|
*/
|
|
322
322
|
export { useDirection, useLayout } from './common/hooks';
|
|
323
323
|
export { useScreenSize } from './common/hooks/useScreenSize';
|
|
324
|
-
export { default as useSnackbar } from './Snackbar/useSnackbar';
|
|
324
|
+
export { default as useSnackbar } from './Prompt/Snackbar/useSnackbar';
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
327
|
* Enums
|
package/src/main.css
CHANGED
|
@@ -26948,15 +26948,14 @@ a[data-toggle="tooltip"] {
|
|
|
26948
26948
|
color: var(--color-white);
|
|
26949
26949
|
}
|
|
26950
26950
|
.np-icon-button-minimal-default {
|
|
26951
|
-
color: var(--color-interactive-primary);
|
|
26952
|
-
background-color: var(--color-background-screen);
|
|
26951
|
+
color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
26953
26952
|
background-color: transparent;
|
|
26954
26953
|
}
|
|
26955
26954
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
|
|
26956
|
-
background-color: var(--color-background-screen-hover);
|
|
26955
|
+
background-color: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-screen-hover));
|
|
26957
26956
|
}
|
|
26958
26957
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
|
|
26959
|
-
background-color: var(--color-background-screen-active);
|
|
26958
|
+
background-color: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-screen-active));
|
|
26960
26959
|
}
|
|
26961
26960
|
.np-icon-button-secondary-default {
|
|
26962
26961
|
color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
@@ -31414,6 +31413,140 @@ button.np-link {
|
|
|
31414
31413
|
overflow: visible;
|
|
31415
31414
|
}
|
|
31416
31415
|
}
|
|
31416
|
+
.wds-Snackbar {
|
|
31417
|
+
display: flex;
|
|
31418
|
+
justify-content: center;
|
|
31419
|
+
box-sizing: border-box;
|
|
31420
|
+
padding-inline: var(--size-16);
|
|
31421
|
+
padding-block-end: calc(var(--size-16) + env(safe-area-inset-bottom));
|
|
31422
|
+
position: fixed;
|
|
31423
|
+
inset-block-end: 0;
|
|
31424
|
+
inset-inline: 0;
|
|
31425
|
+
z-index: 1060;
|
|
31426
|
+
}
|
|
31427
|
+
@media (min-width: 600px) {
|
|
31428
|
+
.wds-Snackbar {
|
|
31429
|
+
padding-block-end: var(--size-24);
|
|
31430
|
+
}
|
|
31431
|
+
}
|
|
31432
|
+
.wds-Snackbar--swipe-dismiss {
|
|
31433
|
+
transition: transform var(--Snackbar-exit-duration) cubic-bezier(1, 0, 1, 1);
|
|
31434
|
+
}
|
|
31435
|
+
.wds-Snackbar--swipe-settle {
|
|
31436
|
+
transition: transform var(--Snackbar-exit-duration) cubic-bezier(0, 0, 0, 1);
|
|
31437
|
+
}
|
|
31438
|
+
.wds-Snackbar-container {
|
|
31439
|
+
--Prompt-border-radius: var(--radius-medium);
|
|
31440
|
+
--Prompt-gap: var(--size-8);
|
|
31441
|
+
--Prompt-padding-x: var(--size-12);
|
|
31442
|
+
--Prompt-padding-y: var(--size-12);
|
|
31443
|
+
box-sizing: border-box;
|
|
31444
|
+
max-inline-size: 480px;
|
|
31445
|
+
text-align: start;
|
|
31446
|
+
cursor: grab;
|
|
31447
|
+
touch-action: pan-x pinch-zoom;
|
|
31448
|
+
}
|
|
31449
|
+
.wds-Snackbar-container .wds-prompt__content-wrapper--with-dismiss {
|
|
31450
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
31451
|
+
}
|
|
31452
|
+
@media (min-width: 600px) {
|
|
31453
|
+
.wds-Snackbar-container .wds-prompt__content-wrapper--with-dismiss {
|
|
31454
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
31455
|
+
}
|
|
31456
|
+
}
|
|
31457
|
+
.wds-Snackbar-container .wds-prompt__media-wrapper {
|
|
31458
|
+
display: flex;
|
|
31459
|
+
align-items: center;
|
|
31460
|
+
min-block-size: max(var(--size-32), 1lh);
|
|
31461
|
+
padding-block-start: 0;
|
|
31462
|
+
color: var(--color-sentiment-content-primary);
|
|
31463
|
+
}
|
|
31464
|
+
.wds-Snackbar-container .wds-prompt__media-wrapper:has(+ .wds-Snackbar__content .wds-Snackbar__action) {
|
|
31465
|
+
min-block-size: max(var(--size-32), calc(1lh + var(--size-5) * 2));
|
|
31466
|
+
}
|
|
31467
|
+
.wds-Snackbar__media-asset {
|
|
31468
|
+
display: flex;
|
|
31469
|
+
}
|
|
31470
|
+
.wds-Snackbar__media-asset svg {
|
|
31471
|
+
inline-size: var(--size-24);
|
|
31472
|
+
block-size: var(--size-24);
|
|
31473
|
+
}
|
|
31474
|
+
.wds-Snackbar__process-indicator .process-circle {
|
|
31475
|
+
stroke: currentColor;
|
|
31476
|
+
}
|
|
31477
|
+
.wds-Snackbar-container .wds-prompt__dismiss {
|
|
31478
|
+
display: none;
|
|
31479
|
+
align-self: flex-start;
|
|
31480
|
+
margin-block-start: calc(var(--size-4) - 1px);
|
|
31481
|
+
}
|
|
31482
|
+
@media (min-width: 600px) {
|
|
31483
|
+
.wds-Snackbar-container .wds-prompt__dismiss {
|
|
31484
|
+
display: flex;
|
|
31485
|
+
}
|
|
31486
|
+
}
|
|
31487
|
+
.wds-Snackbar__action {
|
|
31488
|
+
flex-shrink: 0;
|
|
31489
|
+
}
|
|
31490
|
+
.wds-Snackbar__content {
|
|
31491
|
+
display: flex;
|
|
31492
|
+
align-items: flex-start;
|
|
31493
|
+
gap: var(--size-8);
|
|
31494
|
+
flex: 1 0 0;
|
|
31495
|
+
min-block-size: var(--size-32);
|
|
31496
|
+
min-inline-size: 0;
|
|
31497
|
+
}
|
|
31498
|
+
.wds-Snackbar__message {
|
|
31499
|
+
display: flex;
|
|
31500
|
+
flex-direction: column;
|
|
31501
|
+
justify-content: center;
|
|
31502
|
+
inline-size: auto;
|
|
31503
|
+
flex: 1 0 0;
|
|
31504
|
+
min-inline-size: 0;
|
|
31505
|
+
align-self: stretch;
|
|
31506
|
+
}
|
|
31507
|
+
.wds-Snackbar__body {
|
|
31508
|
+
display: block;
|
|
31509
|
+
}
|
|
31510
|
+
.wds-Snackbar-container-appear,
|
|
31511
|
+
.wds-Snackbar-container-enter {
|
|
31512
|
+
opacity: 0;
|
|
31513
|
+
transform: translateY(80px) scale(0.5);
|
|
31514
|
+
}
|
|
31515
|
+
.wds-Snackbar-container-appear-active,
|
|
31516
|
+
.wds-Snackbar-container-enter-active {
|
|
31517
|
+
opacity: 1;
|
|
31518
|
+
transform: translateY(0) scale(1);
|
|
31519
|
+
transition: opacity 150ms linear, transform var(--Snackbar-enter-duration) cubic-bezier(0, 0, 0, 1);
|
|
31520
|
+
}
|
|
31521
|
+
.wds-Snackbar-container-exit {
|
|
31522
|
+
opacity: 1;
|
|
31523
|
+
transform: translateY(0) scale(1);
|
|
31524
|
+
}
|
|
31525
|
+
.wds-Snackbar-container-exit-active {
|
|
31526
|
+
opacity: 0;
|
|
31527
|
+
transform: translateY(80px) scale(0.5);
|
|
31528
|
+
transition: opacity 50ms linear 50ms, transform var(--Snackbar-exit-duration) cubic-bezier(1, 0, 1, 1);
|
|
31529
|
+
}
|
|
31530
|
+
@media (prefers-reduced-motion: reduce) {
|
|
31531
|
+
.wds-Snackbar--swipe-dismiss,
|
|
31532
|
+
.wds-Snackbar--swipe-settle {
|
|
31533
|
+
transition: none;
|
|
31534
|
+
}
|
|
31535
|
+
.wds-Snackbar-container-appear,
|
|
31536
|
+
.wds-Snackbar-container-appear-active,
|
|
31537
|
+
.wds-Snackbar-container-enter,
|
|
31538
|
+
.wds-Snackbar-container-enter-active,
|
|
31539
|
+
.wds-Snackbar-container-exit {
|
|
31540
|
+
opacity: 1;
|
|
31541
|
+
transform: none;
|
|
31542
|
+
transition: none;
|
|
31543
|
+
}
|
|
31544
|
+
.wds-Snackbar-container-exit-active {
|
|
31545
|
+
opacity: 0;
|
|
31546
|
+
transform: none;
|
|
31547
|
+
transition: none;
|
|
31548
|
+
}
|
|
31549
|
+
}
|
|
31417
31550
|
.wds-expander-toggle {
|
|
31418
31551
|
align-self: flex-start;
|
|
31419
31552
|
flex-shrink: 0;
|
|
@@ -31516,77 +31649,6 @@ button.np-link {
|
|
|
31516
31649
|
[dir="rtl"] .np-theme-personal .sliding-panel.sliding-panel--border-left {
|
|
31517
31650
|
box-shadow: inset 1px 0 0 0 var(--color-border-neutral);
|
|
31518
31651
|
}
|
|
31519
|
-
.snackbar {
|
|
31520
|
-
text-align: center;
|
|
31521
|
-
position: fixed;
|
|
31522
|
-
inset-block-end: 0;
|
|
31523
|
-
inset-inline-start: 0;
|
|
31524
|
-
inset-inline-end: 0;
|
|
31525
|
-
z-index: 1060;
|
|
31526
|
-
}
|
|
31527
|
-
.snackbar__text {
|
|
31528
|
-
background: #37517e;
|
|
31529
|
-
color: #ffffff;
|
|
31530
|
-
display: inline-flex;
|
|
31531
|
-
border-radius: 2px;
|
|
31532
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
|
|
31533
|
-
align-items: center;
|
|
31534
|
-
justify-content: space-between;
|
|
31535
|
-
text-align: start;
|
|
31536
|
-
font-size: var(--wds-font-size-body);
|
|
31537
|
-
margin-block: 0;
|
|
31538
|
-
margin-inline: var(--size-16);
|
|
31539
|
-
padding-block: var(--size-8);
|
|
31540
|
-
padding-inline: var(--size-16);
|
|
31541
|
-
inline-size: calc(100% - var(--size-32));
|
|
31542
|
-
transition: 400ms cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
31543
|
-
}
|
|
31544
|
-
.np-theme-personal .snackbar__text {
|
|
31545
|
-
box-shadow: 0 2px 4px 0 rgba(69, 71, 69, 0.35);
|
|
31546
|
-
position: relative;
|
|
31547
|
-
background: var(--color-contrast-theme);
|
|
31548
|
-
border-radius: var(--radius-small);
|
|
31549
|
-
color: var(--color-contrast-overlay);
|
|
31550
|
-
}
|
|
31551
|
-
.np-theme-personal .snackbar__text::after {
|
|
31552
|
-
display: block;
|
|
31553
|
-
border-radius: inherit;
|
|
31554
|
-
block-size: 100%;
|
|
31555
|
-
inline-size: 100%;
|
|
31556
|
-
content: "";
|
|
31557
|
-
position: absolute;
|
|
31558
|
-
inset-inline-start: 0;
|
|
31559
|
-
inset-block-start: 0;
|
|
31560
|
-
z-index: -1;
|
|
31561
|
-
background-color: var(--color-background-neutral);
|
|
31562
|
-
}
|
|
31563
|
-
.np-theme-personal--dark .snackbar__text,
|
|
31564
|
-
.np-theme-personal--forest-green .snackbar__text {
|
|
31565
|
-
box-shadow: none;
|
|
31566
|
-
}
|
|
31567
|
-
@media (min-width: 600px) {
|
|
31568
|
-
.snackbar__text {
|
|
31569
|
-
inline-size: auto;
|
|
31570
|
-
max-inline-size: 600px;
|
|
31571
|
-
}
|
|
31572
|
-
}
|
|
31573
|
-
.snackbar__text__action {
|
|
31574
|
-
flex-shrink: 0;
|
|
31575
|
-
margin-inline-start: var(--size-16);
|
|
31576
|
-
}
|
|
31577
|
-
.snackbar__text-container-enter,
|
|
31578
|
-
.snackbar__text-container-exit {
|
|
31579
|
-
transform: translateY(calc(100% + 10px));
|
|
31580
|
-
}
|
|
31581
|
-
.snackbar__text-container-enter-active {
|
|
31582
|
-
transform: translateY(-16px);
|
|
31583
|
-
transform: translateY(calc(-16px - env(safe-area-inset-bottom)));
|
|
31584
|
-
}
|
|
31585
|
-
@media (min-width: 600px) {
|
|
31586
|
-
.snackbar__text-container-enter-active {
|
|
31587
|
-
transform: translateY(-24px);
|
|
31588
|
-
}
|
|
31589
|
-
}
|
|
31590
31652
|
.status-circle.negative,
|
|
31591
31653
|
.status-circle.error {
|
|
31592
31654
|
background-color: var(--color-sentiment-interactive-primary, var(--color-sentiment-negative));
|
package/src/main.less
CHANGED
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
@import "./Prompt/InfoPrompt/InfoPrompt.less";
|
|
75
75
|
@import "./Prompt/ActionPrompt/ActionPrompt.less";
|
|
76
76
|
@import "./Prompt/CriticalBanner/CriticalBanner.less";
|
|
77
|
+
@import "./Prompt/Snackbar/Snackbar.less";
|
|
77
78
|
@import "./Prompt/common/Expander/Expander.less";
|
|
78
79
|
@import "./RadioGroup/RadioGroup.less";
|
|
79
80
|
@import "./Section/Section.less";
|
|
80
81
|
@import "./SlidingPanel/SlidingPanel.less";
|
|
81
|
-
@import "./Snackbar/Snackbar.less";
|
|
82
82
|
@import "./StatusIcon/StatusIcon.less";
|
|
83
83
|
@import "./Stepper/Stepper.less";
|
|
84
84
|
@import "./Sticky/Sticky.less";
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var reactTransitionGroup = require('react-transition-group');
|
|
7
|
-
var Button_resolver = require('../Button/Button.resolver.js');
|
|
8
|
-
var Body = require('../Body/Body.js');
|
|
9
|
-
var WithNextPortal = require('../WithNextPortal/WithNextPortal.js');
|
|
10
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
-
|
|
12
|
-
const CSS_TRANSITION_DURATION = 400;
|
|
13
|
-
const Snackbar = props => {
|
|
14
|
-
const bodyRef = React.useRef(null);
|
|
15
|
-
const leaveTimeout = React.useRef(0);
|
|
16
|
-
const transitionTimeout = React.useRef(0);
|
|
17
|
-
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
18
|
-
const committedProps = React.useRef(props);
|
|
19
|
-
const [state, setState] = React.useState({
|
|
20
|
-
visible: false,
|
|
21
|
-
text: ''
|
|
22
|
-
});
|
|
23
|
-
React.useEffect(() => () => {
|
|
24
|
-
window.clearTimeout(leaveTimeout.current);
|
|
25
|
-
window.clearTimeout(transitionTimeout.current);
|
|
26
|
-
}, []);
|
|
27
|
-
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
28
|
-
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
29
|
-
// Layout, not passive, so a notification is shown or replaced before the browser paints, as
|
|
30
|
-
// componentDidUpdate did. Both rules below are disabled on purpose: the dependency-less effect
|
|
31
|
-
// and its synchronous state updates are what keep this conversion behaviour-identical.
|
|
32
|
-
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
33
|
-
React.useLayoutEffect(() => {
|
|
34
|
-
const previousProps = committedProps.current;
|
|
35
|
-
committedProps.current = props;
|
|
36
|
-
const {
|
|
37
|
-
action,
|
|
38
|
-
text,
|
|
39
|
-
timestamp
|
|
40
|
-
} = props;
|
|
41
|
-
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
42
|
-
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
43
|
-
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
44
|
-
const updateWhileTextIsPresent = update => {
|
|
45
|
-
if (committedProps.current.text) {
|
|
46
|
-
update();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const setLeaveTimeout = () => {
|
|
50
|
-
leaveTimeout.current = window.setTimeout(() => {
|
|
51
|
-
updateWhileTextIsPresent(() => setState(current => ({
|
|
52
|
-
...current,
|
|
53
|
-
visible: false
|
|
54
|
-
})));
|
|
55
|
-
}, committedProps.current.timeout);
|
|
56
|
-
};
|
|
57
|
-
const show = () => {
|
|
58
|
-
setState(current => ({
|
|
59
|
-
...current,
|
|
60
|
-
visible: true,
|
|
61
|
-
action,
|
|
62
|
-
text
|
|
63
|
-
}));
|
|
64
|
-
setLeaveTimeout();
|
|
65
|
-
};
|
|
66
|
-
if (!text) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (!previousProps.text) {
|
|
70
|
-
show();
|
|
71
|
-
} else if (previousProps.timestamp !== timestamp) {
|
|
72
|
-
window.clearTimeout(leaveTimeout.current);
|
|
73
|
-
if (state.visible) {
|
|
74
|
-
setState(current => ({
|
|
75
|
-
...current,
|
|
76
|
-
visible: false
|
|
77
|
-
}));
|
|
78
|
-
transitionTimeout.current = window.setTimeout(() => {
|
|
79
|
-
updateWhileTextIsPresent(show);
|
|
80
|
-
}, CSS_TRANSITION_DURATION);
|
|
81
|
-
} else {
|
|
82
|
-
show();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
/* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
87
|
-
const {
|
|
88
|
-
action,
|
|
89
|
-
text,
|
|
90
|
-
visible
|
|
91
|
-
} = state;
|
|
92
|
-
const {
|
|
93
|
-
timeout
|
|
94
|
-
} = props;
|
|
95
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
96
|
-
className: "snackbar",
|
|
97
|
-
"aria-live": "assertive",
|
|
98
|
-
role: "alert",
|
|
99
|
-
children: /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
|
|
100
|
-
nodeRef: bodyRef,
|
|
101
|
-
in: visible,
|
|
102
|
-
classNames: "snackbar__text-container",
|
|
103
|
-
timeout: {
|
|
104
|
-
appear: 0,
|
|
105
|
-
enter: timeout,
|
|
106
|
-
exit: CSS_TRANSITION_DURATION
|
|
107
|
-
},
|
|
108
|
-
unmountOnExit: true,
|
|
109
|
-
children: /*#__PURE__*/jsxRuntime.jsxs(Body.default, {
|
|
110
|
-
ref: bodyRef,
|
|
111
|
-
as: "span",
|
|
112
|
-
className: "snackbar__text",
|
|
113
|
-
children: [text, action ? /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
|
|
114
|
-
className: "snackbar__text__action",
|
|
115
|
-
v2: true,
|
|
116
|
-
size: "sm",
|
|
117
|
-
onClick: action.onClick,
|
|
118
|
-
children: action.label
|
|
119
|
-
}) : null]
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
var SnackbarPortal = WithNextPortal.default(Snackbar);
|
|
125
|
-
|
|
126
|
-
exports.Snackbar = Snackbar;
|
|
127
|
-
exports.default = SnackbarPortal;
|
|
128
|
-
//# sourceMappingURL=Snackbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.js","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport Button from '../Button';\nimport Body from '../Body';\nimport type { ThemeDark, ThemeLight } from '../common';\nimport withNextPortal from '../WithNextPortal/WithNextPortal';\n\nconst CSS_TRANSITION_DURATION = 400;\n\nexport interface SnackbarProps {\n action?: {\n label: string;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n };\n text: React.ReactNode;\n /** @deprecated Has no effect. Snackbar theming is based on ThemeProvider. */\n theme?: ThemeLight | ThemeDark;\n timeout: number;\n timestamp: number;\n}\n\ninterface SnackbarState extends Pick<SnackbarProps, 'action' | 'text'> {\n visible: boolean;\n}\n\nexport const Snackbar = (props: SnackbarProps) => {\n const bodyRef = useRef<HTMLSpanElement>(null);\n const leaveTimeout = useRef(0);\n const transitionTimeout = useRef(0);\n /** The props of the last committed render, as `this.props` was in the class component. */\n const committedProps = useRef(props);\n\n const [state, setState] = useState<SnackbarState>({\n visible: false,\n text: '',\n });\n\n useEffect(\n () => () => {\n window.clearTimeout(leaveTimeout.current);\n window.clearTimeout(transitionTimeout.current);\n },\n [],\n );\n\n // Runs after every render to mirror the componentDidUpdate lifecycle this component previously\n // relied on, including the shouldComponentUpdate guard that ignored every update without text.\n // Layout, not passive, so a notification is shown or replaced before the browser paints, as\n // componentDidUpdate did. Both rules below are disabled on purpose: the dependency-less effect\n // and its synchronous state updates are what keep this conversion behaviour-identical.\n /* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n useLayoutEffect(() => {\n const previousProps = committedProps.current;\n committedProps.current = props;\n\n const { action, text, timestamp } = props;\n\n // shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the\n // updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is\n // given text again. Preserved here deliberately to keep this refactor behaviour-identical.\n const updateWhileTextIsPresent = (update: () => void) => {\n if (committedProps.current.text) {\n update();\n }\n };\n\n const setLeaveTimeout = () => {\n leaveTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(() => setState((current) => ({ ...current, visible: false })));\n }, committedProps.current.timeout);\n };\n\n const show = () => {\n setState((current) => ({ ...current, visible: true, action, text }));\n setLeaveTimeout();\n };\n\n if (!text) {\n return;\n }\n\n if (!previousProps.text) {\n show();\n } else if (previousProps.timestamp !== timestamp) {\n window.clearTimeout(leaveTimeout.current);\n\n if (state.visible) {\n setState((current) => ({ ...current, visible: false }));\n transitionTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(show);\n }, CSS_TRANSITION_DURATION);\n } else {\n show();\n }\n }\n });\n /* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n\n const { action, text, visible } = state;\n const { timeout } = props;\n\n return (\n <div className=\"snackbar\" aria-live=\"assertive\" role=\"alert\">\n <CSSTransition\n nodeRef={bodyRef}\n in={visible}\n classNames=\"snackbar__text-container\"\n timeout={{\n appear: 0,\n enter: timeout,\n exit: CSS_TRANSITION_DURATION,\n }}\n unmountOnExit\n >\n <Body ref={bodyRef} as=\"span\" className=\"snackbar__text\">\n {text}\n {action ? (\n <Button className=\"snackbar__text__action\" v2 size=\"sm\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : null}\n </Body>\n </CSSTransition>\n </div>\n );\n};\n\nexport default withNextPortal(Snackbar);\n"],"names":["CSS_TRANSITION_DURATION","Snackbar","props","bodyRef","useRef","leaveTimeout","transitionTimeout","committedProps","state","setState","useState","visible","text","useEffect","window","clearTimeout","current","useLayoutEffect","previousProps","action","timestamp","updateWhileTextIsPresent","update","setLeaveTimeout","setTimeout","timeout","show","_jsx","className","role","children","CSSTransition","nodeRef","in","classNames","appear","enter","exit","unmountOnExit","_jsxs","Body","ref","as","Button","v2","size","onClick","label","withNextPortal"],"mappings":";;;;;;;;;;;AAQA,MAAMA,uBAAuB,GAAG,GAAG;AAkB5B,MAAMC,QAAQ,GAAIC,KAAoB,IAAI;AAC/C,EAAA,MAAMC,OAAO,GAAGC,YAAM,CAAkB,IAAI,CAAC;AAC7C,EAAA,MAAMC,YAAY,GAAGD,YAAM,CAAC,CAAC,CAAC;AAC9B,EAAA,MAAME,iBAAiB,GAAGF,YAAM,CAAC,CAAC,CAAC;AACnC;AACA,EAAA,MAAMG,cAAc,GAAGH,YAAM,CAACF,KAAK,CAAC;AAEpC,EAAA,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAQ,CAAgB;AAChDC,IAAAA,OAAO,EAAE,KAAK;AACdC,IAAAA,IAAI,EAAE;AACP,GAAA,CAAC;EAEFC,eAAS,CACP,MAAM,MAAK;AACTC,IAAAA,MAAM,CAACC,YAAY,CAACV,YAAY,CAACW,OAAO,CAAC;AACzCF,IAAAA,MAAM,CAACC,YAAY,CAACT,iBAAiB,CAACU,OAAO,CAAC;EAChD,CAAC,EACD,EAAE,CACH;AAED;AACA;AACA;AACA;AACA;AACA;AACAC,EAAAA,qBAAe,CAAC,MAAK;AACnB,IAAA,MAAMC,aAAa,GAAGX,cAAc,CAACS,OAAO;IAC5CT,cAAc,CAACS,OAAO,GAAGd,KAAK;IAE9B,MAAM;MAAEiB,MAAM;MAAEP,IAAI;AAAEQ,MAAAA;AAAS,KAAE,GAAGlB,KAAK;AAEzC;AACA;AACA;IACA,MAAMmB,wBAAwB,GAAIC,MAAkB,IAAI;AACtD,MAAA,IAAIf,cAAc,CAACS,OAAO,CAACJ,IAAI,EAAE;AAC/BU,QAAAA,MAAM,EAAE;AACV,MAAA;IACF,CAAC;IAED,MAAMC,eAAe,GAAGA,MAA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,MAAM;AAAEiB,IAAAA;AAAO,GAAE,GAAGvB,KAAK;AAEzB,EAAA,oBACEyB,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,UAAU;AAAC,IAAA,WAAA,EAAU,WAAW;AAACC,IAAAA,IAAI,EAAC,OAAO;IAAAC,QAAA,eAC1DH,cAAA,CAACI,kCAAa,EAAA;AACZC,MAAAA,OAAO,EAAE7B,OAAQ;AACjB8B,MAAAA,EAAE,EAAEtB,OAAQ;AACZuB,MAAAA,UAAU,EAAC,0BAA0B;AACrCT,MAAAA,OAAO,EAAE;AACPU,QAAAA,MAAM,EAAE,CAAC;AACTC,QAAAA,KAAK,EAAEX,OAAO;AACdY,QAAAA,IAAI,EAAErC;OACN;MACFsC,aAAa,EAAA,IAAA;MAAAR,QAAA,eAEbS,eAAA,CAACC,YAAI,EAAA;AAACC,QAAAA,GAAG,EAAEtC,OAAQ;AAACuC,QAAAA,EAAE,EAAC,MAAM;AAACd,QAAAA,SAAS,EAAC,gBAAgB;AAAAE,QAAAA,QAAA,GACrDlB,IAAI,EACJO,MAAM,gBACLQ,cAAA,CAACgB,uBAAM,EAAA;AAACf,UAAAA,SAAS,EAAC,wBAAwB;UAACgB,EAAE,EAAA,IAAA;AAACC,UAAAA,IAAI,EAAC,IAAI;UAACC,OAAO,EAAE3B,MAAM,CAAC2B,OAAQ;UAAAhB,QAAA,EAC7EX,MAAM,CAAC4B;SACF,CAAC,GACP,IAAI;OACJ;KACO;AACjB,GAAK,CAAC;AAEV;AAEA,qBAAeC,sBAAc,CAAC/C,QAAQ,CAAC;;;"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { useRef, useState, useEffect, useLayoutEffect } from 'react';
|
|
2
|
-
import { CSSTransition } from 'react-transition-group';
|
|
3
|
-
import Button from '../Button/Button.resolver.mjs';
|
|
4
|
-
import Body from '../Body/Body.mjs';
|
|
5
|
-
import withNextPortalWrapper from '../WithNextPortal/WithNextPortal.mjs';
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
const CSS_TRANSITION_DURATION = 400;
|
|
9
|
-
const Snackbar = props => {
|
|
10
|
-
const bodyRef = useRef(null);
|
|
11
|
-
const leaveTimeout = useRef(0);
|
|
12
|
-
const transitionTimeout = useRef(0);
|
|
13
|
-
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
14
|
-
const committedProps = useRef(props);
|
|
15
|
-
const [state, setState] = useState({
|
|
16
|
-
visible: false,
|
|
17
|
-
text: ''
|
|
18
|
-
});
|
|
19
|
-
useEffect(() => () => {
|
|
20
|
-
window.clearTimeout(leaveTimeout.current);
|
|
21
|
-
window.clearTimeout(transitionTimeout.current);
|
|
22
|
-
}, []);
|
|
23
|
-
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
24
|
-
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
25
|
-
// Layout, not passive, so a notification is shown or replaced before the browser paints, as
|
|
26
|
-
// componentDidUpdate did. Both rules below are disabled on purpose: the dependency-less effect
|
|
27
|
-
// and its synchronous state updates are what keep this conversion behaviour-identical.
|
|
28
|
-
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
29
|
-
useLayoutEffect(() => {
|
|
30
|
-
const previousProps = committedProps.current;
|
|
31
|
-
committedProps.current = props;
|
|
32
|
-
const {
|
|
33
|
-
action,
|
|
34
|
-
text,
|
|
35
|
-
timestamp
|
|
36
|
-
} = props;
|
|
37
|
-
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
38
|
-
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
39
|
-
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
40
|
-
const updateWhileTextIsPresent = update => {
|
|
41
|
-
if (committedProps.current.text) {
|
|
42
|
-
update();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const setLeaveTimeout = () => {
|
|
46
|
-
leaveTimeout.current = window.setTimeout(() => {
|
|
47
|
-
updateWhileTextIsPresent(() => setState(current => ({
|
|
48
|
-
...current,
|
|
49
|
-
visible: false
|
|
50
|
-
})));
|
|
51
|
-
}, committedProps.current.timeout);
|
|
52
|
-
};
|
|
53
|
-
const show = () => {
|
|
54
|
-
setState(current => ({
|
|
55
|
-
...current,
|
|
56
|
-
visible: true,
|
|
57
|
-
action,
|
|
58
|
-
text
|
|
59
|
-
}));
|
|
60
|
-
setLeaveTimeout();
|
|
61
|
-
};
|
|
62
|
-
if (!text) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (!previousProps.text) {
|
|
66
|
-
show();
|
|
67
|
-
} else if (previousProps.timestamp !== timestamp) {
|
|
68
|
-
window.clearTimeout(leaveTimeout.current);
|
|
69
|
-
if (state.visible) {
|
|
70
|
-
setState(current => ({
|
|
71
|
-
...current,
|
|
72
|
-
visible: false
|
|
73
|
-
}));
|
|
74
|
-
transitionTimeout.current = window.setTimeout(() => {
|
|
75
|
-
updateWhileTextIsPresent(show);
|
|
76
|
-
}, CSS_TRANSITION_DURATION);
|
|
77
|
-
} else {
|
|
78
|
-
show();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
/* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
83
|
-
const {
|
|
84
|
-
action,
|
|
85
|
-
text,
|
|
86
|
-
visible
|
|
87
|
-
} = state;
|
|
88
|
-
const {
|
|
89
|
-
timeout
|
|
90
|
-
} = props;
|
|
91
|
-
return /*#__PURE__*/jsx("div", {
|
|
92
|
-
className: "snackbar",
|
|
93
|
-
"aria-live": "assertive",
|
|
94
|
-
role: "alert",
|
|
95
|
-
children: /*#__PURE__*/jsx(CSSTransition, {
|
|
96
|
-
nodeRef: bodyRef,
|
|
97
|
-
in: visible,
|
|
98
|
-
classNames: "snackbar__text-container",
|
|
99
|
-
timeout: {
|
|
100
|
-
appear: 0,
|
|
101
|
-
enter: timeout,
|
|
102
|
-
exit: CSS_TRANSITION_DURATION
|
|
103
|
-
},
|
|
104
|
-
unmountOnExit: true,
|
|
105
|
-
children: /*#__PURE__*/jsxs(Body, {
|
|
106
|
-
ref: bodyRef,
|
|
107
|
-
as: "span",
|
|
108
|
-
className: "snackbar__text",
|
|
109
|
-
children: [text, action ? /*#__PURE__*/jsx(Button, {
|
|
110
|
-
className: "snackbar__text__action",
|
|
111
|
-
v2: true,
|
|
112
|
-
size: "sm",
|
|
113
|
-
onClick: action.onClick,
|
|
114
|
-
children: action.label
|
|
115
|
-
}) : null]
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
var SnackbarPortal = withNextPortalWrapper(Snackbar);
|
|
121
|
-
|
|
122
|
-
export { Snackbar, SnackbarPortal as default };
|
|
123
|
-
//# sourceMappingURL=Snackbar.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.mjs","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport Button from '../Button';\nimport Body from '../Body';\nimport type { ThemeDark, ThemeLight } from '../common';\nimport withNextPortal from '../WithNextPortal/WithNextPortal';\n\nconst CSS_TRANSITION_DURATION = 400;\n\nexport interface SnackbarProps {\n action?: {\n label: string;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n };\n text: React.ReactNode;\n /** @deprecated Has no effect. Snackbar theming is based on ThemeProvider. */\n theme?: ThemeLight | ThemeDark;\n timeout: number;\n timestamp: number;\n}\n\ninterface SnackbarState extends Pick<SnackbarProps, 'action' | 'text'> {\n visible: boolean;\n}\n\nexport const Snackbar = (props: SnackbarProps) => {\n const bodyRef = useRef<HTMLSpanElement>(null);\n const leaveTimeout = useRef(0);\n const transitionTimeout = useRef(0);\n /** The props of the last committed render, as `this.props` was in the class component. */\n const committedProps = useRef(props);\n\n const [state, setState] = useState<SnackbarState>({\n visible: false,\n text: '',\n });\n\n useEffect(\n () => () => {\n window.clearTimeout(leaveTimeout.current);\n window.clearTimeout(transitionTimeout.current);\n },\n [],\n );\n\n // Runs after every render to mirror the componentDidUpdate lifecycle this component previously\n // relied on, including the shouldComponentUpdate guard that ignored every update without text.\n // Layout, not passive, so a notification is shown or replaced before the browser paints, as\n // componentDidUpdate did. Both rules below are disabled on purpose: the dependency-less effect\n // and its synchronous state updates are what keep this conversion behaviour-identical.\n /* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n useLayoutEffect(() => {\n const previousProps = committedProps.current;\n committedProps.current = props;\n\n const { action, text, timestamp } = props;\n\n // shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the\n // updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is\n // given text again. Preserved here deliberately to keep this refactor behaviour-identical.\n const updateWhileTextIsPresent = (update: () => void) => {\n if (committedProps.current.text) {\n update();\n }\n };\n\n const setLeaveTimeout = () => {\n leaveTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(() => setState((current) => ({ ...current, visible: false })));\n }, committedProps.current.timeout);\n };\n\n const show = () => {\n setState((current) => ({ ...current, visible: true, action, text }));\n setLeaveTimeout();\n };\n\n if (!text) {\n return;\n }\n\n if (!previousProps.text) {\n show();\n } else if (previousProps.timestamp !== timestamp) {\n window.clearTimeout(leaveTimeout.current);\n\n if (state.visible) {\n setState((current) => ({ ...current, visible: false }));\n transitionTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(show);\n }, CSS_TRANSITION_DURATION);\n } else {\n show();\n }\n }\n });\n /* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n\n const { action, text, visible } = state;\n const { timeout } = props;\n\n return (\n <div className=\"snackbar\" aria-live=\"assertive\" role=\"alert\">\n <CSSTransition\n nodeRef={bodyRef}\n in={visible}\n classNames=\"snackbar__text-container\"\n timeout={{\n appear: 0,\n enter: timeout,\n exit: CSS_TRANSITION_DURATION,\n }}\n unmountOnExit\n >\n <Body ref={bodyRef} as=\"span\" className=\"snackbar__text\">\n {text}\n {action ? (\n <Button className=\"snackbar__text__action\" v2 size=\"sm\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : null}\n </Body>\n </CSSTransition>\n </div>\n );\n};\n\nexport default withNextPortal(Snackbar);\n"],"names":["CSS_TRANSITION_DURATION","Snackbar","props","bodyRef","useRef","leaveTimeout","transitionTimeout","committedProps","state","setState","useState","visible","text","useEffect","window","clearTimeout","current","useLayoutEffect","previousProps","action","timestamp","updateWhileTextIsPresent","update","setLeaveTimeout","setTimeout","timeout","show","_jsx","className","role","children","CSSTransition","nodeRef","in","classNames","appear","enter","exit","unmountOnExit","_jsxs","Body","ref","as","Button","v2","size","onClick","label","withNextPortal"],"mappings":";;;;;;;AAQA,MAAMA,uBAAuB,GAAG,GAAG;AAkB5B,MAAMC,QAAQ,GAAIC,KAAoB,IAAI;AAC/C,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAAkB,IAAI,CAAC;AAC7C,EAAA,MAAMC,YAAY,GAAGD,MAAM,CAAC,CAAC,CAAC;AAC9B,EAAA,MAAME,iBAAiB,GAAGF,MAAM,CAAC,CAAC,CAAC;AACnC;AACA,EAAA,MAAMG,cAAc,GAAGH,MAAM,CAACF,KAAK,CAAC;AAEpC,EAAA,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAgB;AAChDC,IAAAA,OAAO,EAAE,KAAK;AACdC,IAAAA,IAAI,EAAE;AACP,GAAA,CAAC;EAEFC,SAAS,CACP,MAAM,MAAK;AACTC,IAAAA,MAAM,CAACC,YAAY,CAACV,YAAY,CAACW,OAAO,CAAC;AACzCF,IAAAA,MAAM,CAACC,YAAY,CAACT,iBAAiB,CAACU,OAAO,CAAC;EAChD,CAAC,EACD,EAAE,CACH;AAED;AACA;AACA;AACA;AACA;AACA;AACAC,EAAAA,eAAe,CAAC,MAAK;AACn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,MAAM,CAAC4B;SACF,CAAC,GACP,IAAI;OACJ;KACO;AACjB,GAAK,CAAC;AAEV;AAEA,qBAAeC,qBAAc,CAAC/C,QAAQ,CAAC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarContext.js","sources":["../../src/Snackbar/SnackbarContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport { SnackbarProps } from './Snackbar';\n\nexport type SnackbarContextType = {\n createSnackbar: (props: Omit<SnackbarProps, 'timeout' | 'timestamp'>) => void;\n};\n\nexport const SnackbarContext = createContext<SnackbarContextType>({ createSnackbar: () => {} });\n\nexport const SnackbarConsumer = SnackbarContext.Consumer;\n"],"names":["SnackbarContext","createContext","createSnackbar","SnackbarConsumer","Consumer"],"mappings":";;;;AAQO,MAAMA,eAAe,gBAAGC,mBAAa,CAAsB;EAAEC,cAAc,EAAEA,MAAK,CAAE;AAAC,CAAE;AAEvF,MAAMC,gBAAgB,GAAGH,eAAe,CAACI;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarContext.mjs","sources":["../../src/Snackbar/SnackbarContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport { SnackbarProps } from './Snackbar';\n\nexport type SnackbarContextType = {\n createSnackbar: (props: Omit<SnackbarProps, 'timeout' | 'timestamp'>) => void;\n};\n\nexport const SnackbarContext = createContext<SnackbarContextType>({ createSnackbar: () => {} });\n\nexport const SnackbarConsumer = SnackbarContext.Consumer;\n"],"names":["SnackbarContext","createContext","createSnackbar","SnackbarConsumer","Consumer"],"mappings":";;AAQO,MAAMA,eAAe,gBAAGC,aAAa,CAAsB;EAAEC,cAAc,EAAEA,MAAK,CAAE;AAAC,CAAE;AAEvF,MAAMC,gBAAgB,GAAGH,eAAe,CAACI;;"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var Snackbar = require('./Snackbar.js');
|
|
7
|
-
var SnackbarContext = require('./SnackbarContext.js');
|
|
8
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
-
|
|
10
|
-
function SnackbarProvider({
|
|
11
|
-
timeout = 4500,
|
|
12
|
-
children
|
|
13
|
-
}) {
|
|
14
|
-
const [state, setState] = React.useState({
|
|
15
|
-
text: '',
|
|
16
|
-
timestamp: 0
|
|
17
|
-
});
|
|
18
|
-
const {
|
|
19
|
-
action,
|
|
20
|
-
text,
|
|
21
|
-
timestamp
|
|
22
|
-
} = state;
|
|
23
|
-
return /*#__PURE__*/jsxRuntime.jsxs(SnackbarContext.SnackbarContext.Provider, {
|
|
24
|
-
value: React.useMemo(() => ({
|
|
25
|
-
createSnackbar: ({
|
|
26
|
-
action,
|
|
27
|
-
text
|
|
28
|
-
}) => {
|
|
29
|
-
setState({
|
|
30
|
-
action,
|
|
31
|
-
text,
|
|
32
|
-
timestamp: Date.now()
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}), []),
|
|
36
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Snackbar.default, {
|
|
37
|
-
action: action,
|
|
38
|
-
text: text,
|
|
39
|
-
timestamp: timestamp,
|
|
40
|
-
timeout: timeout
|
|
41
|
-
}), children]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.default = SnackbarProvider;
|
|
46
|
-
//# sourceMappingURL=SnackbarProvider.js.map
|