@bigbluebutton/bbb-ui-components-react 0.5.0 → 0.7.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 +38 -10
- package/dist/components/Accordion.js +57 -1
- package/dist/components/Button.js +144 -1
- package/dist/components/Checkbox.js +20 -1
- package/dist/components/Divider.js +9 -1
- package/dist/components/Hint.js +51 -1
- package/dist/components/Input.js +220 -0
- package/dist/components/Modal.js +222 -1
- package/dist/components/Navigation.js +74 -1
- package/dist/components/ScrollArea.js +42 -0
- package/dist/components/Search.js +130 -1
- package/dist/components/Select.js +46 -1
- package/dist/components/Spinner.js +34 -1
- package/dist/components/TextAreaInput.js +28 -1
- package/dist/components/TextInput.js +52 -1
- package/dist/components/Toggle.js +42 -1
- package/dist/components/Typography.js +42 -1
- package/dist/components/colors.js +1 -0
- package/dist/components/index.js +789 -1
- package/dist/esm/components/Accordion/component.js +8 -9
- package/dist/esm/components/Accordion/constants.js +10 -4
- package/dist/esm/components/Accordion/styles.js +63 -17
- package/dist/esm/components/Button/component.js +52 -35
- package/dist/esm/components/Button/constants.js +21 -20
- package/dist/esm/components/Button/styles.js +187 -45
- package/dist/esm/components/Checkbox/component.js +3 -14
- package/dist/esm/components/Checkbox/constants.js +3 -3
- package/dist/esm/components/Checkbox/styles.js +23 -9
- package/dist/esm/components/Divider/styles.js +10 -7
- package/dist/esm/components/Hint/component.js +16 -16
- package/dist/esm/components/Hint/constants.js +3 -3
- package/dist/esm/components/Hint/styles.js +58 -13
- package/dist/esm/components/Input/component.js +111 -0
- package/dist/esm/components/Input/index.js +1 -0
- package/dist/esm/components/Input/styles.js +89 -0
- package/dist/esm/components/Input/types.js +1 -0
- package/dist/esm/components/Modal/component.js +8 -19
- package/dist/esm/components/Modal/styles.js +42 -20
- package/dist/esm/components/Navigation/component.js +3 -4
- package/dist/esm/components/Navigation/styles.js +36 -12
- 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/component.js +16 -17
- package/dist/esm/components/Search/styles.js +103 -14
- package/dist/esm/components/Select/component.js +5 -16
- package/dist/esm/components/Select/styles.js +51 -11
- package/dist/esm/components/Spinner/component.js +1 -2
- package/dist/esm/components/Spinner/styles.js +39 -29
- package/dist/esm/components/TextAreaInput/component.js +4 -15
- package/dist/esm/components/TextAreaInput/styles.js +29 -7
- package/dist/esm/components/TextInput/component.js +2 -13
- package/dist/esm/components/TextInput/styles.js +58 -16
- package/dist/esm/components/Toggle/component.js +6 -17
- package/dist/esm/components/Toggle/constants.js +3 -3
- package/dist/esm/components/Toggle/styles.js +88 -72
- package/dist/esm/components/Typography/component.js +3 -14
- package/dist/esm/components/Typography/constants.js +1 -1
- package/dist/esm/components/Typography/styles.js +50 -17
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/stylesheets/colors.js +57 -0
- package/dist/esm/stylesheets/palette.js +55 -0
- package/dist/esm/stylesheets/sizing.js +9 -9
- package/dist/esm/stylesheets/typography.js +7 -7
- package/dist/types/components/Accordion/component.d.ts +1 -1
- package/dist/types/components/Accordion/constants.d.ts +7 -1
- package/dist/types/components/Accordion/styles.d.ts +2 -1
- package/dist/types/components/Accordion/types.d.ts +15 -1
- package/dist/types/components/Button/constants.d.ts +3 -2
- package/dist/types/components/Button/styles.d.ts +1 -0
- package/dist/types/components/Button/type.d.ts +42 -1
- package/dist/types/components/Checkbox/types.d.ts +4 -0
- package/dist/types/components/Hint/component.d.ts +2 -1
- package/dist/types/components/Hint/types.d.ts +9 -0
- package/dist/types/components/Input/component.d.ts +12 -0
- package/dist/types/components/Input/index.d.ts +1 -0
- package/dist/types/components/Input/styles.d.ts +6 -0
- package/dist/types/components/Input/types.d.ts +69 -0
- package/dist/types/components/Modal/types.d.ts +11 -0
- package/dist/types/components/Navigation/types.d.ts +9 -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/Search/types.d.ts +6 -24
- package/dist/types/components/Select/types.d.ts +4 -0
- package/dist/types/components/Spinner/types.d.ts +3 -0
- package/dist/types/components/TextAreaInput/types.d.ts +7 -0
- package/dist/types/components/TextInput/types.d.ts +3 -0
- package/dist/types/components/Toggle/types.d.ts +6 -0
- package/dist/types/components/Typography/types.d.ts +3 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/stylesheets/colors.d.ts +57 -0
- package/dist/types/stylesheets/{pallete.d.ts → palette.d.ts} +13 -9
- package/package.json +35 -2
- package/dist/esm/stylesheets/pallete.js +0 -46
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const LAYOUTS = {
|
|
2
2
|
RIGHT: 'right',
|
|
3
3
|
LEFT: 'left',
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export const LAYOUT_VALUES = Object.values(LAYOUTS);
|
|
6
|
+
export const DEFAULT_LAYOUT = LAYOUT_VALUES[0];
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import styled from 'styled-components';
|
|
6
2
|
import { Checkbox as MuiCheckbox } from '@mui/material';
|
|
7
|
-
import { colorTextDefault, colorBrand1 } from '../../stylesheets/
|
|
3
|
+
import { colorTextDefault, colorBrand1 } from '../../stylesheets/palette';
|
|
8
4
|
import { fontSizeDefault } from '../../stylesheets/typography';
|
|
9
5
|
import { spacingSmall } from '../../stylesheets/sizing';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export const Container = styled.div `
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: ${spacingSmall};
|
|
10
|
+
`;
|
|
11
|
+
export const Label = styled.label `
|
|
12
|
+
color: ${colorTextDefault};
|
|
13
|
+
font-size: ${fontSizeDefault};
|
|
14
|
+
font-style: normal;
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
line-height: normal;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
`;
|
|
19
|
+
export const StyledCheckbox = styled(MuiCheckbox) `
|
|
20
|
+
&.MuiCheckbox-root {
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.Mui-checked {
|
|
25
|
+
color: ${colorBrand1};
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import styled from 'styled-components';
|
|
6
|
-
import { colorBorderDefault } from '../../stylesheets/
|
|
7
|
-
export
|
|
8
|
-
|
|
2
|
+
import { colorBorderDefault } from '../../stylesheets/palette';
|
|
3
|
+
export const Divider = styled.hr `
|
|
4
|
+
width: 100%;
|
|
5
|
+
border-top: 0px;
|
|
6
|
+
border-right: 0px;
|
|
7
|
+
border-left: 0px;
|
|
8
|
+
border-image: initial;
|
|
9
|
+
border-bottom: 1px solid ${colorBorderDefault};
|
|
10
|
+
margin: 0px;
|
|
11
|
+
`;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
2
|
var t = {};
|
|
14
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -20,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
9
|
}
|
|
21
10
|
return t;
|
|
22
11
|
};
|
|
23
|
-
import React from 'react';
|
|
12
|
+
import React, { useState } from 'react';
|
|
24
13
|
import * as Styled from './styles';
|
|
25
14
|
import { MdClose, MdInfo } from 'react-icons/md';
|
|
26
15
|
/**
|
|
@@ -29,19 +18,30 @@ import { MdClose, MdInfo } from 'react-icons/md';
|
|
|
29
18
|
* This component provides a small contextual hint used to surface tips, short help text or dismissible messages.
|
|
30
19
|
* It can be displayed with a title, an icon, and a close button.
|
|
31
20
|
*
|
|
21
|
+
* Visibility is uncontrolled by default (the hint closes itself when its close button is clicked); pass `open` to control it externally instead.
|
|
32
22
|
*/
|
|
33
23
|
function Hint(_a) {
|
|
34
|
-
var
|
|
35
|
-
|
|
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;
|
|
35
|
+
const renderedLabel = React.createElement(Styled.Label, null,
|
|
36
36
|
label,
|
|
37
37
|
children);
|
|
38
|
-
return (React.createElement(Styled.Container,
|
|
38
|
+
return (React.createElement(Styled.Container, Object.assign({ role: "status", "aria-live": "polite", "aria-atomic": "true", "aria-label": title || label }, rest),
|
|
39
39
|
React.createElement(Styled.Header, null,
|
|
40
40
|
React.createElement(Styled.IconTextWrapper, null,
|
|
41
41
|
React.createElement(Styled.IconWrapper, { "aria-hidden": "true" }, icon),
|
|
42
42
|
title && React.createElement(Styled.Title, null, title),
|
|
43
43
|
!title && renderedLabel),
|
|
44
|
-
|
|
44
|
+
!hideCloseButton && (React.createElement(Styled.CloseButton, { type: "button", "aria-label": "Close", onClick: handleClose },
|
|
45
45
|
React.createElement(MdClose, { fontSize: "1rem" })))),
|
|
46
46
|
title && renderedLabel));
|
|
47
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const LAYOUTS = {
|
|
2
2
|
RIGHT: 'right',
|
|
3
3
|
LEFT: 'left',
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export const LAYOUT_VALUES = Object.values(LAYOUTS);
|
|
6
|
+
export const DEFAULT_LAYOUT = LAYOUT_VALUES[0];
|
|
@@ -1,16 +1,61 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import styled from 'styled-components';
|
|
6
|
-
import { colorTextDefault, colorBrand1, colorBackgroundLight, colorIconDefault, colorHoverLight } from '../../stylesheets/
|
|
2
|
+
import { colorTextDefault, colorBrand1, colorBackgroundLight, colorIconDefault, colorHoverLight } from '../../stylesheets/palette';
|
|
7
3
|
import { fontSizeDefault } from '../../stylesheets/typography';
|
|
8
4
|
import { borderRadiusSmall, spacingMedium, spacingSmall, spacingSmallMedium } from '../../stylesheets/sizing';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
export const Container = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: ${spacingSmall};
|
|
9
|
+
padding: ${spacingMedium};
|
|
10
|
+
background-color: ${colorBackgroundLight};
|
|
11
|
+
`;
|
|
12
|
+
export const IconTextWrapper = styled.div `
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
gap: ${spacingSmallMedium};
|
|
16
|
+
`;
|
|
17
|
+
export const Header = styled.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
`;
|
|
22
|
+
export const IconWrapper = styled.div `
|
|
23
|
+
color: ${colorBrand1};
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
`;
|
|
27
|
+
export const Title = styled.label `
|
|
28
|
+
color: ${colorTextDefault};
|
|
29
|
+
font-size: ${fontSizeDefault}
|
|
30
|
+
font-style: normal;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
line-height: normal;
|
|
33
|
+
`;
|
|
34
|
+
export const CloseButton = styled.button `
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
color: ${colorIconDefault};
|
|
39
|
+
background: transparent;
|
|
40
|
+
border: none;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
aspect-ratio: 1;
|
|
44
|
+
|
|
45
|
+
&&:hover,
|
|
46
|
+
&&:active {
|
|
47
|
+
background-color: ${colorHoverLight};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&&:focus {
|
|
51
|
+
outline: 2px solid ${colorBrand1};
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export const Label = styled.label `
|
|
55
|
+
color: ${colorTextDefault};
|
|
56
|
+
font-size: ${fontSizeDefault};
|
|
57
|
+
font-style: normal;
|
|
58
|
+
font-weight: 400;
|
|
59
|
+
line-height: normal;
|
|
60
|
+
border-radius: ${borderRadiusSmall};
|
|
61
|
+
`;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useId, useRef, useState, } from 'react';
|
|
2
|
+
import Button from '../Button/component';
|
|
3
|
+
import { SIZES, LAYOUTS } from '../Button/constants';
|
|
4
|
+
import * as Styled from './styles';
|
|
5
|
+
/**
|
|
6
|
+
* A labeled, auto-growing text field with an inline action button.
|
|
7
|
+
*
|
|
8
|
+
* Modeled after the core chat text input: unifies the recurring "text field +
|
|
9
|
+
* submit button" pattern used across chat, guest messages and breakouts.
|
|
10
|
+
* It supports both uncontrolled (default) and controlled usage, matching BBBSearch.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
function Input({ label, placeholder, value, onChange, onSubmit, buttonIcon, buttonLabel, buttonAriaLabel, buttonVariant = 'primary', dataTest, buttonDataTest, beforeButton, afterButton, submitOnEnter = true, showSentFeedback = false, sentFeedbackContent = 'Message sent', sentFeedbackDuration = 2000, disabled = false, error = false, helperText, minRows = 1, maxRows = 3, maxLength, autoFocus = false, inputRef, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) {
|
|
14
|
+
const isControlled = value !== undefined;
|
|
15
|
+
const [internalValue, setInternalValue] = useState('');
|
|
16
|
+
const currentValue = isControlled ? (value !== null && value !== void 0 ? value : '') : internalValue;
|
|
17
|
+
const generatedId = useId();
|
|
18
|
+
const fieldId = id !== null && id !== void 0 ? id : generatedId;
|
|
19
|
+
const internalRef = useRef(null);
|
|
20
|
+
const feedbackTimeoutRef = useRef(null);
|
|
21
|
+
const [isFeedbackVisible, setFeedbackVisible] = useState(false);
|
|
22
|
+
const setRefs = useCallback((node) => {
|
|
23
|
+
internalRef.current = node;
|
|
24
|
+
if (typeof inputRef === 'function') {
|
|
25
|
+
inputRef(node);
|
|
26
|
+
}
|
|
27
|
+
else if (inputRef && 'current' in inputRef) {
|
|
28
|
+
inputRef.current = node;
|
|
29
|
+
}
|
|
30
|
+
}, [inputRef]);
|
|
31
|
+
// Auto-grow the textarea between minRows and maxRows as content changes.
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const el = internalRef.current;
|
|
34
|
+
if (!el)
|
|
35
|
+
return;
|
|
36
|
+
el.style.height = 'auto';
|
|
37
|
+
const computedStyle = window.getComputedStyle(el);
|
|
38
|
+
const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
|
|
39
|
+
const verticalExtra = [
|
|
40
|
+
computedStyle.paddingTop,
|
|
41
|
+
computedStyle.paddingBottom,
|
|
42
|
+
computedStyle.borderTopWidth,
|
|
43
|
+
computedStyle.borderBottomWidth,
|
|
44
|
+
].reduce((sum, cssValue) => sum + (parseFloat(cssValue) || 0), 0);
|
|
45
|
+
const minHeight = lineHeight * minRows + verticalExtra;
|
|
46
|
+
const maxHeight = lineHeight * maxRows + verticalExtra;
|
|
47
|
+
const nextHeight = Math.min(Math.max(el.scrollHeight, minHeight), maxHeight);
|
|
48
|
+
el.style.height = `${nextHeight}px`;
|
|
49
|
+
el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';
|
|
50
|
+
}, [currentValue, minRows, maxRows]);
|
|
51
|
+
useEffect(() => () => {
|
|
52
|
+
if (feedbackTimeoutRef.current)
|
|
53
|
+
clearTimeout(feedbackTimeoutRef.current);
|
|
54
|
+
}, []);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (autoFocus && internalRef.current) {
|
|
57
|
+
internalRef.current.focus();
|
|
58
|
+
}
|
|
59
|
+
}, [autoFocus]);
|
|
60
|
+
const handleChange = useCallback((e) => {
|
|
61
|
+
const next = e.target.value;
|
|
62
|
+
if (isControlled) {
|
|
63
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
setInternalValue(next);
|
|
67
|
+
}
|
|
68
|
+
}, [isControlled, onChange]);
|
|
69
|
+
const submit = useCallback(() => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (disabled)
|
|
72
|
+
return;
|
|
73
|
+
const trimmed = currentValue.trim();
|
|
74
|
+
if (!trimmed)
|
|
75
|
+
return;
|
|
76
|
+
onSubmit(trimmed);
|
|
77
|
+
if (!isControlled) {
|
|
78
|
+
setInternalValue('');
|
|
79
|
+
}
|
|
80
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
81
|
+
if (showSentFeedback) {
|
|
82
|
+
setFeedbackVisible(true);
|
|
83
|
+
if (feedbackTimeoutRef.current)
|
|
84
|
+
clearTimeout(feedbackTimeoutRef.current);
|
|
85
|
+
feedbackTimeoutRef.current = setTimeout(() => setFeedbackVisible(false), sentFeedbackDuration);
|
|
86
|
+
}
|
|
87
|
+
}, [disabled, currentValue, onSubmit, isControlled, showSentFeedback, sentFeedbackDuration]);
|
|
88
|
+
const handleKeyDown = useCallback((e) => {
|
|
89
|
+
if (e.key === 'Enter' && !e.shiftKey && submitOnEnter) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
submit();
|
|
92
|
+
}
|
|
93
|
+
}, [submitOnEnter, submit]);
|
|
94
|
+
const showHelper = Boolean(helperText) || isFeedbackVisible;
|
|
95
|
+
const helperElementId = showHelper ? `${fieldId}-helper` : undefined;
|
|
96
|
+
const describedBy = [ariaDescribedBy, helperElementId].filter(Boolean).join(' ') || undefined;
|
|
97
|
+
// Icon-only submissions (the common case) use Button's `squared` layout — a
|
|
98
|
+
// compact, icon-only button matching the real chat input's send button shape.
|
|
99
|
+
// When a text label is provided instead, fall back to the default layout,
|
|
100
|
+
// which is the one that actually renders a label.
|
|
101
|
+
const button = buttonLabel ? (React.createElement(Button, { onClick: submit, disabled: disabled, size: SIZES.SMALL, variant: buttonVariant, dataTest: buttonDataTest, label: buttonLabel, ariaLabel: buttonAriaLabel, iconStart: buttonIcon })) : (React.createElement(Button, { layout: LAYOUTS.SQUARED, onClick: submit, disabled: disabled, variant: buttonVariant, dataTest: buttonDataTest, icon: buttonIcon, ariaLabel: buttonAriaLabel }));
|
|
102
|
+
return (React.createElement(Styled.Wrapper, null,
|
|
103
|
+
label && React.createElement(Styled.Label, { htmlFor: fieldId }, label),
|
|
104
|
+
React.createElement(Styled.FieldContainer, { "$disabled": disabled, "$error": error },
|
|
105
|
+
React.createElement(Styled.TextArea, { ref: setRefs, id: fieldId, rows: minRows, placeholder: placeholder, value: currentValue, onChange: handleChange, onKeyDown: handleKeyDown, disabled: disabled, maxLength: maxLength, "data-test": dataTest, "aria-label": ariaLabel, "aria-describedby": describedBy }),
|
|
106
|
+
beforeButton,
|
|
107
|
+
button,
|
|
108
|
+
afterButton),
|
|
109
|
+
showHelper && (React.createElement(Styled.HelperText, { id: helperElementId, "$success": isFeedbackVisible, "$error": !isFeedbackVisible && error, role: isFeedbackVisible ? 'status' : undefined, "aria-live": isFeedbackVisible ? 'polite' : undefined }, isFeedbackVisible ? sentFeedbackContent : helperText))));
|
|
110
|
+
}
|
|
111
|
+
export default Input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BBBInput } from './component';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { colorBorderDefault, colorBorderSelected, colorBorderError, colorBorderFocusRing, colorTextDefault, colorTextLight, colorError, colorSuccess, } from '../../stylesheets/palette';
|
|
3
|
+
import { borderRadiusDefault, spacingSmall, spacingMedium } from '../../stylesheets/sizing';
|
|
4
|
+
import { fontSizeSmall } from '../../stylesheets/typography';
|
|
5
|
+
export const Wrapper = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
width: 100%;
|
|
9
|
+
gap: ${spacingSmall};
|
|
10
|
+
`;
|
|
11
|
+
export const Label = styled.label `
|
|
12
|
+
color: ${colorTextDefault};
|
|
13
|
+
font-size: ${fontSizeSmall};
|
|
14
|
+
font-style: normal;
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
line-height: normal;
|
|
17
|
+
`;
|
|
18
|
+
export const FieldContainer = styled.div `
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
width: 100%;
|
|
22
|
+
padding: ${spacingSmall} ${spacingMedium};
|
|
23
|
+
gap: ${spacingSmall};
|
|
24
|
+
border-radius: ${borderRadiusDefault};
|
|
25
|
+
border: 1px solid ${colorBorderDefault};
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
29
|
+
|
|
30
|
+
&:focus-within {
|
|
31
|
+
border-color: ${colorBorderSelected};
|
|
32
|
+
box-shadow: 0 0 0 3px ${colorBorderFocusRing};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
${({ $error }) => $error &&
|
|
36
|
+
css `
|
|
37
|
+
border-color: ${colorBorderError};
|
|
38
|
+
`}
|
|
39
|
+
|
|
40
|
+
${({ $disabled }) => $disabled &&
|
|
41
|
+
css `
|
|
42
|
+
opacity: 0.5;
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
`}
|
|
46
|
+
`;
|
|
47
|
+
export const TextArea = styled.textarea `
|
|
48
|
+
flex: 1;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
resize: none;
|
|
51
|
+
border: none;
|
|
52
|
+
outline: none;
|
|
53
|
+
background: transparent;
|
|
54
|
+
color: ${colorTextDefault};
|
|
55
|
+
font-family: inherit;
|
|
56
|
+
font-size: ${fontSizeSmall};
|
|
57
|
+
line-height: 1.5;
|
|
58
|
+
padding: 0;
|
|
59
|
+
|
|
60
|
+
&::placeholder {
|
|
61
|
+
color: ${colorTextLight};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:disabled {
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[dir='rtl'] & {
|
|
69
|
+
text-align: right;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
export const HelperText = styled.div `
|
|
73
|
+
color: ${colorTextDefault};
|
|
74
|
+
font-size: ${fontSizeSmall};
|
|
75
|
+
font-style: normal;
|
|
76
|
+
font-weight: 400;
|
|
77
|
+
line-height: normal;
|
|
78
|
+
padding: 0 ${spacingMedium};
|
|
79
|
+
|
|
80
|
+
${({ $success }) => $success &&
|
|
81
|
+
css `
|
|
82
|
+
color: ${colorSuccess};
|
|
83
|
+
`}
|
|
84
|
+
|
|
85
|
+
${({ $error }) => $error &&
|
|
86
|
+
css `
|
|
87
|
+
color: ${colorError};
|
|
88
|
+
`}
|
|
89
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
2
|
var t = {};
|
|
14
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -34,19 +23,19 @@ import { BBButton } from '../Button';
|
|
|
34
23
|
* It supports accessibility, dividers, scrollable body, and sticky footer.
|
|
35
24
|
*
|
|
36
25
|
*/
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
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"]);
|
|
28
|
+
let _closeButtonDataTest = closeButtonDataTest;
|
|
40
29
|
if (testId && !closeButtonDataTest) {
|
|
41
|
-
_closeButtonDataTest =
|
|
30
|
+
_closeButtonDataTest = `${testId}-close-button`;
|
|
42
31
|
}
|
|
43
|
-
|
|
32
|
+
const renderFooter = useCallback((isSticky) => (React.createElement(React.Fragment, null,
|
|
44
33
|
showDividers && React.createElement(BBBDivider, null),
|
|
45
|
-
React.createElement(Styled.ModalFooter, { "$stickyFooter": isSticky }, footerContent)))
|
|
46
|
-
return (React.createElement(ReactModal,
|
|
34
|
+
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 }),
|
|
47
36
|
React.createElement(Styled.ModalHeader, null,
|
|
48
37
|
React.createElement(BBBTypography, { variant: "header" }, title),
|
|
49
|
-
React.createElement(BBButton,
|
|
38
|
+
React.createElement(BBButton, Object.assign({ layout: "circle", icon: React.createElement(MdClose, { size: "1.5rem" }), onClick: onRequestClose, variant: "subtle", ariaLabel: "close" }, (_closeButtonDataTest ? { dataTest: _closeButtonDataTest } : {})))),
|
|
50
39
|
showDividers && React.createElement(BBBDivider, null),
|
|
51
40
|
React.createElement(Styled.ModalScrollArea, { "$allowScroll": allowScroll },
|
|
52
41
|
React.createElement(Styled.ModalBodyContent, null, children),
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import styled from 'styled-components';
|
|
6
2
|
import { spacingLarge, spacingMedium, spacingSmallMedium, borderRadiusDefault } from '../../stylesheets/sizing';
|
|
7
|
-
import { colorWhite } from '../../stylesheets/
|
|
8
|
-
export
|
|
3
|
+
import { colorWhite, colorOverlay } from '../../stylesheets/palette';
|
|
4
|
+
export const modalStyles = {
|
|
9
5
|
overlay: {
|
|
10
6
|
position: 'fixed',
|
|
11
7
|
top: 0,
|
|
12
8
|
left: 0,
|
|
13
9
|
right: 0,
|
|
14
10
|
bottom: 0,
|
|
15
|
-
backgroundColor:
|
|
11
|
+
backgroundColor: colorOverlay,
|
|
16
12
|
zIndex: 100,
|
|
17
13
|
display: 'flex',
|
|
18
14
|
alignItems: 'center',
|
|
@@ -37,16 +33,42 @@ export var modalStyles = {
|
|
|
37
33
|
flexDirection: 'column',
|
|
38
34
|
},
|
|
39
35
|
};
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
export const ModalHeader = styled.div `
|
|
37
|
+
padding: ${spacingLarge} ${spacingLarge} ${spacingSmallMedium};
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: space-between;
|
|
40
|
+
align-items: center;
|
|
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
|
+
export const ModalScrollArea = styled.div `
|
|
51
|
+
flex-grow: 1;
|
|
52
|
+
overflow-y: ${({ $allowScroll }) => $allowScroll ? 'auto' : 'hidden'};
|
|
53
|
+
overflow-x: hidden;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
`;
|
|
57
|
+
export const ModalBodyContent = styled.div `
|
|
58
|
+
flex-grow: 1;
|
|
59
|
+
padding: 0 ${spacingLarge};
|
|
60
|
+
margin: ${spacingSmallMedium} 0 ${spacingSmallMedium};
|
|
61
|
+
`;
|
|
62
|
+
export const ModalFooter = styled.div `
|
|
63
|
+
padding: ${spacingSmallMedium} ${spacingLarge} ${spacingLarge};
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: flex-end;
|
|
66
|
+
gap: ${spacingMedium};
|
|
67
|
+
|
|
68
|
+
${({ $stickyFooter }) => $stickyFooter &&
|
|
69
|
+
`
|
|
70
|
+
position: sticky;
|
|
71
|
+
bottom: 0;
|
|
72
|
+
background-color: ${colorWhite};
|
|
73
|
+
`}
|
|
74
|
+
`;
|
|
@@ -7,10 +7,9 @@ import { BBBTypography } from '../Typography';
|
|
|
7
7
|
* It can be used for navigation actions within an application.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
function Navigation(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var iconToRender = icon || React.createElement(MdExpandCircleDown, { size: "1.5rem" });
|
|
10
|
+
function Navigation({ label, onClick, onKeyDown, icon, children, ariaLabel, ariaLabelledBy, ariaDescribedBy, dataTest, }) {
|
|
11
|
+
const isCustomIcon = !!icon;
|
|
12
|
+
const iconToRender = icon || React.createElement(MdExpandCircleDown, { size: "1.5rem" });
|
|
14
13
|
return (React.createElement(Styled.NavigationButton, { onClick: onClick, onKeyDown: onKeyDown, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "data-test": dataTest },
|
|
15
14
|
React.createElement(Styled.IconTextWrapper, null,
|
|
16
15
|
React.createElement(Styled.IconWrapper, { "$isCustomIcon": isCustomIcon }, iconToRender),
|
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import styled, { css } from 'styled-components';
|
|
6
2
|
import { borderRadiusSmall, spacingMedium } from '../../stylesheets/sizing';
|
|
7
|
-
import { colorBrand1 } from '../../stylesheets/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
import { colorBrand1 } from '../../stylesheets/palette';
|
|
4
|
+
export const NavigationButton = styled.button `
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
background: transparent;
|
|
10
|
+
border: none;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
margin: 1px; /* Adds margin to prevent outline from being cropped */
|
|
13
|
+
border-radius: ${borderRadiusSmall};
|
|
14
|
+
|
|
15
|
+
&:focus {
|
|
16
|
+
outline: 1px solid ${colorBrand1};
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
export const IconTextWrapper = styled.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
gap: ${spacingMedium};
|
|
25
|
+
`;
|
|
26
|
+
export const IconWrapper = styled.div `
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
color: ${colorBrand1};
|
|
31
|
+
|
|
32
|
+
${({ $isCustomIcon }) => !$isCustomIcon && css `
|
|
33
|
+
transform: rotate(90deg);
|
|
34
|
+
[dir="rtl"] & {
|
|
35
|
+
transform: rotate(-90deg);
|
|
36
|
+
}
|
|
37
|
+
`}
|
|
38
|
+
`;
|
|
@@ -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;
|