@bigbluebutton/bbb-ui-components-react 0.9.0 → 0.10.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.
Files changed (31) hide show
  1. package/README.md +1 -0
  2. package/dist/components/Search.js +3 -2
  3. package/dist/components/Spinner.js +1 -0
  4. package/dist/components/Toast.js +292 -0
  5. package/dist/components/Toggle.js +18 -11
  6. package/dist/components/index.js +366 -216
  7. package/dist/esm/components/Spinner/styles.js +1 -0
  8. package/dist/esm/components/Toast/component.js +144 -0
  9. package/dist/esm/components/Toast/constants.js +36 -0
  10. package/dist/esm/components/Toast/index.js +1 -0
  11. package/dist/esm/components/Toast/styles.js +180 -0
  12. package/dist/esm/components/Toast/types.js +1 -0
  13. package/dist/esm/components/Toggle/component.js +5 -4
  14. package/dist/esm/components/Toggle/styles.js +13 -2
  15. package/dist/esm/components/index.js +1 -0
  16. package/dist/esm/stylesheets/palette.js +4 -0
  17. package/dist/types/components/Accordion/constants.d.ts +1 -1
  18. package/dist/types/components/Button/constants.d.ts +4 -4
  19. package/dist/types/components/Slider/styles.d.ts +1 -1
  20. package/dist/types/components/TextInput/styles.d.ts +1 -1
  21. package/dist/types/components/Toast/component.d.ts +14 -0
  22. package/dist/types/components/Toast/constants.d.ts +42 -0
  23. package/dist/types/components/Toast/index.d.ts +1 -0
  24. package/dist/types/components/Toast/styles.d.ts +14 -0
  25. package/dist/types/components/Toast/types.d.ts +68 -0
  26. package/dist/types/components/Toggle/component.d.ts +1 -1
  27. package/dist/types/components/Toggle/constants.d.ts +2 -2
  28. package/dist/types/components/Toggle/types.d.ts +3 -0
  29. package/dist/types/components/index.d.ts +1 -0
  30. package/dist/types/stylesheets/palette.d.ts +2 -0
  31. package/package.json +11 -1
@@ -14,6 +14,7 @@ export const Wrapper = styled.div `
14
14
  height: ${({ $size }) => typeof $size === 'number' ? `${$size}px` : $size};
15
15
  display: inline-grid;
16
16
  place-items: center;
17
+ overflow: hidden;
17
18
  `;
