beem-component 1.8.9 → 1.9.1
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/Lists/rowLabels.js +14 -11
- package/dist/components/MultipleDateSelector/multipleDateSelector.js +22 -30
- package/dist/components/Tags/tags.js +12 -4
- package/package.json +1 -1
- package/src/App.js +45 -7
- package/src/lib/components/Lists/rowLabels.js +7 -0
- package/src/lib/components/MultipleDateSelector/multipleDateSelector.js +30 -35
- package/src/lib/components/Tags/tags.js +8 -2
|
@@ -16,7 +16,10 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
17
|
var Container = _styledComponents.default.div.withConfig({
|
|
18
18
|
displayName: "rowLabels__Container"
|
|
19
|
-
})(["display:flex;flex-direction:row;align-items:center;padding:0.5rem 1rem;justify-content:space-between;background:", ";margin:0rem;&:hover{background:", ";}"], _colors.BmPrimaryWhite, _colors.BmGrey100)
|
|
19
|
+
})(["display:flex;flex-direction:row;align-items:center;padding:0.5rem 1rem;justify-content:space-between;background:", ";margin:0rem;&:hover{background:", ";}", ";"], _colors.BmPrimaryWhite, _colors.BmGrey100, function (_ref) {
|
|
20
|
+
var disabled = _ref.disabled;
|
|
21
|
+
return disabled && " \n pointer-events: none;\n opacity: 0.5;\n background: ".concat(_colors.BmGrey100, ";\n");
|
|
22
|
+
});
|
|
20
23
|
exports.Container = Container;
|
|
21
24
|
var LeftContainer = _styledComponents.default.div.withConfig({
|
|
22
25
|
displayName: "rowLabels__LeftContainer"
|
|
@@ -28,19 +31,19 @@ var RightContainer = _styledComponents.default.div.withConfig({
|
|
|
28
31
|
exports.RightContainer = RightContainer;
|
|
29
32
|
var Label = _styledComponents.default.p.withConfig({
|
|
30
33
|
displayName: "rowLabels__Label"
|
|
31
|
-
})(["color:", ";", ""], _colors.BmPrimaryBlack, function (
|
|
32
|
-
var trailingIcon =
|
|
34
|
+
})(["color:", ";", ""], _colors.BmPrimaryBlack, function (_ref2) {
|
|
35
|
+
var trailingIcon = _ref2.trailingIcon;
|
|
33
36
|
return trailingIcon && "\n margin-right: 0.5rem;\n ";
|
|
34
37
|
});
|
|
35
38
|
exports.Label = Label;
|
|
36
|
-
var BmRowLabel = function BmRowLabel(
|
|
37
|
-
var children =
|
|
38
|
-
trailingIcon =
|
|
39
|
-
leadingIcon =
|
|
40
|
-
label =
|
|
41
|
-
color =
|
|
42
|
-
size =
|
|
43
|
-
rest = _objectWithoutProperties(
|
|
39
|
+
var BmRowLabel = function BmRowLabel(_ref3) {
|
|
40
|
+
var children = _ref3.children,
|
|
41
|
+
trailingIcon = _ref3.trailingIcon,
|
|
42
|
+
leadingIcon = _ref3.leadingIcon,
|
|
43
|
+
label = _ref3.label,
|
|
44
|
+
color = _ref3.color,
|
|
45
|
+
size = _ref3.size,
|
|
46
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
44
47
|
return /*#__PURE__*/_react.default.createElement(Container, _extends({
|
|
45
48
|
trailingIcon: trailingIcon,
|
|
46
49
|
leadingIcon: leadingIcon,
|
|
@@ -27,46 +27,38 @@ var Wrapper = _styledComponents.default.div.withConfig({
|
|
|
27
27
|
var Box = _styledComponents.default.div.withConfig({
|
|
28
28
|
displayName: "multipleDateSelector__Box"
|
|
29
29
|
})(["display:inline-flex;border:0.071rem solid ", ";padding:0.5rem;cursor:pointer;"], _colors.BmGrey100);
|
|
30
|
-
var BmMultiDateSelector = function BmMultiDateSelector(
|
|
31
|
-
var
|
|
32
|
-
selectedNumbers = _ref.selectedNumbers;
|
|
33
|
-
var numbers = Array.from({
|
|
34
|
-
length: 31
|
|
35
|
-
}, function (_, i) {
|
|
36
|
-
return i;
|
|
37
|
-
});
|
|
38
|
-
var _useState = (0, _react.useState)(selectedNumbers || []),
|
|
30
|
+
var BmMultiDateSelector = function BmMultiDateSelector() {
|
|
31
|
+
var _useState = (0, _react.useState)([]),
|
|
39
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (selected.includes(number)) {
|
|
47
|
-
setSelected(selected.filter(function (n) {
|
|
48
|
-
return n !== number;
|
|
33
|
+
selectedDays = _useState2[0],
|
|
34
|
+
setSelectedDays = _useState2[1];
|
|
35
|
+
var handleDayClick = function handleDayClick(day) {
|
|
36
|
+
if (selectedDays.includes(day)) {
|
|
37
|
+
setSelectedDays(selectedDays.filter(function (d) {
|
|
38
|
+
return d !== day;
|
|
49
39
|
}));
|
|
50
40
|
} else {
|
|
51
|
-
|
|
41
|
+
setSelectedDays([].concat(_toConsumableArray(selectedDays), [day]));
|
|
52
42
|
}
|
|
53
43
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
44
|
+
var days = Array.from({
|
|
45
|
+
length: 31
|
|
46
|
+
}, function (_, i) {
|
|
47
|
+
return i + 1;
|
|
48
|
+
});
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Wrapper, null, days.map(function (day) {
|
|
58
50
|
return /*#__PURE__*/_react.default.createElement(Box, {
|
|
59
|
-
key:
|
|
51
|
+
key: day,
|
|
60
52
|
style: {
|
|
61
|
-
backgroundColor:
|
|
62
|
-
color:
|
|
63
|
-
fontWeight:
|
|
53
|
+
backgroundColor: selectedDays.includes(day) ? _colors.BmPrimaryBlue : _colors.BmPrimaryWhite,
|
|
54
|
+
color: selectedDays.includes(day) ? _colors.BmPrimaryWhite : _colors.BmPrimaryBlack,
|
|
55
|
+
fontWeight: selectedDays.includes(day) ? 'bold' : 'normal'
|
|
64
56
|
},
|
|
65
57
|
onClick: function onClick() {
|
|
66
|
-
return
|
|
58
|
+
return handleDayClick(day);
|
|
67
59
|
}
|
|
68
|
-
},
|
|
69
|
-
}));
|
|
60
|
+
}, day);
|
|
61
|
+
})));
|
|
70
62
|
};
|
|
71
63
|
var _default = BmMultiDateSelector;
|
|
72
64
|
exports.default = _default;
|
|
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
var _icons = require("@material-ui/icons");
|
|
12
12
|
var _iconStyles = require("../iconStyles");
|
|
13
13
|
var _colors = require("../colors");
|
|
14
|
-
var _excluded = ["variant", "size", "disabled", "children", "leadingIcon", "trailingIcon", "color", "bgColor", "closeButton", "onHide"];
|
|
14
|
+
var _excluded = ["variant", "size", "disabled", "children", "leadingIcon", "trailingIcon", "color", "textColor", "bgColor", "closeButton", "onHide"];
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -26,7 +26,11 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
26
26
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
27
|
var Color = function Color(_ref) {
|
|
28
28
|
var variant = _ref.variant,
|
|
29
|
-
color = _ref.color
|
|
29
|
+
color = _ref.color,
|
|
30
|
+
textColor = _ref.textColor;
|
|
31
|
+
if (textColor) {
|
|
32
|
+
return textColor;
|
|
33
|
+
}
|
|
30
34
|
if (variant === 'success' || variant === 'warning' || variant === 'danger' || variant === 'primary') {
|
|
31
35
|
return "".concat(_colors.BmPrimaryWhite);
|
|
32
36
|
}
|
|
@@ -65,10 +69,12 @@ var BeemTag = _styledComponents.default.button.withConfig({
|
|
|
65
69
|
return "".concat(_colors.BmGrey100);
|
|
66
70
|
}, function (_ref5) {
|
|
67
71
|
var variant = _ref5.variant,
|
|
68
|
-
color = _ref5.color
|
|
72
|
+
color = _ref5.color,
|
|
73
|
+
textColor = _ref5.textColor;
|
|
69
74
|
return Color({
|
|
70
75
|
variant: variant,
|
|
71
|
-
color: color
|
|
76
|
+
color: color,
|
|
77
|
+
textColor: textColor
|
|
72
78
|
});
|
|
73
79
|
});
|
|
74
80
|
var BmTag = function BmTag(props) {
|
|
@@ -83,6 +89,7 @@ var BmTag = function BmTag(props) {
|
|
|
83
89
|
leadingIcon = props.leadingIcon,
|
|
84
90
|
trailingIcon = props.trailingIcon,
|
|
85
91
|
color = props.color,
|
|
92
|
+
textColor = props.textColor,
|
|
86
93
|
bgColor = props.bgColor,
|
|
87
94
|
closeButton = props.closeButton,
|
|
88
95
|
onHide = props.onHide,
|
|
@@ -93,6 +100,7 @@ var BmTag = function BmTag(props) {
|
|
|
93
100
|
disabled: disabled,
|
|
94
101
|
children: children,
|
|
95
102
|
color: color,
|
|
103
|
+
textColor: textColor,
|
|
96
104
|
closeButton: closeButton,
|
|
97
105
|
show: toggle,
|
|
98
106
|
bgColor: bgColor
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import CircleIcon from '@mui/icons-material/Circle';
|
|
3
|
+
import { BmRowLabel, BmTag, GlobalStyle } from './lib/components';
|
|
3
4
|
import BmButtonGroup from './lib/components/ButtonGroup/buttonGroup';
|
|
4
5
|
import { BmInputCounter } from './lib/components/InputCounter/inputCounter';
|
|
6
|
+
import BmMultiDateSelector from './lib/components/MultipleDateSelector/multipleDateSelector';
|
|
5
7
|
import BmStepper from './lib/components/Stepper/stepper';
|
|
8
|
+
import {
|
|
9
|
+
BmBgLightBlue,
|
|
10
|
+
// BmGrey200,
|
|
11
|
+
BmGrey400,
|
|
12
|
+
BmGrey50,
|
|
13
|
+
BmPrimaryBlue,
|
|
14
|
+
BmPrimaryGold,
|
|
15
|
+
BmSecondaryGreen,
|
|
16
|
+
BmSecondaryGreen8,
|
|
17
|
+
BmSecondaryPurple,
|
|
18
|
+
BmSecondaryRed,
|
|
19
|
+
} from './lib/components/colors';
|
|
6
20
|
|
|
7
21
|
const App = () => {
|
|
8
22
|
const [item, setItem] = useState();
|
|
@@ -56,6 +70,22 @@ const App = () => {
|
|
|
56
70
|
},
|
|
57
71
|
];
|
|
58
72
|
|
|
73
|
+
const statusa = 'rejected';
|
|
74
|
+
|
|
75
|
+
const getStatusValue = (status) => {
|
|
76
|
+
const STATUSES_V2 = {
|
|
77
|
+
pending: BmPrimaryGold,
|
|
78
|
+
inprogress: BmPrimaryBlue,
|
|
79
|
+
'sent-to-mno': BmSecondaryPurple,
|
|
80
|
+
whitelisted: BmBgLightBlue,
|
|
81
|
+
'partial-approved': BmSecondaryGreen8,
|
|
82
|
+
active: BmSecondaryGreen,
|
|
83
|
+
rejected: BmSecondaryRed,
|
|
84
|
+
inactive: BmGrey400,
|
|
85
|
+
};
|
|
86
|
+
return STATUSES_V2[status] || '';
|
|
87
|
+
};
|
|
88
|
+
|
|
59
89
|
return (
|
|
60
90
|
<>
|
|
61
91
|
<GlobalStyle />
|
|
@@ -73,12 +103,10 @@ const App = () => {
|
|
|
73
103
|
count={count}
|
|
74
104
|
onChange={handleCountChange}
|
|
75
105
|
/>
|
|
76
|
-
<BmMultiDateSelector
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<p>Selected numbers outside the component: {selectedDates.join(', ')}</p>
|
|
81
|
-
|
|
106
|
+
<BmMultiDateSelector onSelect={handleSelectDates} />
|
|
107
|
+
{selectedDates.length > 0 && (
|
|
108
|
+
<p>Selected dates: {selectedDates.join(', ')}</p>
|
|
109
|
+
)}
|
|
82
110
|
{Weekdays.map(({ dayNo, dayInitial }) => {
|
|
83
111
|
return (
|
|
84
112
|
<BmStepper
|
|
@@ -92,6 +120,16 @@ const App = () => {
|
|
|
92
120
|
</BmStepper>
|
|
93
121
|
);
|
|
94
122
|
})}
|
|
123
|
+
<BmRowLabel disabled>Hello</BmRowLabel>
|
|
124
|
+
<BmTag
|
|
125
|
+
color={getStatusValue(statusa)}
|
|
126
|
+
leadingIcon={<CircleIcon />}
|
|
127
|
+
size="xsmall"
|
|
128
|
+
textColor="black"
|
|
129
|
+
bgColor={BmGrey50}
|
|
130
|
+
>
|
|
131
|
+
<p>Hello</p>
|
|
132
|
+
</BmTag>
|
|
95
133
|
</>
|
|
96
134
|
);
|
|
97
135
|
};
|
|
@@ -15,6 +15,13 @@ export const Container = styled.div`
|
|
|
15
15
|
&:hover {
|
|
16
16
|
background: ${BmGrey100};
|
|
17
17
|
}
|
|
18
|
+
${({ disabled }) =>
|
|
19
|
+
disabled &&
|
|
20
|
+
`
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
background: ${BmGrey100};
|
|
24
|
+
`};
|
|
18
25
|
`;
|
|
19
26
|
|
|
20
27
|
export const LeftContainer = styled.div`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useState
|
|
1
|
+
// import { BmColors } from 'beem-component';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import {
|
|
5
5
|
BmGrey100,
|
|
@@ -23,46 +23,41 @@ const Box = styled.div`
|
|
|
23
23
|
padding: 0.5rem;
|
|
24
24
|
cursor: pointer;
|
|
25
25
|
`;
|
|
26
|
+
const BmMultiDateSelector = () => {
|
|
27
|
+
const [selectedDays, setSelectedDays] = useState([]);
|
|
26
28
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const [selected, setSelected] = useState(selectedNumbers || []);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
setSelected(selectedNumbers || []);
|
|
34
|
-
}, [selectedNumbers]);
|
|
35
|
-
|
|
36
|
-
const handleNumberClick = (number) => {
|
|
37
|
-
if (selected.includes(number)) {
|
|
38
|
-
setSelected(selected.filter((n) => n !== number));
|
|
29
|
+
const handleDayClick = (day) => {
|
|
30
|
+
if (selectedDays.includes(day)) {
|
|
31
|
+
setSelectedDays(selectedDays.filter((d) => d !== day));
|
|
39
32
|
} else {
|
|
40
|
-
|
|
33
|
+
setSelectedDays([...selectedDays, day]);
|
|
41
34
|
}
|
|
42
35
|
};
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
onSelect(selected);
|
|
46
|
-
}, [selected, onSelect]);
|
|
37
|
+
const days = Array.from({ length: 31 }, (_, i) => i + 1);
|
|
47
38
|
|
|
48
39
|
return (
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
40
|
+
<div>
|
|
41
|
+
<Wrapper>
|
|
42
|
+
{days.map((day) => (
|
|
43
|
+
<Box
|
|
44
|
+
key={day}
|
|
45
|
+
style={{
|
|
46
|
+
backgroundColor: selectedDays.includes(day)
|
|
47
|
+
? BmPrimaryBlue
|
|
48
|
+
: BmPrimaryWhite,
|
|
49
|
+
color: selectedDays.includes(day)
|
|
50
|
+
? BmPrimaryWhite
|
|
51
|
+
: BmPrimaryBlack,
|
|
52
|
+
fontWeight: selectedDays.includes(day) ? 'bold' : 'normal',
|
|
53
|
+
}}
|
|
54
|
+
onClick={() => handleDayClick(day)}
|
|
55
|
+
>
|
|
56
|
+
{day}
|
|
57
|
+
</Box>
|
|
58
|
+
))}
|
|
59
|
+
</Wrapper>
|
|
60
|
+
</div>
|
|
66
61
|
);
|
|
67
62
|
};
|
|
68
63
|
|
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
BmPrimaryBlue,
|
|
17
17
|
} from '../colors';
|
|
18
18
|
|
|
19
|
-
const Color = ({ variant, color }) => {
|
|
19
|
+
const Color = ({ variant, color, textColor }) => {
|
|
20
|
+
if (textColor) {
|
|
21
|
+
return textColor;
|
|
22
|
+
}
|
|
20
23
|
if (
|
|
21
24
|
variant === 'success' ||
|
|
22
25
|
variant === 'warning' ||
|
|
@@ -64,7 +67,8 @@ const BeemTag = styled.button`
|
|
|
64
67
|
return `${BmGrey100}`;
|
|
65
68
|
}};
|
|
66
69
|
> * {
|
|
67
|
-
color: ${({ variant, color }) =>
|
|
70
|
+
color: ${({ variant, color, textColor }) =>
|
|
71
|
+
Color({ variant, color, textColor })};
|
|
68
72
|
text-transform: uppercase;
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -84,6 +88,7 @@ export const BmTag = (props) => {
|
|
|
84
88
|
leadingIcon,
|
|
85
89
|
trailingIcon,
|
|
86
90
|
color,
|
|
91
|
+
textColor,
|
|
87
92
|
bgColor,
|
|
88
93
|
closeButton,
|
|
89
94
|
onHide,
|
|
@@ -97,6 +102,7 @@ export const BmTag = (props) => {
|
|
|
97
102
|
disabled={disabled}
|
|
98
103
|
children={children}
|
|
99
104
|
color={color}
|
|
105
|
+
textColor={textColor}
|
|
100
106
|
closeButton={closeButton}
|
|
101
107
|
show={toggle}
|
|
102
108
|
bgColor={bgColor}
|