beem-component 2.1.9 → 2.1.10
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/dist/components/BmTabv2/BmTabV2..js +72 -0
- package/dist/components/DepartmentCard/DepartmentCard.js +1 -1
- package/dist/components/ResourceCard/ResourceCard.js +4 -4
- package/package.json +1 -1
- package/src/App.js +13 -1
- package/src/lib/components/BmTabv2/BmTabV2..js +122 -0
- package/src/lib/components/DepartmentCard/DepartmentCard.js +2 -3
- package/src/lib/components/ResourceCard/ResourceCard.js +4 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TabPanel = TabPanel;
|
|
8
|
+
exports.Tabs = Tabs;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
// Utility
|
|
13
|
+
const cn = function () {
|
|
14
|
+
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
classes[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
return classes.filter(Boolean).join(' ');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Styled components
|
|
21
|
+
|
|
22
|
+
const TabsContainer = _styledComponents.default.div.withConfig({
|
|
23
|
+
displayName: "BmTabV2__TabsContainer"
|
|
24
|
+
})(["display:flex;flex-direction:column;gap:0.5rem;@media (max-width:640px){gap:0.25rem;}"]);
|
|
25
|
+
const TabsList = _styledComponents.default.div.withConfig({
|
|
26
|
+
displayName: "BmTabV2__TabsList"
|
|
27
|
+
})(["display:flex;flex-wrap:nowrap;background:#f5f5f5;overflow-x:auto;padding:3px;border-radius:8px;&::-webkit-scrollbar{display:none;}"]);
|
|
28
|
+
const TabButton = _styledComponents.default.button.withConfig({
|
|
29
|
+
displayName: "BmTabV2__TabButton"
|
|
30
|
+
})(["flex:1 0 auto;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:0.5rem 0.75rem;font-size:0.875rem;font-weight:500;white-space:nowrap;border:1px solid transparent;border-radius:8px;background:transparent;color:#333;cursor:pointer;transition:all 0.2s;", " &:focus-visible{outline:2px solid #3b82f6;outline-offset:2px;}&:disabled{pointer-events:none;opacity:0.5;}svg{flex-shrink:0;pointer-events:none;width:1rem;height:1rem;}"], _ref => {
|
|
31
|
+
let {
|
|
32
|
+
active
|
|
33
|
+
} = _ref;
|
|
34
|
+
return active && (0, _styledComponents.css)(["background:#ffffff;color:#111111;border-color:#ddd;"]);
|
|
35
|
+
});
|
|
36
|
+
const TabContent = _styledComponents.default.div.withConfig({
|
|
37
|
+
displayName: "BmTabV2__TabContent"
|
|
38
|
+
})(["flex:1;padding:0.5rem 0;"]);
|
|
39
|
+
|
|
40
|
+
// Main Tabs component
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line func-style
|
|
43
|
+
function Tabs(_ref2) {
|
|
44
|
+
let {
|
|
45
|
+
defaultValue = 0,
|
|
46
|
+
children,
|
|
47
|
+
className
|
|
48
|
+
} = _ref2;
|
|
49
|
+
const [activeIndex, setActiveIndex] = (0, _react.useState)(defaultValue);
|
|
50
|
+
|
|
51
|
+
// Get all children that are type of TabPanel (so we can match titles & content)
|
|
52
|
+
const tabPanels = _react.default.Children.toArray(children).filter(child => child.type.displayName === 'TabPanel');
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(TabsContainer, {
|
|
54
|
+
className: cn(className)
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(TabsList, null, tabPanels.map((panel, index) => /*#__PURE__*/_react.default.createElement(TabButton
|
|
56
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
57
|
+
, {
|
|
58
|
+
key: index,
|
|
59
|
+
active: activeIndex === index,
|
|
60
|
+
onClick: () => setActiveIndex(index)
|
|
61
|
+
}, panel.props.title))), /*#__PURE__*/_react.default.createElement(TabContent, null, tabPanels[activeIndex] && tabPanels[activeIndex].props.children));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Individual Tab panel component
|
|
65
|
+
// eslint-disable-next-line func-style
|
|
66
|
+
function TabPanel(_ref3) {
|
|
67
|
+
let {
|
|
68
|
+
children
|
|
69
|
+
} = _ref3;
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
71
|
+
}
|
|
72
|
+
TabPanel.displayName = 'TabPanel';
|
|
@@ -92,7 +92,7 @@ const BmDepartmentCard = _ref6 => {
|
|
|
92
92
|
onClick: onDelete
|
|
93
93
|
}, DeleteIcon && /*#__PURE__*/_react.default.createElement(DeleteIcon, {
|
|
94
94
|
fontSize: "small"
|
|
95
|
-
})))), /*#__PURE__*/_react.default.createElement(CardDescription, null, description)), /*#__PURE__*/_react.default.createElement(Content, null,
|
|
95
|
+
})))), /*#__PURE__*/_react.default.createElement(CardDescription, null, description)), /*#__PURE__*/_react.default.createElement(Content, null, /*#__PURE__*/_react.default.createElement(ResourceText, null, resourcesCount, " Resources"), /*#__PURE__*/_react.default.createElement(StatusRow, null, /*#__PURE__*/_react.default.createElement(StatusDot, {
|
|
96
96
|
isActive: isActive
|
|
97
97
|
}), /*#__PURE__*/_react.default.createElement(StatusText, null, isActive ? 'Active' : 'Inactive'))));
|
|
98
98
|
};
|
|
@@ -63,19 +63,19 @@ const IconButton = _styledComponents.default.button.withConfig({
|
|
|
63
63
|
});
|
|
64
64
|
const Content = _styledComponents.default.div.withConfig({
|
|
65
65
|
displayName: "ResourceCard__Content"
|
|
66
|
-
})(["padding:0 1rem 0.5rem 1rem;display:flex;flex-direction:column;gap:0.5rem;font-size:0.875rem;"]);
|
|
66
|
+
})(["margin-top:1rem;padding:0 1rem 0.5rem 1rem;display:flex;flex-direction:column;gap:0.5rem;font-size:0.875rem;"]);
|
|
67
67
|
const InfoRow = _styledComponents.default.div.withConfig({
|
|
68
68
|
displayName: "ResourceCard__InfoRow"
|
|
69
69
|
})(["display:flex;flex-wrap:wrap;gap:0.25rem;"]);
|
|
70
70
|
const Label = _styledComponents.default.span.withConfig({
|
|
71
71
|
displayName: "ResourceCard__Label"
|
|
72
|
-
})(["color:#6b7280;"]);
|
|
72
|
+
})(["color:#6b7280;font-size:0.875rem;"]);
|
|
73
73
|
const Value = _styledComponents.default.span.withConfig({
|
|
74
74
|
displayName: "ResourceCard__Value"
|
|
75
|
-
})(["color:#374151;"]);
|
|
75
|
+
})(["color:#374151;font-size:0.875rem;"]);
|
|
76
76
|
const Footer = _styledComponents.default.div.withConfig({
|
|
77
77
|
displayName: "ResourceCard__Footer"
|
|
78
|
-
})(["display:flex;justify-content:flex-end;align-items:center;padding:0 1rem 0.75rem 1rem;"]);
|
|
78
|
+
})(["display:flex;justify-content:flex-end;align-items:center;margin-top:1rem;padding:0 1rem 0.75rem 1rem;"]);
|
|
79
79
|
const StatusDot = _styledComponents.default.span.withConfig({
|
|
80
80
|
displayName: "ResourceCard__StatusDot"
|
|
81
81
|
})(["flex-shrink:0;width:0.5rem;height:0.5rem;margin-right:0.5rem;border-radius:9999px;background-color:", ";"], _ref6 => {
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
BmResourceCard,
|
|
44
44
|
} from './lib/components';
|
|
45
45
|
import AlertBox from './lib/components/Alert/Alert';
|
|
46
|
+
import { TabPanel, Tabs } from './lib/components/BmTabv2/BmTabV2.';
|
|
46
47
|
// import ProgressIndicator from './lib/components/newProgress';
|
|
47
48
|
|
|
48
49
|
// const datsa = JSON.stringify({
|
|
@@ -1016,6 +1017,17 @@ const Chat = () => {
|
|
|
1016
1017
|
<>
|
|
1017
1018
|
<GlobalStyle />
|
|
1018
1019
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
|
|
1020
|
+
<Tabs defaultValue={0}>
|
|
1021
|
+
<TabPanel title="Overview">
|
|
1022
|
+
<p>This is the Overview content.</p>
|
|
1023
|
+
</TabPanel>
|
|
1024
|
+
<TabPanel title="Details">
|
|
1025
|
+
<p>This is the Details content.</p>
|
|
1026
|
+
</TabPanel>
|
|
1027
|
+
<TabPanel title="Settings">
|
|
1028
|
+
<p>This is the Settings content.</p>
|
|
1029
|
+
</TabPanel>
|
|
1030
|
+
</Tabs>
|
|
1019
1031
|
<div style={{ width: '100%', maxWidth: '900px', margin: '2rem auto' }}>
|
|
1020
1032
|
<div style={{ maxWidth: 400, margin: '2rem auto' }}>
|
|
1021
1033
|
<BmDepartmentCard
|
|
@@ -1023,7 +1035,7 @@ const Chat = () => {
|
|
|
1023
1035
|
isActive="true"
|
|
1024
1036
|
name="Radiology Department"
|
|
1025
1037
|
description="Handles imaging and diagnostic scans"
|
|
1026
|
-
|
|
1038
|
+
resourcesCount={0}
|
|
1027
1039
|
onEdit={() => alert('Edit department')}
|
|
1028
1040
|
onDelete={() => alert('Delete department')}
|
|
1029
1041
|
EditIcon={EditIcon}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
|
|
6
|
+
// Utility
|
|
7
|
+
const cn = (...classes) => classes.filter(Boolean).join(' ');
|
|
8
|
+
|
|
9
|
+
// Styled components
|
|
10
|
+
|
|
11
|
+
const TabsContainer = styled.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: 0.5rem;
|
|
15
|
+
|
|
16
|
+
@media (max-width: 640px) {
|
|
17
|
+
gap: 0.25rem;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const TabsList = styled.div`
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-wrap: nowrap;
|
|
24
|
+
background: #f5f5f5;
|
|
25
|
+
overflow-x: auto;
|
|
26
|
+
padding: 3px;
|
|
27
|
+
border-radius: 8px;
|
|
28
|
+
|
|
29
|
+
&::-webkit-scrollbar {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const TabButton = styled.button`
|
|
35
|
+
flex: 1 0 auto;
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
gap: 6px;
|
|
40
|
+
padding: 0.5rem 0.75rem;
|
|
41
|
+
font-size: 0.875rem;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
border: 1px solid transparent;
|
|
45
|
+
border-radius: 8px;
|
|
46
|
+
background: transparent;
|
|
47
|
+
color: #333;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
transition: all 0.2s;
|
|
50
|
+
|
|
51
|
+
${({ active }) =>
|
|
52
|
+
active &&
|
|
53
|
+
css`
|
|
54
|
+
background: #ffffff;
|
|
55
|
+
color: #111111;
|
|
56
|
+
border-color: #ddd;
|
|
57
|
+
`}
|
|
58
|
+
|
|
59
|
+
&:focus-visible {
|
|
60
|
+
outline: 2px solid #3b82f6;
|
|
61
|
+
outline-offset: 2px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:disabled {
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
opacity: 0.5;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
svg {
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
width: 1rem;
|
|
73
|
+
height: 1rem;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const TabContent = styled.div`
|
|
78
|
+
flex: 1;
|
|
79
|
+
padding: 0.5rem 0;
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
// Main Tabs component
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line func-style
|
|
85
|
+
function Tabs({ defaultValue = 0, children, className }) {
|
|
86
|
+
const [activeIndex, setActiveIndex] = useState(defaultValue);
|
|
87
|
+
|
|
88
|
+
// Get all children that are type of TabPanel (so we can match titles & content)
|
|
89
|
+
const tabPanels = React.Children.toArray(children).filter(
|
|
90
|
+
(child) => child.type.displayName === 'TabPanel'
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<TabsContainer className={cn(className)}>
|
|
95
|
+
<TabsList>
|
|
96
|
+
{tabPanels.map((panel, index) => (
|
|
97
|
+
<TabButton
|
|
98
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
99
|
+
key={index}
|
|
100
|
+
active={activeIndex === index}
|
|
101
|
+
onClick={() => setActiveIndex(index)}
|
|
102
|
+
>
|
|
103
|
+
{panel.props.title}
|
|
104
|
+
</TabButton>
|
|
105
|
+
))}
|
|
106
|
+
</TabsList>
|
|
107
|
+
<TabContent>
|
|
108
|
+
{tabPanels[activeIndex] && tabPanels[activeIndex].props.children}
|
|
109
|
+
</TabContent>
|
|
110
|
+
</TabsContainer>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Individual Tab panel component
|
|
115
|
+
// eslint-disable-next-line func-style
|
|
116
|
+
function TabPanel({ children }) {
|
|
117
|
+
return <>{children}</>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
TabPanel.displayName = 'TabPanel';
|
|
121
|
+
|
|
122
|
+
export { Tabs, TabPanel };
|
|
@@ -116,9 +116,8 @@ const BmDepartmentCard = ({
|
|
|
116
116
|
<CardDescription>{description}</CardDescription>
|
|
117
117
|
</Header>
|
|
118
118
|
<Content>
|
|
119
|
-
{resourcesCount
|
|
120
|
-
|
|
121
|
-
)}
|
|
119
|
+
<ResourceText>{resourcesCount} Resources</ResourceText>
|
|
120
|
+
|
|
122
121
|
<StatusRow>
|
|
123
122
|
<StatusDot isActive={isActive} />
|
|
124
123
|
<StatusText>{isActive ? 'Active' : 'Inactive'}</StatusText>
|
|
@@ -73,6 +73,7 @@ const IconButton = styled.button`
|
|
|
73
73
|
`;
|
|
74
74
|
|
|
75
75
|
const Content = styled.div`
|
|
76
|
+
margin-top: 1rem;
|
|
76
77
|
padding: 0 1rem 0.5rem 1rem;
|
|
77
78
|
display: flex;
|
|
78
79
|
flex-direction: column;
|
|
@@ -88,16 +89,19 @@ const InfoRow = styled.div`
|
|
|
88
89
|
|
|
89
90
|
const Label = styled.span`
|
|
90
91
|
color: #6b7280;
|
|
92
|
+
font-size: 0.875rem;
|
|
91
93
|
`;
|
|
92
94
|
|
|
93
95
|
const Value = styled.span`
|
|
94
96
|
color: #374151;
|
|
97
|
+
font-size: 0.875rem;
|
|
95
98
|
`;
|
|
96
99
|
|
|
97
100
|
const Footer = styled.div`
|
|
98
101
|
display: flex;
|
|
99
102
|
justify-content: flex-end;
|
|
100
103
|
align-items: center;
|
|
104
|
+
margin-top: 1rem;
|
|
101
105
|
padding: 0 1rem 0.75rem 1rem;
|
|
102
106
|
`;
|
|
103
107
|
|