18
19
  export const StyledSvg = styled.svg `
19
20
  width: 100%;
@@ -0,0 +1,144 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useEffect, useId, useRef, useState, } from 'react';
13
+ import { MdClose } from 'react-icons/md';
14
+ import * as Styled from './styles';
15
+ import { BBBDivider } from '../Divider';
16
+ import { BBButton } from '../Button';
17
+ import { DEFAULT_AUTO_CLOSE, DEFAULT_CLOSE_BUTTON_ARIA_LABEL, DEFAULT_ICONS, DEFAULT_MAX_HEIGHT, DEFAULT_TOAST_VARIANT, INTERACTIVE_SELECTOR, TOAST_VARIANTS, } from './constants';
18
+ /**
19
+ * A notification card for transient messages.
20
+ *
21
+ * This component renders the presentational part of a toast notification: an icon badge
22
+ * matched to `variant`, the message, optional secondary content and an optional action button.
23
+ *
24
+ * It never hides itself. Both the close button and the `autoClose` timer call `onRequestClose`,
25
+ * leaving removal to whoever owns the toast stack, so the card can live inside an external
26
+ * toast engine without leaving an empty slot behind.
27
+ */
28
+ function Toast(_a) {
29
+ var { message, variant = DEFAULT_TOAST_VARIANT, icon, content, showSeparator = true, small = false, disablePointer, onClick, clickAriaLabel, actionLabel, onActionClick, autoClose = DEFAULT_AUTO_CLOSE, paused = false, hideProgressBar = false, hideCloseButton = false, closeButtonAriaLabel = DEFAULT_CLOSE_BUTTON_ARIA_LABEL, onRequestClose, maxHeight = DEFAULT_MAX_HEIGHT, dataTest, messageDataTest, closeButtonDataTest, actionButtonDataTest, onMouseEnter, onMouseLeave, onFocus, onBlur } = _a, rest = __rest(_a, ["message", "variant", "icon", "content", "showSeparator", "small", "disablePointer", "onClick", "clickAriaLabel", "actionLabel", "onActionClick", "autoClose", "paused", "hideProgressBar", "hideCloseButton", "closeButtonAriaLabel", "onRequestClose", "maxHeight", "dataTest", "messageDataTest", "closeButtonDataTest", "actionButtonDataTest", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur"]);
30
+ // Without an explicit value BBButton derives its own from the label, which is
31
+ // translated at every call site — so the derived ids below are what keep test
32
+ // selectors stable across locales.
33
+ const derive = (explicit, suffix) => explicit !== null && explicit !== void 0 ? explicit : (dataTest ? `${dataTest}-${suffix}` : undefined);
34
+ const testIds = {
35
+ message: derive(messageDataTest, 'message'),
36
+ closeButton: derive(closeButtonDataTest, 'close-button'),
37
+ actionButton: derive(actionButtonDataTest, 'action-button'),
38
+ };
39
+ // Held in a ref so an inline `onRequestClose` doesn't restart the timer on every
40
+ // render, which would keep the toast alive forever.
41
+ const onRequestCloseRef = useRef(onRequestClose);
42
+ useEffect(() => {
43
+ onRequestCloseRef.current = onRequestClose;
44
+ }, [onRequestClose]);
45
+ // Paused while hovered or focused so the toast doesn't vanish under a user who is
46
+ // reading it or about to press one of its buttons (WCAG 2.2.1, Timing Adjustable).
47
+ const [isHovered, setIsHovered] = useState(false);
48
+ const [isFocused, setIsFocused] = useState(false);
49
+ const isPaused = paused || isHovered || isFocused;
50
+ const remainingRef = useRef(autoClose === false ? 0 : autoClose);
51
+ useEffect(() => {
52
+ if (autoClose !== false)
53
+ remainingRef.current = autoClose;
54
+ }, [autoClose]);
55
+ useEffect(() => {
56
+ if (autoClose === false || isPaused)
57
+ return undefined;
58
+ const startedAt = Date.now();
59
+ const delay = remainingRef.current;
60
+ const timeout = setTimeout(() => { var _a; return (_a = onRequestCloseRef.current) === null || _a === void 0 ? void 0 : _a.call(onRequestCloseRef); }, delay);
61
+ return () => {
62
+ clearTimeout(timeout);
63
+ remainingRef.current = Math.max(0, delay - (Date.now() - startedAt));
64
+ };
65
+ }, [autoClose, isPaused]);
66
+ const handleMouseEnter = (event) => {
67
+ setIsHovered(true);
68
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(event);
69
+ };
70
+ const handleMouseLeave = (event) => {
71
+ setIsHovered(false);
72
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(event);
73
+ };
74
+ const handleFocus = (event) => {
75
+ setIsFocused(true);
76
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
77
+ };
78
+ const handleBlur = (event) => {
79
+ if (!event.currentTarget.contains(event.relatedTarget))
80
+ setIsFocused(false);
81
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
82
+ };
83
+ const isAssertive = variant === TOAST_VARIANTS.WARNING || variant === TOAST_VARIANTS.ERROR;
84
+ const contentId = useId();
85
+ const cardActionRef = useRef(null);
86
+ // Every click on the card lands here, including the card action's own (keyboard
87
+ // activation of a button dispatches a click too). Clicks on other interactive
88
+ // elements passed through `message` or `content` belong to those elements.
89
+ const handleCardClick = (event) => {
90
+ if (!onClick)
91
+ return;
92
+ const interactive = event.target.closest(INTERACTIVE_SELECTOR);
93
+ const isOwnedElsewhere = interactive
94
+ && interactive !== cardActionRef.current
95
+ && event.currentTarget.contains(interactive);
96
+ if (isOwnedElsewhere)
97
+ return;
98
+ onClick(event);
99
+ };
100
+ const handleCloseClick = (event) => {
101
+ event.stopPropagation();
102
+ onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
103
+ };
104
+ const handleActionClick = (event) => {
105
+ event.stopPropagation();
106
+ onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick(event);
107
+ };
108
+ const renderIconSection = () => {
109
+ if (icon === false)
110
+ return null;
111
+ const DefaultIcon = DEFAULT_ICONS[variant];
112
+ return (React.createElement(Styled.IconSection, null,
113
+ React.createElement(Styled.IconBand, null,
114
+ React.createElement(Styled.IconBadge, { "$variant": variant, "$small": small, "aria-hidden": "true" }, icon !== null && icon !== void 0 ? icon : React.createElement(DefaultIcon, null)))));
115
+ };
116
+ return (React.createElement(Styled.Container
117
+ // The live-region role can't be swapped for `role="button"`, and the card holds
118
+ // buttons of its own, so the click is exposed through a real button wrapping the
119
+ // message (`Styled.CardAction`) rather than on the container itself.
120
+ , Object.assign({
121
+ // The live-region role can't be swapped for `role="button"`, and the card holds
122
+ // buttons of its own, so the click is exposed through a real button wrapping the
123
+ // message (`Styled.CardAction`) rather than on the container itself.
124
+ role: isAssertive ? 'alert' : 'status', "aria-live": isAssertive ? 'assertive' : 'polite', "aria-atomic": "true" }, rest, { "$disablePointer": disablePointer !== null && disablePointer !== void 0 ? disablePointer : !onClick, "$maxHeight": maxHeight, onClick: onClick ? handleCardClick : undefined, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur }, (dataTest ? { 'data-test': dataTest } : {})),
125
+ renderIconSection(),
126
+ onClick && !message && (React.createElement(Styled.CardAction, { ref: cardActionRef, type: "button", "$visuallyHidden": true, "aria-label": clickAriaLabel, "aria-labelledby": clickAriaLabel ? undefined : contentId })),
127
+ React.createElement(Styled.Body, null,
128
+ (message || !hideCloseButton) && (React.createElement(Styled.Header, null,
129
+ message && (React.createElement(Styled.Message, Object.assign({ "$small": small }, (testIds.message ? { 'data-test': testIds.message } : {})), onClick ? (React.createElement(Styled.CardAction, { ref: cardActionRef, type: "button", "$visuallyHidden": false, "aria-label": clickAriaLabel }, message)) : message)),
130
+ !hideCloseButton && (React.createElement(Styled.CloseButtonWrapper, null,
131
+ React.createElement(BBButton, Object.assign({ layout: "squared", variant: "subtle", size: "sm", icon: React.createElement(MdClose, { size: "1.25rem" }), ariaLabel: closeButtonAriaLabel, onClick: handleCloseClick }, (testIds.closeButton ? { dataTest: testIds.closeButton } : {}))))))),
132
+ content && (React.createElement(React.Fragment, null,
133
+ showSeparator && message && React.createElement(BBBDivider, null),
134
+ React.createElement(Styled.Content, { id: onClick ? contentId : undefined, "$small": small }, content))),
135
+ actionLabel && (React.createElement(Styled.ActionWrapper, null,
136
+ React.createElement(BBButton, Object.assign({ label: actionLabel, variant: "tertiary", size: "sm", onClick: handleActionClick }, (testIds.actionButton ? { dataTest: testIds.actionButton } : {})))))),
137
+ autoClose !== false && !hideProgressBar && (React.createElement(Styled.ProgressTrack, { "aria-hidden": "true" },
138
+ React.createElement(Styled.ProgressBar
139
+ // A new duration restarts the countdown, so the bar restarts with it.
140
+ , {
141
+ // A new duration restarts the countdown, so the bar restarts with it.
142
+ key: autoClose, "$variant": variant, "$duration": autoClose, "$paused": isPaused })))));
143
+ }
144
+ export default Toast;
@@ -0,0 +1,36 @@
1
+ import { MdCheck, MdError, MdHelp, MdInfo, MdWarning } from 'react-icons/md';
2
+ import { colorBrand1, colorSuccessDark, colorWarningDark, colorError, colorWhite, } from '../../stylesheets/palette';
3
+ export const TOAST_VARIANTS = {
4
+ DEFAULT: 'default',
5
+ INFO: 'info',
6
+ SUCCESS: 'success',
7
+ WARNING: 'warning',
8
+ ERROR: 'error',
9
+ };
10
+ export const TOAST_VARIANT_VALUES = Object.values(TOAST_VARIANTS);
11
+ export const DEFAULT_TOAST_VARIANT = TOAST_VARIANTS.DEFAULT;
12
+ export const DEFAULT_AUTO_CLOSE = 5000;
13
+ export const DEFAULT_CLOSE_BUTTON_ARIA_LABEL = 'Close';
14
+ export const INTERACTIVE_SELECTOR = [
15
+ 'a[href]', 'button', 'input', 'select', 'textarea', 'summary', 'label',
16
+ '[role="button"]', '[role="link"]', '[tabindex]:not([tabindex="-1"])',
17
+ ].join(', ');
18
+ // Caps the card so tall content scrolls inside it instead of being clipped in silence by
19
+ // the toast engine's own container (react-toastify's is `max-height: 75vh; overflow: hidden`).
20
+ export const DEFAULT_MAX_HEIGHT = '70vh';
21
+ export const DEFAULT_ICONS = {
22
+ default: MdInfo,
23
+ info: MdHelp,
24
+ success: MdCheck,
25
+ warning: MdWarning,
26
+ error: MdError,
27
+ };
28
+ // The success and warning badges take the dark shades of their colors so the white glyph
29
+ // keeps at least the 3:1 non-text contrast WCAG asks for; it fails on the lighter fills.
30
+ export const VARIANT_COLORS = {
31
+ default: { background: colorBrand1, glyph: colorWhite },
32
+ info: { background: colorBrand1, glyph: colorWhite },
33
+ success: { background: colorSuccessDark, glyph: colorWhite },
34
+ warning: { background: colorWarningDark, glyph: colorWhite },
35
+ error: { background: colorError, glyph: colorWhite },
36
+ };
@@ -0,0 +1 @@
1
+ export { default as BBBToast } from './component';
@@ -0,0 +1,180 @@
1
+ import styled, { css, keyframes } from 'styled-components';
2
+ import { colorBackgroundWhite, colorBrand1, colorShadowDefault, colorTextDefault, colorTextLight, } from '../../stylesheets/palette';
3
+ import { borderRadiusSmall, spacingMediumLarge, spacingSmall, spacingSmallMedium, } from '../../stylesheets/sizing';
4
+ import { fontSizeBig, fontSizeDefault, fontSizeSmall, fontSizeXSmall, fontWeightLight, } from '../../stylesheets/typography';
5
+ import { VARIANT_COLORS } from './constants';
6
+ // `message` and `content` take arbitrary nodes, so any media a consumer passes is
7
+ // capped to the card instead of forcing it wider than its container.
8
+ const richContent = css `
9
+ img,
10
+ svg,
11
+ video {
12
+ max-width: 100%;
13
+ }
14
+ `;
15
+ const visuallyHidden = css `
16
+ position: absolute;
17
+ width: 1px;
18
+ height: 1px;
19
+ overflow: hidden;
20
+ clip-path: inset(50%);
21
+ white-space: nowrap;
22
+ `;
23
+ // Unstyled so the message reads as plain text; its focus ring is drawn on the whole card.
24
+ export const CardAction = styled.button `
25
+ margin: 0;
26
+ padding: 0;
27
+ border: 0;
28
+ background: none;
29
+ color: inherit;
30
+ font: inherit;
31
+ line-height: inherit;
32
+ text-align: start;
33
+ cursor: inherit;
34
+
35
+ &:focus {
36
+ outline: none;
37
+ }
38
+
39
+ ${({ $visuallyHidden }) => $visuallyHidden && visuallyHidden}
40
+ `;
41
+ export const Container = styled.div `
42
+ position: relative;
43
+ display: flex;
44
+ /* Fills the slot it is given even when that slot is a flex container, as toast engines'
45
+ wrappers usually are, so every toast in a stack has the same width. */
46
+ width: 100%;
47
+ flex-direction: row;
48
+ align-items: stretch;
49
+ gap: ${spacingSmallMedium};
50
+ padding: ${spacingMediumLarge};
51
+ background-color: ${colorBackgroundWhite};
52
+ border-radius: ${borderRadiusSmall};
53
+ box-shadow: 0 2px 8px ${colorShadowDefault};
54
+ overflow-wrap: break-word;
55
+ /* So maxHeight caps the whole card, padding included, rather than just its content box. */
56
+ box-sizing: border-box;
57
+ max-height: ${({ $maxHeight }) => $maxHeight};
58
+ cursor: ${({ $disablePointer }) => ($disablePointer ? 'auto' : 'pointer')};
59
+
60
+ &:has(${CardAction}:focus-visible) {
61
+ outline: 2px solid ${colorBrand1};
62
+ }
63
+ `;
64
+ // Mirrors the close button's box. The title row is sized by that button rather than by
65
+ // the text, so pinning the badge to the top left it riding high by half the difference —
66
+ // worse the smaller the badge, which is why it showed up first in the `small` variant.
67
+ // Giving the badge and the title row the same band centers them on one line at any size.
68
+ const titleRowHeight = '2.375rem';
69
+ // The width of BBButton's focus outline, which is drawn outside its box.
70
+ const focusRingWidth = '2px';
71
+ // The icon owns a full-height section of its own on the left; inside it, the badge is
72
+ // centered on the title row so it stays on the title's line as content grows.
73
+ export const IconSection = styled.div `
74
+ display: flex;
75
+ align-items: flex-start;
76
+ flex-shrink: 0;
77
+ `;
78
+ export const IconBand = styled.div `
79
+ display: flex;
80
+ align-items: center;
81
+ min-height: ${titleRowHeight};
82
+ `;
83
+ export const Body = styled.div `
84
+ display: flex;
85
+ flex-direction: column;
86
+ flex: 1;
87
+ min-width: 0;
88
+ gap: ${spacingSmall};
89
+
90
+ /* min-height lets this flex child shrink below its content so the overflow can scroll. */
91
+ min-height: 0;
92
+ overflow-y: auto;
93
+ overflow-x: hidden;
94
+
95
+ /* As a scroll container this clips whatever overflows it, including the focus ring of
96
+ the close button, which spans the full height of the title row. The padding leaves
97
+ room for the ring and the negative margin cancels it out of the layout. */
98
+ padding: ${focusRingWidth};
99
+ margin: -${focusRingWidth};
100
+ `;
101
+ // The close button shares this row with the title only, so it stays on the title's line
102
+ // instead of centering against the content below it.
103
+ export const Header = styled.div `
104
+ display: flex;
105
+ flex-direction: row;
106
+ align-items: center;
107
+ min-height: ${titleRowHeight};
108
+ gap: ${spacingSmall};
109
+ `;
110
+ export const IconBadge = styled.div `
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ flex-shrink: 0;
115
+ border-radius: 50%;
116
+ aspect-ratio: 1;
117
+ width: ${({ $small }) => ($small ? '1.5rem' : '2rem')};
118
+ font-size: ${({ $small }) => ($small ? fontSizeXSmall : fontSizeBig)};
119
+ background-color: ${({ $variant }) => VARIANT_COLORS[$variant].background};
120
+ color: ${({ $variant }) => VARIANT_COLORS[$variant].glyph};
121
+ `;
122
+ export const Message = styled.div `
123
+ flex: 1;
124
+ min-width: 0;
125
+ color: ${colorTextDefault};
126
+ font-size: ${({ $small }) => ($small ? fontSizeSmall : fontSizeDefault)};
127
+ font-weight: ${fontWeightLight};
128
+ line-height: normal;
129
+
130
+ ${richContent}
131
+ `;
132
+ export const Content = styled.div `
133
+ color: ${colorTextLight};
134
+ font-size: ${({ $small }) => ($small ? fontSizeXSmall : fontSizeSmall)};
135
+ font-weight: ${fontWeightLight};
136
+ line-height: normal;
137
+
138
+ ${richContent}
139
+ `;
140
+ export const ActionWrapper = styled.div `
141
+ display: flex;
142
+ justify-content: flex-end;
143
+ `;
144
+ export const CloseButtonWrapper = styled.div `
145
+ display: flex;
146
+ flex-shrink: 0;
147
+ margin-inline-start: auto;
148
+ `;
149
+ const countdown = keyframes `
150
+ from {
151
+ transform: scaleX(1);
152
+ }
153
+
154
+ to {
155
+ transform: scaleX(0);
156
+ }
157
+ `;
158
+ // Clips the bar to the card's rounded bottom corners without clipping the card's content.
159
+ export const ProgressTrack = styled.div `
160
+ position: absolute;
161
+ inset-inline: 0;
162
+ bottom: 0;
163
+ height: 0.25rem;
164
+ overflow: hidden;
165
+ border-end-start-radius: ${borderRadiusSmall};
166
+ border-end-end-radius: ${borderRadiusSmall};
167
+ `;
168
+ // Pausing the animation together with the timer keeps the two in step: both resume from
169
+ // where they stopped instead of restarting.
170
+ export const ProgressBar = styled.div `
171
+ height: 100%;
172
+ background-color: ${({ $variant }) => VARIANT_COLORS[$variant].background};
173
+ transform-origin: left;
174
+ animation: ${countdown} ${({ $duration }) => $duration}ms linear forwards;
175
+ animation-play-state: ${({ $paused }) => ($paused ? 'paused' : 'running')};
176
+
177
+ [dir='rtl'] & {
178
+ transform-origin: right;
179
+ }
180
+ `;
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React, { useId } from 'react';
13
13
  import * as Styled from './styles';
14
- import { DEFAULT_TEXT_POSITION } from './constants';
14
+ import { DEFAULT_TEXT_POSITION, TEXT_POSITIONS } from './constants';
15
15
  /**
16
16
  * A customizable Toggle switch component.
17
17
  *
@@ -20,11 +20,12 @@ import { DEFAULT_TEXT_POSITION } from './constants';
20
20
  *
21
21
  */
22
22
  function Toggle(_a) {
23
- var { label, helperText, textPosition = DEFAULT_TEXT_POSITION, onChange, ariaLabel, ariaLabelledBy, ariaDescribedBy, id: providedId, slotProps } = _a, rest = __rest(_a, ["label", "helperText", "textPosition", "onChange", "ariaLabel", "ariaLabelledBy", "ariaDescribedBy", "id", "slotProps"]);
23
+ var { label, helperText, textPosition = DEFAULT_TEXT_POSITION, fullWidth = false, onChange, ariaLabel, ariaLabelledBy, ariaDescribedBy, id: providedId, slotProps } = _a, rest = __rest(_a, ["label", "helperText", "textPosition", "fullWidth", "onChange", "ariaLabel", "ariaLabelledBy", "ariaDescribedBy", "id", "slotProps"]);
24
24
  const generatedUniqueId = useId();
25
25
  const id = providedId !== null && providedId !== void 0 ? providedId : generatedUniqueId;
26
26
  const labelId = label ? `${id}-label` : undefined;
27
27
  const helperTextId = helperText ? `${id}-helper` : undefined;
28
+ const isFullWidth = fullWidth && (textPosition === TEXT_POSITIONS.LEFT || textPosition === TEXT_POSITIONS.RIGHT);
28
29
  const ariaLabelledByValue = ariaLabel ? undefined : ariaLabelledBy || labelId;
29
30
  // Without a name source, the <label htmlFor> names the input from the helper text,
30
31
  // so it can't also be the description.
@@ -39,8 +40,8 @@ function Toggle(_a) {
39
40
  const inputSlotProps = typeof consumerInputSlotProps === 'function'
40
41
  ? (ownerState) => (Object.assign(Object.assign({}, a11yInputProps), consumerInputSlotProps(ownerState)))
41
42
  : Object.assign(Object.assign({}, a11yInputProps), consumerInputSlotProps);
42
- return (React.createElement(Styled.ToggleWrapper, { "$textPosition": textPosition },
43
- (label || helperText) && (React.createElement(Styled.TextWrapper, { "$textPosition": textPosition, htmlFor: id, "$hasLabel": !!label, "$hasHelperText": !!helperText },
43
+ return (React.createElement(Styled.ToggleWrapper, { "$textPosition": textPosition, "$fullWidth": isFullWidth },
44
+ (label || helperText) && (React.createElement(Styled.TextWrapper, { "$textPosition": textPosition, "$fullWidth": isFullWidth, htmlFor: id, "$hasLabel": !!label, "$hasHelperText": !!helperText },
44
45
  label && React.createElement(Styled.Title, { id: labelId }, label),
45
46
  helperText && React.createElement(Styled.HelperText, { id: helperTextId }, helperText))),
46
47
  React.createElement(Styled.ToggleSwitchWrapper, null,
@@ -25,6 +25,10 @@ export const ToggleWrapper = styled.div `
25
25
  }
