@bigbluebutton/bbb-ui-components-react 0.6.0 → 0.8.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 +30 -0
- package/dist/components/Accordion.js +7 -3
- package/dist/components/Avatar.js +30 -0
- package/dist/components/Button.js +16 -19
- package/dist/components/Checkbox.js +4 -4
- package/dist/components/Hint.js +2 -2
- package/dist/components/Input.js +22 -25
- package/dist/components/Modal.js +35 -45
- package/dist/components/ScrollArea.js +42 -0
- package/dist/components/Search.js +1 -1
- package/dist/components/Slider.js +35 -0
- package/dist/components/TextAreaInput.js +8 -3
- package/dist/components/Toggle.js +5 -5
- package/dist/components/colors.js +1 -0
- package/dist/components/index.js +353 -250
- package/dist/esm/components/Accordion/component.js +3 -3
- package/dist/esm/components/Accordion/constants.js +7 -1
- package/dist/esm/components/Accordion/styles.js +5 -0
- package/dist/esm/components/Avatar/component.js +38 -0
- package/dist/esm/components/Avatar/constants.js +13 -0
- package/dist/esm/components/Avatar/index.js +1 -0
- package/dist/esm/components/Avatar/styles.js +42 -0
- package/dist/esm/components/Avatar/types.js +1 -0
- package/dist/esm/components/Button/constants.js +4 -2
- package/dist/esm/components/Button/styles.js +15 -12
- package/dist/esm/components/Checkbox/component.js +7 -5
- package/dist/esm/components/Hint/component.js +14 -3
- package/dist/esm/components/Input/styles.js +2 -2
- package/dist/esm/components/Modal/component.js +2 -2
- package/dist/esm/components/Modal/styles.js +2 -10
- package/dist/esm/components/ScrollArea/component.js +15 -0
- package/dist/esm/components/ScrollArea/constants.js +3 -0
- package/dist/esm/components/ScrollArea/index.js +1 -0
- package/dist/esm/components/ScrollArea/styles.js +69 -0
- package/dist/esm/components/ScrollArea/types.js +1 -0
- package/dist/esm/components/Search/styles.js +2 -2
- package/dist/esm/components/Slider/component.js +63 -0
- package/dist/esm/components/Slider/constants.js +9 -0
- package/dist/esm/components/Slider/index.js +1 -0
- package/dist/esm/components/Slider/styles.js +138 -0
- package/dist/esm/components/Slider/types.js +1 -0
- package/dist/esm/components/TextAreaInput/styles.js +7 -2
- package/dist/esm/components/Toggle/styles.js +3 -3
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/stylesheets/colors.js +60 -0
- package/dist/esm/stylesheets/palette.js +8 -0
- package/dist/esm/stylesheets/sizing.js +1 -0
- package/dist/types/components/Accordion/component.d.ts +1 -1
- package/dist/types/components/Accordion/constants.d.ts +8 -2
- package/dist/types/components/Accordion/styles.d.ts +2 -1
- package/dist/types/components/Accordion/types.d.ts +7 -1
- package/dist/types/components/Avatar/component.d.ts +12 -0
- package/dist/types/components/Avatar/constants.d.ts +8 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/styles.d.ts +3 -0
- package/dist/types/components/Avatar/types.d.ts +26 -0
- package/dist/types/components/Button/constants.d.ts +3 -3
- package/dist/types/components/Button/type.d.ts +2 -1
- package/dist/types/components/Checkbox/component.d.ts +1 -1
- package/dist/types/components/Checkbox/types.d.ts +2 -0
- package/dist/types/components/Hint/component.d.ts +2 -1
- package/dist/types/components/Hint/types.d.ts +6 -2
- package/dist/types/components/Modal/styles.d.ts +0 -1
- package/dist/types/components/Modal/types.d.ts +2 -0
- package/dist/types/components/ScrollArea/component.d.ts +11 -0
- package/dist/types/components/ScrollArea/constants.d.ts +3 -0
- package/dist/types/components/ScrollArea/index.d.ts +1 -0
- package/dist/types/components/ScrollArea/styles.d.ts +2 -0
- package/dist/types/components/ScrollArea/types.d.ts +37 -0
- package/dist/types/components/Slider/component.d.ts +11 -0
- package/dist/types/components/Slider/constants.d.ts +9 -0
- package/dist/types/components/Slider/index.d.ts +1 -0
- package/dist/types/components/Slider/styles.d.ts +8 -0
- package/dist/types/components/Slider/types.d.ts +46 -0
- package/dist/types/components/Toggle/constants.d.ts +2 -2
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stylesheets/colors.d.ts +60 -0
- package/dist/types/stylesheets/palette.d.ts +5 -0
- package/dist/types/stylesheets/sizing.d.ts +1 -0
- package/package.json +41 -1
|
@@ -3,7 +3,7 @@ import * as Styled from './styles';
|
|
|
3
3
|
import { MdExpandMore } from 'react-icons/md';
|
|
4
4
|
import Tippy from '@tippyjs/react';
|
|
5
5
|
import 'tippy.js/dist/tippy.css';
|
|
6
|
-
import { DEFAULT_TOOLTIP_PLACEMENT } from './constants';
|
|
6
|
+
import { DEFAULT_TOOLTIP_PLACEMENT, DEFAULT_BUTTON_HEADER_POSITION } from './constants';
|
|
7
7
|
/**
|
|
8
8
|
* A customizable Accordion component that allows expanding and collapsing content.
|
|
9
9
|
*
|
|
@@ -11,7 +11,7 @@ import { DEFAULT_TOOLTIP_PLACEMENT } from './constants';
|
|
|
11
11
|
* with a smooth animation. It also supports an optional tooltip on the header.
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
|
-
function Accordion({ title, tooltipLabel = undefined, tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT, ariaLabel, ariaLabelledBy, ariaDescribedBy, buttonHeader = null, children, }) {
|
|
14
|
+
function Accordion({ title, tooltipLabel = undefined, tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT, ariaLabel, ariaLabelledBy, ariaDescribedBy, buttonHeader = null, buttonHeaderPosition = DEFAULT_BUTTON_HEADER_POSITION, children, }) {
|
|
15
15
|
var _a;
|
|
16
16
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
17
17
|
const contentRef = useRef(null);
|
|
@@ -20,7 +20,7 @@ function Accordion({ title, tooltipLabel = undefined, tooltipPlacement = DEFAULT
|
|
|
20
20
|
React.createElement(Styled.ExpandIcon, { "$expanded": isExpanded },
|
|
21
21
|
React.createElement(MdExpandMore, null)),
|
|
22
22
|
React.createElement(Styled.TitleText, null, title),
|
|
23
|
-
buttonHeader)));
|
|
23
|
+
React.createElement(Styled.ButtonHeaderWrapper, { "$position": buttonHeaderPosition }, buttonHeader))));
|
|
24
24
|
return (React.createElement(React.Fragment, null,
|
|
25
25
|
tooltipLabel ? (React.createElement(Tippy, { content: tooltipLabel, placement: tooltipPlacement }, expandButton)) : (expandButton),
|
|
26
26
|
React.createElement(Styled.AccordionContent, { ref: contentRef, "$expanded": isExpanded, "$scrollHeight": ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) || 0 }, children)));
|
|
@@ -6,4 +6,10 @@ const TOOLTIP_PLACEMENTS = {
|
|
|
6
6
|
};
|
|
7
7
|
const TOOLTIP_PLACEMENT_VALUES = Object.values(TOOLTIP_PLACEMENTS);
|
|
8
8
|
const DEFAULT_TOOLTIP_PLACEMENT = TOOLTIP_PLACEMENTS.TOP;
|
|
9
|
-
|
|
9
|
+
const BUTTON_HEADER_POSITIONS = {
|
|
10
|
+
LEFT: 'left',
|
|
11
|
+
RIGHT: 'right',
|
|
12
|
+
};
|
|
13
|
+
const BUTTON_HEADER_POSITION_VALUES = Object.values(BUTTON_HEADER_POSITIONS);
|
|
14
|
+
const DEFAULT_BUTTON_HEADER_POSITION = BUTTON_HEADER_POSITIONS.LEFT;
|
|
15
|
+
export { TOOLTIP_PLACEMENTS, TOOLTIP_PLACEMENT_VALUES, DEFAULT_TOOLTIP_PLACEMENT, BUTTON_HEADER_POSITIONS, BUTTON_HEADER_POSITION_VALUES, DEFAULT_BUTTON_HEADER_POSITION, };
|
|
@@ -46,6 +46,11 @@ export const ExpandIcon = styled.div `
|
|
|
46
46
|
filter: brightness(0.9);
|
|
47
47
|
}
|
|
48
48
|
`;
|
|
49
|
+
export const ButtonHeaderWrapper = styled.span `
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
margin-left: ${({ $position }) => ($position === 'right' ? 'auto' : '0')};
|
|
53
|
+
`;
|
|
49
54
|
export const TitleText = styled.span `
|
|
50
55
|
font-size: ${fontSizeDefault};
|
|
51
56
|
font-weight: 400;
|
|
@@ -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,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,
|
|
2
|
+
import { spacingSmall, spacingSmallMedium, spacingMedium, spacingXLarge, spacingXXLarge, } from '../../stylesheets/sizing';
|
|
3
3
|
const VARIANTS = {
|
|
4
4
|
PRIMARY: 'primary',
|
|
5
5
|
SECONDARY: 'secondary',
|
|
@@ -167,9 +167,11 @@ const CSS_COLOR_PROPERTIES_DISABLED = {
|
|
|
167
167
|
const CSS_SIZE_PROPERTIES = {
|
|
168
168
|
sm: {
|
|
169
169
|
padding: `${spacingSmall} ${spacingSmallMedium}`,
|
|
170
|
+
iconBoxSize: spacingXLarge,
|
|
170
171
|
},
|
|
171
172
|
md: {
|
|
172
|
-
padding: spacingMedium
|
|
173
|
+
padding: spacingMedium,
|
|
174
|
+
iconBoxSize: spacingXXLarge,
|
|
173
175
|
},
|
|
174
176
|
};
|
|
175
177
|
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, };
|
|
@@ -89,26 +89,29 @@ const stackedLayoutStyles = css `
|
|
|
89
89
|
justify-content: center;
|
|
90
90
|
align-items: center;
|
|
91
91
|
`;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
117
|
display: inline-flex;
|
|
@@ -22,15 +22,17 @@ 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
|
|
27
|
-
const
|
|
25
|
+
var { label, layout = DEFAULT_LAYOUT, round = false, ariaLabel, id, dataTest, inputProps } = _a, props = __rest(_a, ["label", "layout", "round", "ariaLabel", "id", "dataTest", "inputProps"]);
|
|
26
|
+
const generatedId = useId();
|
|
27
|
+
const checkboxId = id !== null && id !== void 0 ? id : generatedId;
|
|
28
|
+
const mergedInputProps = Object.assign({ 'data-test': dataTest }, inputProps);
|
|
29
|
+
const checkbox = (React.createElement(Styled.StyledCheckbox, Object.assign({}, props, { id: checkboxId, "aria-label": ariaLabel, icon: round ? React.createElement(RadioButtonUnchecked, null) : undefined, checkedIcon: round ? React.createElement(RadioButtonChecked, null) : undefined, inputProps: mergedInputProps })));
|
|
28
30
|
if (!label) {
|
|
29
31
|
return checkbox;
|
|
30
32
|
}
|
|
31
33
|
return (React.createElement(Styled.Container, null,
|
|
32
|
-
layout === LAYOUTS.LEFT && React.createElement(Styled.Label, { htmlFor:
|
|
34
|
+
layout === LAYOUTS.LEFT && React.createElement(Styled.Label, { htmlFor: checkboxId }, label),
|
|
33
35
|
checkbox,
|
|
34
|
-
layout === LAYOUTS.RIGHT && React.createElement(Styled.Label, { htmlFor:
|
|
36
|
+
layout === LAYOUTS.RIGHT && React.createElement(Styled.Label, { htmlFor: checkboxId }, label)));
|
|
35
37
|
}
|
|
36
38
|
export default Checkbox;
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
13
|
import * as Styled from './styles';
|
|
14
14
|
import { MdClose, MdInfo } from 'react-icons/md';
|
|
15
15
|
/**
|
|
@@ -18,9 +18,20 @@ import { MdClose, MdInfo } from 'react-icons/md';
|
|
|
18
18
|
* This component provides a small contextual hint used to surface tips, short help text or dismissible messages.
|
|
19
19
|
* It can be displayed with a title, an icon, and a close button.
|
|
20
20
|
*
|
|
21
|
+
* Visibility is uncontrolled by default (the hint closes itself when its close button is clicked); pass `open` to control it externally instead.
|
|
21
22
|
*/
|
|
22
23
|
function Hint(_a) {
|
|
23
|
-
var { title, label, icon = React.createElement(MdInfo, { fontSize: "1rem" }), onRequestClose, children } = _a, rest = __rest(_a, ["title", "label", "icon", "onRequestClose", "children"]);
|
|
24
|
+
var { title, label, icon = React.createElement(MdInfo, { fontSize: "1rem" }), open, onRequestClose, hideCloseButton = false, children } = _a, rest = __rest(_a, ["title", "label", "icon", "open", "onRequestClose", "hideCloseButton", "children"]);
|
|
25
|
+
const isControlled = open !== undefined;
|
|
26
|
+
const [internalOpen, setInternalOpen] = useState(true);
|
|
27
|
+
const isOpen = isControlled ? open : internalOpen;
|
|
28
|
+
const handleClose = () => {
|
|
29
|
+
if (!isControlled)
|
|
30
|
+
setInternalOpen(false);
|
|
31
|
+
onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
|
|
32
|
+
};
|
|
33
|
+
if (!isOpen)
|
|
34
|
+
return null;
|
|
24
35
|
const renderedLabel = React.createElement(Styled.Label, null,
|
|
25
36
|
label,
|
|
26
37
|
children);
|
|
@@ -30,7 +41,7 @@ function Hint(_a) {
|
|
|
30
41
|
React.createElement(Styled.IconWrapper, { "aria-hidden": "true" }, icon),
|
|
31
42
|
title && React.createElement(Styled.Title, null, title),
|
|
32
43
|
!title && renderedLabel),
|
|
33
|
-
|
|
44
|
+
!hideCloseButton && (React.createElement(Styled.CloseButton, { type: "button", "aria-label": "Close", onClick: handleClose },
|
|
34
45
|
React.createElement(MdClose, { fontSize: "1rem" })))),
|
|
35
46
|
title && renderedLabel));
|
|
36
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { colorBorderDefault, colorBorderSelected, colorBorderError, colorTextDefault, colorTextLight, colorError, colorSuccess, } from '../../stylesheets/palette';
|
|
2
|
+
import { colorBorderDefault, colorBorderSelected, colorBorderError, colorBorderFocusRing, colorTextDefault, colorTextLight, colorError, colorSuccess, } from '../../stylesheets/palette';
|
|
3
3
|
import { borderRadiusDefault, spacingSmall, spacingMedium } from '../../stylesheets/sizing';
|
|
4
4
|
import { fontSizeSmall } from '../../stylesheets/typography';
|
|
5
5
|
export const Wrapper = styled.div `
|
|
@@ -29,7 +29,7 @@ export const FieldContainer = styled.div `
|
|
|
29
29
|
|
|
30
30
|
&:focus-within {
|
|
31
31
|
border-color: ${colorBorderSelected};
|
|
32
|
-
box-shadow: 0 0 0 3px
|
|
32
|
+
box-shadow: 0 0 0 3px ${colorBorderFocusRing};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
${({ $error }) => $error &&
|
|
@@ -24,7 +24,7 @@ import { BBButton } from '../Button';
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
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"]);
|
|
27
|
+
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
28
|
let _closeButtonDataTest = closeButtonDataTest;
|
|
29
29
|
if (testId && !closeButtonDataTest) {
|
|
30
30
|
_closeButtonDataTest = `${testId}-close-button`;
|
|
@@ -35,7 +35,7 @@ const Modal = (_a) => {
|
|
|
35
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 }),
|
|
36
36
|
React.createElement(Styled.ModalHeader, null,
|
|
37
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 } : {})))),
|
|
38
|
+
!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
39
|
showDividers && React.createElement(BBBDivider, null),
|
|
40
40
|
React.createElement(Styled.ModalScrollArea, { "$allowScroll": allowScroll },
|
|
41
41
|
React.createElement(Styled.ModalBodyContent, null, children),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { spacingLarge, spacingMedium, spacingSmallMedium, borderRadiusDefault } from '../../stylesheets/sizing';
|
|
3
|
-
import { colorWhite } from '../../stylesheets/palette';
|
|
3
|
+
import { colorWhite, colorOverlay } from '../../stylesheets/palette';
|
|
4
4
|
export const modalStyles = {
|
|
5
5
|
overlay: {
|
|
6
6
|
position: 'fixed',
|
|
@@ -8,7 +8,7 @@ export const modalStyles = {
|
|
|
8
8
|
left: 0,
|
|
9
9
|
right: 0,
|
|
10
10
|
bottom: 0,
|
|
11
|
-
backgroundColor:
|
|
11
|
+
backgroundColor: colorOverlay,
|
|
12
12
|
zIndex: 100,
|
|
13
13
|
display: 'flex',
|
|
14
14
|
alignItems: 'center',
|
|
@@ -39,14 +39,6 @@ export const ModalHeader = styled.div `
|
|
|
39
39
|
justify-content: space-between;
|
|
40
40
|
align-items: center;
|
|
41
41
|
`;
|
|
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;
|
|
49
|
-
`;
|
|
50
42
|
export const ModalScrollArea = styled.div `
|
|
51
43
|
flex-grow: 1;
|
|
52
44
|
overflow-y: ${({ $allowScroll }) => $allowScroll ? 'auto' : 'hidden'};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as Styled from './styles';
|
|
3
|
+
import { DEFAULT_VERTICAL_SCROLL, DEFAULT_HORIZONTAL_SCROLL, DEFAULT_FADE_EDGES } from './constants';
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper that applies standardized scrollbar styling to its content.
|
|
6
|
+
*
|
|
7
|
+
* Use it around any scrollable area (chat, lists, side panels) to get a consistent
|
|
8
|
+
* scrollbar look, with optional axis control, size capping, and edge fading.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
function ScrollArea({ children, verticalScroll = DEFAULT_VERTICAL_SCROLL, horizontalScroll = DEFAULT_HORIZONTAL_SCROLL, maxHeight, maxWidth, fadeEdges = DEFAULT_FADE_EDGES, fadeColor, paddingTop, paddingRight, paddingBottom, paddingLeft, }) {
|
|
12
|
+
const isScrollable = verticalScroll || horizontalScroll;
|
|
13
|
+
return (React.createElement(Styled.ScrollAreaWrapper, { "$verticalScroll": verticalScroll, "$horizontalScroll": horizontalScroll, "$maxHeight": maxHeight, "$maxWidth": maxWidth, "$fadeEdges": fadeEdges, "$fadeColor": fadeColor, "$paddingTop": paddingTop, "$paddingRight": paddingRight, "$paddingBottom": paddingBottom, "$paddingLeft": paddingLeft, tabIndex: isScrollable ? 0 : undefined }, children));
|
|
14
|
+
}
|
|
15
|
+
export default ScrollArea;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BBBScrollArea } from './component';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
const FADE_MASK_SIZE = '40px';
|
|
3
|
+
const FADE_SHADOW_SIZE = '14px';
|
|
4
|
+
const FADE_SHADOW_COLOR = 'rgba(0, 0, 0, .2)';
|
|
5
|
+
const verticalFadeLayers = (color) => [
|
|
6
|
+
{ image: `linear-gradient(${color} 30%, transparent)`, position: '0 0', size: `100% ${FADE_MASK_SIZE}`, attachment: 'local' },
|
|
7
|
+
{ image: `linear-gradient(transparent, ${color} 70%)`, position: '0 100%', size: `100% ${FADE_MASK_SIZE}`, attachment: 'local' },
|
|
8
|
+
{ image: `radial-gradient(farthest-side at 50% 0, ${FADE_SHADOW_COLOR}, transparent)`, position: '0 0', size: `100% ${FADE_SHADOW_SIZE}`, attachment: 'scroll' },
|
|
9
|
+
{ image: `radial-gradient(farthest-side at 50% 100%, ${FADE_SHADOW_COLOR}, transparent)`, position: '0 100%', size: `100% ${FADE_SHADOW_SIZE}`, attachment: 'scroll' },
|
|
10
|
+
];
|
|
11
|
+
const horizontalFadeLayers = (color) => [
|
|
12
|
+
{ image: `linear-gradient(to right, ${color} 30%, transparent)`, position: '0 0', size: `${FADE_MASK_SIZE} 100%`, attachment: 'local' },
|
|
13
|
+
{ image: `linear-gradient(to right, transparent, ${color} 70%)`, position: '100% 0', size: `${FADE_MASK_SIZE} 100%`, attachment: 'local' },
|
|
14
|
+
{ image: `radial-gradient(farthest-side at 0 50%, ${FADE_SHADOW_COLOR}, transparent)`, position: '0 0', size: `${FADE_SHADOW_SIZE} 100%`, attachment: 'scroll' },
|
|
15
|
+
{ image: `radial-gradient(farthest-side at 100% 50%, ${FADE_SHADOW_COLOR}, transparent)`, position: '100% 0', size: `${FADE_SHADOW_SIZE} 100%`, attachment: 'scroll' },
|
|
16
|
+
];
|
|
17
|
+
const fadeBackground = ({ $verticalScroll, $horizontalScroll, $fadeEdges, $fadeColor, }) => {
|
|
18
|
+
if (!$fadeEdges || !$fadeColor)
|
|
19
|
+
return '';
|
|
20
|
+
const layers = [
|
|
21
|
+
...($verticalScroll ? verticalFadeLayers($fadeColor) : []),
|
|
22
|
+
...($horizontalScroll ? horizontalFadeLayers($fadeColor) : []),
|
|
23
|
+
];
|
|
24
|
+
if (!layers.length)
|
|
25
|
+
return '';
|
|
26
|
+
return css `
|
|
27
|
+
background-image: ${layers.map((layer) => layer.image).join(', ')};
|
|
28
|
+
background-position: ${layers.map((layer) => layer.position).join(', ')};
|
|
29
|
+
background-size: ${layers.map((layer) => layer.size).join(', ')};
|
|
30
|
+
background-attachment: ${layers.map((layer) => layer.attachment).join(', ')};
|
|
31
|
+
background-repeat: no-repeat;
|
|
32
|
+
background-color: transparent;
|
|
33
|
+
`;
|
|
34
|
+
};
|
|
35
|
+
export const ScrollAreaWrapper = styled.div `
|
|
36
|
+
overflow-y: ${({ $verticalScroll }) => ($verticalScroll ? 'auto' : 'hidden')};
|
|
37
|
+
overflow-x: ${({ $horizontalScroll }) => ($horizontalScroll ? 'auto' : 'hidden')};
|
|
38
|
+
${({ $maxHeight }) => $maxHeight && css `max-height: ${$maxHeight};`}
|
|
39
|
+
${({ $maxWidth }) => $maxWidth && css `max-width: ${$maxWidth};`}
|
|
40
|
+
${({ $paddingTop }) => $paddingTop && css `padding-top: ${$paddingTop};`}
|
|
41
|
+
${({ $paddingRight }) => $paddingRight && css `padding-right: ${$paddingRight};`}
|
|
42
|
+
${({ $paddingBottom }) => $paddingBottom && css `padding-bottom: ${$paddingBottom};`}
|
|
43
|
+
${({ $paddingLeft }) => $paddingLeft && css `padding-left: ${$paddingLeft};`}
|
|
44
|
+
${fadeBackground}
|
|
45
|
+
|
|
46
|
+
&::-webkit-scrollbar {
|
|
47
|
+
width: 5px;
|
|
48
|
+
height: 5px;
|
|
49
|
+
}
|
|
50
|
+
&::-webkit-scrollbar-button {
|
|
51
|
+
width: 0;
|
|
52
|
+
height: 0;
|
|
53
|
+
}
|
|
54
|
+
&::-webkit-scrollbar-thumb {
|
|
55
|
+
background: rgba(0, 0, 0, .25);
|
|
56
|
+
border: none;
|
|
57
|
+
border-radius: 50px;
|
|
58
|
+
}
|
|
59
|
+
&::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .5); }
|
|
60
|
+
&::-webkit-scrollbar-thumb:active { background: rgba(0, 0, 0, .25); }
|
|
61
|
+
&::-webkit-scrollbar-track {
|
|
62
|
+
background: rgba(0, 0, 0, .25);
|
|
63
|
+
border: none;
|
|
64
|
+
border-radius: 50px;
|
|
65
|
+
}
|
|
66
|
+
&::-webkit-scrollbar-track:hover { background: rgba(0, 0, 0, .25); }
|
|
67
|
+
&::-webkit-scrollbar-track:active { background: rgba(0, 0, 0, .25); }
|
|
68
|
+
&::-webkit-scrollbar-corner { background: 0 0; }
|
|
69
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { colorBorderDefault, colorBorderSelected, colorTextDefault, colorTextLight, colorIconDefault, colorIconBlue, colorBrand1, } from '../../stylesheets/palette';
|
|
2
|
+
import { colorBorderDefault, colorBorderSelected, colorBorderFocusRing, colorTextDefault, colorTextLight, colorIconDefault, colorIconBlue, colorBrand1, } from '../../stylesheets/palette';
|
|
3
3
|
import { spacingSmall, spacingMedium, borderRadiusDefault, } from '../../stylesheets/sizing';
|
|
4
4
|
import { fontSizeSmall } from '../../stylesheets/typography';
|
|
5
5
|
export const Container = styled.div `
|
|
@@ -19,7 +19,7 @@ export const Container = styled.div `
|
|
|
19
19
|
|
|
20
20
|
&:focus-within {
|
|
21
21
|
border-color: ${colorBorderSelected};
|
|
22
|
-
box-shadow: 0 0 0 3px
|
|
22
|
+
box-shadow: 0 0 0 3px ${colorBorderFocusRing};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
${({ $disabled }) => $disabled &&
|
|
@@ -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';
|