@bigbluebutton/bbb-ui-components-react 0.7.0 → 0.9.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 (62) hide show
  1. package/README.md +6 -3
  2. package/dist/components/Accordion.js +1 -1
  3. package/dist/components/Avatar.js +30 -0
  4. package/dist/components/Button.js +42 -44
  5. package/dist/components/Checkbox.js +4 -4
  6. package/dist/components/Input.js +68 -70
  7. package/dist/components/Modal.js +89 -91
  8. package/dist/components/Search.js +1 -1
  9. package/dist/components/Select.js +9 -9
  10. package/dist/components/Slider.js +35 -0
  11. package/dist/components/TextAreaInput.js +1 -1
  12. package/dist/components/TextInput.js +10 -10
  13. package/dist/components/Toggle.js +12 -12
  14. package/dist/components/colors.js +1 -1
  15. package/dist/components/index.js +239 -178
  16. package/dist/esm/components/Avatar/component.js +38 -0
  17. package/dist/esm/components/Avatar/constants.js +13 -0
  18. package/dist/esm/components/Avatar/index.js +1 -0
  19. package/dist/esm/components/Avatar/styles.js +42 -0
  20. package/dist/esm/components/Avatar/types.js +1 -0
  21. package/dist/esm/components/Button/component.js +7 -7
  22. package/dist/esm/components/Button/constants.js +12 -3
  23. package/dist/esm/components/Button/styles.js +21 -17
  24. package/dist/esm/components/Checkbox/component.js +11 -5
  25. package/dist/esm/components/Modal/component.js +4 -6
  26. package/dist/esm/components/Modal/styles.js +11 -8
  27. package/dist/esm/components/Slider/component.js +63 -0
  28. package/dist/esm/components/Slider/constants.js +9 -0
  29. package/dist/esm/components/Slider/index.js +1 -0
  30. package/dist/esm/components/Slider/styles.js +138 -0
  31. package/dist/esm/components/Slider/types.js +1 -0
  32. package/dist/esm/components/Toggle/component.js +16 -2
  33. package/dist/esm/components/index.js +2 -0
  34. package/dist/esm/stylesheets/colors.js +4 -1
  35. package/dist/esm/stylesheets/palette.js +7 -3
  36. package/dist/esm/stylesheets/sizing.js +1 -0
  37. package/dist/types/components/Accordion/constants.d.ts +1 -1
  38. package/dist/types/components/Avatar/component.d.ts +12 -0
  39. package/dist/types/components/Avatar/constants.d.ts +8 -0
  40. package/dist/types/components/Avatar/index.d.ts +1 -0
  41. package/dist/types/components/Avatar/styles.d.ts +3 -0
  42. package/dist/types/components/Avatar/types.d.ts +26 -0
  43. package/dist/types/components/Button/constants.d.ts +11 -4
  44. package/dist/types/components/Button/type.d.ts +11 -2
  45. package/dist/types/components/Checkbox/component.d.ts +1 -1
  46. package/dist/types/components/Checkbox/types.d.ts +3 -1
  47. package/dist/types/components/Modal/styles.d.ts +3 -2
  48. package/dist/types/components/Modal/types.d.ts +2 -0
  49. package/dist/types/components/Slider/component.d.ts +11 -0
  50. package/dist/types/components/Slider/constants.d.ts +9 -0
  51. package/dist/types/components/Slider/index.d.ts +1 -0
  52. package/dist/types/components/Slider/styles.d.ts +8 -0
  53. package/dist/types/components/Slider/types.d.ts +46 -0
  54. package/dist/types/components/TextInput/styles.d.ts +1 -1
  55. package/dist/types/components/Toggle/component.d.ts +1 -1
  56. package/dist/types/components/Toggle/constants.d.ts +2 -2
  57. package/dist/types/components/Toggle/types.d.ts +1 -1
  58. package/dist/types/components/index.d.ts +2 -0
  59. package/dist/types/stylesheets/colors.d.ts +8 -5
  60. package/dist/types/stylesheets/palette.d.ts +6 -5
  61. package/dist/types/stylesheets/sizing.d.ts +1 -0
  62. package/package.json +23 -3