26
26
  return horizontalStyles;
27
27
  }};
28
+ ${({ $fullWidth }) => $fullWidth && css `
29
+ width: 100%;
30
+ justify-content: space-between;
31
+ `}
28
32
  `;
29
33
  export const ToggleSwitchWrapper = styled.div `
30
34
  display: flex;
@@ -44,13 +48,20 @@ export const TextWrapper = styled.label `
44
48
  }};
45
49
  cursor: pointer;
46
50
  ${({ $hasLabel, $hasHelperText }) => (!$hasLabel || !$hasHelperText) && `justify-content: center;`}
47
- ${({ $textPosition }) => {
51
+ ${({ $textPosition, $fullWidth }) => {
48
52
  if ($textPosition === TEXT_POSITIONS.TOP || $textPosition === TEXT_POSITIONS.BOTTOM) {
49
53
  return css `
50
54
  align-items: center;
51
55
  `;
52
56
  }
53
- if ($textPosition === TEXT_POSITIONS.LEFT)
57
+ // A full-width row aligns the text to the container's edge; otherwise it hugs the switch.
58
+ if ($fullWidth && $textPosition === TEXT_POSITIONS.RIGHT) {
59
+ return css `
60
+ align-items: end;
61
+ text-align: end;
62
+ `;
63
+ }
64
+ if ($textPosition === TEXT_POSITIONS.LEFT && !$fullWidth)
54
65
  return css `align-items: end;`;
55
66
  return css `
