@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
|
@@ -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,19 +11,18 @@ 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(
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var expandButton = (React.createElement(Styled.ExpandButton, { onClick: function () { return setIsExpanded(function (current) { return !current; }); }, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy },
|
|
14
|
+
function Accordion({ title, tooltipLabel = undefined, tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT, ariaLabel, ariaLabelledBy, ariaDescribedBy, buttonHeader = null, buttonHeaderPosition = DEFAULT_BUTTON_HEADER_POSITION, children, }) {
|
|
15
|
+
var _a;
|
|
16
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
17
|
+
const contentRef = useRef(null);
|
|
18
|
+
const expandButton = (React.createElement(Styled.ExpandButton, { onClick: () => setIsExpanded((current) => !current), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy },
|
|
20
19
|
React.createElement(Styled.ButtonContent, null,
|
|
21
20
|
React.createElement(Styled.ExpandIcon, { "$expanded": isExpanded },
|
|
22
21
|
React.createElement(MdExpandMore, null)),
|
|
23
22
|
React.createElement(Styled.TitleText, null, title),
|
|
24
|
-
buttonHeader)));
|
|
23
|
+
React.createElement(Styled.ButtonHeaderWrapper, { "$position": buttonHeaderPosition }, buttonHeader))));
|
|
25
24
|
return (React.createElement(React.Fragment, null,
|
|
26
25
|
tooltipLabel ? (React.createElement(Tippy, { content: tooltipLabel, placement: tooltipPlacement }, expandButton)) : (expandButton),
|
|
27
|
-
React.createElement(Styled.AccordionContent, { ref: contentRef, "$expanded": isExpanded, "$scrollHeight": ((
|
|
26
|
+
React.createElement(Styled.AccordionContent, { ref: contentRef, "$expanded": isExpanded, "$scrollHeight": ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) || 0 }, children)));
|
|
28
27
|
}
|
|
29
28
|
export default Accordion;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const TOOLTIP_PLACEMENTS = {
|
|
2
2
|
TOP: 'top',
|
|
3
3
|
BOTTOM: 'bottom',
|
|
4
4
|
LEFT: 'left',
|
|
5
5
|
RIGHT: 'right',
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const TOOLTIP_PLACEMENT_VALUES = Object.values(TOOLTIP_PLACEMENTS);
|
|
8
|
+
const DEFAULT_TOOLTIP_PLACEMENT = TOOLTIP_PLACEMENTS.TOP;
|
|
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, };
|
|
@@ -1,20 +1,66 @@
|
|
|
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 { colorBackgroundLight, colorBrand1, colorTextDefault, colorWhite } from '../../stylesheets/
|
|
2
|
+
import { colorBackgroundLight, colorBrand1, colorTextDefault, colorWhite } from '../../stylesheets/palette';
|
|
7
3
|
import { fontSizeDefault } from '../../stylesheets/typography';
|
|
8
4
|
import { borderRadiusDefault, spacingMedium, spacingSmall } from '../../stylesheets/sizing';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
export const ExpandButton = styled.button `
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
background: none;
|
|
9
|
+
border: none;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
padding: ${spacingSmall};
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
border-radius: ${borderRadiusDefault};
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
background: ${colorBackgroundLight};
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
export const ButtonContent = styled.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding: ${spacingSmall};
|
|
24
|
+
border-radius: ${borderRadiusDefault};
|
|
25
|
+
gap: ${spacingMedium};
|
|
26
|
+
`;
|
|
27
|
+
export const ExpandIcon = styled.div `
|
|
28
|
+
width: 1.375rem;
|
|
29
|
+
height: 1.375rem;
|
|
30
|
+
aspect-ratio: 1;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
transform: ${({ $expanded }) => ($expanded ? 'rotate(180deg)' : 'rotate(0deg)')};
|
|
35
|
+
transition: all 0.3s ease;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background-color: ${colorBrand1};
|
|
38
|
+
|
|
39
|
+
svg {
|
|
40
|
+
color: ${colorWhite};
|
|
41
|
+
font-size: 1.25rem;
|
|
42
|
+
transition: transform 0.3s ease;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
filter: brightness(0.9);
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
export const ButtonHeaderWrapper = styled.span `
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
margin-left: ${({ $position }) => ($position === 'right' ? 'auto' : '0')};
|
|
53
|
+
`;
|
|
54
|
+
export const TitleText = styled.span `
|
|
55
|
+
font-size: ${fontSizeDefault};
|
|
56
|
+
font-weight: 400;
|
|
57
|
+
color: ${colorTextDefault};
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
`;
|
|
61
|
+
export const AccordionContent = styled.div `
|
|
62
|
+
max-height: ${({ $expanded, $scrollHeight }) => $expanded ? `${$scrollHeight}px` : '0'};
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
transition: max-height 0.3s ease-in-out;
|
|
65
|
+
padding: 0px 1rem;
|
|
66
|
+
`;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
import React, { useId } from 'react';
|
|
13
|
-
import { MdSettings } from 'react-icons/md';
|
|
1
|
+
import React, { useCallback, useEffect, useId, useRef, useState, } from 'react';
|
|
2
|
+
import { MdSettings, MdCheckCircle } from 'react-icons/md';
|
|
14
3
|
import { DEFAULT_VARIANT, DEFAULT_COLOR, DEFAULT_SIZE, DEFAULT_LAYOUT, LAYOUTS, DEFAULT_TOOLTIP_PLACEMENT, } from './constants';
|
|
15
4
|
import * as Styled from './styles';
|
|
16
5
|
import Tippy from '@tippyjs/react';
|
|
@@ -24,46 +13,74 @@ import 'tippy.js/dist/tippy.css';
|
|
|
24
13
|
*
|
|
25
14
|
*/
|
|
26
15
|
function Button(props) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
17
|
+
const feedbackTimeoutRef = useRef(null);
|
|
18
|
+
const [isFeedbackVisible, setFeedbackVisible] = useState(false);
|
|
19
|
+
useEffect(() => () => {
|
|
20
|
+
if (feedbackTimeoutRef.current)
|
|
21
|
+
clearTimeout(feedbackTimeoutRef.current);
|
|
22
|
+
}, []);
|
|
23
|
+
const handleClick = useCallback((event) => {
|
|
24
|
+
onClick(event);
|
|
25
|
+
if (showFeedback) {
|
|
26
|
+
setFeedbackVisible(true);
|
|
27
|
+
if (feedbackTimeoutRef.current)
|
|
28
|
+
clearTimeout(feedbackTimeoutRef.current);
|
|
29
|
+
feedbackTimeoutRef.current = setTimeout(() => setFeedbackVisible(false), feedbackDuration);
|
|
30
|
+
}
|
|
31
|
+
}, [onClick, showFeedback, feedbackDuration]);
|
|
32
|
+
const accessibilityProps = {};
|
|
33
|
+
const generatedId = useId();
|
|
34
|
+
const defaultLabelId = `${id || generatedId}-label`;
|
|
35
|
+
// Only default aria-labelledby to defaultLabelId when an element with that id is
|
|
36
|
+
// actually rendered (stacked always renders ButtonText; default when labeled, or
|
|
37
|
+
// when the feedback content is taking the label's place). circle never renders a
|
|
38
|
+
// label element, so it must rely on aria-label instead — otherwise aria-labelledby
|
|
39
|
+
// would point at a non-existent id.
|
|
40
|
+
const hasRenderedLabelElement = layout === LAYOUTS.STACKED
|
|
41
|
+
|| (layout === LAYOUTS.DEFAULT && (Boolean(label) || isFeedbackVisible));
|
|
31
42
|
accessibilityProps['aria-label'] = ariaLabel || label;
|
|
32
|
-
|
|
43
|
+
if (ariaLabelledBy) {
|
|
44
|
+
accessibilityProps['aria-labelledby'] = ariaLabelledBy;
|
|
45
|
+
}
|
|
46
|
+
else if (hasRenderedLabelElement) {
|
|
47
|
+
accessibilityProps['aria-labelledby'] = defaultLabelId;
|
|
48
|
+
}
|
|
33
49
|
if (ariaDescribedBy)
|
|
34
50
|
accessibilityProps['aria-describedby'] = ariaDescribedBy;
|
|
35
|
-
|
|
36
|
-
if (props.layout === LAYOUTS.CIRCLE) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (React.createElement(Styled.Button,
|
|
51
|
+
const buttonElement = (() => {
|
|
52
|
+
if (props.layout === LAYOUTS.CIRCLE || props.layout === LAYOUTS.SQUARED) {
|
|
53
|
+
const { icon } = props;
|
|
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));
|
|
40
56
|
}
|
|
41
57
|
if (props.layout === LAYOUTS.STACKED) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return (React.createElement(Styled.ButtonWrapper, { "data-test":
|
|
45
|
-
React.createElement(Styled.Button,
|
|
58
|
+
const { icon, helperIcon = React.createElement(MdSettings, { fontSize: "small" }), hideHelperIcon = false, helperOnClick = null, } = props;
|
|
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 }),
|
|
46
62
|
!hideHelperIcon && (React.createElement(Styled.HelperIconContainer
|
|
47
63
|
// Add this property only when there is a onClick function for the auxiliary icon.
|
|
48
64
|
// It controls whether the auxiliary button is going to have an independent hover state.
|
|
49
|
-
,
|
|
50
|
-
if (
|
|
51
|
-
|
|
65
|
+
, Object.assign({}, (helperOnClick && { 'data-is-aux-icon': true }), (helperOnClick && { 'aria-label': accessibilityProps['aria-label'] + ' helper' }), (helperOnClick && { role: "button" }), { "$hover": helperOnClick !== null, "$color": color, "$variant": variant, onClick: (event) => {
|
|
66
|
+
if (helperOnClick) {
|
|
67
|
+
helperOnClick(event);
|
|
52
68
|
event.preventDefault();
|
|
53
69
|
event.stopPropagation();
|
|
54
70
|
}
|
|
55
71
|
} }),
|
|
56
72
|
React.createElement(Styled.HelperIcon, null, helperIcon))),
|
|
57
|
-
|
|
73
|
+
isFeedbackVisible ? (React.createElement(Styled.IconWrapper, null,
|
|
74
|
+
React.createElement(Styled.FeedbackContent, { role: "status", "aria-live": "polite" }, feedbackContent))) : (icon && React.createElement(Styled.IconWrapper, null, icon))),
|
|
58
75
|
React.createElement(Styled.ButtonText, { id: defaultLabelId }, label)));
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (React.createElement(Styled.Button,
|
|
77
|
+
const { iconStart, iconEnd } = props;
|
|
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,
|
|
63
80
|
iconStart && iconStart,
|
|
64
81
|
label && React.createElement("span", { id: defaultLabelId }, label),
|
|
65
82
|
children,
|
|
66
|
-
iconEnd && iconEnd));
|
|
83
|
+
iconEnd && iconEnd))));
|
|
67
84
|
})();
|
|
68
85
|
if (tooltipLabel) {
|
|
69
86
|
return (React.createElement(Tippy, { content: tooltipLabel, placement: tooltipPlacement }, buttonElement));
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { colorBrand1, colorHoverDark, colorWhite, colorError, colorBorderError, colorErrorDark, colorBackgroundWhite, colorBackgroundBlue, colorHoverLight, colorLightGray, colorNeutral3, colorBackgroundLight, colorBorderSelected, colorTextLight, colorIconDefault, colorGray, colorBrandAux, } from '../../stylesheets/
|
|
1
|
+
import { colorBrand1, colorHoverDark, colorWhite, colorError, colorBorderError, colorErrorDark, colorBackgroundWhite, colorBackgroundBlue, colorHoverLight, colorLightGray, colorNeutral3, colorBackgroundLight, colorBorderSelected, colorTextLight, colorIconDefault, colorGray, colorBrandAux, } from '../../stylesheets/palette';
|
|
2
2
|
import { spacingMedium, spacingSmall, spacingSmallMedium } from '../../stylesheets/sizing';
|
|
3
|
-
|
|
3
|
+
const VARIANTS = {
|
|
4
4
|
PRIMARY: 'primary',
|
|
5
5
|
SECONDARY: 'secondary',
|
|
6
6
|
TERTIARY: 'tertiary',
|
|
7
7
|
SUBTLE: 'subtle',
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const VARIANT_VALUES = Object.values(VARIANTS);
|
|
10
|
+
const DEFAULT_VARIANT = VARIANT_VALUES[0];
|
|
11
|
+
const COLORS = {
|
|
12
12
|
DEFAULT: 'default',
|
|
13
13
|
DANGER: 'danger',
|
|
14
14
|
NEUTRAL: 'neutral',
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const COLOR_VALUES = Object.values(COLORS);
|
|
17
|
+
const DEFAULT_COLOR = COLOR_VALUES[0];
|
|
18
|
+
const SIZES = {
|
|
19
19
|
MEDIUM: 'md',
|
|
20
20
|
SMALL: 'sm',
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const SIZE_VALUES = Object.values(SIZES);
|
|
23
|
+
const DEFAULT_SIZE = SIZE_VALUES[0];
|
|
24
|
+
const LAYOUTS = {
|
|
25
25
|
DEFAULT: 'default',
|
|
26
26
|
STACKED: 'stacked',
|
|
27
27
|
CIRCLE: 'circle',
|
|
28
|
+
SQUARED: 'squared',
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const LAYOUT_VALUES = Object.values(LAYOUTS);
|
|
31
|
+
const DEFAULT_LAYOUT = LAYOUT_VALUES[0];
|
|
32
|
+
const TOOLTIP_PLACEMENTS = {
|
|
32
33
|
TOP: 'top',
|
|
33
34
|
BOTTOM: 'bottom',
|
|
34
35
|
LEFT: 'left',
|
|
35
36
|
RIGHT: 'right',
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const TOOLTIP_PLACEMENT_VALUES = Object.values(TOOLTIP_PLACEMENTS);
|
|
39
|
+
const DEFAULT_TOOLTIP_PLACEMENT = TOOLTIP_PLACEMENTS.TOP;
|
|
40
|
+
const CSS_COLOR_PROPERTIES = {
|
|
40
41
|
primary: {
|
|
41
42
|
default: {
|
|
42
43
|
color: colorWhite,
|
|
@@ -157,15 +158,15 @@ var CSS_COLOR_PROPERTIES = {
|
|
|
157
158
|
},
|
|
158
159
|
},
|
|
159
160
|
};
|
|
160
|
-
|
|
161
|
+
const CSS_COLOR_PROPERTIES_DISABLED = {
|
|
161
162
|
color: colorNeutral3,
|
|
162
163
|
background: colorBackgroundLight,
|
|
163
164
|
border: false,
|
|
164
165
|
outline: colorNeutral3,
|
|
165
166
|
};
|
|
166
|
-
|
|
167
|
+
const CSS_SIZE_PROPERTIES = {
|
|
167
168
|
sm: {
|
|
168
|
-
padding:
|
|
169
|
+
padding: `${spacingSmall} ${spacingSmallMedium}`,
|
|
169
170
|
},
|
|
170
171
|
md: {
|
|
171
172
|
padding: spacingMedium
|
|
@@ -1,60 +1,202 @@
|
|
|
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 { CSS_COLOR_PROPERTIES, CSS_COLOR_PROPERTIES_DISABLED, CSS_SIZE_PROPERTIES, DEFAULT_COLOR, DEFAULT_SIZE, DEFAULT_VARIANT, VARIANTS, LAYOUTS, } from './constants';
|
|
7
|
-
import { borderRadiusDefault, spacingSmall, } from '../../stylesheets/sizing';
|
|
8
|
-
import { colorBorderDefault, colorTextDefault } from '../../stylesheets/
|
|
3
|
+
import { borderRadiusDefault, borderRadiusSmall, spacingSmall, } from '../../stylesheets/sizing';
|
|
4
|
+
import { colorBorderDefault, colorTextDefault } from '../../stylesheets/palette';
|
|
9
5
|
import { fontSizeSmall } from '../../stylesheets/typography';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
6
|
+
const commonButtonStyles = css `
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
user-select: none;
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
line-height: normal;
|
|
11
|
+
text-align: center;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
text-transform: none;
|
|
14
|
+
position: relative;
|
|
15
|
+
transition: opacity 0.2s ease-in-out;
|
|
16
|
+
|
|
17
|
+
${({ $size }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const safeSize = $size !== null && $size !== void 0 ? $size : DEFAULT_SIZE;
|
|
20
|
+
return `padding: ${((_a = CSS_SIZE_PROPERTIES[safeSize]) !== null && _a !== void 0 ? _a : CSS_SIZE_PROPERTIES[DEFAULT_SIZE]).padding};`;
|
|
21
|
+
}}
|
|
22
|
+
|
|
23
|
+
${({ $color, $variant }) => {
|
|
24
|
+
const safeColor = $color || DEFAULT_COLOR;
|
|
25
|
+
const safeVariant = $variant || DEFAULT_VARIANT;
|
|
26
|
+
const { color: contentColor, iconColor, background, border, hoverColor, hoverBackground, hoverBorder, outline, } = CSS_COLOR_PROPERTIES[safeVariant][safeColor];
|
|
27
|
+
return css `
|
|
28
|
+
& span {
|
|
29
|
+
color: ${contentColor};
|
|
30
|
+
}
|
|
31
|
+
${iconColor ? `color: ${iconColor}` : `color: ${contentColor}`};
|
|
32
|
+
${background && `background-color: ${background};`}
|
|
33
|
+
${border ? `border: 1px solid ${border};` : 'border: 1px solid transparent;'}
|
|
34
|
+
|
|
35
|
+
&&:hover:not(:has(> [data-is-aux-icon]:hover)),
|
|
36
|
+
&&:active {
|
|
37
|
+
color: ${hoverColor};
|
|
38
|
+
${hoverBackground && `background-color: ${hoverBackground};`}
|
|
39
|
+
${hoverBorder ? `border: 1px solid ${hoverBorder};` : 'border: 1px solid transparent;'}
|
|
40
|
+
}
|
|
41
|
+
&&:focus {
|
|
42
|
+
border: 1px solid transparent;
|
|
43
|
+
outline: 2px solid ${outline};
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
}}
|
|
47
|
+
|
|
48
|
+
${({ $variant }) => $variant === VARIANTS.SUBTLE &&
|
|
49
|
+
`
|
|
50
|
+
text-decoration: underline;
|
|
51
|
+
`}
|
|
52
|
+
|
|
53
|
+
${({ disabled }) => {
|
|
27
54
|
if (!disabled)
|
|
28
55
|
return null;
|
|
29
|
-
|
|
30
|
-
return css
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
const { color, background, border, outline } = CSS_COLOR_PROPERTIES_DISABLED;
|
|
57
|
+
return css `
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
& span {
|
|
61
|
+
color: ${color};
|
|
62
|
+
}
|
|
63
|
+
color: ${color};
|
|
64
|
+
${background ? `background-color: ${background}` : `background-color: none`};
|
|
65
|
+
border: ${border ? `1px solid ${border}` : 'none'};
|
|
66
|
+
|
|
67
|
+
&&:hover,
|
|
68
|
+
&&:active {
|
|
69
|
+
color: ${color};
|
|
70
|
+
${background ? `background-color: ${background}` : `background-color: none`};
|
|
71
|
+
border: ${border ? `1px solid ${border}` : 'none'};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&&:focus {
|
|
75
|
+
outline: 2px solid ${outline};
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
}}
|
|
79
|
+
`;
|
|
80
|
+
const stackedLayoutStyles = css `
|
|
81
|
+
width: 4.5rem;
|
|
82
|
+
height: 4.5rem;
|
|
83
|
+
border-radius: ${borderRadiusDefault} !important;
|
|
84
|
+
border: 1px solid ${colorBorderDefault} !important;
|
|
85
|
+
padding: ${spacingSmall} !important;
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
align-items: center;
|
|
91
|
+
`;
|
|
92
|
+
const circleLayoutStyles = css `
|
|
93
|
+
border-radius: 50%;
|
|
94
|
+
width: 3rem;
|
|
95
|
+
height: 3rem;
|
|
96
|
+
aspect-ratio: 1;
|
|
97
|
+
padding: 0;
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
align-items: center;
|
|
101
|
+
`;
|
|
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.
|
|
105
|
+
const squaredLayoutStyles = css `
|
|
106
|
+
border-radius: ${borderRadiusSmall};
|
|
107
|
+
aspect-ratio: 1;
|
|
108
|
+
padding: ${spacingSmall};
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
align-items: center;
|
|
112
|
+
`;
|
|
113
|
+
const defaultLayoutStyles = css `
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: ${spacingSmall};
|
|
118
|
+
border-radius: ${borderRadiusDefault};
|
|
119
|
+
`;
|
|
120
|
+
export const ButtonWrapper = styled.div `
|
|
121
|
+
${({ $layout }) => $layout === LAYOUTS.STACKED && `
|
|
122
|
+
width: 5rem;
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: ${spacingSmall};
|
|
126
|
+
align-items: center;
|
|
127
|
+
`}
|
|
128
|
+
`;
|
|
129
|
+
export const Button = styled.button `
|
|
130
|
+
${commonButtonStyles}
|
|
131
|
+
|
|
132
|
+
${({ $layout }) => {
|
|
41
133
|
switch ($layout) {
|
|
42
134
|
case LAYOUTS.STACKED:
|
|
43
135
|
return stackedLayoutStyles;
|
|
44
136
|
case LAYOUTS.CIRCLE:
|
|
45
137
|
return circleLayoutStyles;
|
|
138
|
+
case LAYOUTS.SQUARED:
|
|
139
|
+
return squaredLayoutStyles;
|
|
46
140
|
default:
|
|
47
141
|
return defaultLayoutStyles;
|
|
48
142
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
143
|
+
}}
|
|
144
|
+
`;
|
|
145
|
+
export const HelperIconContainer = styled.div `
|
|
146
|
+
${({ $hover, $variant, $color }) => {
|
|
52
147
|
if (!$hover)
|
|
53
148
|
return null;
|
|
54
|
-
return css
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
149
|
+
return css `
|
|
150
|
+
&&:hover,
|
|
151
|
+
&&:active {
|
|
152
|
+
${CSS_COLOR_PROPERTIES[$variant][$color].hoverBackground &&
|
|
153
|
+
`background-color: ${CSS_COLOR_PROPERTIES[$variant][$color].hoverBackground};`}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&&:focus {
|
|
157
|
+
outline: 1px solid ${CSS_COLOR_PROPERTIES[$variant][$color].outline};
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
}}
|
|
161
|
+
border-radius: 50%;
|
|
162
|
+
padding: 0.2rem;
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: 0.1rem;
|
|
165
|
+
right: 0.1rem;
|
|
166
|
+
& svg {
|
|
167
|
+
font-size: 1.25rem;
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
export const HelperIcon = styled.div `
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
`;
|
|
175
|
+
export const IconWrapper = styled.div `
|
|
176
|
+
display: flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
justify-content: center;
|
|
179
|
+
flex: 1;
|
|
180
|
+
|
|
181
|
+
> i {
|
|
182
|
+
font-size: 2rem;
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
export const FeedbackContent = styled.span `
|
|
186
|
+
display: inline-flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
gap: ${spacingSmall};
|
|
190
|
+
`;
|
|
191
|
+
export const ButtonText = styled.div `
|
|
192
|
+
color: ${colorTextDefault};
|
|
193
|
+
font-size: ${fontSizeSmall};
|
|
194
|
+
width: 100%;
|
|
195
|
+
text-align: center;
|
|
196
|
+
line-height: 1;
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
text-overflow: ellipsis;
|
|
199
|
+
display: -webkit-box;
|
|
200
|
+
-webkit-line-clamp: 2;
|
|
201
|
+
-webkit-box-orient: vertical;
|
|
202
|
+
`;
|
|
@@ -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)
|
|
@@ -33,9 +22,9 @@ import { RadioButtonUnchecked, RadioButtonChecked } from '@mui/icons-material';
|
|
|
33
22
|
*
|
|
34
23
|
*/
|
|
35
24
|
function Checkbox(_a) {
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
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 })));
|
|
39
28
|
if (!label) {
|
|
40
29
|
return checkbox;
|
|
41
30
|
}
|