@@ -0,0 +1,38 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Tippy from '@tippyjs/react';
3
+ import 'tippy.js/dist/tippy.css';
4
+ import * as Styled from './styles';
5
+ import { DEFAULT_AVATAR_SIZE, AVATAR_FALLBACK_COLORS } from './constants';
6
+ import { colorUserYou } from '../../stylesheets/palette';
7
+ function getInitials(name) {
8
+ const words = name.trim().split(/\s+/).filter(Boolean);
9
+ if (words.length === 0)
10
+ return '';
11
+ if (words.length === 1)
12
+ return words[0].slice(0, 2).toUpperCase();
13
+ return `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase();
14
+ }
15
+ function getFallbackColor(name) {
16
+ const hash = name.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
17
+ return AVATAR_FALLBACK_COLORS[hash % AVATAR_FALLBACK_COLORS.length];
18
+ }
19
+ /**
20
+ * A user avatar component.
21
+ *
22
+ * Renders the user's avatar image when available, falling back to their initials on a
23
+ * deterministically-colored background when no image is provided or it fails to load.
24
+ *
25
+ */
26
+ function Avatar({ name, avatarUrl, color, size = DEFAULT_AVATAR_SIZE, isModerator = false, isYou = false, isTalking = false, disableTooltip = false, }) {
27
+ const [hasImageError, setHasImageError] = useState(false);
28
+ const resolvedColor = color || (isYou ? colorUserYou : getFallbackColor(name));
29
+ useEffect(() => {
30
+ setHasImageError(false);
31
+ }, [avatarUrl]);
32
+ const avatarElement = avatarUrl && !hasImageError ? (React.createElement(Styled.AvatarImage, { src: avatarUrl, alt: name, "$size": size, "$color": resolvedColor, "$isModerator": isModerator, "$isTalking": isTalking, onError: () => setHasImageError(true) })) : (React.createElement(Styled.AvatarInitials, { "$size": size, "$color": resolvedColor, "$isModerator": isModerator, "$isTalking": isTalking }, getInitials(name)));
33
+ if (disableTooltip) {
34
+ return avatarElement;
35
+ }
36
+ return (React.createElement(Tippy, { content: name, placement: "top" }, avatarElement));
37
+ }
38
+ export default Avatar;
@@ -0,0 +1,13 @@
1
+ export const AVATAR_SIZES = {
2
+ SMALL: 'small',
3
+ MEDIUM: 'medium',
4
+ LARGE: 'large',
5
+ };
6
+ export const AVATAR_SIZE_VALUES = Object.values(AVATAR_SIZES);
7
+ export const DEFAULT_AVATAR_SIZE = AVATAR_SIZES.MEDIUM;
8
+ // Mirrors the palette akka-bbb-apps' ColorPicker assigns to users server-side (round-robin per
9
+ // meeting), so a name-hash fallback here lands on the same colors real BBB users get.
10
+ export const AVATAR_FALLBACK_COLORS = [
11
+ '#7b1fa2', '#6a1b9a', '#4a148c', '#5e35b1', '#512da8', '#4527a0', '#311b92',
12
+ '#3949ab', '#303f9f', '#283593', '#1a237e', '#1976d2', '#1565c0', '#0d47a1', '#0277bd', '#01579b',
13
+ ];
@@ -0,0 +1 @@
1
+ export { default as BBBAvatar } from './component';
@@ -0,0 +1,42 @@
1
+ import styled, { css, keyframes } from 'styled-components';
2
+ import { colorWhite } from '../../stylesheets/palette';
3
+ import { AVATAR_SIZES } from './constants';
4
+ const DIMENSIONS = {
5
+ [AVATAR_SIZES.SMALL]: { dimension: '1.625rem', fontSize: '0.625rem', fontWeight: '600' },
6
+ [AVATAR_SIZES.MEDIUM]: { dimension: '3rem', fontSize: '1.125rem', fontWeight: '500' },
7
+ [AVATAR_SIZES.LARGE]: { dimension: '6rem', fontSize: '2.75rem', fontWeight: '400' },
8
+ };
9
+ // Mirrors BBB's talking indicator (a ring, in the user's own color, that spreads and fades out).
10
+ const talkingPulse = (color) => keyframes `
11
+ 0% { box-shadow: 0 0 0 0 ${color}; }
12
+ 100% { box-shadow: 0 0 0 4px transparent; }
13
+ `;
14
+ const talkingStyles = css `
15
+ ${({ $isTalking, $color }) => $isTalking && css `
16
+ animation: ${talkingPulse($color)} 1s infinite ease-in;
17
+ `}
18
+ `;
19
+ export const AvatarInitials = styled.div `
20
+ width: ${({ $size }) => DIMENSIONS[$size].dimension};
21
+ height: ${({ $size }) => DIMENSIONS[$size].dimension};
22
+ border-radius: ${({ $isModerator }) => ($isModerator ? '20%' : '50%')};
23
+ flex-shrink: 0;
24
+ background: ${({ $color }) => $color};
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ font-size: ${({ $size }) => DIMENSIONS[$size].fontSize};
29
+ font-weight: ${({ $size }) => DIMENSIONS[$size].fontWeight};
30
+ color: ${colorWhite};
31
+ text-transform: uppercase;
32
+ ${talkingStyles}
33
+ `;
34
+ export const AvatarImage = styled.img `
35
+ width: ${({ $size }) => DIMENSIONS[$size].dimension};
36
+ height: ${({ $size }) => DIMENSIONS[$size].dimension};
37
+ border-radius: ${({ $isModerator }) => ($isModerator ? '20%' : '50%')};
38
+ flex-shrink: 0;
39
+ object-fit: cover;
40
+ border: 2px solid ${({ $color }) => $color};
41
+ ${talkingStyles}
42
+ `;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect, useId, useRef, useState, } from 'react';
2
2
  import { MdSettings, MdCheckCircle } from 'react-icons/md';
3
- import { DEFAULT_VARIANT, DEFAULT_COLOR, DEFAULT_SIZE, DEFAULT_LAYOUT, LAYOUTS, DEFAULT_TOOLTIP_PLACEMENT, } from './constants';
3
+ import { DEFAULT_VARIANT, DEFAULT_COLOR, DEFAULT_SIZE, DEFAULT_LAYOUT, LAYOUTS, DEFAULT_TOOLTIP_PLACEMENT, DEFAULT_TYPE, } from './constants';
4
4
  import * as Styled from './styles';
5
5
  import Tippy from '@tippyjs/react';
6
6
  import 'tippy.js/dist/tippy.css';
@@ -13,7 +13,7 @@ import 'tippy.js/dist/tippy.css';
13
13
  *
14
14
  */
15
15
  function Button(props) {
16
- const { id = '', dataTest, label, tooltipLabel, tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT, onClick, onKeyDown, ariaLabel = '', ariaLabelledBy = '', ariaDescribedBy = '', color = DEFAULT_COLOR, variant = DEFAULT_VARIANT, size = DEFAULT_SIZE, layout = DEFAULT_LAYOUT, disabled = false, children, showFeedback = false, feedbackContent = React.createElement(MdCheckCircle, { fontSize: "small" }), feedbackDuration = 2000, } = props;
16
+ const { id = '', dataTest, label, tooltipLabel, tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT, onClick, onKeyDown, ariaLabel = '', ariaLabelledBy = '', ariaDescribedBy = '', color = DEFAULT_COLOR, variant = DEFAULT_VARIANT, size = DEFAULT_SIZE, layout = DEFAULT_LAYOUT, type = DEFAULT_TYPE, disabled = false, children, showFeedback = false, feedbackContent = React.createElement(MdCheckCircle, { fontSize: "small" }), feedbackDuration = 2000, className, } = props;
17
17
  const feedbackTimeoutRef = useRef(null);
18
18
  const [isFeedbackVisible, setFeedbackVisible] = useState(false);
19
19
  useEffect(() => () => {
@@ -52,13 +52,13 @@ function Button(props) {
52
52
  if (props.layout === LAYOUTS.CIRCLE || props.layout === LAYOUTS.SQUARED) {
53
53
  const { icon } = props;
54
54
  const testId = dataTest || `button-${id || 'default'}`;
55
- return (React.createElement(Styled.Button, Object.assign({ id: id, "data-test": testId, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, disabled: disabled }), isFeedbackVisible ? (React.createElement(Styled.FeedbackContent, { role: "status", "aria-live": "polite" }, feedbackContent)) : icon));
55
+ return (React.createElement(Styled.Button, Object.assign({ id: id, className: className, type: type, "data-test": testId, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, disabled: disabled }), isFeedbackVisible ? (React.createElement(Styled.FeedbackContent, { role: "status", "aria-live": "polite" }, feedbackContent)) : icon));
56
56
  }
57
57
  if (props.layout === LAYOUTS.STACKED) {
58
58
  const { icon, helperIcon = React.createElement(MdSettings, { fontSize: "small" }), hideHelperIcon = false, helperOnClick = null, } = props;
59
59
  const testId = dataTest || `${LAYOUTS.STACKED}-button-${id || label || 'default'}`;
60
- return (React.createElement(Styled.ButtonWrapper, { "data-test": testId, "$layout": layout },
61
- React.createElement(Styled.Button, Object.assign({ id: id, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, disabled: disabled }),
60
+ return (React.createElement(Styled.ButtonWrapper, { className: className, "data-test": testId, "$layout": layout },
61
+ React.createElement(Styled.Button, Object.assign({ id: id, type: type, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, disabled: disabled }),
62
62
  !hideHelperIcon && (React.createElement(Styled.HelperIconContainer
63
63
  // Add this property only when there is a onClick function for the auxiliary icon.
64
64
  // It controls whether the auxiliary button is going to have an independent hover state.
@@ -74,9 +74,9 @@ function Button(props) {
74
74
  React.createElement(Styled.FeedbackContent, { role: "status", "aria-live": "polite" }, feedbackContent))) : (icon && React.createElement(Styled.IconWrapper, null, icon))),
75
75
  React.createElement(Styled.ButtonText, { id: defaultLabelId }, label)));
76
76
  }
77
- const { iconStart, iconEnd } = props;
77
+ const { iconStart, iconEnd, fullWidth = false } = props;
78
78
  const testId = dataTest || `button-${id || label || 'default'}`;
79
- return (React.createElement(Styled.Button, Object.assign({ id: id, "data-test": testId, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, disabled: disabled }), isFeedbackVisible ? (React.createElement(Styled.FeedbackContent, { id: defaultLabelId, role: "status", "aria-live": "polite" }, feedbackContent)) : (React.createElement(React.Fragment, null,
79
+ return (React.createElement(Styled.Button, Object.assign({ id: id, className: className, type: type, "data-test": testId, onClick: handleClick, onKeyDown: onKeyDown }, accessibilityProps, { "$color": color, "$variant": variant, "$size": size, "$layout": layout, "$fullWidth": fullWidth, disabled: disabled }), isFeedbackVisible ? (React.createElement(Styled.FeedbackContent, { id: defaultLabelId, role: "status", "aria-live": "polite" }, feedbackContent)) : (React.createElement(React.Fragment, null,
80
80
  iconStart && iconStart,
81
81
  label && React.createElement("span", { id: defaultLabelId }, label),
82
82
  children,
@@ -1,5 +1,5 @@
1
1
  import { colorBrand1, colorHoverDark, colorWhite, colorError, colorBorderError, colorErrorDark, colorBackgroundWhite, colorBackgroundBlue, colorHoverLight, colorLightGray, colorNeutral3, colorBackgroundLight, colorBorderSelected, colorTextLight, colorIconDefault, colorGray, colorBrandAux, } from '../../stylesheets/palette';
2
- import { spacingMedium, spacingSmall, spacingSmallMedium } from '../../stylesheets/sizing';
2
+ import { spacingSmall, spacingSmallMedium, spacingMedium, spacingXLarge, spacingXXLarge, } from '../../stylesheets/sizing';
3
3
  const VARIANTS = {
4
4
  PRIMARY: 'primary',
5
5
  SECONDARY: 'secondary',
@@ -37,6 +37,13 @@ const TOOLTIP_PLACEMENTS = {
37
37
  };
38
38
  const TOOLTIP_PLACEMENT_VALUES = Object.values(TOOLTIP_PLACEMENTS);
39
39
  const DEFAULT_TOOLTIP_PLACEMENT = TOOLTIP_PLACEMENTS.TOP;
40
+ const TYPES = {
41
+ BUTTON: 'button',
42
+ SUBMIT: 'submit',
43
+ RESET: 'reset',
44
+ };
45
+ const TYPE_VALUES = Object.values(TYPES);
46
+ const DEFAULT_TYPE = TYPES.BUTTON;
40
47
  const CSS_COLOR_PROPERTIES = {
41
48
  primary: {
42
49
  default: {
@@ -167,9 +174,11 @@ const CSS_COLOR_PROPERTIES_DISABLED = {
167
174
  const CSS_SIZE_PROPERTIES = {
168
175
  sm: {
169
176
  padding: `${spacingSmall} ${spacingSmallMedium}`,
177
+ iconBoxSize: spacingXLarge,
170
178
  },
171
179
  md: {
172
- padding: spacingMedium
180
+ padding: spacingMedium,
181
+ iconBoxSize: spacingXXLarge,
173
182
  },
174
183
  };
175
- export { VARIANTS, VARIANT_VALUES, DEFAULT_VARIANT, COLORS, COLOR_VALUES, DEFAULT_COLOR, SIZES, SIZE_VALUES, DEFAULT_SIZE, LAYOUTS, LAYOUT_VALUES, DEFAULT_LAYOUT, TOOLTIP_PLACEMENTS, TOOLTIP_PLACEMENT_VALUES, DEFAULT_TOOLTIP_PLACEMENT, CSS_COLOR_PROPERTIES, CSS_COLOR_PROPERTIES_DISABLED, CSS_SIZE_PROPERTIES, };
184
+ export { VARIANTS, VARIANT_VALUES, DEFAULT_VARIANT, COLORS, COLOR_VALUES, DEFAULT_COLOR, SIZES, SIZE_VALUES, DEFAULT_SIZE, LAYOUTS, LAYOUT_VALUES, DEFAULT_LAYOUT, TOOLTIP_PLACEMENTS, TOOLTIP_PLACEMENT_VALUES, DEFAULT_TOOLTIP_PLACEMENT, TYPES, TYPE_VALUES, DEFAULT_TYPE, CSS_COLOR_PROPERTIES, CSS_COLOR_PROPERTIES_DISABLED, CSS_SIZE_PROPERTIES, };
@@ -61,14 +61,14 @@ const commonButtonStyles = css `
61
61
  color: ${color};
62
62
  }