56
67
  align-items: start;
@@ -14,5 +14,6 @@ export { BBBSlider } from './Slider';
14
14
  export { BBBSpinner } from './Spinner';
15
15
  export { BBBTextAreaInput } from './TextAreaInput';
16
16
  export { BBBTextInput } from './TextInput';
17
+ export { BBBToast } from './Toast';
17
18
  export { BBBToggle } from './Toggle';
18
19
  export { BBBTypography } from './Typography';
@@ -25,6 +25,10 @@ const colorError_base = 'var(--color-error, #DF2721)';
25
25
  const colorErrorDark_base = 'var(--color-error-dark, #AE1010)';
26
26
  export const colorSuccess = 'var(--color-success, #2DD36F)';
27
27
  export const colorWarning = 'var(--color-warning, #F59240)';
28
+ // Darker shades of the two above, for fills that carry white text or icons - motivation: BBBToast
29
+ // warning and success which lack of contrast for displaying white icons
30
+ export const colorSuccessDark = 'var(--color-success-dark, #209B51)';
31
+ export const colorWarningDark = 'var(--color-warning-dark, #D8680B)';
28
32
  // Mapped to core css vars
29
33
  export const colorError = `var(--color-danger, ${colorError_base})`;
30
34
  export const colorErrorDark = `var(--color-danger-dark, ${colorErrorDark_base})`;
@@ -4,7 +4,7 @@ declare const TOOLTIP_PLACEMENTS: {
4
4
  readonly LEFT: "left";
5
5
  readonly RIGHT: "right";
6
6
  };
7
- declare const TOOLTIP_PLACEMENT_VALUES: ("left" | "right" | "bottom" | "top")[];
7
+ declare const TOOLTIP_PLACEMENT_VALUES: ("top" | "bottom" | "left" | "right")[];
8
8
  declare const DEFAULT_TOOLTIP_PLACEMENT: "top";
9
9
  declare const BUTTON_HEADER_POSITIONS: {
10
10
  readonly LEFT: "left";
@@ -26,22 +26,22 @@ declare const LAYOUTS: {
26
26
  readonly CIRCLE: "circle";
27
27
  readonly SQUARED: "squared";
28
28
  };
29
- declare const LAYOUT_VALUES: ("default" | "circle" | "stacked" | "squared")[];
30
- declare const DEFAULT_LAYOUT: "default" | "circle" | "stacked" | "squared";
29
+ declare const LAYOUT_VALUES: ("default" | "stacked" | "circle" | "squared")[];
30
+ declare const DEFAULT_LAYOUT: "default" | "stacked" | "circle" | "squared";
31
31
  declare const TOOLTIP_PLACEMENTS: {
32
32
  readonly TOP: "top";
33
33
  readonly BOTTOM: "bottom";
34
34
  readonly LEFT: "left";
35
35
  readonly RIGHT: "right";
36
36
  };
37
- declare const TOOLTIP_PLACEMENT_VALUES: ("left" | "right" | "bottom" | "top")[];
37
+ declare const TOOLTIP_PLACEMENT_VALUES: ("top" | "bottom" | "left" | "right")[];
38
38
  declare const DEFAULT_TOOLTIP_PLACEMENT: "top";
39
39
  declare const TYPES: {
40
40
  readonly BUTTON: "button";
41
41
  readonly SUBMIT: "submit";
42
42
  readonly RESET: "reset";
43
43
  };
44
- declare const TYPE_VALUES: ("button" | "reset" | "submit")[];
44
+ declare const TYPE_VALUES: ("button" | "submit" | "reset")[];
45
45
  declare const DEFAULT_TYPE: "button";
46
46
  declare const CSS_COLOR_PROPERTIES: CSSColorPropertiesType;
47
47
  declare const CSS_COLOR_PROPERTIES_DISABLED: EssentialColorProperties;
@@ -5,4 +5,4 @@ export declare const Title: import("styled-components/dist/types").IStyledCompon
5
5
  export declare const HelperText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
6
6
  export declare const SliderRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledSliderRowProps>> & string;
7
7
  export declare const IconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
8
- export declare const MaterialSlider: import("@emotion/styled").StyledComponent<import("@mui/material").SliderOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "name" | "color" | "size" | "style" | "disabled" | "defaultValue" | "className" | "tabIndex" | "aria-label" | "aria-labelledby" | "aria-valuetext" | "onChange" | "track" | "value" | "classes" | "slots" | "slotProps" | "sx" | "step" | "max" | "min" | "scale" | "orientation" | "components" | "componentsProps" | "disableSwap" | "getAriaLabel" | "getAriaValueText" | "marks" | "onChangeCommitted" | "shiftStep" | "valueLabelDisplay" | "valueLabelFormat"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
8
+ export declare const MaterialSlider: import("@emotion/styled").StyledComponent<import("@mui/material").SliderOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "color" | "size" | "disabled" | "className" | "aria-label" | "aria-labelledby" | "style" | "track" | "name" | "value" | "defaultValue" | "tabIndex" | "aria-valuetext" | "onChange" | "step" | "classes" | "slots" | "slotProps" | "sx" | "max" | "min" | "scale" | "orientation" | "components" | "componentsProps" | "disableSwap" | "getAriaLabel" | "getAriaValueText" | "marks" | "onChangeCommitted" | "shiftStep" | "valueLabelDisplay" | "valueLabelFormat"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -2,7 +2,7 @@ import { TextField } from '@mui/material';
2
2
  import { StyledTextProps } from './types';
3
3
  export declare const StyledTextField: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<{
4
4
  variant?: import("@mui/material").TextFieldVariants;
5
- } & Omit<import("@mui/material").FilledTextFieldProps | import("@mui/material").StandardTextFieldProps | import("@mui/material").OutlinedTextFieldProps, "variant">, StyledTextProps>> & string & Omit<typeof TextField, keyof import("react").Component<any, {}, any>>;
5
+ } & Omit<import("@mui/material").FilledTextFieldProps | import("@mui/material").OutlinedTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant">, StyledTextProps>> & string & Omit<typeof TextField, keyof import("react").Component<any, {}, any>>;
6
6
  export declare const Label: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