63
63
  color: ${color};
64
- ${background ? `background-color: ${background}` : `background-color: none`};
65
- border: ${border ? `1px solid ${border}` : 'none'};
64
+ ${background ? `background-color: ${background}` : `background-color: transparent`};
65
+ border: ${border ? `1px solid ${border}` : '1px solid transparent'};
66
66
 
67
67
  &&:hover,
68
68
  &&:active {
69
69
  color: ${color};
70
- ${background ? `background-color: ${background}` : `background-color: none`};
71
- border: ${border ? `1px solid ${border}` : 'none'};
70
+ ${background ? `background-color: ${background}` : `background-color: transparent`};
71
+ border: ${border ? `1px solid ${border}` : '1px solid transparent'};
72
72
  }
73
73
 
74
74
  &&:focus {
@@ -89,29 +89,33 @@ const stackedLayoutStyles = css `
89
89
  justify-content: center;
90
90
  align-items: center;
91
91
  `;
92
- const circleLayoutStyles = css `
93
- border-radius: 50%;
94
- width: 3rem;
95
- height: 3rem;
92
+ // Shared by `circle` and `squared`: both are icon-only, fixed-box layouts that
93
+ // must render at the same width/height for a given `size` — they differ only
94
+ // in border-radius (round vs. slightly rounded square).
95
+ const iconOnlyBoxStyles = css `
96
+ ${({ $size }) => {
97
+ var _a;
98
+ const safeSize = $size !== null && $size !== void 0 ? $size : DEFAULT_SIZE;
99
+ const { iconBoxSize } = (_a = CSS_SIZE_PROPERTIES[safeSize]) !== null && _a !== void 0 ? _a : CSS_SIZE_PROPERTIES[DEFAULT_SIZE];
100
+ return `width: ${iconBoxSize}; height: ${iconBoxSize};`;
101
+ }}
96
102
  aspect-ratio: 1;
97
103
  padding: 0;
98
104
  display: flex;
99
105
  justify-content: center;
100
106
  align-items: center;
101
107
  `;
102
- // Icon-only, sized by its own (equal, non-text) padding rather than a fixed
103
- // box — stays compact next to a single line of text instead of forcing a
104
- // fixed height like circle/stacked do.
108
+ const circleLayoutStyles = css `
109
+ ${iconOnlyBoxStyles}
110
+ border-radius: 50%;
111
+ `;
105
112
  const squaredLayoutStyles = css `
113
+ ${iconOnlyBoxStyles}
106
114
  border-radius: ${borderRadiusSmall};
107
- aspect-ratio: 1;
108
- padding: ${spacingSmall};
109
- display: flex;
110
- justify-content: center;
111
- align-items: center;
112
115
  `;
113
116
  const defaultLayoutStyles = css `
114
- display: inline-flex;
117
+ display: ${({ $fullWidth }) => ($fullWidth ? 'flex' : 'inline-flex')};
118
+ ${({ $fullWidth }) => $fullWidth && 'width: 100%;'}
115
119
  justify-content: center;
116
120
  align-items: center;
117
121
  gap: ${spacingSmall};
@@ -22,15 +22,21 @@ import { RadioButtonUnchecked, RadioButtonChecked } from '@mui/icons-material';
22
22
  *
23
23
  */
24
24
  function Checkbox(_a) {
25
- var { label, layout = DEFAULT_LAYOUT, round = false, ariaLabel } = _a, props = __rest(_a, ["label", "layout", "round", "ariaLabel"]);
26
- const id = useId();
27
- const checkbox = (React.createElement(Styled.StyledCheckbox, Object.assign({}, props, { id: id, "aria-label": ariaLabel, icon: round ? React.createElement(RadioButtonUnchecked, null) : undefined, checkedIcon: round ? React.createElement(RadioButtonChecked, null) : undefined })));
25
+ var { label, layout = DEFAULT_LAYOUT, round = false, ariaLabel, id, dataTest, slotProps } = _a, props = __rest(_a, ["label", "layout", "round", "ariaLabel", "id", "dataTest", "slotProps"]);
26
+ const generatedId = useId();
27
+ const checkboxId = id !== null && id !== void 0 ? id : generatedId;
28
+ const ownInputProps = { 'aria-label': ariaLabel, 'data-test': dataTest };
29
+ const _b = slotProps !== null && slotProps !== void 0 ? slotProps : {}, { input: consumerInputSlotProps } = _b, otherSlotProps = __rest(_b, ["input"]);
30
+ const inputSlotProps = typeof consumerInputSlotProps === 'function'
31
+ ? (ownerState) => (Object.assign(Object.assign({}, ownInputProps), consumerInputSlotProps(ownerState)))
32
+ : Object.assign(Object.assign({}, ownInputProps), consumerInputSlotProps);
33
+ const checkbox = (React.createElement(Styled.StyledCheckbox, Object.assign({}, props, { id: checkboxId, icon: round ? React.createElement(RadioButtonUnchecked, null) : undefined, checkedIcon: round ? React.createElement(RadioButtonChecked, null) : undefined, slotProps: Object.assign(Object.assign({}, otherSlotProps), { input: inputSlotProps }) })));
28
34
  if (!label) {
29
35
  return checkbox;
30
36
  }
31
37
  return (React.createElement(Styled.Container, null,
32
- layout === LAYOUTS.LEFT && React.createElement(Styled.Label, { htmlFor: id }, label),
38
+ layout === LAYOUTS.LEFT && React.createElement(Styled.Label, { htmlFor: checkboxId }, label),
33
39
  checkbox,
34
- layout === LAYOUTS.RIGHT && React.createElement(Styled.Label, { htmlFor: id }, label)));
40
+ layout === LAYOUTS.RIGHT && React.createElement(Styled.Label, { htmlFor: checkboxId }, label)));
35
41
  }
36
42
  export default Checkbox;
@@ -10,9 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useCallback } from 'react';
13
- import ReactModal from 'react-modal';
14
13
  import * as Styled from './styles';
15
- import { BBBTypography } from '../Typography';
16
14
  import { MdClose } from 'react-icons/md';
17
15
  import { BBBDivider } from '../Divider';
18
16
  import { BBButton } from '../Button';
@@ -24,7 +22,7 @@ import { BBButton } from '../Button';
24
22
  *
25
23
  */
26
24
  const Modal = (_a) => {
27
- var { isOpen = true, onRequestClose, appElement, title, contentLabel, showDividers = false, shouldCloseOnOverlayClick = false, shouldCloseOnEsc = false, allowScroll = true, noFooter = false, footerContent = null, stickyFooter = true, testId, closeButtonDataTest, children } = _a, rest = __rest(_a, ["isOpen", "onRequestClose", "appElement", "title", "contentLabel", "showDividers", "shouldCloseOnOverlayClick", "shouldCloseOnEsc", "allowScroll", "noFooter", "footerContent", "stickyFooter", "testId", "closeButtonDataTest", "children"]);
25
+ var { isOpen = true, onRequestClose, appElement, title, contentLabel, showDividers = false, shouldCloseOnOverlayClick = false, shouldCloseOnEsc = false, allowScroll = true, noFooter = false, hideCloseButton = false, footerContent = null, stickyFooter = true, testId, closeButtonDataTest, children } = _a, rest = __rest(_a, ["isOpen", "onRequestClose", "appElement", "title", "contentLabel", "showDividers", "shouldCloseOnOverlayClick", "shouldCloseOnEsc", "allowScroll", "noFooter", "hideCloseButton", "footerContent", "stickyFooter", "testId", "closeButtonDataTest", "children"]);
28
26
  let _closeButtonDataTest = closeButtonDataTest;
29
27
  if (testId && !closeButtonDataTest) {
30
28
  _closeButtonDataTest = `${testId}-close-button`;
@@ -32,10 +30,10 @@ const Modal = (_a) => {
32
30
  const renderFooter = useCallback((isSticky) => (React.createElement(React.Fragment, null,
33
31
  showDividers && React.createElement(BBBDivider, null),
34
32
  React.createElement(Styled.ModalFooter, { "$stickyFooter": isSticky }, footerContent))), [footerContent, showDividers]);
35
- return (React.createElement(ReactModal, Object.assign({}, rest, { isOpen: isOpen, onRequestClose: onRequestClose, contentLabel: contentLabel, style: Styled.modalStyles, shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, shouldCloseOnEsc: shouldCloseOnEsc, appElement: appElement, testId: testId }),
33
+ return (React.createElement(Styled.Modal, Object.assign({}, rest, { isOpen: isOpen, onRequestClose: onRequestClose, contentLabel: contentLabel, style: Styled.modalStyles, shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, shouldCloseOnEsc: shouldCloseOnEsc, appElement: appElement, testId: testId }),
36
34
  React.createElement(Styled.ModalHeader, null,
37
- React.createElement(BBBTypography, { variant: "header" }, title),
38
- React.createElement(BBButton, Object.assign({ layout: "circle", icon: React.createElement(MdClose, { size: "1.5rem" }), onClick: onRequestClose, variant: "subtle", ariaLabel: "close" }, (_closeButtonDataTest ? { dataTest: _closeButtonDataTest } : {})))),
35
+ React.createElement(Styled.ModalTitle, { variant: "header" }, title),
36
+ !hideCloseButton && (React.createElement(BBButton, Object.assign({ layout: "circle", icon: React.createElement(MdClose, { size: "1.5rem" }), onClick: onRequestClose, variant: "subtle", ariaLabel: "close" }, (_closeButtonDataTest ? { dataTest: _closeButtonDataTest } : {}))))),
39
37
  showDividers && React.createElement(BBBDivider, null),
40
38
  React.createElement(Styled.ModalScrollArea, { "$allowScroll": allowScroll },
41
39
  React.createElement(Styled.ModalBodyContent, null, children),
@@ -1,6 +1,8 @@
1
1
  import styled from 'styled-components';
2
+ import ReactModal from 'react-modal';
2
3
  import { spacingLarge, spacingMedium, spacingSmallMedium, borderRadiusDefault } from '../../stylesheets/sizing';
3
4
  import { colorWhite, colorOverlay } from '../../stylesheets/palette';
5
+ import { BBBTypography } from '../Typography';
4
6
  export const modalStyles = {
5
7
  overlay: {
6
8
  position: 'fixed',
@@ -21,7 +23,6 @@ export const modalStyles = {
21
23
  right: 'auto',
22
24
  bottom: 'auto',
23
25
  borderRadius: borderRadiusDefault,
24
- background: colorWhite,
25
26
  overflow: 'hidden',
26
27
  WebkitOverflowScrolling: 'touch',
27
28
  outline: 'none',
@@ -38,14 +39,12 @@ export const ModalHeader = styled.div `
38
39
  display: flex;
39
40
  justify-content: space-between;
40
41
  align-items: center;
42
+ gap: ${spacingMedium};
41
43
  `;
42
- export const CloseButton = styled.button `
43
- background: none;
44
- border: none;
45
- font-size: 1.5rem;
46
- cursor: pointer;
47
- padding: 0;
48
- line-height: 1;
44
+ export const ModalTitle = styled(BBBTypography) `
45
+ flex: 1;
46
+ min-width: 0;
47
+ overflow-wrap: anywhere;
49
48
  `;
50
49
  export const ModalScrollArea = styled.div `
51
50
  flex-grow: 1;
@@ -72,3 +71,7 @@ export const ModalFooter = styled.div `
72
71
  background-color: ${colorWhite};
73
72
  `}
74
73
  `;
74
+ // Background lives in a class instead of the inline `style` so the BBB dark theme and consumers can override it.
75
+ export const Modal = styled(ReactModal) `
76
+ background: ${colorWhite};
77
+ `;
@@ -0,0 +1,63 @@
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, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
13
+ import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
14
+ import * as Styled from './styles';
15
+ import { DEFAULT_ANIMATE, DEFAULT_SHOW_MARK_TICKS, DEFAULT_VALUE_LABEL_DISPLAY } from './constants';
16
+ /**
17
+ * A horizontal, single-thumb slider for picking a value inside a range.
18
+ *
19
+ * It supports labels (label and helperText), decorative end icons, marks and a value tooltip,
20
+ * and keeps its accessible name and description on the underlying range input.
21
+ *
22
+ */
23
+ function Slider(_a) {
24
+ var { label, helperText, iconStart, iconEnd, showMarkTicks = DEFAULT_SHOW_MARK_TICKS, animate = DEFAULT_ANIMATE, valueLabelDisplay = DEFAULT_VALUE_LABEL_DISPLAY, onChange, onChangeCommitted, id: providedId, dataTest, ariaLabel, ariaLabelledBy, ariaDescribedBy, slotProps } = _a, rest = __rest(_a, ["label", "helperText", "iconStart", "iconEnd", "showMarkTicks", "animate", "valueLabelDisplay", "onChange", "onChangeCommitted", "id", "dataTest", "ariaLabel", "ariaLabelledBy", "ariaDescribedBy", "slotProps"]);
25
+ const generatedUniqueId = useId();
26
+ const id = providedId !== null && providedId !== void 0 ? providedId : generatedUniqueId;
27
+ const labelId = label ? `${id}-label` : undefined;
28
+ const helperTextId = helperText ? `${id}-helper` : undefined;
29
+ const wrapperRef = useRef(null);
30
+ const [isRtl, setIsRtl] = useState(false);
31
+ useEffect(() => {
32
+ const wrapper = wrapperRef.current;
33
+ if (!wrapper)
34
+ return undefined;
35
+ const readDirection = () => {
36
+ setIsRtl(window.getComputedStyle(wrapper).direction === 'rtl');
37
+ };
38
+ readDirection();
39
+ const observer = new MutationObserver(readDirection);
40
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] });
41
+ return () => observer.disconnect();
42
+ }, []);
43
+ const outerTheme = useTheme();
44
+ const theme = useMemo(() => (isRtl && outerTheme.direction !== 'rtl'
45
+ ? createTheme(outerTheme, { direction: 'rtl' })
46
+ : outerTheme), [outerTheme, isRtl]);
47
+ const handleChange = useCallback((event, value) => {
48
+ onChange === null || onChange === void 0 ? void 0 : onChange(event, Array.isArray(value) ? value[0] : value);
49
+ }, [onChange]);
50
+ const handleChangeCommitted = useCallback((event, value) => {
51
+ onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted(event, Array.isArray(value) ? value[0] : value);
52
+ }, [onChangeCommitted]);
53
+ return (React.createElement(Styled.SliderWrapper, { ref: wrapperRef, "$valueLabelSpace": valueLabelDisplay !== 'off' },
54
+ (label || helperText) && (React.createElement(Styled.TextWrapper, { htmlFor: id },
55
+ label && React.createElement(Styled.Title, { id: labelId }, label),
56
+ helperText && React.createElement(Styled.HelperText, { id: helperTextId }, helperText))),
57
+ React.createElement(Styled.SliderRow, { "$showMarkTicks": showMarkTicks, "$animate": animate, "$isRtl": isRtl },
58
+ iconStart && React.createElement(Styled.IconWrapper, { "aria-hidden": true }, iconStart),
59
+ React.createElement(ThemeProvider, { theme: theme },
60
+ React.createElement(Styled.MaterialSlider, Object.assign({}, rest, { valueLabelDisplay: valueLabelDisplay, onChange: handleChange, onChangeCommitted: handleChangeCommitted, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy || labelId, "data-test": dataTest, slotProps: Object.assign(Object.assign({}, slotProps), { input: Object.assign(Object.assign({ id, 'aria-describedby': ariaDescribedBy || helperTextId }, (dataTest ? { 'data-test': `${dataTest}-input` } : {})), (typeof (slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === 'object' ? slotProps.input : {})) }) }))),
61
+ iconEnd && React.createElement(Styled.IconWrapper, { "aria-hidden": true }, iconEnd))));
62
+ }
63
+ export default Slider;
@@ -0,0 +1,9 @@
1
+ export const VALUE_LABEL_DISPLAYS = {
2
+ AUTO: 'auto',
3
+ ON: 'on',
4
+ OFF: 'off',
5
+ };
6
+ export const VALUE_LABEL_DISPLAY_VALUES = Object.values(VALUE_LABEL_DISPLAYS);
7
+ export const DEFAULT_VALUE_LABEL_DISPLAY = VALUE_LABEL_DISPLAYS.AUTO;
8
+ export const DEFAULT_SHOW_MARK_TICKS = true;
9
+ export const DEFAULT_ANIMATE = true;
@@ -0,0 +1 @@
1
+ export { default as BBBSlider } from './component';
@@ -0,0 +1,138 @@
1
+ import { Slider } from '@mui/material';
2
+ import { styled as materialStyled } from '@mui/material/styles';
3
+ import styled from 'styled-components';
4
+ import { colorBrand1, colorNeutral3, colorWhite, colorShadowDefault, colorTextDefault, colorTextLight, colorIconDefault, colorBorderFocusRing, } from '../../stylesheets/palette';
5
+ import { fontSizeXSmall, fontSizeDefault, fontSizeBig, fontWeightDefault, fontWeightLight, } from '../../stylesheets/typography';
6
+ import { spacingXSmall, spacingSmall, spacingXLarge, borderRadiusSmall, } from '../../stylesheets/sizing';
7
+ const THUMB_SIZE = '1rem';
8
+ const TRACK_HEIGHT = '0.3125rem';
9
+ const MARK_SIZE = '0.25rem';
10
+ const ICON_SIZE = '1.5rem';
11
+ export const SliderWrapper = styled.div `
12
+ display: flex;
13
+ flex-direction: column;
14
+ width: 100%;
15
+
16
+ ${({ $valueLabelSpace }) => $valueLabelSpace && `
17
+ gap: ${spacingXLarge};
18
+ `}
19
+ `;
20
+ export const TextWrapper = styled.label `
21
+ display: flex;
22
+ flex-direction: column;
23
+ cursor: pointer;
24
+ `;
25
+ export const Title = styled.span `
26
+ color: ${colorTextDefault};
27
+ font-size: ${fontSizeBig};
28
+ font-weight: ${fontWeightLight};
29
+ `;
30
+ export const HelperText = styled.span `
31
+ color: ${colorTextLight};
32
+ font-size: ${fontSizeDefault};
33
+ font-weight: ${fontWeightLight};
34
+ `;
35
+ export const SliderRow = styled.div `
36
+ display: flex;
37
+ align-items: center;
38
+ gap: ${spacingSmall};
39
+ width: 100%;
40
+
41
+ ${({ $showMarkTicks }) => !$showMarkTicks && `
42
+ & .MuiSlider-mark {
43
+ display: none;
44
+ }
45
+ `}
46
+
47
+ ${({ $animate }) => !$animate && `
48
+ & .MuiSlider-thumb,
49
+ & .MuiSlider-track,
50
+ & .MuiSlider-valueLabel {
51
+ transition: none;
52
+ }
53
+
54
+ & .MuiSlider-thumb:hover:not(.Mui-focusVisible),
55
+ & .MuiSlider-thumb.Mui-active:not(.Mui-focusVisible) {
56
+ box-shadow: 0 2px 4px 0 ${colorShadowDefault};
57
+ }
58
+ `}
59
+
60
+ ${({ $isRtl }) => $isRtl && `
61
+ /* MUI only mirrors right:-anchored positioning under RTL, not the LTR transforms paired
62
+ with it (that half normally comes from stylis-plugin-rtl, which this library can't add) */
63
+ && .MuiSlider-thumb {
64
+ transform: translate(50%, -50%);
65
+ }
66
+
67
+ && .MuiSlider-mark {
68
+ transform: translate(1px, -50%);
69
+ }
70
+
71
+ && .MuiSlider-markLabel {
72
+ transform: translateX(50%);
73
+ }
74
+ `}
75
+ `;
76
+ export const IconWrapper = styled.span `
77
+ display: flex;
78
+ align-items: center;
79
+ color: ${colorIconDefault};
80
+ font-size: ${ICON_SIZE};
81
+ `;
82
+ export const MaterialSlider = materialStyled(Slider)({
83
+ color: colorBrand1,
84
+ height: TRACK_HEIGHT,
85
+ '& .MuiSlider-rail': {
86
+ backgroundColor: 'currentColor',
87
+ opacity: 0.38,
88
+ },
89
+ '& .MuiSlider-track': {
90
+ border: '1px solid currentColor',
91
+ backgroundColor: colorBrand1,
92
+ },
93
+ '& .MuiSlider-thumb': {
94
+ height: THUMB_SIZE,
95
+ width: THUMB_SIZE,
96
+ backgroundColor: 'currentColor',
97
+ boxShadow: `0 2px 4px 0 ${colorShadowDefault}`,
98
+ '&:hover, &.Mui-focusVisible': {
99
+ boxShadow: `0 0 0 0.5rem ${colorBorderFocusRing}`,
100
+ },
101
+ '&.Mui-active': {
102
+ boxShadow: `0 0 0 0.875rem ${colorBorderFocusRing}`,
103
+ },
104
+ },
105
+ '& .MuiSlider-mark': {
106
+ width: MARK_SIZE,
107
+ height: MARK_SIZE,
108
+ borderRadius: '50%',
109
+ backgroundColor: colorNeutral3,
110
+ '&.MuiSlider-markActive': {
111
+ backgroundColor: colorWhite,
112
+ },
113
+ },
114
+ '& .MuiSlider-markLabel': {
115
+ color: colorTextLight,
116
+ fontSize: fontSizeXSmall,
117
+ // RTL: resolve each label's own direction so a leading minus sign doesn't get reordered
118
+ unicodeBidi: 'plaintext',
119
+ },
120
+ '& .MuiSlider-valueLabel': {
121
+ backgroundColor: colorTextDefault,
122
+ color: colorWhite,
123
+ fontSize: fontSizeXSmall,
124
+ fontWeight: fontWeightDefault,
125
+ borderRadius: borderRadiusSmall,
126
+ padding: `${spacingXSmall} ${spacingSmall}`,
127
+ '& .MuiSlider-valueLabelLabel': {
128
+ // RTL: resolve each label's own direction so a leading minus sign doesn't get reordered
129
+ unicodeBidi: 'plaintext',
130
+ },
131
+ },
132
+ '&.Mui-disabled': {
133
+ color: colorNeutral3,
134
+ '& .MuiSlider-track': {
135
+ backgroundColor: colorNeutral3,
136
+ },
137
+ },
138
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -20,16 +20,30 @@ 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 } = _a, rest = __rest(_a, ["label", "helperText", "textPosition", "onChange", "ariaLabel", "ariaLabelledBy", "ariaDescribedBy", "id"]);
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"]);
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 ariaLabelledByValue = ariaLabel ? undefined : ariaLabelledBy || labelId;
29
+ // Without a name source, the <label htmlFor> names the input from the helper text,
30
+ // so it can't also be the description.
31
+ const hasNameSource = !!ariaLabel || !!ariaLabelledByValue;
32
+ const a11yInputProps = {
33
+ role: 'switch',
34
+ 'aria-label': ariaLabel,
35
+ 'aria-labelledby': ariaLabelledByValue,
36
+ 'aria-describedby': ariaDescribedBy || (hasNameSource ? helperTextId : undefined),
37
+ };
38
+ const _b = slotProps !== null && slotProps !== void 0 ? slotProps : {}, { input: consumerInputSlotProps } = _b, otherSlotProps = __rest(_b, ["input"]);
39
+ const inputSlotProps = typeof consumerInputSlotProps === 'function'
40
+ ? (ownerState) => (Object.assign(Object.assign({}, a11yInputProps), consumerInputSlotProps(ownerState)))
41
+ : Object.assign(Object.assign({}, a11yInputProps), consumerInputSlotProps);
28
42
  return (React.createElement(Styled.ToggleWrapper, { "$textPosition": textPosition },
29
43
  (label || helperText) && (React.createElement(Styled.TextWrapper, { "$textPosition": textPosition, htmlFor: id, "$hasLabel": !!label, "$hasHelperText": !!helperText },
30
44
  label && React.createElement(Styled.Title, { id: labelId }, label),
31
45
  helperText && React.createElement(Styled.HelperText, { id: helperTextId }, helperText))),
32
46
  React.createElement(Styled.ToggleSwitchWrapper, null,
33
- React.createElement(Styled.MaterialToggle, Object.assign({}, rest, { id: id, onChange: onChange, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy || labelId, "aria-describedby": ariaDescribedBy || helperTextId })))));
47
+ React.createElement(Styled.MaterialToggle, Object.assign({}, rest, { id: id, onChange: onChange, slotProps: Object.assign(Object.assign({}, otherSlotProps), { input: inputSlotProps }) })))));
34
48
  }
35
49
  export default Toggle;
@@ -1,4 +1,5 @@
1
1
  export { BBBAccordion } from './Accordion';
2
+ export { BBBAvatar } from './Avatar';
2
3
  export { BBButton } from './Button';
3
4
  export { BBBCheckbox } from './Checkbox';
4
5
  export { BBBDivider } from './Divider';
@@ -9,6 +10,7 @@ export { BBBNavigation } from './Navigation';
9
10
  export { BBBScrollArea } from './ScrollArea';
10
11
  export { BBBSearch } from './Search';
11
12
  export { BBBSelect } from './Select';
13
+ export { BBBSlider } from './Slider';
12
14
  export { BBBSpinner } from './Spinner';
13
15
  export { BBBTextAreaInput } from './TextAreaInput';
14
16
  export { BBBTextInput } from './TextInput';