7
  export declare const HelperText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledTextProps>> & string;
8
8
  export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,14 @@
1
+ import { JSX } from 'react';
2
+ import { ToastProps } from './types';
3
+ /**
4
+ * A notification card for transient messages.
5
+ *
6
+ * This component renders the presentational part of a toast notification: an icon badge
7
+ * matched to `variant`, the message, optional secondary content and an optional action button.
8
+ *
9
+ * It never hides itself. Both the close button and the `autoClose` timer call `onRequestClose`,
10
+ * leaving removal to whoever owns the toast stack, so the card can live inside an external
11
+ * toast engine without leaving an empty slot behind.
12
+ */
13
+ declare function Toast({ message, variant, icon, content, showSeparator, small, disablePointer, onClick, clickAriaLabel, actionLabel, onActionClick, autoClose, paused, hideProgressBar, hideCloseButton, closeButtonAriaLabel, onRequestClose, maxHeight, dataTest, messageDataTest, closeButtonDataTest, actionButtonDataTest, onMouseEnter, onMouseLeave, onFocus, onBlur, ...rest }: ToastProps): JSX.Element;
14
+ export default Toast;
@@ -0,0 +1,42 @@
1
+ export declare const TOAST_VARIANTS: {
2
+ readonly DEFAULT: "default";
3
+ readonly INFO: "info";
4
+ readonly SUCCESS: "success";
5
+ readonly WARNING: "warning";
6
+ readonly ERROR: "error";
7
+ };
8
+ export declare const TOAST_VARIANT_VALUES: ("default" | "error" | "info" | "success" | "warning")[];
9
+ export declare const DEFAULT_TOAST_VARIANT: "default";
10
+ export declare const DEFAULT_AUTO_CLOSE = 5000;
11
+ export declare const DEFAULT_CLOSE_BUTTON_ARIA_LABEL = "Close";
12
+ export declare const INTERACTIVE_SELECTOR: string;
13
+ export declare const DEFAULT_MAX_HEIGHT = "70vh";
14
+ export declare const DEFAULT_ICONS: {
15
+ readonly default: import("react-icons/lib").IconType;
16
+ readonly info: import("react-icons/lib").IconType;
17
+ readonly success: import("react-icons/lib").IconType;
18
+ readonly warning: import("react-icons/lib").IconType;
19
+ readonly error: import("react-icons/lib").IconType;
20
+ };
21
+ export declare const VARIANT_COLORS: {
22
+ readonly default: {
23
+ readonly background: "var(--color-primary, var(--color-brand-1, #0F70D7))";
24
+ readonly glyph: "var(--color-white, var(--color-neutral-white, #FFFFFF))";
25
+ };
26
+ readonly info: {
27
+ readonly background: "var(--color-primary, var(--color-brand-1, #0F70D7))";
28
+ readonly glyph: "var(--color-white, var(--color-neutral-white, #FFFFFF))";
29
+ };
30
+ readonly success: {
31
+ readonly background: "var(--color-success-dark, #209B51)";
32
+ readonly glyph: "var(--color-white, var(--color-neutral-white, #FFFFFF))";
33
+ };
34
+ readonly warning: {
35
+ readonly background: "var(--color-warning-dark, #D8680B)";
36
+ readonly glyph: "var(--color-white, var(--color-neutral-white, #FFFFFF))";
37
+ };
38
+ readonly error: {
39
+ readonly background: "var(--color-danger, var(--color-error, #DF2721))";
40
+ readonly glyph: "var(--color-white, var(--color-neutral-white, #FFFFFF))";
41
+ };
42
+ };
@@ -0,0 +1 @@
1
+ export { default as BBBToast } from './component';
@@ -0,0 +1,14 @@
1
+ import { StyledCardActionProps, StyledIconBadgeProps, StyledProgressBarProps, StyledTextProps, StyledToastProps } from './types';
2
+ export declare const CardAction: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, StyledCardActionProps>> & string;
3
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledToastProps>> & string;
4
+ export declare const IconSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
5
+ export declare const IconBand: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
+ export declare const Body: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
+ export declare const Header: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
+ export declare const IconBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledIconBadgeProps>> & string;
9
+ export declare const Message: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledTextProps>> & string;
10
+ export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledTextProps>> & string;
11
+ export declare const ActionWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
+ export declare const CloseButtonWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
13
+ export declare const ProgressTrack: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
+ export declare const ProgressBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledProgressBarProps>> & string;